|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Endpoints; |
|
4
|
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
|
6
|
|
|
use AcquiaCloudApi\Response\RoleResponse; |
|
7
|
|
|
use AcquiaCloudApi\Response\RolesResponse; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Class Roles |
|
11
|
|
|
* |
|
12
|
|
|
* @package AcquiaCloudApi\CloudApi |
|
13
|
|
|
*/ |
|
14
|
|
|
class Roles extends CloudApiBase |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* Show all roles in an organization. |
|
18
|
|
|
* |
|
19
|
|
|
* @return RolesResponse<RoleResponse> |
|
20
|
|
|
*/ |
|
21
|
|
|
public function getAll(string $organizationUuid): RolesResponse |
|
22
|
|
|
{ |
|
23
|
|
|
return new RolesResponse( |
|
24
|
|
|
$this->client->request('get', "/organizations/$organizationUuid/roles") |
|
25
|
|
|
); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Return details about a specific role. |
|
30
|
|
|
*/ |
|
31
|
|
|
public function get(string $roleUuid): RoleResponse |
|
32
|
|
|
{ |
|
33
|
|
|
return new RoleResponse( |
|
34
|
|
|
$this->client->request('get', "/roles/$roleUuid") |
|
35
|
|
|
); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Create a new role. |
|
40
|
|
|
* |
|
41
|
|
|
* @param array<string> $permissions |
|
42
|
|
|
*/ |
|
43
|
|
|
public function create( |
|
44
|
|
|
string $organizationUuid, |
|
45
|
|
|
string $name, |
|
46
|
|
|
array $permissions, |
|
47
|
|
|
?string $description = null |
|
48
|
|
|
): OperationResponse { |
|
49
|
|
|
$options = [ |
|
50
|
|
|
'json' => [ |
|
51
|
|
|
'name' => $name, |
|
52
|
|
|
'permissions' => $permissions, |
|
53
|
|
|
'description' => $description, |
|
54
|
|
|
], |
|
55
|
|
|
]; |
|
56
|
|
|
|
|
57
|
|
|
return new OperationResponse( |
|
58
|
|
|
$this->client->request('post', "/organizations/$organizationUuid/roles", $options) |
|
59
|
|
|
); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Update the permissions associated with a role. |
|
64
|
|
|
* |
|
65
|
|
|
* @param array<string> $permissions |
|
66
|
|
|
*/ |
|
67
|
|
|
public function update(string $roleUuid, array $permissions): OperationResponse |
|
68
|
|
|
{ |
|
69
|
|
|
$options = [ |
|
70
|
|
|
'json' => [ |
|
71
|
|
|
'permissions' => $permissions, |
|
72
|
|
|
], |
|
73
|
|
|
]; |
|
74
|
|
|
|
|
75
|
|
|
return new OperationResponse( |
|
76
|
|
|
$this->client->request('put', "/roles/$roleUuid", $options) |
|
77
|
|
|
); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Delete a role. |
|
82
|
|
|
*/ |
|
83
|
|
|
public function delete(string $roleUuid): OperationResponse |
|
84
|
|
|
{ |
|
85
|
|
|
return new OperationResponse($this->client->request('delete', "/roles/$roleUuid")); |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|