sphinx-tribes icon indicating copy to clipboard operation
sphinx-tribes copied to clipboard

Endpoint Management API

Open tobi-bams opened this issue 1 year ago • 2 comments

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, and data.
  • 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.
  • 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.
  • 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.
  • DELETE /feature_flags/{feature_flag_id}/endpoints/{endpoint_id}:
    • Validate that the endpoint_id exists and is associated with the specified feature_flag_id.

Error Handling

  • Return appropriate success: false responses 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 avatar Dec 19 '24 14:12 tobi-bams

@tobi-bams @humansinstitute assign me?

aliraza556 avatar Dec 19 '24 14:12 aliraza556

@tobi-bams @humansinstitute assign

MahtabBukhari avatar Dec 19 '24 14:12 MahtabBukhari