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