Endurance

Roles

A role is a named set of permissions. Assigning one to a group decides what its members can do.

Update a role

PUT /rbac/roles/{id}

Edit a Role

This change is staged. Send PUT /services/apply to apply it.

Path parameters
id string Required

The id of the role.

Body parameters
name string Required
users array Required

Array of users ids

groups array Required

Array of groups ids

endpoints array Required

Array of endpoints ids

curl
curl -X PUT "https://appliance.example.com/api/v1/rbac/roles/{id}" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "<name>",
  "users": [
    "<users>"
  ],
  "groups": [
    "<groups>"
  ],
  "endpoints": [
    "<endpoints>"
  ]
}'
PHP
<?php

$url = 'https://appliance.example.com/api/v1/rbac/roles/{id}';
$headers = [
    'Authorization: Bearer ' . $token,
    'Content-Type: application/json',
];

$payload = [
    'name' => '<name>',
    'users' => [
        '<users>',
    ],
    'groups' => [
        '<groups>',
    ],
    'endpoints' => [
        '<endpoints>',
    ],
];

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS => json_encode($payload),
]);

$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests

headers = {"Authorization": f"Bearer {token}"}
payload = {
    "name": "<name>",
    "users": [
        "<users>"
    ],
    "groups": [
        "<groups>"
    ],
    "endpoints": [
        "<endpoints>"
    ]
}

response = requests.put("https://appliance.example.com/api/v1/rbac/roles/{id}", headers=headers, json=payload)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/rbac/roles/{id}', {
  method: 'PUT',
  headers: {
    Authorization: `Bearer ${token}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "name": "<name>",
  "users": [
    "<users>"
  ],
  "groups": [
    "<groups>"
  ],
  "endpoints": [
    "<endpoints>"
  ]
}),
});

const data = await response.json();
Response
{
  "status": "success",
  "message": "Role edited"
}