-
Notifications
You must be signed in to change notification settings - Fork 219
Open
Labels
Description
Description
Extend the API Status functionality to allow updating an existing API status by api_group. This will enable clients to modify API status details dynamically without creating new entries.
Acceptance Criteria
- A PUT request should be available at /api-status/{api_group}.
- It should update an existing API status based on the provided api_group.
- If the API status does not exist, it should return a 404 Not Found response.
- The response should contain the updated API status.
Purpose
- Allow clients to modify API status details dynamically.
- Prevent duplicate API status entries by updating existing ones.
- Allow clients to update specific API status records without creating new ones, providing a more precise way to manage API status data while maintaining a consistent response structure.
Requirements
- Implement an update method in APIStatusService.
- Validate that the API status exists before updating.
- Return a 404 Not Found response if the API status does not exist.
- Add a PUT route (/api-status/{api_group}) for updating API statuses.
- Test the endpoint for correctness and accuracy.
Tasks
- Implement the update method in APIStatusService.
- Add a PUT route (/api-status/{api_group}) in the router.
- Validate inputs and return appropriate responses.
- Test the endpoint for correctness and accuracy.
Testing
PUT API Status
curl -X PUT {rootdomain}/api-status/{api_group} \
-H "Content-Type: application/json" \
-d '{
"api_group": "user",
"status": "active",
"response_time": "200ms",
"details": "API is running fine"
}'
Response body [success - 200 OK]:
{
"status": "success",
"status_code": 200,
"message": "API Status updated successfully",
"data": {
"api_group": "string",
"status": "string",
"response_time": integer,
"details": "string"
}
}
Response body [Failure - 404 Not Found]
{
"status": "error",
"status_code": 404,
"message": "API Status not found",
"data": null
}
Testing
- Ensure that the endpoint correctly updates the API status record when a valid api_group is provided.
- Ensure that the endpoint returns the updated data in the format { "status": "success", "status_code": 200, "message": "string", "data": {} }.
- Ensure that the endpoint returns a 404 error in the format { "status": "error", "status_code": 404, "message": "string", "data": null } when the specified api_group does not exist.
- Test with partial updates (e.g., only updating status) to ensure all fields are handled properly and the response adheres to the specified structure.