1: <?php
2:
3: namespace Cloudflare\Zone;
4:
5: use Cloudflare\Api;
6: use Cloudflare\Zone;
7:
8: /**
9: * CloudFlare API wrapper
10: *
11: * Custom SSL for a Zone
12: *
13: * @author James Bell <[email protected]>
14: *
15: * @version 1
16: */
17: class SSL extends Api
18: {
19: /**
20: * Default permissions level
21: *
22: * @var array
23: */
24: protected $permission_level = ['read' => '#ssl:read', 'edit' => '#ssl:edit'];
25:
26: /**
27: * List SSL configurations (permission needed: #ssl:read)
28: *
29: * @param string $zone_identifier API item identifier tag
30: */
31: public function certificates($zone_identifier)
32: {
33: return $this->get('zones/'.$zone_identifier.'/custom_certificates');
34: }
35:
36: /**
37: * List SSL configuration details (permission needed: #ssl:read)
38: *
39: * @param string $zone_identifier API item identifier tag
40: * @param string $identifier
41: */
42: public function details($zone_identifier, $identifier)
43: {
44: return $this->get('zones/'.$zone_identifier.'/custom_certificates/'.$identifier);
45: }
46:
47: /**
48: * Create SSL configuration (permission needed: #ssl:edit)
49: *
50: * @param string $zone_identifier API item identifier tag
51: * @param string $certificate The zone's SSL certificate or certificate and the intermediate(s)
52: * @param string $private_key The zone's private key
53: */
54: public function create($zone_identifier, $certificate, $private_key)
55: {
56: $data = [
57: 'certificate' => $certificate,
58: 'private_key' => $private_key,
59: ];
60:
61: return $this->post('zones/'.$zone_identifier.'/custom_certificates', $data);
62: }
63:
64: /**
65: * Update SSL configuration (permission needed: #ssl:edit)
66: *
67: * @param string $zone_identifier API item identifier tag
68: * @param string $identifier
69: * @param string $certificate The zone's SSL certificate or certificate and the intermediate(s)
70: * @param string $private_key The zone's private key
71: */
72: public function update($zone_identifier, $identifier, $certificate, $private_key)
73: {
74: $data = [
75: 'certificate' => $certificate,
76: 'private_key' => $private_key,
77: ];
78:
79: return $this->patch('zones/'.$zone_identifier.'/custom_certificates/'.$identifier, $data);
80: }
81:
82: /**
83: * Re-prioritize SSL certificates (permission needed: #ssl:edit)
84: *
85: * @param string $zone_identifier API item identifier tag
86: * @param array $certificates Array of ordered certificates
87: */
88: public function prioritize($zone_identifier, array $certificates)
89: {
90: $data = [
91: 'certificates' => $certificates,
92: ];
93:
94: return $this->patch('zones/'.$zone_identifier.'/custom_certificates/prioritize', $data);
95: }
96:
97: /**
98: * Delete an SSL certificate (permission needed: #ssl:edit)
99: *
100: * @param string $zone_identifier API item identifier tag
101: * @param string $identifier
102: */
103: public function delete_ssl($zone_identifier, $identifier)
104: {
105: return $this->delete('zones/'.$zone_identifier.'/custom_certificates/'.$identifier);
106: }
107: }
108: