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 Teams |
13
|
|
|
* @package AcquiaCloudApi\CloudApi |
14
|
|
|
*/ |
15
|
|
|
class Teams extends CloudApiBase implements CloudApiInterface |
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Create a new team. |
20
|
|
|
* |
21
|
|
|
* @param string $organizationUuid |
22
|
|
|
* @param string $name |
23
|
|
|
* @return OperationResponse |
24
|
|
|
*/ |
25
|
|
|
public function create($organizationUuid, $name) |
26
|
|
|
{ |
27
|
|
|
$options = [ |
28
|
|
|
'form_params' => [ |
29
|
|
|
'name' => $name, |
30
|
|
|
], |
31
|
|
|
]; |
32
|
|
|
|
33
|
|
|
return new OperationResponse( |
34
|
|
|
$this->client->request('post', "/organizations/${organizationUuid}/teams", $options) |
|
|
|
|
35
|
|
|
); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Show all teams. |
40
|
|
|
* |
41
|
|
|
* @return TeamsResponse |
42
|
|
|
*/ |
43
|
|
|
public function getAll() |
44
|
|
|
{ |
45
|
|
|
return new TeamsResponse( |
46
|
|
|
$this->client->request('get', '/teams') |
|
|
|
|
47
|
|
|
); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Rename an existing team. |
52
|
|
|
* |
53
|
|
|
* @param string $teamUuid |
54
|
|
|
* @param string $name |
55
|
|
|
* @return OperationResponse |
56
|
|
|
*/ |
57
|
|
|
public function rename($teamUuid, $name) |
58
|
|
|
{ |
59
|
|
|
$options = [ |
60
|
|
|
'form_params' => [ |
61
|
|
|
'name' => $name, |
62
|
|
|
], |
63
|
|
|
]; |
64
|
|
|
|
65
|
|
|
return new OperationResponse( |
66
|
|
|
$this->client->request('put', "/teams/${teamUuid}", $options) |
|
|
|
|
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Delete a team. |
73
|
|
|
* |
74
|
|
|
* @param string $teamUuid |
75
|
|
|
* @return OperationResponse |
76
|
|
|
*/ |
77
|
|
|
public function delete($teamUuid) |
78
|
|
|
{ |
79
|
|
|
return new OperationResponse( |
80
|
|
|
$this->client->request('delete', "/teams/${teamUuid}") |
|
|
|
|
81
|
|
|
); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Add an application to a team. |
86
|
|
|
* |
87
|
|
|
* @param string $teamUuid |
88
|
|
|
* @param string $applicationUuid |
89
|
|
|
* @return OperationResponse |
90
|
|
|
*/ |
91
|
|
|
public function addApplication($teamUuid, $applicationUuid) |
92
|
|
|
{ |
93
|
|
|
$options = [ |
94
|
|
|
'form_params' => [ |
95
|
|
|
'uuid' => $applicationUuid, |
96
|
|
|
], |
97
|
|
|
]; |
98
|
|
|
|
99
|
|
|
return new OperationResponse( |
100
|
|
|
$this->client->request('post', "/teams/${teamUuid}/applications", $options) |
|
|
|
|
101
|
|
|
); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Invites a user to join a team. |
106
|
|
|
* |
107
|
|
|
* @param string $teamUuid |
108
|
|
|
* @param string $email |
109
|
|
|
* @param array $roles |
110
|
|
|
* @return OperationResponse |
111
|
|
|
*/ |
112
|
|
|
public function invite($teamUuid, $email, $roles) |
113
|
|
|
{ |
114
|
|
|
$options = [ |
115
|
|
|
'form_params' => [ |
116
|
|
|
'email' => $email, |
117
|
|
|
'roles' => $roles |
118
|
|
|
], |
119
|
|
|
]; |
120
|
|
|
|
121
|
|
|
return new OperationResponse( |
122
|
|
|
$this->client->request('post', "/teams/${teamUuid}/invites", $options) |
|
|
|
|
123
|
|
|
); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Show all applications associated with a team. |
128
|
|
|
* |
129
|
|
|
* @param string $teamUuid |
130
|
|
|
* @return ApplicationsResponse |
131
|
|
|
*/ |
132
|
|
|
public function getApplications($teamUuid) |
133
|
|
|
{ |
134
|
|
|
return new ApplicationsResponse( |
135
|
|
|
$this->client->request('get', "/teams/${teamUuid}/applications") |
|
|
|
|
136
|
|
|
); |
137
|
|
|
} |
138
|
|
|
} |
139
|
|
|
|