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