1## Domain Registry Interface, OpenSRS Registry Driver
2##
3## Copyright (c) 2008,2009 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#
16####################################################################################################
17
18package Net::DRI::DRD::OpenSRS;
19
20use strict;
21use warnings;
22
23use base qw/Net::DRI::DRD/;
24
25use DateTime::Duration;
26use Net::DRI::Util;
27
28our $VERSION=do { my @r=(q$Revision: 1.3 $=~/\d+/g); sprintf("%d".".%02d" x $#r, @r); };
29
30=pod
31
32=head1 NAME
33
34Net::DRI::DRD::OpenSRS - OpenSRS Registry driver for Net::DRI
35
36=head1 DESCRIPTION
37
38Please see the README file for details.
39
40=head2 CURRENT LIMITATIONS
41
42Only domain_info and account_list_domains are available.
43
44=head1 SUPPORT
45
46For now, support questions should be sent to:
47
48E<lt>netdri@dotandco.comE<gt>
49
50Please also see the SUPPORT file in the distribution.
51
52=head1 SEE ALSO
53
54E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
55
56=head1 AUTHOR
57
58Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
59
60=head1 COPYRIGHT
61
62Copyright (c) 2008,2009 Patrick Mevzek <netdri@dotandco.com>.
63All rights reserved.
64
65This program is free software; you can redistribute it and/or modify
66it under the terms of the GNU General Public License as published by
67the Free Software Foundation; either version 2 of the License, or
68(at your option) any later version.
69
70See the LICENSE file that comes with this distribution for more details.
71
72=cut
73
74####################################################################################################
75
76sub new
77{
78 my $class=shift;
79 my $self=$class->SUPER::new(@_);
80 return $self;
81}
82
83sub periods      { return map { DateTime::Duration->new(years => $_) } (1..10); }
84sub name         { return 'OpenSRS'; }
85sub tlds         { return (qw/example com net org info biz mobi name asia at be ca cc ch cn de dk es eu fr it li me com.mx nl tv uk us/); } ## see http://services.tucows.com/services/domains/pricing.php
86sub object_types { return ('domain'); }
87sub profile_types { return qw/xcp/; }
88
89sub transport_protocol_default
90{
91 my ($self,$type)=@_;
92
93 return ('Net::DRI::Transport::HTTP',{},'Net::DRI::Protocol::OpenSRS::XCP',{}) if $type eq 'xcp';
94 return;
95}
96
97####################################################################################################
98
99sub domain_operation_needs_is_mine
100{
101 my ($self,$ndr,$domain,$op)=@_;
102 return;
103}
104
105sub account_list_domains
106{
107 my ($self,$ndr)=@_;
108 my $rc=$ndr->try_restore_from_cache('account','domains','list');
109 if (! defined $rc) { $rc=$ndr->process('account','list_domains'); }
110 return $rc;
111}
112
113sub domain_info
114{
115 my ($self,$ndr,$domain,$rd)=@_;
116 $self->enforce_domain_name_constraints($ndr,$domain,'info');
117
118 my $rc=$ndr->try_restore_from_cache('domain',$domain,'info');
119 if (! defined $rc)
120 {
121  ## First grab a cookie, if needed
122  unless (Net::DRI::Util::has_key($rd,'cookie'))
123  {
124   $rd={} unless defined($rd); ## will fail in set_cookie because other params needed, but at least this will be ok for next line ; otherwise do true checks of value needed
125   $rd->{domain}=$domain;
126   $rc=$ndr->process('session','set_cookie',[$rd]);
127   return $rc unless $rc->is_success();
128   $rd->{cookie}=$ndr->get_info('value','session','cookie'); ## Store cookie somewhere (taking into account date of expiry or some TTLs) ?
129  }
130  ## Now do the real info
131  $rc=$ndr->process('domain','info',[$domain,$rd]); ## the $domain is not really used here, as it was used during set_cookie above
132 }
133 return $rc;
134}
135
136####################################################################################################
1371;
138