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