|
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
|
|
|
* |
|
12
|
|
|
* @package AcquiaCloudApi\Endpoints |
|
13
|
|
|
*/ |
|
14
|
|
|
class Variables extends CloudApiBase |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* Fetches all environment variables. |
|
18
|
|
|
* |
|
19
|
|
|
* @return VariablesResponse<VariableResponse> |
|
20
|
|
|
*/ |
|
21
|
|
|
public function getAll(string $environmentUuid): VariablesResponse |
|
22
|
|
|
{ |
|
23
|
|
|
return new VariablesResponse( |
|
24
|
|
|
$this->client->request( |
|
25
|
|
|
'get', |
|
26
|
|
|
"/environments/$environmentUuid/variables" |
|
27
|
|
|
) |
|
28
|
|
|
); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Returns details about an environment variable. |
|
33
|
|
|
*/ |
|
34
|
|
|
public function get(string $environmentUuid, string $name): VariableResponse |
|
35
|
|
|
{ |
|
36
|
|
|
return new VariableResponse( |
|
37
|
|
|
$this->client->request( |
|
38
|
|
|
'get', |
|
39
|
|
|
"/environments/$environmentUuid/variables/$name" |
|
40
|
|
|
) |
|
41
|
|
|
); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Adds an environment variable. |
|
46
|
|
|
*/ |
|
47
|
|
|
public function create(string $environmentUuid, string $name, string $value): OperationResponse |
|
48
|
|
|
{ |
|
49
|
|
|
$options = [ |
|
50
|
|
|
'json' => [ |
|
51
|
|
|
'name' => $name, |
|
52
|
|
|
'value' => $value, |
|
53
|
|
|
], |
|
54
|
|
|
]; |
|
55
|
|
|
|
|
56
|
|
|
return new OperationResponse( |
|
57
|
|
|
$this->client->request('post', "/environments/$environmentUuid/variables", $options) |
|
58
|
|
|
); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Updates an environment variable. |
|
63
|
|
|
*/ |
|
64
|
|
|
public function update(string $environmentUuid, string $name, string $value): OperationResponse |
|
65
|
|
|
{ |
|
66
|
|
|
$options = [ |
|
67
|
|
|
'json' => [ |
|
68
|
|
|
'name' => $name, |
|
69
|
|
|
'value' => $value, |
|
70
|
|
|
], |
|
71
|
|
|
]; |
|
72
|
|
|
|
|
73
|
|
|
return new OperationResponse( |
|
74
|
|
|
$this->client->request('put', "/environments/$environmentUuid/variables/$name", $options) |
|
75
|
|
|
); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Deletes an environment variable. |
|
80
|
|
|
*/ |
|
81
|
|
|
public function delete(string $environmentUuid, string $name): OperationResponse |
|
82
|
|
|
{ |
|
83
|
|
|
return new OperationResponse( |
|
84
|
|
|
$this->client->request('delete', "/environments/$environmentUuid/variables/$name") |
|
85
|
|
|
); |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|