1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Endpoints; |
4
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Response\DomainsResponse; |
6
|
|
|
use AcquiaCloudApi\Response\DomainResponse; |
7
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
8
|
|
|
use AcquiaCloudApi\Response\MetricsResponse; |
9
|
|
|
use AcquiaCloudApi\Response\MetricResponse; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class Domains |
13
|
|
|
* |
14
|
|
|
* @package AcquiaCloudApi\CloudApi |
15
|
|
|
*/ |
16
|
|
|
class Domains extends CloudApiBase implements CloudApiInterface |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Shows all domains on an environment. |
21
|
|
|
* |
22
|
|
|
* @param string $environmentUuid |
23
|
|
|
* @return DomainsResponse<DomainResponse> |
24
|
|
|
*/ |
25
|
|
|
public function getAll($environmentUuid): DomainsResponse |
26
|
|
|
{ |
27
|
|
|
return new DomainsResponse( |
28
|
|
|
$this->client->request( |
29
|
|
|
'get', |
30
|
|
|
"/environments/${environmentUuid}/domains" |
31
|
|
|
) |
32
|
|
|
); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Return details about a domain. |
37
|
|
|
* |
38
|
|
|
* @param string $environmentUuid |
39
|
|
|
* @param string $domain |
40
|
|
|
* @return DomainResponse |
41
|
|
|
*/ |
42
|
|
|
public function get($environmentUuid, $domain): DomainResponse |
43
|
|
|
{ |
44
|
|
|
return new DomainResponse( |
45
|
|
|
$this->client->request( |
46
|
|
|
'get', |
47
|
|
|
"/environments/${environmentUuid}/domains/${domain}" |
48
|
|
|
) |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Adds a domain to an environment. |
54
|
|
|
* |
55
|
|
|
* @param string $environmentUuid |
56
|
|
|
* @param string $hostname |
57
|
|
|
* @return OperationResponse |
58
|
|
|
*/ |
59
|
|
|
public function create($environmentUuid, $hostname): OperationResponse |
60
|
|
|
{ |
61
|
|
|
|
62
|
|
|
$options = [ |
63
|
|
|
'json' => [ |
64
|
|
|
'hostname' => $hostname, |
65
|
|
|
], |
66
|
|
|
]; |
67
|
|
|
|
68
|
|
|
return new OperationResponse( |
69
|
|
|
$this->client->request('post', "/environments/${environmentUuid}/domains", $options) |
70
|
|
|
); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Deletes a domain from an environment. |
75
|
|
|
* |
76
|
|
|
* @param string $environmentUuid |
77
|
|
|
* @param string $domain |
78
|
|
|
* @return OperationResponse |
79
|
|
|
*/ |
80
|
|
|
public function delete($environmentUuid, $domain): OperationResponse |
81
|
|
|
{ |
82
|
|
|
return new OperationResponse( |
83
|
|
|
$this->client->request('delete', "/environments/${environmentUuid}/domains/${domain}") |
84
|
|
|
); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Purges cache for selected domains in an environment. |
89
|
|
|
* |
90
|
|
|
* @param string $environmentUuid |
91
|
|
|
* @param array<string> $domains |
92
|
|
|
* @return OperationResponse |
93
|
|
|
*/ |
94
|
|
|
public function purge($environmentUuid, array $domains): OperationResponse |
95
|
|
|
{ |
96
|
|
|
$options = [ |
97
|
|
|
'json' => [ |
98
|
|
|
'domains' => $domains, |
99
|
|
|
], |
100
|
|
|
]; |
101
|
|
|
|
102
|
|
|
return new OperationResponse( |
103
|
|
|
$this->client->request( |
104
|
|
|
'post', |
105
|
|
|
"/environments/${environmentUuid}/actions/clear-caches", |
106
|
|
|
$options |
107
|
|
|
) |
108
|
|
|
); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Purges cache for a single domain in an environment. |
113
|
|
|
* |
114
|
|
|
* @param string $environmentUuid |
115
|
|
|
* @param string $domain |
116
|
|
|
* @return OperationResponse |
117
|
|
|
*/ |
118
|
|
|
public function clearDomainCache($environmentUuid, $domain): OperationResponse |
119
|
|
|
{ |
120
|
|
|
return new OperationResponse( |
121
|
|
|
$this->client->request( |
122
|
|
|
'post', |
123
|
|
|
"/environments/${environmentUuid}/domains/${domain}/actions/clear-caches" |
124
|
|
|
) |
125
|
|
|
); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Retrieves the scan data for a domain name that is part of this environment. |
130
|
|
|
* |
131
|
|
|
* @param string $environmentUuid |
132
|
|
|
* @param string $domain |
133
|
|
|
* @return MetricsResponse<MetricResponse> |
134
|
|
|
*/ |
135
|
|
|
public function metrics($environmentUuid, $domain): MetricsResponse |
136
|
|
|
{ |
137
|
|
|
return new MetricsResponse( |
138
|
|
|
$this->client->request( |
139
|
|
|
'get', |
140
|
|
|
"/environments/${environmentUuid}/domains/${domain}/metrics/uptime" |
141
|
|
|
) |
142
|
|
|
); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Returns details about the domain. |
147
|
|
|
* |
148
|
|
|
* @param string $environmentUuid |
149
|
|
|
* @param string $domain |
150
|
|
|
* @return DomainResponse |
151
|
|
|
*/ |
152
|
|
|
public function status($environmentUuid, $domain): DomainResponse |
153
|
|
|
{ |
154
|
|
|
return new DomainResponse( |
155
|
|
|
$this->client->request( |
156
|
|
|
'get', |
157
|
|
|
"/environments/${environmentUuid}/domains/${domain}/status" |
158
|
|
|
) |
159
|
|
|
); |
160
|
|
|
} |
161
|
|
|
} |
162
|
|
|
|