Role service#
RoleService provides methods for managing roles within Nominal.
OpenAPI file: nominal.authorization.roles.v1.json
Endpoints#
Batch get resource roles#
POST /authorization/roles/v1/batch-get-resource-roles
Gets the role assignments for multiple resources.
Body
resourcesarray of string
Response
roleAssignmentsByResourcemap of string toRoleAssignmentWrapper
Fields of
RoleAssignmentWrapperroleAssignmentsarray ofRoleAssignmentResponse
Fields of
RoleAssignmentResponseroleRole
Values of
RoleROLE_UNSPECIFIEDDefault value, should not be used.
ROLE_OWNER
userRidstring
Request
curl -X POST "https://api.gov.nominal.io/api/authorization/roles/v1/batch-get-resource-roles" \
-H "Authorization: Bearer <api key>" \
-H "Content-Type: application/json" \
--data '{
"resources": [
"<resources>"
]
}'
import requests
response = requests.post(
"https://api.gov.nominal.io/api/authorization/roles/v1/batch-get-resource-roles",
headers={"Authorization": "Bearer <api key>"},
json={"resources": ["<resources>"]},
)
response.raise_for_status()
print(response.json())
import httpx
response = httpx.post(
"https://api.gov.nominal.io/api/authorization/roles/v1/batch-get-resource-roles",
headers={"Authorization": "Bearer <api key>"},
json={"resources": ["<resources>"]},
)
response.raise_for_status()
print(response.json())
import asyncio
import aiohttp
async def main() -> None:
async with aiohttp.ClientSession() as session:
async with session.post(
"https://api.gov.nominal.io/api/authorization/roles/v1/batch-get-resource-roles",
headers={"Authorization": "Bearer <api key>"},
json={"resources": ["<resources>"]},
) as response:
response.raise_for_status()
print(await response.json())
asyncio.run(main())
Response: 200
{
"roleAssignmentsByResource": {
"<key>": {
"roleAssignments": [
{
"role": "ROLE_OWNER",
"userRid": "<user rid>"
}
]
}
}
}
Get resource roles#
GET /authorization/roles/v1/resource/{resource}/roles
Gets the role assignments for a resource.
Path parameters
resourcestring required
Response
roleAssignmentsarray ofRoleAssignmentResponse
Fields of
RoleAssignmentResponseroleRole
Values of
RoleROLE_UNSPECIFIEDDefault value, should not be used.
ROLE_OWNER
userRidstring
Request
curl "https://api.gov.nominal.io/api/authorization/roles/v1/resource/<resource>/roles" \
-H "Authorization: Bearer <api key>"
import requests
response = requests.get(
"https://api.gov.nominal.io/api/authorization/roles/v1/resource/<resource>/roles",
headers={"Authorization": "Bearer <api key>"},
)
response.raise_for_status()
print(response.json())
import httpx
response = httpx.get(
"https://api.gov.nominal.io/api/authorization/roles/v1/resource/<resource>/roles",
headers={"Authorization": "Bearer <api key>"},
)
response.raise_for_status()
print(response.json())
import asyncio
import aiohttp
async def main() -> None:
async with aiohttp.ClientSession() as session:
async with session.get(
"https://api.gov.nominal.io/api/authorization/roles/v1/resource/<resource>/roles",
headers={"Authorization": "Bearer <api key>"},
) as response:
response.raise_for_status()
print(await response.json())
asyncio.run(main())
Response: 200
{
"roleAssignments": [
{
"role": "ROLE_OWNER",
"userRid": "<user rid>"
}
]
}
Update resource roles#
POST /authorization/roles/v1/resource/{resource}/roles
Atomically adds and removes role assignments for a resource. Throws if the same role assignment is both added and removed in the same request.
Path parameters
resourcestring required
Body
assignmentsToAddarray ofRoleAssignmentRequest
Fields of
RoleAssignmentRequestroleRole
Values of
RoleROLE_UNSPECIFIEDDefault value, should not be used.
ROLE_OWNER
userRidstring
assignmentsToRemovearray ofRoleAssignmentRequest
Response
An empty JSON object, {}.
Request
curl -X POST "https://api.gov.nominal.io/api/authorization/roles/v1/resource/<resource>/roles" \
-H "Authorization: Bearer <api key>" \
-H "Content-Type: application/json" \
--data '{
"assignmentsToAdd": [
{
"role": "ROLE_OWNER",
"userRid": "<user rid>"
}
],
"assignmentsToRemove": [
{
"role": "ROLE_OWNER",
"userRid": "<user rid>"
}
]
}'
import requests
response = requests.post(
"https://api.gov.nominal.io/api/authorization/roles/v1/resource/<resource>/roles",
headers={"Authorization": "Bearer <api key>"},
json={
"assignmentsToAdd": [{"role": "ROLE_OWNER", "userRid": "<user rid>"}],
"assignmentsToRemove": [{"role": "ROLE_OWNER", "userRid": "<user rid>"}],
},
)
response.raise_for_status()
print(response.json())
import httpx
response = httpx.post(
"https://api.gov.nominal.io/api/authorization/roles/v1/resource/<resource>/roles",
headers={"Authorization": "Bearer <api key>"},
json={
"assignmentsToAdd": [{"role": "ROLE_OWNER", "userRid": "<user rid>"}],
"assignmentsToRemove": [{"role": "ROLE_OWNER", "userRid": "<user rid>"}],
},
)
response.raise_for_status()
print(response.json())
import asyncio
import aiohttp
async def main() -> None:
async with aiohttp.ClientSession() as session:
async with session.post(
"https://api.gov.nominal.io/api/authorization/roles/v1/resource/<resource>/roles",
headers={"Authorization": "Bearer <api key>"},
json={
"assignmentsToAdd": [{"role": "ROLE_OWNER", "userRid": "<user rid>"}],
"assignmentsToRemove": [{"role": "ROLE_OWNER", "userRid": "<user rid>"}],
},
) as response:
response.raise_for_status()
print(await response.json())
asyncio.run(main())
Response: 200
{}
Types#
Role#
ROLE_UNSPECIFIEDDefault value, should not be used.
ROLE_OWNER
RoleAssignmentRequest#
roleRole
userRidstring
RoleAssignmentResponse#
roleRole
userRidstring
RoleAssignmentWrapper#
roleAssignmentsarray ofRoleAssignmentResponse
Page design based on Scalar, MIT License.