1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Endpoints; |
4
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
6
|
|
|
use AcquiaCloudApi\Response\VariableResponse; |
7
|
|
|
use AcquiaCloudApi\Response\VariablesResponse; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class Variables |
11
|
|
|
* @package AcquiaCloudApi\Endpoints |
12
|
|
|
*/ |
13
|
|
|
class Variables extends CloudApiBase implements CloudApiInterface |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Fetches all environment variables. |
18
|
|
|
* |
19
|
|
|
* @param string $environmentUuid |
20
|
|
|
* @return VariablesResponse |
21
|
|
|
*/ |
22
|
|
|
public function getAll($environmentUuid) |
23
|
|
|
{ |
24
|
|
|
return new VariablesResponse( |
25
|
|
|
$this->client->request( |
|
|
|
|
26
|
|
|
'get', |
27
|
|
|
"/environments/${environmentUuid}/variables" |
28
|
|
|
) |
29
|
|
|
); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Returns details about an environment variable. |
34
|
|
|
* |
35
|
|
|
* @param string $environmentUuid |
36
|
|
|
* @param string $name |
37
|
|
|
* @return VariableResponse |
38
|
|
|
*/ |
39
|
|
|
public function get($environmentUuid, $name) |
40
|
|
|
{ |
41
|
|
|
return new VariableResponse( |
42
|
|
|
$this->client->request( |
43
|
|
|
'get', |
44
|
|
|
"/environments/${environmentUuid}/variables/${name}" |
45
|
|
|
) |
46
|
|
|
); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Adds an environment variable. |
51
|
|
|
* |
52
|
|
|
* @param string $environmentUuid |
53
|
|
|
* @param string $name |
54
|
|
|
* @param string $value |
55
|
|
|
* @return OperationResponse |
56
|
|
|
*/ |
57
|
|
|
public function create($environmentUuid, $name, $value) |
58
|
|
|
{ |
59
|
|
|
$options = [ |
60
|
|
|
'form_params' => [ |
61
|
|
|
'name' => $name, |
62
|
|
|
'value' => $value, |
63
|
|
|
], |
64
|
|
|
]; |
65
|
|
|
|
66
|
|
|
return new OperationResponse( |
67
|
|
|
$this->client->request('post', "/environments/${environmentUuid}/variables", $options) |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Updates an environment variable. |
73
|
|
|
* |
74
|
|
|
* @param string $environmentUuid |
75
|
|
|
* @param string $name |
76
|
|
|
* @param string $value |
77
|
|
|
* @return OperationResponse |
78
|
|
|
*/ |
79
|
|
|
public function update($environmentUuid, $name, $value) |
80
|
|
|
{ |
81
|
|
|
$options = [ |
82
|
|
|
'form_params' => [ |
83
|
|
|
'name' => $name, |
84
|
|
|
'value' => $value, |
85
|
|
|
], |
86
|
|
|
]; |
87
|
|
|
|
88
|
|
|
return new OperationResponse( |
89
|
|
|
$this->client->request('put', "/environments/${environmentUuid}/variables/${name}", $options) |
90
|
|
|
); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Deletes an environment variable. |
95
|
|
|
* |
96
|
|
|
* @param string $environmentUuid |
97
|
|
|
* @param string $name |
98
|
|
|
* @return OperationResponse |
99
|
|
|
*/ |
100
|
|
|
public function delete($environmentUuid, $name) |
101
|
|
|
{ |
102
|
|
|
return new OperationResponse( |
103
|
|
|
$this->client->request('delete', "/environments/${environmentUuid}/variables/${name}") |
104
|
|
|
); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|