Environments::disableLiveDev()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 14
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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
    public function copyFiles(string $environmentUuidFrom, string $environmentUuidTo): OperationResponse
20
    {
21
        $options = [
22
            'json' => [
23
                'source' => $environmentUuidFrom,
24
            ],
25
        ];
26
27
        return new OperationResponse(
28
            $this->client->request('post', "/environments/$environmentUuidTo/files", $options)
29
        );
30
    }
31
32
    /**
33
     * Gets information about an environment.
34
     */
35
    public function get(string $environmentUuid): EnvironmentResponse
36
    {
37
        return new EnvironmentResponse(
38
            $this->client->request(
39
                'get',
40
                "/environments/$environmentUuid"
41
            )
42
        );
43
    }
44
45
    /**
46
     * Shows all environments in an application.
47
     *
48
     * @return EnvironmentsResponse<EnvironmentResponse>
49
     */
50
    public function getAll(string $applicationUuid): EnvironmentsResponse
51
    {
52
        return new EnvironmentsResponse(
53
            $this->client->request(
54
                'get',
55
                "/applications/$applicationUuid/environments"
56
            )
57
        );
58
    }
59
60
    /**
61
     * Modifies configuration settings for an environment.
62
     *
63
     * @param mixed[] $config
64
     */
65
    public function update(string $environmentUuid, array $config): OperationResponse
66
    {
67
68
        $options = [
69
            'json' => $config,
70
        ];
71
72
        return new OperationResponse(
73
            $this->client->request(
74
                'put',
75
                "/environments/$environmentUuid",
76
                $options
77
            )
78
        );
79
    }
80
81
    /**
82
     * Renames an environment.
83
     */
84
    public function rename(string $environmentUuid, string $label): OperationResponse
85
    {
86
87
        $options = [
88
            'json' => [
89
                'label' => $label,
90
            ],
91
        ];
92
93
        return new OperationResponse(
94
            $this->client->request(
95
                'post',
96
                "/environments/$environmentUuid/actions/change-label",
97
                $options
98
            )
99
        );
100
    }
101
102
    /**
103
     * Enable livedev mode for an environment.
104
     */
105
    public function enableLiveDev(string $environmentUuid): OperationResponse
106
    {
107
        return new OperationResponse(
108
            $this->client->request('post', "/environments/$environmentUuid/livedev/actions/enable")
109
        );
110
    }
111
112
    /**
113
     * Disable livedev mode for an environment.
114
     */
115
    public function disableLiveDev(string $environmentUuid): OperationResponse
116
    {
117
118
        $options = [
119
            'json' => [
120
                'discard' => 1,
121
            ],
122
        ];
123
124
        return new OperationResponse(
125
            $this->client->request(
126
                'post',
127
                "/environments/$environmentUuid/livedev/actions/disable",
128
                $options
129
            )
130
        );
131
    }
132
133
    /**
134
     * Enable production mode for an environment.
135
     */
136
    public function enableProductionMode(string $environmentUuid): OperationResponse
137
    {
138
        return new OperationResponse(
139
            $this->client->request(
140
                'post',
141
                "/environments/$environmentUuid/production-mode/actions/enable"
142
            )
143
        );
144
    }
145
146
    /**
147
     * Disable production mode for an environment.
148
     */
149
    public function disableProductionMode(string $environmentUuid): OperationResponse
150
    {
151
        return new OperationResponse(
152
            $this->client->request(
153
                'post',
154
                "/environments/$environmentUuid/production-mode/actions/disable"
155
            )
156
        );
157
    }
158
159
    /**
160
     * Enable platform email for an environment.
161
     */
162
    public function enableEmail(string $environmentUuid): OperationResponse
163
    {
164
        return new OperationResponse(
165
            $this->client->request(
166
                'post',
167
                "/environments/$environmentUuid/email/actions/enable"
168
            )
169
        );
170
    }
171
172
    /**
173
     * Disable platform email for an environment.
174
     */
175
    public function disableEmail(string $environmentUuid): OperationResponse
176
    {
177
        return new OperationResponse(
178
            $this->client->request(
179
                'post',
180
                "/environments/$environmentUuid/email/actions/disable"
181
            )
182
        );
183
    }
184
185
    /**
186
     * Add a new continuous delivery environment to an application.
187
     *
188
     * @param array<string> $databases
189
     */
190
    public function create(string $applicationUuid, string $label, string $branch, array $databases): OperationResponse
191
    {
192
        $options = [
193
            'json' => [
194
                'label' => $label,
195
                'branch' => $branch,
196
                'databases' => $databases,
197
            ],
198
        ];
199
200
        return new OperationResponse(
201
            $this->client->request(
202
                'post',
203
                "/applications/$applicationUuid/environments",
204
                $options
205
            )
206
        );
207
    }
208
209
    /**
210
     * Deletes a CD environment.
211
     */
212
    public function delete(string $environmentUuid): OperationResponse
213
    {
214
        return new OperationResponse(
215
            $this->client->request(
216
                'delete',
217
                "/environments/$environmentUuid"
218
            )
219
        );
220
    }
221
}
222