1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Cloudflare\Zone; |
4
|
|
|
|
5
|
|
|
use Cloudflare\Api; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* CloudFlare API wrapper |
9
|
|
|
* |
10
|
|
|
* Custom SSL for a Zone |
11
|
|
|
* |
12
|
|
|
* @author James Bell <[email protected]> |
13
|
|
|
* |
14
|
|
|
* @version 1 |
15
|
|
|
*/ |
16
|
|
|
class SSL extends Api |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* List SSL configurations (permission needed: #ssl:read) |
20
|
|
|
* |
21
|
|
|
* @param string $zone_identifier API item identifier tag |
22
|
|
|
*/ |
23
|
|
|
public function certificates($zone_identifier) |
24
|
|
|
{ |
25
|
|
|
return $this->get('zones/'.$zone_identifier.'/custom_certificates'); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* List SSL configuration details (permission needed: #ssl:read) |
30
|
|
|
* |
31
|
|
|
* @param string $zone_identifier API item identifier tag |
32
|
|
|
* @param string $identifier |
33
|
|
|
*/ |
34
|
|
|
public function details($zone_identifier, $identifier) |
35
|
|
|
{ |
36
|
|
|
return $this->get('zones/'.$zone_identifier.'/custom_certificates/'.$identifier); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Create SSL configuration (permission needed: #ssl:edit) |
41
|
|
|
* |
42
|
|
|
* @param string $zone_identifier API item identifier tag |
43
|
|
|
* @param string $certificate The zone's SSL certificate or certificate and the intermediate(s) |
44
|
|
|
* @param string $private_key The zone's private key |
45
|
|
|
*/ |
46
|
|
|
public function create($zone_identifier, $certificate, $private_key) |
|
|
|
|
47
|
|
|
{ |
48
|
|
|
$data = [ |
49
|
|
|
'certificate' => $certificate, |
50
|
|
|
'private_key' => $private_key, |
51
|
|
|
]; |
52
|
|
|
|
53
|
|
|
return $this->post('zones/'.$zone_identifier.'/custom_certificates', $data); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Update SSL configuration (permission needed: #ssl:edit) |
58
|
|
|
* |
59
|
|
|
* @param string $zone_identifier API item identifier tag |
60
|
|
|
* @param string $identifier |
61
|
|
|
* @param string $certificate The zone's SSL certificate or certificate and the intermediate(s) |
62
|
|
|
* @param string $private_key The zone's private key |
63
|
|
|
*/ |
64
|
|
|
public function update($zone_identifier, $identifier, $certificate, $private_key) |
|
|
|
|
65
|
|
|
{ |
66
|
|
|
$data = [ |
67
|
|
|
'certificate' => $certificate, |
68
|
|
|
'private_key' => $private_key, |
69
|
|
|
]; |
70
|
|
|
|
71
|
|
|
return $this->patch('zones/'.$zone_identifier.'/custom_certificates/'.$identifier, $data); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Re-prioritize SSL certificates (permission needed: #ssl:edit) |
76
|
|
|
* |
77
|
|
|
* @param string $zone_identifier API item identifier tag |
78
|
|
|
* @param array $certificates Array of ordered certificates |
79
|
|
|
*/ |
80
|
|
|
public function prioritize($zone_identifier, array $certificates) |
81
|
|
|
{ |
82
|
|
|
$data = [ |
83
|
|
|
'certificates' => $certificates, |
84
|
|
|
]; |
85
|
|
|
|
86
|
|
|
return $this->patch('zones/'.$zone_identifier.'/custom_certificates/prioritize', $data); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Delete an SSL certificate (permission needed: #ssl:edit) |
91
|
|
|
* |
92
|
|
|
* @param string $zone_identifier API item identifier tag |
93
|
|
|
* @param string $identifier |
94
|
|
|
*/ |
95
|
|
|
public function delete_ssl($zone_identifier, $identifier) |
96
|
|
|
{ |
97
|
|
|
return $this->delete('zones/'.$zone_identifier.'/custom_certificates/'.$identifier); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.