1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Endpoints; |
4
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Response\ApplicationsResponse; |
6
|
|
|
use AcquiaCloudApi\Response\InvitationsResponse; |
7
|
|
|
use AcquiaCloudApi\Response\MembersResponse; |
8
|
|
|
use AcquiaCloudApi\Response\MemberResponse; |
9
|
|
|
use AcquiaCloudApi\Response\OrganizationsResponse; |
10
|
|
|
use AcquiaCloudApi\Response\TeamsResponse; |
11
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class Organizations |
15
|
|
|
* |
16
|
|
|
* @package AcquiaCloudApi\CloudApi |
17
|
|
|
*/ |
18
|
|
|
class Organizations extends CloudApiBase implements CloudApiInterface |
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Show all organizations. |
23
|
|
|
* |
24
|
|
|
* @return OrganizationsResponse |
25
|
|
|
*/ |
26
|
|
|
public function getAll() |
27
|
|
|
{ |
28
|
|
|
return new OrganizationsResponse($this->client->request('get', '/organizations')); |
|
|
|
|
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Show all applications in an organization. |
33
|
|
|
* |
34
|
|
|
* @param string $organizationUuid |
35
|
|
|
* @return ApplicationsResponse |
36
|
|
|
*/ |
37
|
|
|
public function getApplications($organizationUuid) |
38
|
|
|
{ |
39
|
|
|
return new ApplicationsResponse( |
40
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/applications") |
|
|
|
|
41
|
|
|
); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Show all members of an organization. |
46
|
|
|
* |
47
|
|
|
* @param string $organizationUuid |
48
|
|
|
* @return MembersResponse |
49
|
|
|
*/ |
50
|
|
|
public function getMembers($organizationUuid) |
51
|
|
|
{ |
52
|
|
|
return new MembersResponse( |
53
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/members") |
|
|
|
|
54
|
|
|
); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Returns the user profile of this organization member. |
59
|
|
|
* |
60
|
|
|
* @param string $organizationUuid |
61
|
|
|
* @param string $memberUuid |
62
|
|
|
* @return MemberResponse |
63
|
|
|
*/ |
64
|
|
|
public function getMember($organizationUuid, $memberUuid) |
65
|
|
|
{ |
66
|
|
|
return new MemberResponse( |
67
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/members/${memberUuid}") |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Show all admins of an organization. |
73
|
|
|
* |
74
|
|
|
* @param string $organizationUuid |
75
|
|
|
* @return MembersResponse |
76
|
|
|
*/ |
77
|
|
|
public function getAdmins($organizationUuid) |
78
|
|
|
{ |
79
|
|
|
return new MembersResponse( |
80
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/admins") |
|
|
|
|
81
|
|
|
); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Returns the user profile of this organization administrator. |
86
|
|
|
* |
87
|
|
|
* @param string $organizationUuid |
88
|
|
|
* @param string $memberUuid |
89
|
|
|
* @return MemberResponse |
90
|
|
|
*/ |
91
|
|
|
public function getAdmin($organizationUuid, $memberUuid) |
92
|
|
|
{ |
93
|
|
|
return new MemberResponse( |
94
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/admins/${memberUuid}") |
95
|
|
|
); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Show all members invited to an organization. |
100
|
|
|
* |
101
|
|
|
* @param string $organizationUuid |
102
|
|
|
* @return InvitationsResponse |
103
|
|
|
*/ |
104
|
|
|
public function getMemberInvitations($organizationUuid) |
105
|
|
|
{ |
106
|
|
|
return new InvitationsResponse( |
107
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/team-invites") |
|
|
|
|
108
|
|
|
); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Delete a member from an organization. |
113
|
|
|
* |
114
|
|
|
* @param string $organizationUuid |
115
|
|
|
* @param string $memberUuid |
116
|
|
|
* @return OperationResponse |
117
|
|
|
*/ |
118
|
|
|
public function deleteMember($organizationUuid, $memberUuid) |
119
|
|
|
{ |
120
|
|
|
return new OperationResponse( |
121
|
|
|
$this->client->request( |
122
|
|
|
'delete', |
123
|
|
|
"/organizations/${organizationUuid}/members/${memberUuid}" |
124
|
|
|
) |
125
|
|
|
); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Leave an organization. |
130
|
|
|
* |
131
|
|
|
* @param string $organizationUuid |
132
|
|
|
* @return OperationResponse |
133
|
|
|
*/ |
134
|
|
|
public function leaveOrganization($organizationUuid) |
135
|
|
|
{ |
136
|
|
|
return new OperationResponse( |
137
|
|
|
$this->client->request( |
138
|
|
|
'post', |
139
|
|
|
"/organizations/${organizationUuid}/actions/leave" |
140
|
|
|
) |
141
|
|
|
); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Change the owner of an organization. |
146
|
|
|
* |
147
|
|
|
* @param string $organizationUuid |
148
|
|
|
* @param string $newOwnerUuid |
149
|
|
|
* @return OperationResponse |
150
|
|
|
*/ |
151
|
|
|
public function changeOwner($organizationUuid, $newOwnerUuid) |
152
|
|
|
{ |
153
|
|
|
$options = [ |
154
|
|
|
'json' => [ |
155
|
|
|
'user_uuid' => $newOwnerUuid, |
156
|
|
|
], |
157
|
|
|
]; |
158
|
|
|
return new OperationResponse( |
159
|
|
|
$this->client->request( |
160
|
|
|
'post', |
161
|
|
|
"/organizations/${organizationUuid}/actions/change-owner", |
162
|
|
|
$options |
163
|
|
|
) |
164
|
|
|
); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Show all teams in an organization. |
169
|
|
|
* |
170
|
|
|
* @param string $organizationUuid |
171
|
|
|
* @return TeamsResponse |
172
|
|
|
*/ |
173
|
|
|
public function getTeams($organizationUuid) |
174
|
|
|
{ |
175
|
|
|
return new TeamsResponse( |
176
|
|
|
$this->client->request('get', "/organizations/${organizationUuid}/teams") |
|
|
|
|
177
|
|
|
); |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* Invites a user to become admin of an organization. |
182
|
|
|
* |
183
|
|
|
* @param string $organizationUuid |
184
|
|
|
* @param string $email |
185
|
|
|
* @return OperationResponse |
186
|
|
|
*/ |
187
|
|
|
public function inviteAdmin($organizationUuid, $email) |
188
|
|
|
{ |
189
|
|
|
$options = [ |
190
|
|
|
'json' => [ |
191
|
|
|
'email' => $email, |
192
|
|
|
], |
193
|
|
|
]; |
194
|
|
|
|
195
|
|
|
return new OperationResponse( |
196
|
|
|
$this->client->request('post', "/organizations/${organizationUuid}/admin-invites", $options) |
197
|
|
|
); |
198
|
|
|
} |
199
|
|
|
} |
200
|
|
|
|