1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Endpoints; |
4
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Connector\ClientInterface; |
6
|
|
|
use AcquiaCloudApi\Response\DomainsResponse; |
7
|
|
|
use AcquiaCloudApi\Response\DomainResponse; |
8
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class Client |
12
|
|
|
* @package AcquiaCloudApi\CloudApi |
13
|
|
|
*/ |
14
|
|
|
class Domains 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
|
|
|
* Shows all domains on an environment. |
32
|
|
|
* |
33
|
|
|
* @param string $environmentUuid |
34
|
|
|
* @return DomainsResponse |
35
|
|
|
*/ |
36
|
|
|
public function getAll($environmentUuid) |
37
|
|
|
{ |
38
|
|
|
return new DomainsResponse( |
39
|
|
|
$this->client->request( |
|
|
|
|
40
|
|
|
'get', |
41
|
|
|
"/environments/${environmentUuid}/domains" |
42
|
|
|
) |
43
|
|
|
); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Return details about a domain. |
48
|
|
|
* |
49
|
|
|
* @param string $environmentUuid |
50
|
|
|
* @param string $domain |
51
|
|
|
* @return DomainResponse |
52
|
|
|
*/ |
53
|
|
|
public function get($environmentUuid, $domain) |
54
|
|
|
{ |
55
|
|
|
return new DomainResponse( |
56
|
|
|
$this->client->request( |
|
|
|
|
57
|
|
|
'get', |
58
|
|
|
"/environments/${environmentUuid}/domains/${domain}" |
59
|
|
|
) |
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Adds a domain to an environment. |
65
|
|
|
* |
66
|
|
|
* @param string $environmentUuid |
67
|
|
|
* @param string $hostname |
68
|
|
|
* @return OperationResponse |
69
|
|
|
*/ |
70
|
|
|
public function create($environmentUuid, $hostname) |
71
|
|
|
{ |
72
|
|
|
|
73
|
|
|
$options = [ |
74
|
|
|
'form_params' => [ |
75
|
|
|
'hostname' => $hostname, |
76
|
|
|
], |
77
|
|
|
]; |
78
|
|
|
|
79
|
|
|
return new OperationResponse( |
80
|
|
|
$this->client->request('post', "/environments/${environmentUuid}/domains", $options) |
|
|
|
|
81
|
|
|
); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Deletes a domain from an environment. |
86
|
|
|
* |
87
|
|
|
* @param string $environmentUuid |
88
|
|
|
* @param string $domain |
89
|
|
|
* @return OperationResponse |
90
|
|
|
*/ |
91
|
|
|
public function delete($environmentUuid, $domain) |
92
|
|
|
{ |
93
|
|
|
return new OperationResponse( |
94
|
|
|
$this->client->request('delete', "/environments/${environmentUuid}/domains/${domain}") |
|
|
|
|
95
|
|
|
); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Purges varnish for selected domains in an environment. |
100
|
|
|
* |
101
|
|
|
* @param string $environmentUuid |
102
|
|
|
* @param array $domains |
103
|
|
|
* @return OperationResponse |
104
|
|
|
*/ |
105
|
|
|
public function purge($environmentUuid, array $domains) |
106
|
|
|
{ |
107
|
|
|
|
108
|
|
|
$options = [ |
109
|
|
|
'form_params' => [ |
110
|
|
|
'domains' => $domains, |
111
|
|
|
], |
112
|
|
|
]; |
113
|
|
|
|
114
|
|
|
return new OperationResponse( |
115
|
|
|
$this->client->request( |
|
|
|
|
116
|
|
|
'post', |
117
|
|
|
"/environments/${environmentUuid}/domains/actions/clear-varnish", |
118
|
|
|
$options |
119
|
|
|
) |
120
|
|
|
); |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|