1 | <?php |
||
17 | class Dns extends Api |
||
18 | { |
||
19 | /** |
||
20 | * Create DNS record (permission needed: #dns_records:edit) |
||
21 | * Create a new DNS record for a zone. See the record object definitions for required attributes for each record type |
||
22 | * |
||
23 | * @param string $zone_identifier |
||
24 | * @param string $type DNS record type (A, AAAA, CNAME, TXT, SRV, LOC, MX, NS, SPF) |
||
25 | * @param string $name DNS record name |
||
26 | * @param string $content DNS record content |
||
27 | * @param int|null $ttl Time to live for DNS record. Value of 1 is 'automatic' |
||
28 | * @param bool|null $proxied Whether to proxy the domain through CloudFlare or not |
||
29 | * @param int|null $priority MX record priority value |
||
30 | * @param array|null $data Additional data required for SRV record |
||
31 | */ |
||
32 | public function create($zone_identifier, $type, $name, $content, $ttl = null, $proxied = null, $priority = null, $data = null) |
||
33 | { |
||
34 | $data = [ |
||
35 | 'type' => strtoupper($type), |
||
36 | 'name' => $name, |
||
37 | 'content' => $content, |
||
38 | 'ttl' => $ttl, |
||
39 | 'proxied' => $proxied, |
||
40 | 'priority' => $priority, |
||
41 | 'data' => $data, |
||
42 | ]; |
||
43 | |||
44 | return $this->post('zones/'.$zone_identifier.'/dns_records', $data); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * List DNS Records (permission needed: #dns_records:read) |
||
49 | * List, search, sort, and filter a zones' DNS records. |
||
50 | * |
||
51 | * @param string $zone_identifier |
||
52 | * @param string|null $type DNS record type (A, AAAA, CNAME, TXT, SRV, LOC, MX, NS, SPF) |
||
53 | * @param string|null $name DNS record name |
||
54 | * @param string|null $content DNS record content |
||
55 | * @param string|null $vanity_name_server_record Flag for records that were created for the vanity name server feature (true, false) |
||
56 | * @param int|null $page Page number of paginated results |
||
57 | * @param int|null $per_page Number of DNS records per page |
||
58 | * @param string|null $order Field to order records by (type, name, content, ttl, proxied) |
||
59 | * @param string|null $direction Direction to order domains (asc, desc) |
||
60 | * @param string|null $match Whether to match all search requirements or at least one (any) (any, all) |
||
61 | */ |
||
62 | public function list_records($zone_identifier, $type = null, $name = null, $content = null, $vanity_name_server_record = null, $page = null, $per_page = null, $order = null, $direction = null, $match = null) |
||
78 | |||
79 | /** |
||
80 | * DNS record details (permission needed: #dns_records:read) |
||
81 | * |
||
82 | * @param string $zone_identifier |
||
83 | * @param string $identifier API item identifier tag |
||
84 | */ |
||
85 | public function details($zone_identifier, $identifier) |
||
89 | |||
90 | /** |
||
91 | * Update DNS record (permission needed: #dns_records:edit) |
||
92 | * |
||
93 | * @param string $zone_identifier |
||
94 | * @param string $identifier API item identifier tag |
||
95 | * @param string|null $type DNS record type (A, AAAA, CNAME, TXT, SRV, LOC, MX, NS, SPF) |
||
96 | * @param string|null $name DNS record name |
||
97 | * @param string|null $content DNS record content |
||
98 | * @param string|null $ttl Time to live for DNS record. Value of 1 is 'automatic' |
||
99 | * @param bool|null $proxied Whether to proxy the domain through CloudFlare or not |
||
100 | * @param array|null $data Additional data required for SRV record |
||
101 | * @param int|null $priority MX record priority value |
||
102 | */ |
||
103 | public function update($zone_identifier, $identifier, $type = null, $name = null, $content = null, $ttl = null, $proxied = null, $data = null, $priority = null) |
||
104 | { |
||
105 | $data = [ |
||
106 | 'type' => $type, |
||
107 | 'name' => $name, |
||
108 | 'content' => $content, |
||
109 | 'ttl' => $ttl, |
||
110 | 'proxied' => $proxied, |
||
111 | 'priority' => $priority, |
||
112 | 'data' => $data, |
||
113 | ]; |
||
114 | |||
115 | return $this->put('zones/'.$zone_identifier.'/dns_records/'.$identifier, $data); |
||
116 | } |
||
117 | |||
118 | /** |
||
119 | * Update DNS record (permission needed: #dns_records:edit) |
||
120 | * |
||
121 | * @param string $zone_identifier |
||
122 | * @param string $identifier API item identifier tag |
||
123 | */ |
||
124 | public function delete_record($zone_identifier, $identifier) |
||
128 | } |
||
129 |