| 1 | ## Domain Registry Interface, OVH Web Services Domain commands | ||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||
| 3 | ## Copyright (c) 2008,2009,2013 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::OVH::WS::Domain; | ||||||||||||||||||||||||||||
| 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::Exception; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use Net::DRI::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | =pod | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | =head1 NAME | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | Net::DRI::Protocol::OVH::WS::Domain - OVH Web Services Domain commands for Net::DRI | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | Please see the README file for details. | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | For now, support questions should be sent to: | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | E<lt>netdri@dotandco.comE<gt> | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | Please also see the SUPPORT file in the distribution. | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt> | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | Patrick Mevzek, E<lt>netdri@dotandco.comE<gt> | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | Copyright (c) 2008,2009,2013 Patrick Mevzek <netdri@dotandco.com>. | ||||||||||||||||||||||||||||
| 52 | All rights reserved. | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 55 | it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||
| 56 | the Free Software Foundation; either version 2 of the License, or | ||||||||||||||||||||||||||||
| 57 | (at your option) any later version. | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | See the LICENSE file that comes with this distribution for more details. | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =cut | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | #################################################################################################### | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | sub register_commands | ||||||||||||||||||||||||||||
| 66 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
register_commands: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 67 | 0 | my ($class,$version)=@_; | |||||||||||||||||||||||||||
| 68 | 0 | my %tmp=( | |||||||||||||||||||||||||||
| 69 | info => [\&info, \&info_parse ], | ||||||||||||||||||||||||||||
| 70 | check => [\&check, \&check_parse ], | ||||||||||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | return { 'domain' => \%tmp }; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | sub parse_ArrayOfNsStruct | ||||||||||||||||||||||||||||
| 77 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
parse_ArrayOfNsStruct: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 78 | 0 | my ($po,$r)=@_; | |||||||||||||||||||||||||||
| 79 | 0 | ▶ | Net::DRI::Exception->die(1,'protocol/ovh/ws',1,'Unexpected content for dns: '.$r) unless (ref($r) eq 'MyArrayOfNsStructType'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 0 | my $h=$po->create_local_object('hosts'); | |||||||||||||||||||||||||||
| 81 | 0 | foreach my $ns (@$r) | |||||||||||||||||||||||||||
| 82 | { | ||||||||||||||||||||||||||||
| 83 | 0 | ▶ | Net::DRI::Exception->die(1,'protocol/ovh/ws',1,'Unexpected content for ArrayOfNsStruct member: '.$ns) unless (ref($ns) eq 'nsStruct'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | 0 | my $name=$ns->{name}; | |||||||||||||||||||||||||||
| 85 | 0 | my $ip=$ns->{ip}; ## how are multiple IPs handled ? | |||||||||||||||||||||||||||
| 86 | 0 | ▶ | $h->add($name,defined($ip)? [$ip] : undef); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | 0 | return $h; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | sub build_msg | ||||||||||||||||||||||||||||
| 92 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
build_msg: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 93 | 0 | my ($msg,$command,$domain)=@_; | |||||||||||||||||||||||||||
| 94 | 0 | ▶ | Net::DRI::Exception->die(1,'protocol/ovh/ws',2,'Domain name needed') unless defined($domain) && $domain; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $domain and $domain
MC/DC0%0/2
defined $domain and $domain
defined $domain
$domain
Truth table0%0/3
A and B
A= defined $domainB= $domain
| |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | Net::DRI::Exception->die(1,'protocol/ovh/ws',10,'Invalid domain name') unless Net::DRI::Util::is_hostname($domain); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | $msg->method($command) if defined($command); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 0 | return; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | sub info | ||||||||||||||||||||||||||||
| 102 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
info: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 103 | 0 | my ($po,$domain)=@_; | |||||||||||||||||||||||||||
| 104 | 0 | my $msg=$po->message(); | |||||||||||||||||||||||||||
| 105 | 0 | build_msg($msg,'domainInfo',$domain); | |||||||||||||||||||||||||||
| 106 | 0 | $msg->params([$domain]); | |||||||||||||||||||||||||||
| 107 | 0 | return; | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | sub info_parse | ||||||||||||||||||||||||||||
| 111 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
info_parse: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 112 | 0 | my ($po,$otype,$oaction,$oname,$rinfo)=@_; | |||||||||||||||||||||||||||
| 113 | 0 | my $mes=$po->message(); | |||||||||||||||||||||||||||
| 114 | 0 | ▶ | return unless $mes->is_success(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 0 | my $r=$mes->result(); | |||||||||||||||||||||||||||
| 117 | 0 | ▶ | Net::DRI::Exception->die(1,'protocol/ovh/ws',1,'Unexpected reply for domain_info: '.$r) unless (ref($r) eq 'domainInfoReturn'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 0 | my %r=%$r; | |||||||||||||||||||||||||||
| 120 | 0 | $oname=lc($r->{domain}); | |||||||||||||||||||||||||||
| 121 | 0 | $rinfo->{domain}->{$oname}->{action}='info'; | |||||||||||||||||||||||||||
| 122 | 0 | $rinfo->{domain}->{$oname}->{exist}=1; | |||||||||||||||||||||||||||
| 123 | 0 | my %d=(creation => 'crDate', modification => 'upDate', expiration => 'exDate'); | |||||||||||||||||||||||||||
| 124 | 0 | ▶ | while (my ($k,$v)=each(%d)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 125 | { | ||||||||||||||||||||||||||||
| 126 | 0 | ▶ | next unless exists($r{$k}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | 0 | $rinfo->{domain}->{$oname}->{$v}=$po->parse_iso8601($r{$k}); | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | 0 | my %c=(nicowner => 'registrant', nicadmin => 'admin', nictech => 'tech', nicbilling => 'billing'); | |||||||||||||||||||||||||||
| 130 | 0 | my $cs=$po->create_local_object('contactset'); | |||||||||||||||||||||||||||
| 131 | 0 | ▶ | while (my ($k,$v)=each(%c)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | { | ||||||||||||||||||||||||||||
| 133 | 0 | ▶ | next unless exists($r{$k}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 134 | 0 | my $c=$po->create_local_object('contact')->srid($r{$k}); | |||||||||||||||||||||||||||
| 135 | 0 | $cs->add($c,$v); | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | 0 | $rinfo->{domain}->{$oname}->{contact}=$cs; | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | ## From WSDL file: the authinfo if the domain is unlocked | ||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if (exists($r{authinfo})) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | { | ||||||||||||||||||||||||||||
| 142 | 0 | $rinfo->{domain}->{$oname}->{auth}={pw => $r{authinfo}}; | |||||||||||||||||||||||||||
| 143 | 0 | $rinfo->{domain}->{$oname}->{status}=$po->create_local_object('status')->add('ok'); | |||||||||||||||||||||||||||
| 144 | } else | ||||||||||||||||||||||||||||
| 145 | { | ||||||||||||||||||||||||||||
| 146 | 0 | $rinfo->{domain}->{$oname}->{status}=$po->create_local_object('status')->add('clientLock'); ## ? ## | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | 0 | ▶ | $rinfo->{domain}->{$oname}->{ns}=parse_ArrayOfNsStruct($po,$r{dns}) if exists($r{dns}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | 0 | return; | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | sub check | ||||||||||||||||||||||||||||
| 153 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
check: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 154 | 0 | my ($po,$domain)=@_; | |||||||||||||||||||||||||||
| 155 | 0 | my $msg=$po->message(); | |||||||||||||||||||||||||||
| 156 | 0 | build_msg($msg,'domainCheck',$domain); | |||||||||||||||||||||||||||
| 157 | 0 | $msg->params([$domain]); | |||||||||||||||||||||||||||
| 158 | 0 | return; | |||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | sub check_parse | ||||||||||||||||||||||||||||
| 162 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
check_parse: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 163 | 0 | my ($po,$otype,$oaction,$oname,$rinfo)=@_; | |||||||||||||||||||||||||||
| 164 | 0 | my $mes=$po->message(); | |||||||||||||||||||||||||||
| 165 | 0 | ▶ | return unless $mes->is_success(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 0 | my $r=$mes->result(); | |||||||||||||||||||||||||||
| 168 | 0 | ▶ | Net::DRI::Exception->die(1,'protocol/ovh/ws',1,'Unexpected reply for domain_check: '.$r) unless (ref($r) eq 'MyArrayOfDomainCheckStructType'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 0 | ▶ | my @r=grep { exists $_->{predicate} && $_->{predicate} eq 'is_available' } @$r; ## also: is_transferable, is_renewable | ||||||||||||||||||||||||||
|
Condition0%0/3
exists $_->{'predicate'} && $_->{'predicate'} eq 'is_available'
MC/DC0%0/2
exists $_->{'predicate'} && $_->{'predicate'} eq 'is_available'
exists $_->{'predicate'}
$_->{'predicate'} eq 'is_available'
Truth table0%0/3
A && B
A= exists $_->{'predicate'}B= $_->{'predicate'} eq 'is_available'
| |||||||||||||||||||||||||||||
| 171 | 0 | $rinfo->{domain}->{$oname}->{action}='check'; | |||||||||||||||||||||||||||
| 172 | 0 | ▶ | $rinfo->{domain}->{$oname}->{exist}=(@r==1 && $r[0]->{value}==1)? 0 : 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@r == 1 and $r[0]{"value"} == 1
MC/DC0%0/2
@r == 1 and $r[0]{"value"} == 1
@r == 1
$r[0]{"value"} == 1
Truth table0%0/3
A and B
A= @r == 1B= $r[0]{"value"} == 1
| |||||||||||||||||||||||||||||
| 173 | 0 | ▶ | $rinfo->{domain}->{$oname}->{exist_reason}=$r[0]->{reason} if @r==1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 174 | 0 | return; | |||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | #################################################################################################### | ||||||||||||||||||||||||||||
| 178 | 1 | 1; | |||||||||||||||||||||||||||