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