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