1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Endpoints; |
4
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Response\BackupResponse; |
6
|
|
|
use AcquiaCloudApi\Response\BackupsResponse; |
7
|
|
|
use AcquiaCloudApi\Response\DomainResponse; |
8
|
|
|
use AcquiaCloudApi\Response\DomainsResponse; |
9
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
10
|
|
|
use AcquiaCloudApi\Response\SiteInstanceResponse; |
11
|
|
|
use AcquiaCloudApi\Response\SiteInstanceDatabaseResponse; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class SiteInstances |
15
|
|
|
* |
16
|
|
|
* @package AcquiaCloudApi\CloudApi |
17
|
|
|
*/ |
18
|
|
|
class SiteInstances extends CloudApiBase |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Returns details about a specific site instance. |
22
|
|
|
*/ |
23
|
|
|
public function get(string $siteId, string $environmentId): SiteInstanceResponse |
24
|
|
|
{ |
25
|
|
|
return new SiteInstanceResponse( |
26
|
|
|
$this->client->request( |
27
|
|
|
'get', |
28
|
|
|
"/api/site-instances/$siteId.$environmentId" |
29
|
|
|
) |
30
|
|
|
); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Returns database details for a site instance. |
35
|
|
|
*/ |
36
|
|
|
public function getDatabase(string $siteId, string $environmentId): SiteInstanceDatabaseResponse |
37
|
|
|
{ |
38
|
|
|
return new SiteInstanceDatabaseResponse( |
39
|
|
|
$this->client->request( |
40
|
|
|
'get', |
41
|
|
|
"/api/site-instances/$siteId.$environmentId/database" |
42
|
|
|
) |
43
|
|
|
); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Copies database from source environment to target environment. |
48
|
|
|
*/ |
49
|
|
|
public function copyDatabase(string $siteId, string $environmentId, string $sourceEnvironmentId): OperationResponse |
50
|
|
|
{ |
51
|
|
|
$options = [ |
52
|
|
|
'json' => [ |
53
|
|
|
'source' => $sourceEnvironmentId, |
54
|
|
|
], |
55
|
|
|
]; |
56
|
|
|
|
57
|
|
|
return new OperationResponse( |
58
|
|
|
$this->client->request( |
59
|
|
|
'post', |
60
|
|
|
"/api/site-instances/$siteId.$environmentId/database", |
61
|
|
|
$options |
62
|
|
|
) |
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Returns a list of database backups for a site instance. |
68
|
|
|
* |
69
|
|
|
* @return BackupsResponse<BackupResponse> |
70
|
|
|
*/ |
71
|
|
|
public function getDatabaseBackups(string $siteId, string $environmentId): BackupsResponse |
72
|
|
|
{ |
73
|
|
|
return new BackupsResponse( |
74
|
|
|
$this->client->request( |
75
|
|
|
'get', |
76
|
|
|
"/api/site-instances/$siteId.$environmentId/database/backups" |
77
|
|
|
) |
78
|
|
|
); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Creates a database backup for a site instance. |
83
|
|
|
*/ |
84
|
|
|
public function createDatabaseBackup(string $siteId, string $environmentId): OperationResponse |
85
|
|
|
{ |
86
|
|
|
return new OperationResponse( |
87
|
|
|
$this->client->request( |
88
|
|
|
'post', |
89
|
|
|
"/api/site-instances/$siteId.$environmentId/database/backups" |
90
|
|
|
) |
91
|
|
|
); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Returns details about a specific database backup. |
96
|
|
|
*/ |
97
|
|
|
public function getDatabaseBackup(string $siteId, string $environmentId, string $backupId): BackupResponse |
98
|
|
|
{ |
99
|
|
|
return new BackupResponse( |
100
|
|
|
$this->client->request( |
101
|
|
|
'get', |
102
|
|
|
"/api/site-instances/$siteId.$environmentId/database/backups/$backupId" |
103
|
|
|
) |
104
|
|
|
); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Downloads a database backup. |
109
|
|
|
*/ |
110
|
|
|
public function downloadDatabaseBackup(string $siteId, string $environmentId, string $backupId): OperationResponse |
111
|
|
|
{ |
112
|
|
|
return new OperationResponse( |
113
|
|
|
$this->client->request( |
114
|
|
|
'get', |
115
|
|
|
"/api/site-instances/$siteId.$environmentId/database/backups/$backupId/actions/download" |
116
|
|
|
) |
117
|
|
|
); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Restores a database backup. |
122
|
|
|
*/ |
123
|
|
|
public function restoreDatabaseBackup(string $siteId, string $environmentId, string $backupId): OperationResponse |
124
|
|
|
{ |
125
|
|
|
return new OperationResponse( |
126
|
|
|
$this->client->request( |
127
|
|
|
'post', |
128
|
|
|
"/api/site-instances/$siteId.$environmentId/database/backups/$backupId/actions/restore" |
129
|
|
|
) |
130
|
|
|
); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Returns a list of domains for a site instance. |
135
|
|
|
* |
136
|
|
|
* @return DomainsResponse<DomainResponse> |
137
|
|
|
*/ |
138
|
|
|
public function getDomains(string $siteId, string $environmentId): DomainsResponse |
139
|
|
|
{ |
140
|
|
|
return new DomainsResponse( |
141
|
|
|
$this->client->request( |
142
|
|
|
'get', |
143
|
|
|
"/api/site-instances/$siteId.$environmentId/domains" |
144
|
|
|
) |
145
|
|
|
); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Returns details about a specific domain for a site instance. |
150
|
|
|
*/ |
151
|
|
|
public function getDomain(string $siteId, string $environmentId, string $domainName): DomainResponse |
152
|
|
|
{ |
153
|
|
|
return new DomainResponse( |
154
|
|
|
$this->client->request( |
155
|
|
|
'get', |
156
|
|
|
"/api/site-instances/$siteId.$environmentId/domains/$domainName" |
157
|
|
|
) |
158
|
|
|
); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* Returns the status of a specific domain for a site instance. |
163
|
|
|
*/ |
164
|
|
|
public function getDomainStatus(string $siteId, string $environmentId, string $domainName): DomainResponse |
165
|
|
|
{ |
166
|
|
|
return new DomainResponse( |
167
|
|
|
$this->client->request( |
168
|
|
|
'get', |
169
|
|
|
"/api/site-instances/$siteId.$environmentId/domains/$domainName/status" |
170
|
|
|
) |
171
|
|
|
); |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Copies files from source environment to target environment. |
176
|
|
|
*/ |
177
|
|
|
public function copyFiles(string $siteId, string $environmentId, string $sourceEnvironmentId): OperationResponse |
178
|
|
|
{ |
179
|
|
|
$options = [ |
180
|
|
|
'json' => [ |
181
|
|
|
'source' => $sourceEnvironmentId, |
182
|
|
|
], |
183
|
|
|
]; |
184
|
|
|
|
185
|
|
|
return new OperationResponse( |
186
|
|
|
$this->client->request( |
187
|
|
|
'post', |
188
|
|
|
"/api/site-instances/$siteId.$environmentId/files", |
189
|
|
|
$options |
190
|
|
|
) |
191
|
|
|
); |
192
|
|
|
} |
193
|
|
|
} |
194
|
|
|
|