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