Introduction
Roles
are used to manage Permissions
in intratool.
The binding of Permissions
to a Role
is done by a pivot table called permission_role
, in which each Permission
of the unique Role
is assigned.
Those Roles
will then get assigned to a Department so that every member of a Department has the same Permissions
unless the Permissions
are not modified for a specific User .
All this data can then be retrieved/created or modified via the Roles
API.
Model Definition
Alias
role
Relations
Relation Key Type Relation Field(s)
List
Get a list of all Roles
.
Definition
GET
/api/roles
Example Request
PHP
Copy $client = new GuzzleHttp \ Client ([ 'base_uri' => 'https://{tenant}.intratool.de' ]);
$response = $client -> request ( 'GET' , '/api/roles' , [
'headers' => [ 'Authorization' => "Bearer {accessToken}" ]
] ) ;
Example Response
Copy [
{
"id" : 2 ,
"name" : "Usergroup-1" ,
"active" : 1 ,
"department_id" : 2 ,
"sort_number" : 1 ,
"created_at" : "2019-01-21 13:55:33" ,
"updated_at" : "2019-01-21 13:56:22" ,
"deleted_at" : null ,
"department" : {
"id" : 2 ,
"name" : "Usergroup-1"
} ,
"permissions" : [
{
"id" : 1 ,
"type" : "infoboard" ,
"name" : "infoboard-administration-rights" ,
"description" : "Administrationsrechte" ,
"sort_number" : 2
} ,
{
"id" : 12 ,
"type" : "infoboard" ,
"name" : "infoboard-show" ,
"description" : "Infoboard anzeigen" ,
"sort_number" : 1
} ,
{
"id" : 100 ,
"type" : "manual" ,
"name" : "manual-administration-rights" ,
"description" : "Administrationsrechte" ,
"sort_number" : 101
}
]
}
]
Show
Show a single Role
by id
.
Definition
GET
/api/roles/{id}
Example Request
PHP
Copy $client = new GuzzleHttp \ Client ([ 'base_uri' => 'https://{tenant}.intratool.de' ]);
$response = $client -> request ( 'GET' , '/api/roles/3' , [
'headers' => [ 'Authorization' => "Bearer {accessToken}" ]
] ) ;
Example Response
Copy {
"id" : 3 ,
"name" : "Usergroup-2" ,
"active" : 1 ,
"department_id" : 3 ,
"sort_number" : 2 ,
"created_at" : "2019-01-21 13:55:35" ,
"updated_at" : "2019-01-21 13:56:24" ,
"deleted_at" : null ,
"department" : {
"id" : 3 ,
"name" : "Usergroup-2"
} ,
"permissions" : [
{
"id" : 12 ,
"type" : "infoboard" ,
"name" : "infoboard-show" ,
"description" : "Infoboard anzeigen" ,
"sort_number" : 1
}
] ,
"departments" : [
{
"id" : 3 ,
"name" : "Usergroup-2"
}
] ,
"infoboard_departments" : [
{
"id" : 3 ,
"name" : "Usergroup-2"
}
]
}
Create
Create a new Role
.
Definition
POST
/api/roles
Request Keys
Key Type Default Description The granted Permissions
of the Role
Keys with *
are required.
Example Request
PHP
Copy $client = new GuzzleHttp \ Client ([ 'base_uri' => 'https://{tenant}.intratool.de' ]);
$response = $client -> request ( 'POST' , '/api/roles' , [
'headers' => [ 'Authorization' => "Bearer {accessToken}" ] ,
'json' => [
'department_id' => 7 ,
'name' => 'Usergroup-4' ,
'permission_ids' => '1'
]
] ) ;
Example Response
Copy {
"status" : "success" ,
"data" : {
"department_id" : 7 ,
"name" : "Usergroup-4" ,
"sort_number" : -1 ,
"active" : 1 ,
"updated_at" : "2019-01-24 15:58:18" ,
"created_at" : "2019-01-24 15:58:18" ,
"id" : 5
}
}
Update
Update an existing Role
by id
.
Definition
PUT
/api/roles/{id}
Request Keys
Key Type Description The granted Permissions
of the Role
Example Request
PHP
Copy $client = new GuzzleHttp \ Client ([ 'base_uri' => 'https://{tenant}.intratool.de' ]);
$response = $client -> request ( 'PUT' , '/api/roles/5' , [
'headers' => [ 'Authorization' => "Bearer {accessToken}" ] ,
'json' => [
'department_ids' => '2'
]
] ) ;
Example Response
Copy {
"status" : "success" ,
"data" : {
"id" : 5 ,
"name" : "Usergroup-4" ,
"active" : 1 ,
"department_id" : 7 ,
"sort_number" : 4 ,
"created_at" : "2019-01-24 15:58:18" ,
"updated_at" : "2019-01-24 15:58:19" ,
"deleted_at" : null
}
}
Delete
Delete an existing Role
by id
.
Definition
DELETE
/api/roles/{id}
Example Request
PHP
Copy $client = new GuzzleHttp \ Client ([ 'base_uri' => 'https://{tenant}.intratool.de' ]);
$response = $client -> request ( ' DELETE ' , '/api/roles/5' , [
'headers' => [ 'Authorization' => "Bearer {accessToken}" ]
] ) ;
Example Response
Copy {
"status" : "success" ,
"data" : []
}
Last updated 4 months ago