File Coverage

blib/lib/Regru/API/Zone.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 18 18 100.0


line stmt bran cond sub pod time code
1              
2             # ABSTRACT: REG.API v2 DNS resource records management
3              
4             use strict;
5 1     1   521 use warnings;
  1         2  
  1         29  
6 1     1   4 use Moo;
  1         2  
  1         23  
7 1     1   4 use namespace::autoclean;
  1         2  
  1         8  
8 1     1   2363  
  1         3  
  1         6  
9             our $VERSION = '0.052'; # VERSION
10             our $AUTHORITY = 'cpan:CHIM'; # AUTHORITY
11              
12             with 'Regru::API::Role::Client';
13              
14             has '+namespace' => (
15             default => sub { 'zone' },
16             );
17              
18             nop
19 1     1   4 add_alias
20             add_aaaa
21             add_caa
22             add_cname
23             add_mx
24             add_ns
25             add_txt
26             add_srv
27             add_spf
28             get_resource_records
29             update_records
30             update_soa
31             tune_forwarding
32             clear_forwarding
33             tune_parking
34             clear_parking
35             remove_record
36             clear
37             )]}
38              
39             __PACKAGE__->namespace_methods;
40             __PACKAGE__->meta->make_immutable;
41              
42             1; # End of Regru::API::Zone
43              
44              
45             =pod
46              
47             =encoding UTF-8
48              
49             =head1 NAME
50              
51             Regru::API::Zone - REG.API v2 DNS resource records management
52              
53             =head1 VERSION
54              
55             version 0.052
56              
57             =head1 DESCRIPTION
58              
59             REG.API DNS management methods such as create/remove resource records, enable/disable parking and forwarding features.
60              
61             =head1 ATTRIBUTES
62              
63             =head2 namespace
64              
65             Always returns the name of category: C<zone>. For internal uses only.
66              
67             =head1 REG.API METHODS
68              
69             =head2 nop
70              
71             For testing purposes to check the ability to manage DNS resource records. This feature is available for domain names
72             that hosted by REG.RU DNS servers only. Scope: B<clients>. Typical usage:
73              
74             $resp = $client->zone->nop(
75             domains => [
76             { dname => 'bluth-company.com' },
77             { dname => 'sitwell-enterprises.com' },
78             ],
79             );
80              
81             Answer will contains a field C<domains> with a list of domain names which allows to manage resource records
82             or error otherwise.
83              
84             More info at L<DNS management: nop|https://www.reg.com/support/help/api2#zone_nop>.
85              
86             =head2 add_alias
87              
88             Creates an A (IPv4 address) resource record for domain(s). Scope: B<clients>. Typical usage:
89              
90             $resp = $client->zone->add_alias(
91             subdomain => 'gob',
92             ipaddr => '172.26.14.51',
93             domains => [
94             { dname => 'bluth-company.com' },
95             ],
96             );
97              
98             B<NOTE> Also allowed to pass subdomain as C<@> (at) - resource record will point to domain itself or
99             C<*> (asterisk) - catch-all resource record.
100              
101             Answer will contains a field C<domains> with a list of results for each involved to this operation domain names or
102             error otherwise.
103              
104             More info at L<DNS management: add_alias|https://www.reg.com/support/help/api2#zone_add_alias>.
105              
106             =head2 add_aaaa
107              
108             Creates an AAAA (IPv6 address) resource record for domain(s). Scope: B<clients>. Typical usage:
109              
110             $resp = $client->zone->add_aaaa(
111             subdomain => 'coffee',
112             ipaddr => '2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d',
113             domains => [
114             { dname => 'gobias-industries.net' },
115             ],
116             );
117              
118             This one also supports a special names for subdomains. See note for L</add_alias>.
119              
120             Answer will contains a field C<domains> with a list of results for each involved to this operation domain names or
121             error otherwise.
122              
123             More info at L<DNS management: add_aaaa|https://www.reg.com/support/help/api2#zone_add_aaaa>.
124              
125             =head2 add_caa
126              
127             Creates a CAA (SSL certificate issue rule) resource record for domain(s). Scope: B<clients>. Typical usage:
128              
129             $resp = $client->zone->add_caa(
130             subdomain => 'home',
131             flags => 128,
132             tag => 'issue',
133             value => 'commodo.com; id=321'
134             domain_name => 'gobias.co.uk',
135             );
136              
137             Answer will contains a field C<domains> with a list of results for each involved to this operation domain names or
138             error otherwise.
139              
140             More info at L<DNS management: add_caa|https://www.reg.com/support/help/api2#zone_add_caa>.
141              
142             =head2 add_cname
143              
144             Creates a CNAME (canonical name) resource record for domain(s). Scope: B<clients>. Typical usage:
145              
146             $resp = $client->zone->add_cname(
147             subdomain => 'products',
148             canonical_name => 'coffee.gobias-industries.net',
149             domain_name => 'gobias.co.uk',
150             );
151              
152             Answer will contains a field C<domains> with a list of results for each involved to this operation domain names or
153             error otherwise.
154              
155             More info at L<DNS management: add_cname|https://www.reg.com/support/help/api2#zone_add_cname>.
156              
157             =head2 add_mx
158              
159             Creates a MX (mail exchange) resource record for domain(s). Scope: B<clients>. Typical usage:
160              
161             $resp = $client->zone->add_mx(
162             subdomain => '@',
163             priority => 5,
164             mail_server => 'mail.hot-cops.xxx', # mail server host should have an A/AAAA record(s)
165             domains => [
166             { dname => 'blue-man-group.org' },
167             { dname => 'gobias-industri.es' },
168             { dname => 'sudden-valley.travel' },
169             ],
170             );
171              
172             Answer will contains a field C<domains> with a list of results for each involved to this operation domain names or
173             error otherwise.
174              
175             More info at L<DNS management: add_mx|https://www.reg.com/support/help/api2#zone_add_mx>.
176              
177             =head2 add_ns
178              
179             Creates a NS (name server) resource record which will delegate a subdomain onto the other name server. Scope: B<clients>.
180             Typical usage:
181              
182             $resp = $client->zone->add_ns(
183             subdomain => 'annyong',
184             dns_server => 'ns1.milford-school.ac.us',
185             domain_name => 'bluth-family.ru',
186             record_number => 1, # just for relative arrangement of the NS records
187             );
188              
189             Answer will contains a field C<domains> with a list of results for each involved to this operation domain names or
190             error otherwise.
191              
192             More info at L<DNS management: add_ns|https://www.reg.com/support/help/api2#zone_add_ns>.
193              
194             =head2 add_txt
195              
196             Creates a TXT (text) resource record up to 512 characters in length. Scope: B<clients>. Typical usage:
197              
198             $resp = $client->zone->add_txt(
199             subdomain => '@',
200             domain_name => 'bluth-company.com',
201             text => 'v=spf1 include:_spf.google.com ~all',
202             );
203              
204             Answer will contains a field C<domains> with a list of results for each involved to this operation domain names or
205             error otherwise.
206              
207             More info at L<DNS management: add_txt|https://www.reg.com/support/help/api2#zone_add_txt>.
208              
209             =head2 add_srv
210              
211             Creates a SRV (service locator) resource record. Scope: B<clients>. Typical usage:
212              
213             $resp = $client->zone->add_srv(
214             domain_name => 'gobias-industri.es',
215             service => '_sip._tcp',
216             priority => 0,
217             weight => 5,
218             port => 5060,
219             target => 'phone.gobias.co.uk', # target host should have an A/AAAA record(s)
220             );
221              
222             Answer will contains a field C<domains> with a list of results for each involved to this operation domain names or
223             error otherwise.
224              
225             More info at L<DNS management: add_srv|https://www.reg.com/support/help/api2#zone_add_srv>.
226              
227             =head2 add_spf
228              
229             Creates a SPF (sender policy framework) resource record up to 512 characters in length.
230             Scope: B<clients>. Typical usage:
231              
232             $resp = $client->zone->add_spf(
233             subdomain => '@',
234             domain_name => 'stand-poor.net',
235             text => 'v=spf1 include:_spf.google.com ~all',
236             );
237              
238             Answer will contains a field C<domains> with a list of results for each involved to this operation domain names or
239             error otherwise.
240              
241             More info at L<DNS management: add_spf|https://www.reg.com/support/help/api2#zone_add_spf>.
242              
243             =head2 get_resource_records
244              
245             Retrieves all resource records for domain(s). Scope: B<clients>. Typical usage:
246              
247             $resp = $client->zone->get_resource_records(
248             domains => [
249             { dname => 'gangie.tv' },
250             { dname => 'wrench.tv' },
251             ],
252             );
253              
254             Answer will contains a field C<domains> with a list of domains. For each domain will be shown a resource records set (as a
255             list), settings of the SOA resource record. If any error will occur this also will be reported.
256              
257             More info at L<DNS management: get_resource_records|https://www.reg.com/support/help/api2#zone_get_resource_records>.
258              
259             =head2 update_records
260              
261             Takes a set of actions and manipulates the resource records in batch mode. Scope: B<partners>. Typical usage:
262              
263             $update = [
264             { action => 'add_alias', subdomain => '@', ipaddr => '127.0.0.1' },
265             { action => 'add_alias', subdomain => 'www', ipaddr => '127.0.0.1' },
266             { action => 'add_mx', subdomain => '@', priority => 5, mail_server => 'mx.bluth-company.net' },
267             { action => 'add_mx', subdomain => '@', priority => 10, mail_server => 'mx.bluth-family.com' },
268             { action => 'remove_record', subdomain => 'maeby', record_type => 'TXT' },
269             { action => 'remove_record', subdomain => 'buster', record_type => 'A', content => '10.13.0.5' },
270             { action => 'add_txt', subdomain => 'maeby', text => 'Marry Me!' },
271             ];
272             $resp = $client->zone->update_records(
273             domain_name => 'bluth.com',
274             action_list => $update,
275             );
276              
277             # or more complex
278             $update1 = [ # actions for 'gobias.com'
279             { action => '..', ... },
280             ...
281             ];
282             $update2 = [ # actions for 'gobias.net'
283             { action => '..', ... },
284             ...
285             ];
286             $resp = $client->zone->update_records(
287             domains => [
288             { dname => 'gobias.com', action_list => $update1 },
289             { dname => 'gobias.net', action_list => $update2 },
290             ],
291             );
292              
293             Action should one of allowed methods related to resource records: L</add_alias>, L</add_aaaa>, L</add_caa>, L</add_cname>, L</add_mx>,
294             L</add_ns>, L</add_txt>, L</add_srv> or L</remove_record>.
295              
296             Answer will contains a field C<domains> with a list of results for each involved to this operation domain names and actions or
297             error otherwise.
298              
299             More info at L<DNS management: update_records|https://www.reg.com/support/help/api2#zone_update_records>.
300              
301             =head2 update_soa
302              
303             Changes a cache settings for the SOA (start of authority) resource record. Scope: B<clients>. Typical usage:
304              
305             $resp = $client->zone->update_soa(
306             ttl => '2h', # for the entire zone
307             minimum_ttl => '1h', # for the NXDOMAIN answers
308             domains => [
309             { dname => 'gobias.com' },
310             { dname => 'gobias.net' },
311             ],
312             );
313              
314             Answer will contains a field C<domains> with a list of results for each involved to this operation domain names or
315             error otherwise.
316              
317             More info at L<DNS management: update_soa|https://www.reg.com/support/help/api2#zone_update_soa>.
318              
319             =head2 tune_forwarding
320              
321             Enables a web forwarding feature for domain name(s). Scope: B<clients>. Typical usage:
322              
323             $resp = $client->zone->tune_forwarding(
324             domain_name => 'barrygood.biz',
325             );
326              
327             Prior to use this method ensure that desired domain name(s) has attached and configured correctly a C<srv_webfwd> service.
328             This can be done by using methods L<Regru::API::Domain/create> or L<Regru::API::Domain/update>.
329              
330             Answer will contains a field C<domains> with a list of results for each involved to this operation domain names or
331             error otherwise.
332              
333             More info at L<DNS management: tune_forwarding|https://www.reg.com/support/help/api2#zone_tune_forwarding>.
334              
335             =head2 clear_forwarding
336              
337             Disables a web forwarding feature for domain name(s). Scope: B<clients>. Typical usage:
338              
339             $resp = $client->zone->clear_forwarding(
340             domain_name => 'barrygood.biz',
341             );
342              
343             Prior to use this method ensure that desired domain name(s) has attached and configured correctly a C<srv_webfwd> service.
344             This can be done by using methods L<Regru::API::Domain/create> or L<Regru::API::Domain/update>.
345              
346             Answer will contains a field C<domains> with a list of results for each involved to this operation domain names or
347             error otherwise.
348              
349             More info at L<DNS management: clear_forwarding|https://www.reg.com/support/help/api2#zone_clear_forwarding>.
350              
351             =head2 tune_parking
352              
353             Enables a web parking feature for domain name(s). Scope: B<clients>. Typical usage:
354              
355             $resp = $client->zone->tune_parking(
356             domains => [
357             { dname => 'barrygood.biz' },
358             ],
359             );
360              
361             Prior to use this method ensure that desired domain name(s) has attached and configured correctly a C<srv_parking> service.
362             This can be done by using methods L<Regru::API::Domain/create> or L<Regru::API::Domain/update>.
363              
364             Answer will contains a field C<domains> with a list of results for each involved to this operation domain names or
365             error otherwise.
366              
367             More info at L<DNS management: tune_parking|https://www.reg.com/support/help/api2#zone_tune_parking>.
368              
369             =head2 clear_parking
370              
371             Disables a web parking feature for domain name(s). Scope: B<clients>. Typical usage:
372              
373             $resp = $client->zone->clear_parking(
374             domains => [
375             { dname => 'barrygood.biz' },
376             ],
377             );
378              
379             Prior to use this method ensure that desired domain name(s) has attached and configured correctly a C<srv_parking> service.
380             This can be done by using methods L<Regru::API::Domain/create> or L<Regru::API::Domain/update>.
381              
382             Answer will contains a field C<domains> with a list of results for each involved to this operation domain names or
383             error otherwise.
384              
385             More info at L<DNS management: clear_parking|https://www.reg.com/support/help/api2#zone_clear_parking>.
386              
387             =head2 remove_record
388              
389             Removes any resource record from domain name(s). Scope: B<clients>. Typical usage:
390              
391             $resp = $client->zone->remove_record(
392             domains => [
393             { dname => 'cia.com' },
394             ],
395             subdomain => 'tobias',
396             record_type => 'TXT',
397             content => 'Mr. F!',
398             );
399              
400             Answer will contains a field C<domains> with a list of results for each involved to this operation domain names or
401             error otherwise.
402              
403             More info at L<DNS management: remove_record|https://www.reg.com/support/help/api2#zone_remove_record>.
404              
405             =head2 clear
406              
407             B<Watch out! Handy way to get lost everything!>
408              
409             Deletes ALL resource records. Scope: B<clients>. Typical usage:
410              
411             $resp = $client->zone->clear(
412             domains => [
413             { dname => 'scandalmakers.com' },
414             { dname => 'weathers.net' },
415             ],
416             );
417              
418             Answer will contains a field C<domains> with a list of results for each involved to this operation domain names or
419             error otherwise.
420              
421             More info at L<DNS management: clear|https://www.reg.com/support/help/api2#zone_clear>.
422              
423             =head1 SEE ALSO
424              
425             L<Regru::API>
426              
427             L<Regru::API::Role::Client>
428              
429             L<Regru::API::Domain>
430              
431             L<REG.API DNS management|https://www.reg.com/support/help/api2#zone_functions>
432              
433             L<REG.API Common error codes|https://www.reg.com/support/help/api2#common_errors>
434              
435             =head1 BUGS
436              
437             Please report any bugs or feature requests on the bugtracker website
438             L<https://github.com/regru/regru-api-perl/issues>
439              
440             When submitting a bug or request, please include a test-file or a
441             patch to an existing test-file that illustrates the bug or desired
442             feature.
443              
444             =head1 AUTHORS
445              
446             =over 4
447              
448             =item *
449              
450             Polina Shubina <shubina@reg.ru>
451              
452             =item *
453              
454             Anton Gerasimov <a.gerasimov@reg.ru>
455              
456             =back
457              
458             =head1 COPYRIGHT AND LICENSE
459              
460             This software is copyright (c) 2013 by REG.RU LLC.
461              
462             This is free software; you can redistribute it and/or modify it under
463             the same terms as the Perl 5 programming language system itself.
464              
465             =cut