Implement KindCache single/group update request API
#537 (closed) Implement KindCache single/group update request API
Task:Description:
This task involves implementing new API endpoints for updating the cache(s) associated with the Kind
configuration. It includes endpoints for updating a single cache and a group of caches by name, alongside the original method for updating all caches belonging to a given Kind.
Requirements:
-
Update Caches for a Given Kind (
updateCache
):- This method already exists and updates all caches associated with a specific Kind.
- No changes required here, but ensure this behavior is consistent with the new methods.
-
Single Cache Update (
updateCacheForSingle
):- Implement an API endpoint that allows updating a single cache based on the
cacheName
of the Kind. - The update request should be queued for asynchronous processing using the
FeatureCacheSynchronizer
service. - Ensure proper validation and error handling, including validation of whether the cache exists.
- Implement an API endpoint that allows updating a single cache based on the
-
Group Cache Update (
updateCacheForList
):- Implement a
POST
API endpoint that accepts a list of cache names and attempts to queue update requests for each. - The response should include two arrays:
- Succeeded: List of cache names whose updates were successfully queued.
- Failed: List of cache names whose update requests failed, along with the reasons for failure (e.g., cache not found, invalid request).
- Ensure validation for each cache in the list, and only attempt updates for valid caches.
- Implement a
-
Error and Validation Handling:
- When a cache does not exist, return a clear error message for that cache in the
failed
array. - If all caches succeed, return a response with an empty
failed
array. - Ensure appropriate logging for both success and failure cases.
- When a cache does not exist, return a clear error message for that cache in the
-
Swagger Documentation:
- Document both the single cache and group cache update endpoints in Swagger.
- For the group update, provide an example response showing the
succeeded
andfailed
arrays, including sample error messages for failed caches. - Mention that "success" only means that the operation was successfully queued; the actual result of the operation will be handled asynchronously.
Key Details:
-
Validation: The system should validate the existence of caches before attempting to queue update requests. This can be achieved by checking the cache against the
KindCacheConfigurationCacheService
. -
Response Structure for Group Update: The response for
updateCacheForList
will be a JSON object containing:-
succeeded
: An array of cache names whose update requests were successfully queued. -
failed
: An array of objects withcacheName
andreason
, explaining why the update request failed.
-
Example Response for Group Cache Update:
{
"succeeded": [
"cache1",
"cache2"
],
"failed": [
{
"cacheName": "cache3",
"reason": "Cache not found"
},
{
"cacheName": "cache4",
"reason": "Invalid request format"
}
]
}
Acceptance Criteria:
-
The updateCacheForSingle
method is implemented and can update a single cache asynchronously. -
The updateCacheForList
method is implemented and can update a list of caches asynchronously, returning success and failure arrays. -
The existing updateCache
method for updating all caches for a given Kind remains functional. -
Validation is added to ensure that caches exist before attempting updates. -
Swagger documentation is updated to reflect the new methods, including examples of successful and failed responses.
Edited by Rostislav Dublin (EPAM)