Endurance

Roles

Updated

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

Update a role

Edit a role. Refused with a 400 if it would leave no enabled local user who can edit users and roles, or would remove your own access to do so. Refused while a transaction is open. Commit or roll back the transaction first.

PUT /rbac/roles/{id}

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

The ids of the groups linked to the role. On an edit, leave it out or send null to keep them; an empty list unlinks them all.

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();
Bruno
meta {
  name: Update a role
  type: http
  seq: 1
}

put {
  url: https://{{node-0}}:{{port}}/api/v1/rbac/roles/{id}
  body: json
  auth: bearer
}

headers {
  Content-Type: application/json
}

auth:bearer {
  token: {{token}}
}

body:json {
  {
    "name": "<name>",
    "users": [
      "<users>"
    ],
    "groups": [
      "<groups>"
    ],
    "endpoints": [
      "<endpoints>"
    ]
  }
}
Response
{
  "status": "success",
  "message": "Role edited"
}