Role¶
Contents
Summary¶
Resource |
Operation |
Description |
---|---|---|
Role |
Creates a new role. Requires the admin role. |
|
Gets a single role given its ID. |
||
Gets a list of all the roles. |
||
Updates an existing role. Requires the admin role. |
||
Deletes a role. Requires the admin role. |
Create¶
JSON Schema
Required parameters are in bold.
type |
object |
|
properties |
||
|
type |
string |
maxLength |
80 |
|
minLength |
1 |
|
|
type |
string |
maxLength |
255 |
|
minLength |
1 |
|
additionalProperties |
False |
-
POST
/api/roles
¶ Creates a new role. Requires the admin role.
Example request:
POST /roles HTTP/1.1 Host: 127.0.0.1 Content-Type: application/json { "name": "analyst", "description": "Users that create and process intel" }
Example response:
HTTP/1.1 201 Created Content-Type: application/json { "id": 1, "name": "analyst", "description": "Users that create and process intel" }
- Request Headers
Authorization – Optional Apikey value
- Response Headers
Content-Type – application/json
- Status Codes
201 Created – Role created
400 Bad Request – JSON does not match the schema
401 Unauthorized – Invalid role to perform this action
409 Conflict – Role already exists
Read Single¶
-
GET
/api/roles/
(int: role_id)¶ Gets a single role given its ID.
Example request:
GET /roles/1 HTTP/1.1 Host: 127.0.0.1 Accept: application/json
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "id": 1, "name": "analyst", "description": "Users that create and process intel" }
- Request Headers
Authorization – Optional Apikey value
- Response Headers
Content-Type – application/json
- Status Codes
200 OK – Role found
401 Unauthorized – Invalid role to perform this action
404 Not Found – Role ID not found
Read Multiple¶
-
GET
/api/roles
¶ Gets a list of all the roles.
Example request:
GET /roles HTTP/1.1 Host: 127.0.0.1 Accept: application/json
Example response:
HTTP/1.1 200 OK Content-Type: application/json [ { "id": 1, "name": "analyst", "description": "Users that create and process intel" }, { "id": 2, "name": "readonly", "description": "Users that can only read the database" } ]
- Request Headers
Authorization – Optional Apikey value
- Response Headers
Content-Type – application/json
- Status Codes
200 OK – Roles found
401 Unauthorized – Invalid role to perform this action
Update¶
JSON Schema
Required parameters are in bold.
type |
object |
|
properties |
||
|
type |
string |
maxLength |
80 |
|
minLength |
1 |
|
|
type |
string |
maxLength |
255 |
|
minLength |
1 |
|
additionalProperties |
False |
-
PUT
/api/roles/
(int: role_id)¶ Updates an existing role. Requires the admin role.
Example request:
PUT /roles/1 HTTP/1.1 Host: 127.0.0.1 Content-Type: application/json { "name": "intelusers" }
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "id": 1, "name": "intelusers", "description": "Users that create and process intel" }
- Request Headers
Authorization – Optional Apikey value
- Response Headers
Content-Type – application/json
- Status Codes
200 OK – Role updated
400 Bad Request – JSON does not match the schema
401 Unauthorized – Invalid role to perform this action
404 Not Found – Role ID not found
409 Conflict – Role already exists
Delete¶
-
DELETE
/api/roles/
(int: role_id)¶ Deletes a role. Requires the admin role.
Example request:
DELETE /roles/1 HTTP/1.1 Host: 127.0.0.1
Example response:
HTTP/1.1 204 No Content
- Request Headers
Authorization – Optional Apikey value
- Status Codes
204 No Content – Role deleted
401 Unauthorized – Invalid role to perform this action
404 Not Found – Role ID not found
409 Conflict – Unable to delete role due to foreign key constraints