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\TeamsResponse; |
9
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class Client |
13
|
|
|
* @package AcquiaCloudApi\CloudApi |
14
|
|
|
*/ |
15
|
|
|
class Team implements CloudApi |
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
/** @var ClientInterface The API client. */ |
19
|
|
|
protected $client; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Client constructor. |
23
|
|
|
* |
24
|
|
|
* @param ClientInterface $connector |
25
|
|
|
*/ |
26
|
|
|
public function __construct(ClientInterface $client) |
27
|
|
|
{ |
28
|
|
|
$this->client = $client; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Show all teams. |
33
|
|
|
* |
34
|
|
|
* @return TeamsResponse |
35
|
|
|
*/ |
36
|
|
|
public function getTeams() |
37
|
|
|
{ |
38
|
|
|
return new TeamsResponse( |
39
|
|
|
$this->client->request('get', '/teams') |
|
|
|
|
40
|
|
|
); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Rename an existing team. |
45
|
|
|
* |
46
|
|
|
* @param string $teamUuid |
47
|
|
|
* @param string $name |
48
|
|
|
* @return OperationResponse |
49
|
|
|
*/ |
50
|
|
|
public function renameTeam($teamUuid, $name) |
51
|
|
|
{ |
52
|
|
|
$options = [ |
53
|
|
|
'form_params' => [ |
54
|
|
|
'name' => $name, |
55
|
|
|
], |
56
|
|
|
]; |
57
|
|
|
|
58
|
|
|
return new OperationResponse( |
59
|
|
|
$this->client->request('put', "/teams/${teamUuid}", $options) |
|
|
|
|
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Delete a team. |
66
|
|
|
* |
67
|
|
|
* @param string $teamUuid |
68
|
|
|
* @return OperationResponse |
69
|
|
|
*/ |
70
|
|
|
public function deleteTeam($teamUuid) |
71
|
|
|
{ |
72
|
|
|
return new OperationResponse( |
73
|
|
|
$this->client->request('delete', "/teams/${teamUuid}") |
|
|
|
|
74
|
|
|
); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Add an application to a team. |
79
|
|
|
* |
80
|
|
|
* @param string $teamUuid |
81
|
|
|
* @param string $applicationUuid |
82
|
|
|
* @return OperationResponse |
83
|
|
|
*/ |
84
|
|
|
public function addApplicationToTeam($teamUuid, $applicationUuid) |
85
|
|
|
{ |
86
|
|
|
$options = [ |
87
|
|
|
'form_params' => [ |
88
|
|
|
'uuid' => $applicationUuid, |
89
|
|
|
], |
90
|
|
|
]; |
91
|
|
|
|
92
|
|
|
return new OperationResponse( |
93
|
|
|
$this->client->request('post', "/teams/${teamUuid}/applications", $options) |
|
|
|
|
94
|
|
|
); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Invites a user to join a team. |
99
|
|
|
* |
100
|
|
|
* @param string $teamUuid |
101
|
|
|
* @param string $email |
102
|
|
|
* @param array $roles |
103
|
|
|
* @return OperationResponse |
104
|
|
|
*/ |
105
|
|
|
public function createTeamInvite($teamUuid, $email, $roles) |
106
|
|
|
{ |
107
|
|
|
$options = [ |
108
|
|
|
'form_params' => [ |
109
|
|
|
'email' => $email, |
110
|
|
|
'roles' => $roles |
111
|
|
|
], |
112
|
|
|
]; |
113
|
|
|
|
114
|
|
|
return new OperationResponse( |
115
|
|
|
$this->client->request('post', "/teams/${teamUuid}/invites", $options) |
|
|
|
|
116
|
|
|
); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Invites a user to become admin of an organization. |
121
|
|
|
* |
122
|
|
|
* @param string $organizationUuid |
123
|
|
|
* @param string $email |
124
|
|
|
* @return OperationResponse |
125
|
|
|
*/ |
126
|
|
|
public function createOrganizationAdminInvite($organizationUuid, $email) |
127
|
|
|
{ |
128
|
|
|
$options = [ |
129
|
|
|
'form_params' => [ |
130
|
|
|
'email' => $email, |
131
|
|
|
], |
132
|
|
|
]; |
133
|
|
|
|
134
|
|
|
return new OperationResponse( |
135
|
|
|
$this->client->request('post', "/teams/${organizationUuid}/invites", $options) |
|
|
|
|
136
|
|
|
); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Show all applications associated with a team. |
141
|
|
|
* |
142
|
|
|
* @param string $teamUuid |
143
|
|
|
* @return ApplicationsResponse |
144
|
|
|
*/ |
145
|
|
|
public function getApplications($teamUuid) |
146
|
|
|
{ |
147
|
|
|
return new ApplicationsResponse( |
148
|
|
|
$this->client->request('get', "/teams/${teamUuid}/applications") |
|
|
|
|
149
|
|
|
); |
150
|
|
|
} |
151
|
|
|
} |
152
|
|
|
|