mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 12:14:46 -04:00
Fix put
This commit is contained in:
parent
8a816b587f
commit
dc5fd8f5a3
@ -170,6 +170,33 @@ public class CrudApi<T> : BaseApi
|
|||||||
return await Repository.Edit(resource);
|
return await Repository.Edit(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Edit
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Edit an item. If the ID is specified it will be used to identify the resource.
|
||||||
|
/// If not, the slug will be used to identify it.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="identifier">The id or slug of the resource.</param>
|
||||||
|
/// <param name="resource">The resource to edit.</param>
|
||||||
|
/// <returns>The edited resource.</returns>
|
||||||
|
/// <response code="400">The resource in the request body is invalid.</response>
|
||||||
|
/// <response code="404">No item found with the specified ID (or slug).</response>
|
||||||
|
[HttpPut("{identifier:id}")]
|
||||||
|
[PartialPermission(Kind.Write)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(RequestError))]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
public async Task<ActionResult<T>> Edit(Identifier identifier, [FromBody] T resource)
|
||||||
|
{
|
||||||
|
Guid id = await identifier.Match(
|
||||||
|
id => Task.FromResult(id),
|
||||||
|
async slug => (await Repository.Get(slug)).Id
|
||||||
|
);
|
||||||
|
resource.Id = id;
|
||||||
|
return await Repository.Edit(resource);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Patch
|
/// Patch
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -43,20 +43,24 @@ class Subscriber:
|
|||||||
|
|
||||||
async def listen(self, scanner: Matcher):
|
async def listen(self, scanner: Matcher):
|
||||||
async def on_message(message: AbstractIncomingMessage):
|
async def on_message(message: AbstractIncomingMessage):
|
||||||
msg = decoder.decode(message.body)
|
try:
|
||||||
ack = False
|
msg = decoder.decode(message.body)
|
||||||
match msg:
|
ack = False
|
||||||
case Scan(path):
|
match msg:
|
||||||
ack = await scanner.identify(path)
|
case Scan(path):
|
||||||
case Delete(path):
|
ack = await scanner.identify(path)
|
||||||
ack = await scanner.delete(path)
|
case Delete(path):
|
||||||
case Refresh(kind, id):
|
ack = await scanner.delete(path)
|
||||||
ack = await scanner.refresh(kind, id)
|
case Refresh(kind, id):
|
||||||
case _:
|
ack = await scanner.refresh(kind, id)
|
||||||
logger.error(f"Invalid action: {msg.action}")
|
case _:
|
||||||
if ack:
|
logger.error(f"Invalid action: {msg.action}")
|
||||||
await message.ack()
|
if ack:
|
||||||
else:
|
await message.ack()
|
||||||
|
else:
|
||||||
|
await message.reject()
|
||||||
|
except Exception as e:
|
||||||
|
logger.exception("Unhandled error", exc_info=e)
|
||||||
await message.reject()
|
await message.reject()
|
||||||
|
|
||||||
# Allow up to 20 scan requests to run in parallel on the same listener.
|
# Allow up to 20 scan requests to run in parallel on the same listener.
|
||||||
|
@ -177,7 +177,7 @@ class KyooClient:
|
|||||||
jdkwargs={"indent": 4},
|
jdkwargs={"indent": 4},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
async with self.client.post(
|
async with self.client.put(
|
||||||
f"{self._url}/{path}",
|
f"{self._url}/{path}",
|
||||||
json=data,
|
json=data,
|
||||||
headers={"X-API-Key": self._api_key},
|
headers={"X-API-Key": self._api_key},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user