POST users.types.scopes - ocariot/api-gateway GitHub Wiki

Description

Replaces the scopes of all users according to the type.

Permissions:

  • This route is not restricted to having a user logged in. Its protection occurs through the host, where only 'localhost' can access it.

Scope

This endpoint is not protected by any scope.

URL

POST https://localhost/v1/users/types/{user_type}/scopes

Parameters

user_type: string (available values: admin, application, child, educator, family, healthprofessional)

Request body

{
  "scopes": [
     "new_scope_1",
     "new_scope_2"
  ]
}

Curl example

curl -X POST "https://localhost/v1/users/types/child/scopes" -H "accept: /" -H "Content-Type: application/json" -d "{"scopes":["new_scope_1", "new_scope_2", ...]}"

Response body

  • 204 Operation successfully performed. The scope have been updated (or there was no user in the database that was of the type informed in endpoint) and there is no data to be returned.

  • 400 Validation errors

    • Invalid JSON format

    • Invalid user_type

      • Pattern
      {
        "code": 400,
        "message": "One or more request fields are invalid...",
        "description": "The user types allowed are: admin, child, educator, healthprofessional, family, application."
      }
      
    • Invalid scopes 1 (receives undefined or an empty array)

      • Pattern
      {
        "code": 400,
        "message": "The list of new scopes is invalid!",
        "description": "A scopes array with at least one item is required."
      }
      
    • Invalid scopes 2 (receives one or more invalid scopes for the user type informed)

      • Pattern
      {
        "code": 400,
        "message": "The list of new scopes is invalid!",
        "description": "{0} are not valid scopes for {1} users."
      }
      
      • Example
      {
        "code": 400,
        "message": "The list of new scopes is invalid!",
        "description": "children:readAll, institutions:create, environment:create are not valid scopes for child users."
      }
      
  • 429 Too Many Requests Error

  • 500 Internal Server Error