You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The route to the new resource will be returned in the Location header of the response.
Note: Attempting to create a role with a role_name which already exists will return 409 Conflict with a Content-Location header pointing to the route of the conflicting record.
For this we need to use the auth service RPC method called "auth_file.set_roles".
Note that this method sets the ENTIRE roles dictionary, rather than appending to it. We can get the existing roles dictionary with the "auth_file.read" method, then modify and store it if appropriate (here is some pseudo-code where "role_name" is the name of the role we are adding -- we got that from the request body in the data variable.):
roles <--- _rpc('platform.auth', "auth_file.read")["roles"]
# Check that the role does not already exist, return error if it does.
if role_name in roles:
return 409 Conflict response with a content-location header containing a route to the endpoint for the existing role entry.
# Add the role to the current roles dictionary and save it. Return a created response.
roles[role_name] <--- list of capabilities from the request body (in our data dictionary).
_rpc('platform.auth', "auth_file.set_roles", roles)
return 201 created with location header containing a route to the endpoint for the new role entry.
Create a new role on the specified platform.
The route to the new resource will be returned in the
Location
header of the response.Request:
BEARER <jwt_token>
application/json
Response:
201 Created
/platforms/:platform/roles/:role
409 Conflict
application/json
/vui/platforms/:platform/roles/:role_name
400 Bad Request
application/json
401 Unauthorized
The text was updated successfully, but these errors were encountered: