1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Endpoints; |
4
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Connector\ClientInterface; |
6
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
7
|
|
|
use AcquiaCloudApi\Response\ServersResponse; |
8
|
|
|
use AcquiaCloudApi\Response\ServerResponse; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class Client |
12
|
|
|
* @package AcquiaCloudApi\CloudApi |
13
|
|
|
*/ |
14
|
|
|
class Servers implements CloudApi |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
/** @var ClientInterface The API client. */ |
18
|
|
|
protected $client; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Client constructor. |
22
|
|
|
* |
23
|
|
|
* @param ClientInterface $client |
24
|
|
|
*/ |
25
|
|
|
public function __construct(ClientInterface $client) |
26
|
|
|
{ |
27
|
|
|
$this->client = $client; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Gets information about a single server. |
32
|
|
|
* |
33
|
|
|
* @param string $environmentUuid |
34
|
|
|
* @return ServerResponse |
35
|
|
|
*/ |
36
|
|
|
public function get($environmentUuid, $serverId) |
37
|
|
|
{ |
38
|
|
|
return new ServerResponse( |
39
|
|
|
$this->client->request( |
|
|
|
|
40
|
|
|
'get', |
41
|
|
|
"/environments/${environmentUuid}/servers/${serverId}" |
42
|
|
|
) |
43
|
|
|
); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Modifies configuration settings for a server. |
48
|
|
|
* |
49
|
|
|
* @param string $environmentUuid |
50
|
|
|
* @param array $config |
51
|
|
|
* @return OperationResponse |
52
|
|
|
*/ |
53
|
|
|
public function update($environmentUuid, $serverId, array $config) |
54
|
|
|
{ |
55
|
|
|
|
56
|
|
|
return new OperationResponse( |
57
|
|
|
$this->client->request( |
|
|
|
|
58
|
|
|
'put', |
59
|
|
|
"/environments/${environmentUuid}/servers/${serverId}", |
60
|
|
|
$config |
61
|
|
|
) |
62
|
|
|
); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Show all servers associated with an environment. |
67
|
|
|
* |
68
|
|
|
* @param string $environmentUuid |
69
|
|
|
* @return ServersResponse |
70
|
|
|
*/ |
71
|
|
|
public function getAll($environmentUuid) |
72
|
|
|
{ |
73
|
|
|
return new ServersResponse( |
74
|
|
|
$this->client->request( |
|
|
|
|
75
|
|
|
'get', |
76
|
|
|
"/environments/${environmentUuid}/servers" |
77
|
|
|
) |
78
|
|
|
); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|