1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Endpoints; |
4
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
6
|
|
|
use AcquiaCloudApi\Response\SslCertificateResponse; |
7
|
|
|
use AcquiaCloudApi\Response\SslCertificatesResponse; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class SslCertificates |
11
|
|
|
* |
12
|
|
|
* @package AcquiaCloudApi\CloudApi |
13
|
|
|
*/ |
14
|
|
|
class SslCertificates extends CloudApiBase |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* Returns a list of SSL certificates. |
18
|
|
|
* |
19
|
|
|
* @param string $environmentUuid The environment ID |
20
|
|
|
* @return SslCertificatesResponse<SslCertificateResponse> |
21
|
|
|
*/ |
22
|
|
|
public function getAll(string $environmentUuid): SslCertificatesResponse |
23
|
|
|
{ |
24
|
|
|
return new SslCertificatesResponse( |
25
|
|
|
$this->client->request( |
26
|
|
|
'get', |
27
|
|
|
"/environments/$environmentUuid/ssl/certificates" |
28
|
|
|
) |
29
|
|
|
); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Returns a specific certificate by certificate ID. |
34
|
|
|
* |
35
|
|
|
* @param string $environmentUuid The environment ID |
36
|
|
|
*/ |
37
|
|
|
public function get(string $environmentUuid, int $certificateId): SslCertificateResponse |
38
|
|
|
{ |
39
|
|
|
return new SslCertificateResponse( |
40
|
|
|
$this->client->request( |
41
|
|
|
'get', |
42
|
|
|
"/environments/$environmentUuid/ssl/certificates/$certificateId" |
43
|
|
|
) |
44
|
|
|
); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Install an SSL certificate. |
49
|
|
|
*/ |
50
|
|
|
public function create( |
51
|
|
|
string $envUuid, |
52
|
|
|
string $label, |
53
|
|
|
string $cert, |
54
|
|
|
string $key, |
55
|
|
|
?string $ca = null, |
56
|
|
|
?int $csr = null, |
57
|
|
|
bool $legacy = false |
58
|
|
|
): OperationResponse { |
59
|
|
|
|
60
|
|
|
$options = [ |
61
|
|
|
'json' => [ |
62
|
|
|
'label' => $label, |
63
|
|
|
'certificate' => $cert, |
64
|
|
|
'private_key' => $key, |
65
|
|
|
'ca_certificates' => $ca, |
66
|
|
|
'csr_id' => $csr, |
67
|
|
|
'legacy' => $legacy, |
68
|
|
|
], |
69
|
|
|
]; |
70
|
|
|
|
71
|
|
|
return new OperationResponse( |
72
|
|
|
$this->client->request('post', "/environments/$envUuid/ssl/certificates", $options) |
73
|
|
|
); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Delete a specific certificate by ID. |
78
|
|
|
*/ |
79
|
|
|
public function delete(string $environmentUuid, int $certificateId): OperationResponse |
80
|
|
|
{ |
81
|
|
|
return new OperationResponse( |
82
|
|
|
$this->client->request('delete', "/environments/$environmentUuid/ssl/certificates/$certificateId") |
83
|
|
|
); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Deactivates an active SSL certificate. |
88
|
|
|
*/ |
89
|
|
|
public function disable(string $environmentUuid, int $certificateId): OperationResponse |
90
|
|
|
{ |
91
|
|
|
return new OperationResponse( |
92
|
|
|
$this->client->request( |
93
|
|
|
'post', |
94
|
|
|
"/environments/$environmentUuid/ssl/certificates/$certificateId/actions/deactivate" |
95
|
|
|
) |
96
|
|
|
); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Activates an SSL certificate. |
101
|
|
|
*/ |
102
|
|
|
public function enable(string $environmentUuid, int $certificateId): OperationResponse |
103
|
|
|
{ |
104
|
|
|
return new OperationResponse( |
105
|
|
|
$this->client->request( |
106
|
|
|
'post', |
107
|
|
|
"/environments/$environmentUuid/ssl/certificates/$certificateId/actions/activate" |
108
|
|
|
) |
109
|
|
|
); |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|