Passed
Push — master ( 56d86a...d313c4 )
by Dane
03:16 queued 01:17
created

Environments::disableEmail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace AcquiaCloudApi\Endpoints;
4
5
use AcquiaCloudApi\Response\EnvironmentResponse;
6
use AcquiaCloudApi\Response\EnvironmentsResponse;
7
use AcquiaCloudApi\Response\OperationResponse;
8
9
/**
10
 * Class Environments
11
 *
12
 * @package AcquiaCloudApi\CloudApi
13
 */
14
class Environments extends CloudApiBase
15
{
16
    /**
17
     * Copies files from an environment to another environment.
18
     *
19
     * @param string $environmentUuidFrom
20
     * @param string $environmentUuidTo
21
     *
22
     * @return OperationResponse
23
     */
24
    public function copyFiles(string $environmentUuidFrom, string $environmentUuidTo): OperationResponse
25
    {
26
        $options = [
27
            'json' => [
28
                'source' => $environmentUuidFrom,
29
            ],
30
        ];
31
32
        return new OperationResponse(
33
            $this->client->request('post', "/environments/$environmentUuidTo/files", $options)
34
        );
35
    }
36
37
    /**
38
     * Gets information about an environment.
39
     *
40
     * @param string $environmentUuid
41
     *
42
     * @return EnvironmentResponse
43
     */
44
    public function get(string $environmentUuid): EnvironmentResponse
45
    {
46
        return new EnvironmentResponse(
47
            $this->client->request(
48
                'get',
49
                "/environments/$environmentUuid"
50
            )
51
        );
52
    }
53
54
    /**
55
     * Shows all environments in an application.
56
     *
57
     * @param string $applicationUuid
58
     *
59
     * @return EnvironmentsResponse<EnvironmentResponse>
60
     */
61
    public function getAll(string $applicationUuid): EnvironmentsResponse
62
    {
63
        return new EnvironmentsResponse(
64
            $this->client->request(
65
                'get',
66
                "/applications/$applicationUuid/environments"
67
            )
68
        );
69
    }
70
71
    /**
72
     * Modifies configuration settings for an environment.
73
     *
74
     * @param string $environmentUuid
75
     * @param mixed[] $config
76
     *
77
     * @return OperationResponse
78
     */
79
    public function update(string $environmentUuid, array $config): OperationResponse
80
    {
81
82
        $options = [
83
            'json' => $config,
84
        ];
85
86
        return new OperationResponse(
87
            $this->client->request(
88
                'put',
89
                "/environments/$environmentUuid",
90
                $options
91
            )
92
        );
93
    }
94
95
    /**
96
     * Renames an environment.
97
     *
98
     * @param string $environmentUuid
99
     * @param string $label
100
     *
101
     * @return OperationResponse
102
     */
103
    public function rename(string $environmentUuid, string $label): OperationResponse
104
    {
105
106
        $options = [
107
            'json' => [
108
                'label' => $label,
109
            ],
110
        ];
111
112
        return new OperationResponse(
113
            $this->client->request(
114
                'post',
115
                "/environments/$environmentUuid/actions/change-label",
116
                $options
117
            )
118
        );
119
    }
120
121
    /**
122
     * Enable livedev mode for an environment.
123
     *
124
     * @param string $environmentUuid
125
     *
126
     * @return OperationResponse
127
     */
128
    public function enableLiveDev(string $environmentUuid): OperationResponse
129
    {
130
        return new OperationResponse(
131
            $this->client->request('post', "/environments/$environmentUuid/livedev/actions/enable")
132
        );
133
    }
134
135
    /**
136
     * Disable livedev mode for an environment.
137
     *
138
     * @param string $environmentUuid
139
     *
140
     * @return OperationResponse
141
     */
142
    public function disableLiveDev(string $environmentUuid): OperationResponse
143
    {
144
145
        $options = [
146
            'json' => [
147
                'discard' => 1,
148
            ],
149
        ];
150
151
        return new OperationResponse(
152
            $this->client->request(
153
                'post',
154
                "/environments/$environmentUuid/livedev/actions/disable",
155
                $options
156
            )
157
        );
158
    }
159
160
    /**
161
     * Enable production mode for an environment.
162
     *
163
     * @param string $environmentUuid
164
     *
165
     * @return OperationResponse
166
     */
167
    public function enableProductionMode(string $environmentUuid): OperationResponse
168
    {
169
        return new OperationResponse(
170
            $this->client->request(
171
                'post',
172
                "/environments/$environmentUuid/production-mode/actions/enable"
173
            )
174
        );
175
    }
176
177
    /**
178
     * Disable production mode for an environment.
179
     *
180
     * @param string $environmentUuid
181
     *
182
     * @return OperationResponse
183
     */
184
    public function disableProductionMode(string $environmentUuid): OperationResponse
185
    {
186
        return new OperationResponse(
187
            $this->client->request(
188
                'post',
189
                "/environments/$environmentUuid/production-mode/actions/disable"
190
            )
191
        );
192
    }
193
194
    /**
195
     * Enable platform email for an environment.
196
     *
197
     * @param string $environmentUuid
198
     *
199
     * @return OperationResponse
200
     */
201
    public function enableEmail(string $environmentUuid): OperationResponse
202
    {
203
        return new OperationResponse(
204
            $this->client->request(
205
                'post',
206
                "/environments/$environmentUuid/email/actions/enable"
207
            )
208
        );
209
    }
210
211
    /**
212
     * Disable platform email for an environment.
213
     *
214
     * @param string $environmentUuid
215
     *
216
     * @return OperationResponse
217
     */
218
    public function disableEmail(string $environmentUuid): OperationResponse
219
    {
220
        return new OperationResponse(
221
            $this->client->request(
222
                'post',
223
                "/environments/$environmentUuid/email/actions/disable"
224
            )
225
        );
226
    }
227
228
    /**
229
     * Add a new continuous delivery environment to an application.
230
     *
231
     * @param string $applicationUuid
232
     * @param string $label
233
     * @param string $branch
234
     * @param array<string> $databases
235
     *
236
     * @return OperationResponse
237
     */
238
    public function create(string $applicationUuid, string $label, string $branch, array $databases): OperationResponse
239
    {
240
        $options = [
241
            'json' => [
242
                'label' => $label,
243
                'branch' => $branch,
244
                'databases' => $databases,
245
            ],
246
        ];
247
248
        return new OperationResponse(
249
            $this->client->request(
250
                'post',
251
                "/applications/$applicationUuid/environments",
252
                $options
253
            )
254
        );
255
    }
256
257
    /**
258
     * Deletes a CD environment.
259
     *
260
     * @param string $environmentUuid
261
     *
262
     * @return OperationResponse
263
     */
264
    public function delete(string $environmentUuid): OperationResponse
265
    {
266
        return new OperationResponse(
267
            $this->client->request(
268
                'delete',
269
                "/environments/$environmentUuid"
270
            )
271
        );
272
    }
273
}
274