sphinx-tribes
sphinx-tribes copied to clipboard
Endpoint Management API
Breakdown of feature flag system in: https://github.com/stakwork/sphinx-tribes/issues/2235
Endpoint Management API
1. POST /feature_flags/{feature_flag_id}/endpoints
-
Description:
Adds one or more endpoints to an existing feature flag. -
Request Body:
[
"/api/select",
"/api/bounty"
]
-
Response:
- The response will include the feature flag details (
feature_name,description,uuid) and the updated array of endpoints. - Includes
success,message, anddata.
- The response will include the feature flag details (
-
Example Response (Success):
{
"success": true,
"message": "Endpoints added successfully.",
"data": {
"name": "FF_Select",
"description": "Feature for selecting items",
"uuid": "123e4567-e89b-12d3-a456-426614174000",
"endpoints": [
{ "path": "/api/select", "uuid": "567e4567-e89b-12d3-a456-426614174110" },
{ "path": "/api/bounty", "uuid": "567e4567-e89b-12d3-a456-426614174111" }
]
}
}
- Example Response (Validation Error):
{
"success": false,
"message": "Invalid input. Please provide an array of endpoint paths.",
"data": null
}
2. PUT /feature_flags/{feature_flag_id}/endpoints/{endpoint_id}
-
Description:
Updates the path of an existing endpoint associated with a feature flag. -
Request Body:
{
"new_endpoint_path": "/api/new_endpoint_path"
}
-
Response:
- The response will include the feature flag details (
feature_name,description,uuid) and the updated array of endpoints.
- The response will include the feature flag details (
-
Example Response (Success):
{
"success": true,
"message": "Endpoint updated successfully.",
"data": {
"name": "FF_Select",
"description": "Feature for selecting items",
"uuid": "123e4567-e89b-12d3-a456-426614174000",
"endpoints": [
{ "path": "/api/new_endpoint_path", "uuid": "567e4567-e89b-12d3-a456-426614174110" },
{ "path": "/api/bounty", "uuid": "567e4567-e89b-12d3-a456-426614174111" }
]
}
}
- Example Response (Validation Error):
{
"success": false,
"message": "Invalid input. Please provide a valid new_endpoint_path.",
"data": null
}
- Example Response (Not Found):
{
"success": false,
"message": "Endpoint or Feature Flag not found.",
"data": null
}
3. DELETE /feature_flags/{feature_flag_id}/endpoints/{endpoint_id}
-
Description:
Removes an endpoint from an existing feature flag. -
Response:
- The response will include the feature flag details (
feature_name,description,uuid) and the updated array of endpoints.
- The response will include the feature flag details (
-
Example Response (Success):
{
"success": true,
"message": "Endpoint deleted successfully.",
}
- Example Response (Not Found):
{
"success": false,
"message": "Endpoint or Feature Flag not found.",
"data": null
}
Input Validation
- POST /feature_flags/{feature_flag_id}/endpoints:
- Ensure the request body is an array of strings.
- Each string must represent a valid API path.
- PUT /feature_flags/{feature_flag_id}/endpoints/{endpoint_id}:
- Ensure the request body contains a valid
new_endpoint_path. - Validate that the endpoint belongs to the specified feature flag.
- Ensure the request body contains a valid
- DELETE /feature_flags/{feature_flag_id}/endpoints/{endpoint_id}:
- Validate that the
endpoint_idexists and is associated with the specifiedfeature_flag_id.
- Validate that the
Error Handling
- Return appropriate
success: falseresponses for the following cases:- Invalid inputs (e.g., malformed request bodies or invalid UUIDs).
- Feature flag or endpoint not found.
- Endpoint path already exists for the feature flag (for POST).
@tobi-bams @humansinstitute assign me?
@tobi-bams @humansinstitute assign