DRI/Protocol/EPP/Extensions/AusRegistry/KeyValue.pm

filter: Statementstmt 19.1% 13 / 68 Branchbran 0.0% 0 / 22 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 36.3% 4 / 11 Podpod 0.0% 0 / 7 totaltotal 15.7% 17 / 108 CC 16 SCAR 36.5
CC
16
Cov
14%
build_kvlists
72.0
info_parse
56.0
create_build
6.0
CRAP 38.5
« DRI/Protocol/EPP/Extensions/AusRegistry/IDN.pm ↑ Summary DRI/Protocol/AdamsNames/WS/Domain.pm »
1 ## Domain Registry Interface, EPP AusRegistry Key Value Extension
2 ##
3 ## Copyright (c) 2013,2018 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
4 ##
5 ## This file is part of Net::DRI
6 ##
7 ## Net::DRI is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2 of the License, or
10 ## (at your option) any later version.
11 ##
12 ## See the LICENSE file that comes with this distribution for more details.
13 ####################################################################################################
14  
15 package Net::DRI::Protocol::EPP::Extensions::AusRegistry::KeyValue;
16  
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 ####################################################################################################
24  
25 sub register_commands
26 {
27 0 ▶ my ($class,$version)=@_;
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
28 0 my %tmp=(
29 info => [ undef , \&info_parse ],
30 create => [ \&create_build, undef ],
31 update => [ \&update_build, undef ],
32 );
33  
34 0 return { 'domain' => \%tmp };
35 }
36  
37 sub setup
38 {
39 0 ▶ my ($class,$po,$version)=@_;
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
40 0 $po->ns({ 'kv' => 'urn:X-ar:params:xml:ns:kv-1.0' });
41 0 return;
42 }
43  
44 0 ▶sub capabilities_add { return ('domain_update','keyvalue',['set']); }
Subroutine capabilities_add: not called CC=1 SCAR=6.9
Pod undocumented
45  
46 ####################################################################################################
47  
48 ## <extension>
49 ## <infData xmlns="urn:X-ar:params:xml:ns:kv-1.0">
50 ## <kvlist name="ext">
51 ## <item key="key1">value1</item>
52 ## <item key="key2">value2</item>
53 ## </kvlist>
54 ## </infData>
55 ## </extension>
56  
57 sub info_parse
58 {
59 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine info_parse: not called CC=7 SCAR=40.3
Pod undocumented
60 0 my $mes=$po->message();
61 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
62  
63 0 my $data=$mes->get_extension('kv','infData');
64 0 ▶ return unless defined $data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data 0 0 0
65  
66 0 my %kvs;
67 0 foreach my $el (Net::DRI::Util::xml_list_children($data))
68 {
69 0 my ($name,$node)=@$el;
70 0 ▶ if ($name eq 'kvlist')
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "kvlist") 0 0 0
71 {
72 0 my $kvname=$node->getAttribute('name');
73 0 my %kv;
74 0 foreach my $kvel (Net::DRI::Util::xml_list_children($node))
75 {
76 0 my ($kvelname,$kvelnode)=@$kvel;
77 0 ▶ if ($kvelname eq 'item')
Branch: 1 branch
BranchTrueFalseTotal
if ($kvelname eq "item") 0 0 0
78 {
79 0 $kv{$kvelnode->getAttribute('key')}=$kvelnode->textContent();
80 }
81 }
82 0 $kvs{$kvname}=\%kv;
83 }
84 }
85  
86 0 $rinfo->{domain}->{$oname}->{keyvalue}=\%kvs;
87 0 return;
88 }
89  
90 sub build_kvlists
91 {
92 0 ▶ my ($rd)=@_;
Subroutine build_kvlists: not called CC=8 SCAR=42.8
Pod undocumented
93 0 ▶ Net::DRI::Exception::usererr_invalid_parameters(qq{keyvalue parameter must be ref hash, not: }.$rd) unless ref $rd eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $rd eq "HASH" 0 0 0
94 0 my @kvs;
95 0 foreach my $kvlistname (sort { $a cmp $b } keys %$rd)
96 {
97 0 ▶ Net::DRI::Exception::usererr_invalid_parameters(qq{kvlist name "$kvlistname" must be an XML token}) unless Net::DRI::Util::xml_is_token($kvlistname);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($kvlistname) 0 0 0
98 0 ▶ Net::DRI::Exception::usererr_invalid_parameters(qq{value for kvlistname "$kvlistname" must be ref hash, not: }.$rd->{$kvlistname}) unless ref $rd->{$kvlistname} eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $rd->{$kvlistname} eq "HASH" 0 0 0
99 0 my @kv;
100 0 foreach my $key (sort { $a cmp $b } keys %{$rd->{$kvlistname}})
101 {
102 0 ▶ Net::DRI::Exception::usererr_invalid_parameters(qq{item name "$key" (in kvlist name "$kvlistname") must be an XML token}) unless Net::DRI::Util::xml_is_token($key);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($key) 0 0 0
103 0 my $v=$rd->{$kvlistname}->{$key};
104 0 ▶ Net::DRI::Exception::usererr_invalid_parameters(qq{value "$v" for item name "$key" (in kvlist name "$kvlistname") must be an XML string}) unless Net::DRI::Util::xml_is_string($v);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_string($v) 0 0 0
105 0 push @kv,['kv:item',{key => $key},$v];
106 }
107 0 push @kvs,['kv:kvlist',{name => $kvlistname},@kv];
108 }
109 0 return @kvs;
110 }
111  
112 ## <extension>
113 ## <create xmlns="urn:X-ar:params:xml:ns:kv-1.0">
114 ## <kvlist name="ext">
115 ## <item key="key1">value1</item>
116 ## <item key="key2">value2</item>
117 ## </kvlist>
118 ## </create>
119 ## </extension>
120  
121 sub create_build
122 {
123 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine create_build: not called CC=2 SCAR=17.9
Pod undocumented
124 0 my $mes=$epp->message();
125  
126 0 ▶ return unless Net::DRI::Util::has_key($rd,'keyvalue');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "keyvalue") 0 0 0
127  
128 0 my $eid=$mes->command_extension_register('kv','create');
129 0 $mes->command_extension($eid,[build_kvlists($rd->{keyvalue})]);
130  
131 0 return;
132 }
133  
134 ## <extension>
135 ## <update xmlns="urn:X-ar:params:xml:ns:kv-1.0">
136 ## <kvlist name="ext">
137 ## <item key="key1">value1</item>
138 ## <item key="key2">value2</item>
139 ## </kvlist>
140 ## </update>
141 ## </extension>
142  
143 sub update_build
144 {
145 0 ▶ my ($epp,$domain,$todo)=@_;
Subroutine update_build: not called CC=2 SCAR=17.9
Pod undocumented
146 0 my $mes=$epp->message();
147  
148 0 my $toset=$todo->set('keyvalue');
149 0 ▶ return unless defined $toset;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $toset 0 0 0
150  
151 0 my $eid=$mes->command_extension_register('kv','update');
152 0 $mes->command_extension($eid,[build_kvlists($toset)]);
153  
154 0 return;
155 }
156  
157 ####################################################################################################
158 1 1;
159  
160 __END__
161  
162 =pod
163  
164 =head1 NAME
165  
166 Net::DRI::Protocol::EPP::Extensions::AusRegistry::KeyValue - EPP AusRegistry Key Value commands for Net::DRI
167  
168 =head1 DESCRIPTION
169  
170 Please see the README file for details.
171  
172 =head1 SUPPORT
173  
174 For now, support questions should be sent to:
175  
176 E<lt>netdri@dotandco.comE<gt>
177  
178 Please also see the SUPPORT file in the distribution.
179  
180 =head1 SEE ALSO
181  
182 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
183  
184 =head1 AUTHOR
185  
186 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
187  
188 =head1 COPYRIGHT
189  
190 Copyright (c) 2013,2018 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
191  
192 This program is free software; you can redistribute it and/or modify
193 it under the terms of the GNU General Public License as published by
194 the Free Software Foundation; either version 2 of the License, or
195 (at your option) any later version.
196  
197 See the LICENSE file that comes with this distribution for more details.
198  
199 =cut
200  
« DRI/Protocol/EPP/Extensions/AusRegistry/IDN.pm ↑ Summary DRI/Protocol/AdamsNames/WS/Domain.pm »