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