| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | ## Domain Registry Interface, Gandi Web Services Domain commands | 
| 2 |  |  |  |  |  |  | ## | 
| 3 |  |  |  |  |  |  | ## Copyright (c) 2008,2009,2013 Patrick Mevzek . 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::Gandi::WS::Domain; | 
| 16 |  |  |  |  |  |  |  | 
| 17 | 1 |  |  | 1 |  | 788 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 27 |  | 
| 18 | 1 |  |  | 1 |  | 4 | use warnings; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 22 |  | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 1 |  |  | 1 |  | 4 | use DateTime::Format::ISO8601; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 21 |  | 
| 21 |  |  |  |  |  |  |  | 
| 22 | 1 |  |  | 1 |  | 3 | use Net::DRI::Exception; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 17 |  | 
| 23 | 1 |  |  | 1 |  | 4 | use Net::DRI::Util; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 633 |  | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | =pod | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | =head1 NAME | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | Net::DRI::Protocol::Gandi::WS::Domain - Gandi Web Services Domain commands for Net::DRI | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | Please see the README file for details. | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | =head1 SUPPORT | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | For now, support questions should be sent to: | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | Enetdri@dotandco.comE | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | Please also see the SUPPORT file in the distribution. | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | Ehttp://www.dotandco.com/services/software/Net-DRI/E | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | =head1 AUTHOR | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | Patrick Mevzek, Enetdri@dotandco.comE | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | =head1 COPYRIGHT | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | Copyright (c) 2008,2009,2013 Patrick Mevzek . | 
| 54 |  |  |  |  |  |  | All rights reserved. | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | This program is free software; you can redistribute it and/or modify | 
| 57 |  |  |  |  |  |  | it under the terms of the GNU General Public License as published by | 
| 58 |  |  |  |  |  |  | the Free Software Foundation; either version 2 of the License, or | 
| 59 |  |  |  |  |  |  | (at your option) any later version. | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | See the LICENSE file that comes with this distribution for more details. | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | =cut | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | #################################################################################################### | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | sub register_commands | 
| 68 |  |  |  |  |  |  | { | 
| 69 | 0 |  |  | 0 | 0 |  | my ($class,$version)=@_; | 
| 70 | 0 |  |  |  |  |  | my %tmp=( | 
| 71 |  |  |  |  |  |  | info  => [\&info, \&info_parse ], | 
| 72 |  |  |  |  |  |  | check => [\&check, \&check_parse ], | 
| 73 |  |  |  |  |  |  | ); | 
| 74 |  |  |  |  |  |  |  | 
| 75 | 0 |  |  |  |  |  | return { 'domain' => \%tmp }; | 
| 76 |  |  |  |  |  |  | } | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | sub build_msg | 
| 79 |  |  |  |  |  |  | { | 
| 80 | 0 |  |  | 0 | 0 |  | my ($msg,$command,$domain)=@_; | 
| 81 | 0 | 0 | 0 |  |  |  | Net::DRI::Exception->die(1,'protocol/gandi/ws',2,'Domain name needed') unless defined($domain) && $domain; | 
| 82 | 0 | 0 |  |  |  |  | Net::DRI::Exception->die(1,'protocol/gandi/ws',10,'Invalid domain name') unless Net::DRI::Util::is_hostname($domain); | 
| 83 |  |  |  |  |  |  |  | 
| 84 | 0 | 0 |  |  |  |  | $msg->method($command) if defined($command); | 
| 85 | 0 |  |  |  |  |  | return; | 
| 86 |  |  |  |  |  |  | } | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | sub info | 
| 89 |  |  |  |  |  |  | { | 
| 90 | 0 |  |  | 0 | 0 |  | my ($po,$domain)=@_; | 
| 91 | 0 |  |  |  |  |  | my $msg=$po->message(); | 
| 92 | 0 |  |  |  |  |  | build_msg($msg,'domain_info',$domain); | 
| 93 | 0 |  |  |  |  |  | $msg->params([$domain]); | 
| 94 | 0 |  |  |  |  |  | return; | 
| 95 |  |  |  |  |  |  | } | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  | sub info_parse | 
| 98 |  |  |  |  |  |  | { | 
| 99 | 0 |  |  | 0 | 0 |  | my ($po,$otype,$oaction,$oname,$rinfo)=@_; | 
| 100 | 0 |  |  |  |  |  | my $mes=$po->message(); | 
| 101 | 0 | 0 |  |  |  |  | return unless $mes->is_success(); | 
| 102 |  |  |  |  |  |  |  | 
| 103 | 0 |  |  |  |  |  | my $r=$mes->result(); | 
| 104 | 0 | 0 |  |  |  |  | Net::DRI::Exception->die(1,'protocol/gandi/ws',1,'Unexpected reply for domain_info: '.$r) unless (ref($r) eq 'HASH'); | 
| 105 |  |  |  |  |  |  |  | 
| 106 | 0 |  |  |  |  |  | my %r=%$r; | 
| 107 | 0 |  |  |  |  |  | $rinfo->{domain}->{$oname}->{action}='info'; | 
| 108 | 0 |  |  |  |  |  | $rinfo->{domain}->{$oname}->{exist}=1; | 
| 109 | 0 |  |  |  |  |  | my %d=(registry_creation_date => 'crDate', registry_last_update => 'upDate', registry_expiration_date => 'exDate', registrar_creation_date => 'trDate'); | 
| 110 | 0 |  |  |  |  |  | while (my ($k,$v)=each(%d)) | 
| 111 |  |  |  |  |  |  | { | 
| 112 | 0 | 0 |  |  |  |  | next unless exists($r{$k}); | 
| 113 | 0 |  |  |  |  |  | $rinfo->{domain}->{$oname}->{$v}=$po->parse_iso8601($r{$k}); | 
| 114 |  |  |  |  |  |  | } | 
| 115 | 0 |  |  |  |  |  | my %c=(owner_handle => 'registrant', admin_handle => 'admin', tech_handle => 'tech', billing_handle => 'billing'); | 
| 116 | 0 |  |  |  |  |  | my $cs=$po->create_local_object('contactset'); | 
| 117 | 0 |  |  |  |  |  | while (my ($k,$v)=each(%c)) | 
| 118 |  |  |  |  |  |  | { | 
| 119 | 0 | 0 |  |  |  |  | next unless exists($r{$k}); | 
| 120 | 0 |  |  |  |  |  | my $c=$po->create_local_object('contact')->srid($r{$k}); | 
| 121 | 0 |  |  |  |  |  | $cs->add($c,$v); | 
| 122 |  |  |  |  |  |  | } | 
| 123 | 0 |  |  |  |  |  | $rinfo->{domain}->{$oname}->{contact}=$cs; | 
| 124 | 0 |  |  |  |  |  | $rinfo->{domain}->{$oname}->{auth}={pw => $r{authorization_code}}; | 
| 125 |  |  |  |  |  |  |  | 
| 126 | 0 | 0 |  |  |  |  | if ($r{locked}) | 
| 127 |  |  |  |  |  |  | { | 
| 128 | 0 |  |  |  |  |  | $rinfo->{domain}->{$oname}->{status}=$po->create_local_object('status')->add('clientTransferProhibited'); ## ? | 
| 129 |  |  |  |  |  |  | } else | 
| 130 |  |  |  |  |  |  | { | 
| 131 | 0 |  |  |  |  |  | $rinfo->{domain}->{$oname}->{status}=$po->create_local_object('status')->add('ok'); | 
| 132 |  |  |  |  |  |  | } | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | ## And what about nameservers ? No information in documentation, only separate functions for that: domain_ns_* | 
| 135 |  |  |  |  |  |  | # $rinfo->{domain}->{$oname}->{ns}=?? | 
| 136 | 0 |  |  |  |  |  | return; | 
| 137 |  |  |  |  |  |  | } | 
| 138 |  |  |  |  |  |  |  | 
| 139 |  |  |  |  |  |  | sub check | 
| 140 |  |  |  |  |  |  | { | 
| 141 | 0 |  |  | 0 | 0 |  | my ($po,$domain)=@_; | 
| 142 | 0 |  |  |  |  |  | my $msg=$po->message(); | 
| 143 | 0 |  |  |  |  |  | build_msg($msg,'domain_available',$domain); | 
| 144 | 0 |  |  |  |  |  | $msg->params([$domain]); | 
| 145 | 0 |  |  |  |  |  | return; | 
| 146 |  |  |  |  |  |  | } | 
| 147 |  |  |  |  |  |  |  | 
| 148 |  |  |  |  |  |  | sub check_parse | 
| 149 |  |  |  |  |  |  | { | 
| 150 | 0 |  |  | 0 | 0 |  | my ($po,$otype,$oaction,$oname,$rinfo)=@_; | 
| 151 | 0 |  |  |  |  |  | my $mes=$po->message(); | 
| 152 | 0 | 0 |  |  |  |  | return unless $mes->is_success(); | 
| 153 |  |  |  |  |  |  |  | 
| 154 | 0 |  |  |  |  |  | my $r=$mes->result(); | 
| 155 | 0 | 0 |  |  |  |  | Net::DRI::Exception->die(1,'protocol/gandi/ws',1,'Unexpected reply for domain_check: '.$r) unless (ref($r) eq 'HASH'); | 
| 156 |  |  |  |  |  |  |  | 
| 157 | 0 |  |  |  |  |  | $rinfo->{domain}->{$oname}->{action}='check'; | 
| 158 | 0 | 0 | 0 |  |  |  | $rinfo->{domain}->{$oname}->{exist}=(exists($r->{$oname}) && $r->{$oname}==1)? 0 : 1; | 
| 159 | 0 |  |  |  |  |  | return; | 
| 160 |  |  |  |  |  |  | } | 
| 161 |  |  |  |  |  |  |  | 
| 162 |  |  |  |  |  |  | #################################################################################################### | 
| 163 |  |  |  |  |  |  | 1; |