File Coverage

blib/lib/Net/EPP/Frame/ObjectSpec.pm
Criterion Covered Total %
statement 6 9 66.6
branch 0 2 0.0
condition n/a
subroutine 2 3 66.6
pod 0 1 0.0
total 8 15 53.3


line stmt bran cond sub pod time code
1             package Net::EPP::Frame::ObjectSpec;
2 1     1   6 use vars qw($SPEC);
  1         2  
  1         44  
3 1     1   6 use strict;
  1         2  
  1         119  
4              
5             our $SPEC = {
6             'domain' => [ 'urn:ietf:params:xml:ns:domain-1.0', 'urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd' ],
7             'contact' => [ 'urn:ietf:params:xml:ns:contact-1.0', 'urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd' ],
8             'host' => [ 'urn:ietf:params:xml:ns:host-1.0', 'urn:ietf:params:xml:ns:host-1.0 host-1.0.xsd' ],
9             'secDNS' => [ 'urn:ietf:params:xml:ns:secDNS-1.1', 'urn:ietf:params:xml:ns:secDNS-1.1 secDNS-1.1.xsd' ],
10             'rgp' => [ 'urn:ietf:params:xml:ns:rgp-1.1', 'urn:ietf:params:xml:ns:rgp-1.1 rgp-1.1.xsd' ],
11             };
12              
13             sub spec {
14 0     0 0   my $type = $_[1];
15              
16 0 0         return (!defined($SPEC->{$type}) ? undef : ($type, @{$SPEC->{$type}}));
  0            
17             }
18              
19             =pod
20              
21             =head1 NAME
22              
23             Net::EPP::Frame::ObjectSpec - metadata about EPP object types
24              
25             =head1 SYNOPSIS
26              
27             use Net::EPP::Frame;
28             use strict;
29              
30             # create an EPP frame:
31             my $check = Net::EPP::Frame::Command::Check->new;
32              
33             # get the spec:
34             my @spec = Net::EPP::Frame::ObjectSpec->spec('domain');
35              
36             # create an object:
37             my $domain = $check->addObject(@spec);
38              
39             # set the attributes:
40             my $name = $check->createElement('domain:name');
41             $name->addText('example.tld');
42              
43             # assemble the frame:
44             $domain->appendChild($name);
45             $check->getCommandNode->appendChild($domain);
46              
47             print $check->toString;
48              
49             =head1 DESCRIPTION
50              
51             Net::EPP::Frame::ObjectSpec is a simple module designed to provide easy access to
52             metadata for the object types defined in the EPP specification.
53              
54             =head1 USAGE
55              
56             my @spec = Net::EPP::Frame::ObjectSpec->spec($type);
57              
58             This function returns an array containing metadata for the given object type.
59             If no metadata is registered then the function returns undef.
60              
61             The array contains three members:
62              
63             @spec = (
64             $type,
65             $xmlns,
66             $schemaLocation,
67             );
68              
69             C<$type> is the same as the supplied argument, and the other two members
70             correspond to the XML attributes used to specify the object in an EPP
71             CcommandE> or CresponseE> frame.
72              
73             The objects currently registered are:
74              
75             =over
76              
77             =item * C, for domain names;
78              
79             =item * C, for DNS server hosts;
80              
81             =item * C, for contact objects;
82              
83             =item * C, for DNSSEC information;
84              
85             =item * C, for registry grace periods.
86              
87             =back
88              
89             Note that C and C refer to extensions to the domain object rather than
90             objects in their own right.
91              
92             =cut
93              
94             1;