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

Build Feature Flag Endpoints

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

Breakdown of feature flag system in: https://github.com/stakwork/sphinx-tribes/issues/2235

1. GET /feature_flags

  • Description:
    This endpoint retrieves a list of all feature flags, including their status (enabled) and associated endpoints.

  • Response:

    • The response will return a structured object with the following fields:
      • success: A boolean indicating whether the operation was successful.
      • message: A descriptive message (e.g., "Feature flags fetched successfully").
      • data: An array of feature flag objects containing the details of each feature flag
  • Example Response:

{
  "success": true,
  "message": "Feature flags fetched successfully.",
  "data": [
    {
      "name": "FF_Chat",
      "description": "Enables chat feature",
      "enabled": true,
      "uuid": "123e4567-e89b-12d3-a456-426614174000",
      "endpoints": [
        { "path": "/api/v1/chat", "uuid": "567e4567-e89b-12d3-a456-426614174111" },
        { "path": "/api/v1/chat/:id", "uuid": "567e4567-e89b-12d3-a456-426614174112" }
      ]
    },
    {
      "name": "FF_Payments",
      "description": "Enables payments feature",
      "enabled": false,
      "uuid": "123e4567-e89b-12d3-a456-426614174001",
      "endpoints": [
        { "path": "/api/v1/payment", "uuid": "567e4567-e89b-12d3-a456-426614174113" }
      ]
    }
  ]
}

2. POST /feature_flags

  • Description:
    This endpoint allows admins to create a new feature flag with associated endpoints.

  • Request Body:

{
  "name": "FF_Chat",
  "description": "Enables chat feature",
  "enabled": false,
  "endpoints": ["/api/v1/chat", "/api/v1/chat/:id"]
}
  • Response:

    • The response will return the newly created feature flag object, along with a success status, a message, and the created data.
  • Example Response:

{
  "success": true,
  "message": "Feature flag created successfully.",
  "data": {
    "name": "FF_Chat",
    "description": "Enables chat feature",
    "enabled": false,
    "uuid": "123e4567-e89b-12d3-a456-426614174000",
    "endpoints": [
      { "path": "/api/v1/chat", "uuid": "567e4567-e89b-12d3-a456-426614174111" },
      { "path": "/api/v1/chat/:id", "uuid": "567e4567-e89b-12d3-a456-426614174112" }
    ]
  }
}

3. PUT /feature_flags/{id}

  • Description:
    This endpoint allows admins to update an existing feature flag’s name, description, and enabled status.

  • Request Body:

{
  "name": "FF_Chat",
  "description": "Enables chat feature with enhancements",
  "enabled": true
}
  • Response:

    • The response will return the updated feature flag object, along with a success status, a message, and the updated data.
  • Example Response:

{
  "success": true,
  "message": "Feature flag updated successfully.",
  "data": {
    "name": "FF_Chat",
    "description": "Enables chat feature with enhancements",
    "enabled": true,
    "uuid": "123e4567-e89b-12d3-a456-426614174000",
    "endpoints": [
      { "path": "/api/v1/chat", "uuid": "567e4567-e89b-12d3-a456-426614174111" },
      { "path": "/api/v1/chat/:id", "uuid": "567e4567-e89b-12d3-a456-426614174112" }
    ]
  }
}

4. DELETE /feature_flags/{id}

  • Description:
    This endpoint allows admins to delete an existing feature flag along with its associated endpoints.

  • Response:

    • The response will return a success status, a message indicating whether the deletion was successful, and an appropriate error message if the feature flag was not found.
  • Example Response (Success):

{
  "success": true,
  "message": "Feature flag successfully deleted.",
  "data": null
}
  • Example Response (Not Found):
{
  "success": false,
  "message": "Feature flag not found.",
  "data": null
}

tobi-bams avatar Dec 19 '24 13:12 tobi-bams

@humansinstitute @tobi-bams assign me?

AbuBakar877 avatar Dec 19 '24 13:12 AbuBakar877

@tobi-bams @humansinstitute Please assign me?

aliraza556 avatar Dec 19 '24 13:12 aliraza556

@tobi-bams @humansinstitute assign

MahtabBukhari avatar Dec 19 '24 14:12 MahtabBukhari