1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Endpoints; |
4
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Connector\ClientInterface; |
6
|
|
|
use AcquiaCloudApi\Response\ApplicationResponse; |
7
|
|
|
use AcquiaCloudApi\Response\ApplicationsResponse; |
8
|
|
|
use AcquiaCloudApi\Response\InvitationsResponse; |
9
|
|
|
use AcquiaCloudApi\Response\MembersResponse; |
10
|
|
|
use AcquiaCloudApi\Response\OrganizationsResponse; |
11
|
|
|
use AcquiaCloudApi\Response\RolesResponse; |
12
|
|
|
use AcquiaCloudApi\Response\TeamsResponse; |
13
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class Client |
17
|
|
|
* @package AcquiaCloudApi\CloudApi |
18
|
|
|
*/ |
19
|
|
|
class Organizations implements CloudApi |
20
|
|
|
{ |
21
|
|
|
|
22
|
|
|
/** @var ClientInterface The API client. */ |
23
|
|
|
protected $client; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Client constructor. |
27
|
|
|
* |
28
|
|
|
* @param ClientInterface $client |
29
|
|
|
*/ |
30
|
|
|
public function __construct(ClientInterface $client) |
31
|
|
|
{ |
32
|
|
|
$this->client = $client; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Show all organizations. |
37
|
|
|
* |
38
|
|
|
* @return OrganizationsResponse |
39
|
|
|
*/ |
40
|
|
|
public function getOrganizations() |
41
|
|
|
{ |
42
|
|
|
return new OrganizationsResponse($this->client->request('get', '/organizations')); |
|
|
|
|
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Show all applications in an organisation. |
47
|
|
|
* |
48
|
|
|
* @param string $organizationUuid |
49
|
|
|
* |
50
|
|
|
* @return ApplicationsResponse |
51
|
|
|
*/ |
52
|
|
|
public function getApplications($organizationUuid) |
53
|
|
|
{ |
54
|
|
|
return new ApplicationsResponse( |
55
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/applications") |
|
|
|
|
56
|
|
|
); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Show all roles in an organization. |
61
|
|
|
* |
62
|
|
|
* @param string $organizationUuid |
63
|
|
|
* @return RolesResponse |
64
|
|
|
*/ |
65
|
|
|
public function getRoles($organizationUuid) |
66
|
|
|
{ |
67
|
|
|
return new RolesResponse( |
68
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/roles") |
|
|
|
|
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Create a new role. |
74
|
|
|
* |
75
|
|
|
* @param string $organizationUuid |
76
|
|
|
* @param string $name |
77
|
|
|
* @param array $permissions |
78
|
|
|
* @param null|string $description |
79
|
|
|
* @return OperationResponse |
80
|
|
|
*/ |
81
|
|
|
public function createRole($organizationUuid, $name, array $permissions, $description = null) |
82
|
|
|
{ |
83
|
|
|
$options = [ |
84
|
|
|
'form_params' => [ |
85
|
|
|
'name' => $name, |
86
|
|
|
'permissions' => $permissions, |
87
|
|
|
'description' => $description, |
88
|
|
|
], |
89
|
|
|
]; |
90
|
|
|
|
91
|
|
|
return new OperationResponse( |
92
|
|
|
$this->client->request('post', "/organizations/${organizationUuid}/roles", $options) |
|
|
|
|
93
|
|
|
); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Show all teams in an organization. |
98
|
|
|
* |
99
|
|
|
* @param string $organizationUuid |
100
|
|
|
* @return TeamsResponse |
101
|
|
|
*/ |
102
|
|
|
public function getTeams($organizationUuid) |
103
|
|
|
{ |
104
|
|
|
return new TeamsResponse( |
105
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/teams") |
|
|
|
|
106
|
|
|
); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Create a new team. |
111
|
|
|
* |
112
|
|
|
* @param string $organizationUuid |
113
|
|
|
* @param string $name |
114
|
|
|
* @return OperationResponse |
115
|
|
|
*/ |
116
|
|
|
public function createTeam($organizationUuid, $name) |
117
|
|
|
{ |
118
|
|
|
$options = [ |
119
|
|
|
'form_params' => [ |
120
|
|
|
'name' => $name, |
121
|
|
|
], |
122
|
|
|
]; |
123
|
|
|
|
124
|
|
|
return new OperationResponse( |
125
|
|
|
$this->client->request('post', "/organizations/${organizationUuid}/teams", $options) |
|
|
|
|
126
|
|
|
); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Show all members of an organisation. |
131
|
|
|
* |
132
|
|
|
* @param string $organizationUuid |
133
|
|
|
* @return MembersResponse |
134
|
|
|
*/ |
135
|
|
|
public function getMembers($organizationUuid) |
136
|
|
|
{ |
137
|
|
|
return new MembersResponse( |
138
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/members") |
|
|
|
|
139
|
|
|
); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* Show all members invited to an organisation. |
144
|
|
|
* |
145
|
|
|
* @param string $organizationUuid |
146
|
|
|
* @return InvitationsResponse |
147
|
|
|
*/ |
148
|
|
|
public function getInvitees($organizationUuid) |
149
|
|
|
{ |
150
|
|
|
return new InvitationsResponse( |
151
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/team-invites") |
|
|
|
|
152
|
|
|
); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* Delete a member from an organisation. |
157
|
|
|
* |
158
|
|
|
* @param string $organizationUuid |
159
|
|
|
* @param string $memberUuid |
160
|
|
|
* @return OperationResponse |
161
|
|
|
*/ |
162
|
|
|
public function deleteMember($organizationUuid, $memberUuid) |
163
|
|
|
{ |
164
|
|
|
return new OperationResponse( |
165
|
|
|
$this->client->request( |
|
|
|
|
166
|
|
|
'delete', |
167
|
|
|
"/organizations/${organizationUuid}/members/${memberUuid}" |
168
|
|
|
) |
169
|
|
|
); |
170
|
|
|
} |
171
|
|
|
} |
172
|
|
|
|