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
|
|
|
* @param string $serverId |
35
|
|
|
* @return ServerResponse |
36
|
|
|
*/ |
37
|
|
|
public function get($environmentUuid, $serverId) |
38
|
|
|
{ |
39
|
|
|
return new ServerResponse( |
40
|
|
|
$this->client->request( |
|
|
|
|
41
|
|
|
'get', |
42
|
|
|
"/environments/${environmentUuid}/servers/${serverId}" |
43
|
|
|
) |
44
|
|
|
); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Modifies configuration settings for a server. |
49
|
|
|
* |
50
|
|
|
* @param string $environmentUuid |
51
|
|
|
* @param string $serverId |
52
|
|
|
* @param array $config |
53
|
|
|
* @return OperationResponse |
54
|
|
|
*/ |
55
|
|
|
public function update($environmentUuid, $serverId, array $config) |
56
|
|
|
{ |
57
|
|
|
|
58
|
|
|
return new OperationResponse( |
59
|
|
|
$this->client->request( |
|
|
|
|
60
|
|
|
'put', |
61
|
|
|
"/environments/${environmentUuid}/servers/${serverId}", |
62
|
|
|
$config |
63
|
|
|
) |
64
|
|
|
); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Show all servers associated with an environment. |
69
|
|
|
* |
70
|
|
|
* @param string $environmentUuid |
71
|
|
|
* @return ServersResponse |
72
|
|
|
*/ |
73
|
|
|
public function getAll($environmentUuid) |
74
|
|
|
{ |
75
|
|
|
return new ServersResponse( |
76
|
|
|
$this->client->request( |
|
|
|
|
77
|
|
|
'get', |
78
|
|
|
"/environments/${environmentUuid}/servers" |
79
|
|
|
) |
80
|
|
|
); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|