gandirb 1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +1 -0
- data/LICENSE +19 -0
- data/README +35 -0
- data/Rakefile +32 -0
- data/gandirb.gemspec +34 -0
- data/lib/gandi/base.rb +121 -0
- data/lib/gandi/domain.rb +134 -0
- data/lib/gandi/domain_modules/contact.rb +36 -0
- data/lib/gandi/domain_modules/host.rb +29 -0
- data/lib/gandi/domain_modules/mail.rb +80 -0
- data/lib/gandi/domain_modules/name_servers.rb +28 -0
- data/lib/gandi/domain_modules/operations.rb +30 -0
- data/lib/gandi/domain_modules/redirection.rb +25 -0
- data/lib/gandi.rb +9 -0
- data/rdoc/classes/Gandi/Base.html +397 -0
- data/rdoc/classes/Gandi/DataError.html +111 -0
- data/rdoc/classes/Gandi/Domain.html +623 -0
- data/rdoc/classes/Gandi/DomainModules/Contact.html +246 -0
- data/rdoc/classes/Gandi/DomainModules/Host.html +227 -0
- data/rdoc/classes/Gandi/DomainModules/NameServers.html +226 -0
- data/rdoc/classes/Gandi/DomainModules/Operations.html +229 -0
- data/rdoc/classes/Gandi/DomainModules/Redirection.html +215 -0
- data/rdoc/classes/Gandi/DomainModules.html +136 -0
- data/rdoc/classes/Gandi/ServerError.html +111 -0
- data/rdoc/classes/Gandi.html +153 -0
- data/rdoc/created.rid +1 -0
- data/rdoc/files/README.html +162 -0
- data/rdoc/files/lib/gandi/base_rb.html +109 -0
- data/rdoc/files/lib/gandi/domain_modules/contact_rb.html +101 -0
- data/rdoc/files/lib/gandi/domain_modules/host_rb.html +101 -0
- data/rdoc/files/lib/gandi/domain_modules/name_servers_rb.html +101 -0
- data/rdoc/files/lib/gandi/domain_modules/operations_rb.html +101 -0
- data/rdoc/files/lib/gandi/domain_modules/redirection_rb.html +101 -0
- data/rdoc/files/lib/gandi/domain_rb.html +101 -0
- data/rdoc/files/lib/gandi_rb.html +101 -0
- data/rdoc/fr_class_index.html +38 -0
- data/rdoc/fr_file_index.html +36 -0
- data/rdoc/fr_method_index.html +83 -0
- data/rdoc/index.html +24 -0
- data/rdoc/rdoc-style.css +208 -0
- data/test/gandi/base_test.rb +188 -0
- data/test/gandi/domain_test.rb +302 -0
- data/test/gandi_test.rb +9 -0
- data/test/test_helper.rb +9 -0
- metadata +124 -0
data/CHANGELOG
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
v1.0. Gem creation
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2009 Pickabee
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
= Gandirb - Ruby library for using Gandi XML-RPC API
|
2
|
+
|
3
|
+
This is a ruby library for using Gandi XML-RPC API.
|
4
|
+
It should only support the domain and mail API, but may be extensible enough to add hosting in the future.
|
5
|
+
|
6
|
+
== Howto
|
7
|
+
|
8
|
+
See http://wiki.gandi.net/fr/api-xml/docs/domain for the full documentation on the API.
|
9
|
+
Note the session_id doesn't have to be explicitly provided when calling a method.
|
10
|
+
|
11
|
+
It should also be noted that the ruby xml-rpc lib seems to have a bug with the ssl support, resulting in a timeout of 15 seconds.
|
12
|
+
After this time the current connection won't work and result in various exception.
|
13
|
+
This lib takes this issue into account and provides a workaround by restarting the connection. See the code comments for more details.
|
14
|
+
|
15
|
+
Quick example :
|
16
|
+
|
17
|
+
gandi_session = Gandi::Domain.login 'XXYYY-Gandi', 'mypasswd', Gandi::Domain::TEST_URL #omit the last param for real url
|
18
|
+
gandi_session.account_currency # => "EUR"
|
19
|
+
gandi_session.domain_available ["mycoolwebsite.com"] # => {"mycoolwebsite.com"=>true}
|
20
|
+
gandi_session.domain_available "mycoolwebsite.com" # => true #rubyfied syntax
|
21
|
+
gandi_session.domain_list # => ["mypersonalwebsite.com"]
|
22
|
+
|
23
|
+
Detailed RDoc documentation for each method is available using rake rdoc.
|
24
|
+
|
25
|
+
== TODO
|
26
|
+
|
27
|
+
* Tests
|
28
|
+
* Finish adding and cleaning up domain and mail methods
|
29
|
+
* Better handling of failures and server exceptions, and stricter params checking
|
30
|
+
* Gemification (with Jeweler)
|
31
|
+
|
32
|
+
== Copyright
|
33
|
+
|
34
|
+
Copyright (c) 2009 Pickabee. Released under the MIT licence, see LICENSE for details.
|
35
|
+
Some parts inspired by http://github.com/jerome/gandi/tree
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
require 'rake/testtask'
|
5
|
+
Rake::TestTask.new(:test) do |test|
|
6
|
+
test.libs << 'lib' << 'test'
|
7
|
+
test.pattern = 'test/**/*_test.rb'
|
8
|
+
test.verbose = false
|
9
|
+
end
|
10
|
+
|
11
|
+
begin
|
12
|
+
require 'rcov/rcovtask'
|
13
|
+
Rcov::RcovTask.new do |test|
|
14
|
+
test.libs << 'test'
|
15
|
+
test.pattern = 'test/**/*_test.rb'
|
16
|
+
test.verbose = true
|
17
|
+
end
|
18
|
+
rescue LoadError
|
19
|
+
task :rcov do
|
20
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
task :default => :test
|
25
|
+
|
26
|
+
require 'rake/rdoctask'
|
27
|
+
Rake::RDocTask.new do |rdoc|
|
28
|
+
rdoc.rdoc_dir = 'rdoc'
|
29
|
+
rdoc.title = "Gandirb"
|
30
|
+
rdoc.rdoc_files.include('README*')
|
31
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
32
|
+
end
|
data/gandirb.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{gandirb}
|
5
|
+
s.version = "1.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Pickabee"]
|
9
|
+
s.date = %q{2010-04-30}
|
10
|
+
s.description = <<-EOL
|
11
|
+
This is a ruby library for using Gandi XML-RPC API.
|
12
|
+
It should only support the domain and mail API, but may be extensible enough to add hosting in the future.
|
13
|
+
EOL
|
14
|
+
s.summary = %q{Ruby library for using Gandi XML-RPC API}
|
15
|
+
s.email = %q{}
|
16
|
+
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "lib/gandi.rb", "lib/gandi/base.rb", "lib/gandi/domain.rb", "lib/gandi/domain_modules/contact.rb", "lib/gandi/domain_modules/host.rb", "lib/gandi/domain_modules/mail.rb", "lib/gandi/domain_modules/name_servers.rb", "lib/gandi/domain_modules/operations.rb", "lib/gandi/domain_modules/redirection.rb"]
|
17
|
+
s.files = ["CHANGELOG", "LICENSE", "README", "Rakefile", "lib/gandi.rb", "lib/gandi/base.rb", "lib/gandi/domain.rb", "lib/gandi/domain_modules/contact.rb", "lib/gandi/domain_modules/host.rb", "lib/gandi/domain_modules/mail.rb", "lib/gandi/domain_modules/name_servers.rb", "lib/gandi/domain_modules/operations.rb", "lib/gandi/domain_modules/redirection.rb", "rdoc/classes/Gandi.html", "rdoc/classes/Gandi/Base.html", "rdoc/classes/Gandi/DataError.html", "rdoc/classes/Gandi/Domain.html", "rdoc/classes/Gandi/DomainModules.html", "rdoc/classes/Gandi/DomainModules/Contact.html", "rdoc/classes/Gandi/DomainModules/Host.html", "rdoc/classes/Gandi/DomainModules/NameServers.html", "rdoc/classes/Gandi/DomainModules/Operations.html", "rdoc/classes/Gandi/DomainModules/Redirection.html", "rdoc/classes/Gandi/ServerError.html", "rdoc/created.rid", "rdoc/files/README.html", "rdoc/files/lib/gandi/base_rb.html", "rdoc/files/lib/gandi/domain_modules/contact_rb.html", "rdoc/files/lib/gandi/domain_modules/host_rb.html", "rdoc/files/lib/gandi/domain_modules/name_servers_rb.html", "rdoc/files/lib/gandi/domain_modules/operations_rb.html", "rdoc/files/lib/gandi/domain_modules/redirection_rb.html", "rdoc/files/lib/gandi/domain_rb.html", "rdoc/files/lib/gandi_rb.html", "rdoc/fr_class_index.html", "rdoc/fr_file_index.html", "rdoc/fr_method_index.html", "rdoc/index.html", "rdoc/rdoc-style.css", "test/gandi/base_test.rb", "test/gandi/domain_test.rb", "test/gandi_test.rb", "test/test_helper.rb", "gandirb.gemspec"]
|
18
|
+
s.homepage = %q{http://github.com/pickabee/gandirb}
|
19
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Gandirb", "--main", "README"]
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
s.rubyforge_project = %q{gandirb}
|
22
|
+
s.rubygems_version = %q{1.3.6}
|
23
|
+
s.test_files = ["test/gandi/domain_test.rb", "test/gandi/base_test.rb", "test/gandi_test.rb", "test/test_helper.rb"]
|
24
|
+
|
25
|
+
if s.respond_to? :specification_version then
|
26
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
27
|
+
s.specification_version = 3
|
28
|
+
|
29
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
30
|
+
else
|
31
|
+
end
|
32
|
+
else
|
33
|
+
end
|
34
|
+
end
|
data/lib/gandi/base.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'xmlrpc/client'
|
2
|
+
require 'openssl'
|
3
|
+
|
4
|
+
#Common session, account and call methods
|
5
|
+
module Gandi
|
6
|
+
class Base
|
7
|
+
|
8
|
+
TIMEOUT_EXCEPTIONS = [EOFError, Errno::EPIPE, OpenSSL::SSL::SSLError]
|
9
|
+
|
10
|
+
URL = "https://api.gandi.net/xmlrpc/"
|
11
|
+
TEST_URL = "https://api.ote.gandi.net/xmlrpc/"
|
12
|
+
|
13
|
+
attr_reader :session_id, :handler
|
14
|
+
|
15
|
+
public
|
16
|
+
|
17
|
+
def initialize(login, password, uri = nil)
|
18
|
+
@login = login
|
19
|
+
@password = password
|
20
|
+
@uri = uri
|
21
|
+
if @uri.nil?
|
22
|
+
begin
|
23
|
+
self.class.const_get(:URL)
|
24
|
+
rescue NameError
|
25
|
+
raise ArgumentError.new "You must provide an URL when using Gandi::Base directly"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
#Calls a RPC method, transparently providing the session id
|
31
|
+
def call(method, *arguments)
|
32
|
+
raise "You have to log in before using methods requiring a session id" unless logged_in?
|
33
|
+
raw_call(method.to_s, @session_id, *arguments)
|
34
|
+
end
|
35
|
+
|
36
|
+
#Instanciates a rpc handler and log in to the interface to retrieve a session id
|
37
|
+
def login
|
38
|
+
@handler = XMLRPC::Client.new_from_uri(@uri)
|
39
|
+
#Get rid of SSL warnings "peer certificate won't be verified in this SSL session"
|
40
|
+
#See http://developer.amazonwebservices.com/connect/thread.jspa?threadID=37139
|
41
|
+
#and http://blog.chmouel.com/2008/03/21/ruby-xmlrpc-over-a-self-certified-ssl-with-a-warning/
|
42
|
+
if @handler.instance_variable_get('@http').use_ssl?
|
43
|
+
@handler.instance_variable_get('@http').instance_variable_get("@ssl_context").verify_mode = OpenSSL::SSL::VERIFY_NONE
|
44
|
+
end
|
45
|
+
@session_id = raw_call("login", @login, @password, false)
|
46
|
+
end
|
47
|
+
|
48
|
+
#Gets a new session id by switching to another handle
|
49
|
+
def su(handle)
|
50
|
+
@session_id = call("su", handle)
|
51
|
+
end
|
52
|
+
|
53
|
+
#Changes password
|
54
|
+
def password(password)
|
55
|
+
@password = password
|
56
|
+
call("password", password)
|
57
|
+
end
|
58
|
+
|
59
|
+
#Current prepaid account balance
|
60
|
+
def account_balance
|
61
|
+
call('account_balance')
|
62
|
+
end
|
63
|
+
|
64
|
+
#Currency name used with the prepaid account
|
65
|
+
def account_currency
|
66
|
+
call('account_currency')
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.login(login, password, uri = nil)
|
70
|
+
client = self.new(login, password, uri)
|
71
|
+
client.login
|
72
|
+
return client
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
#Handle RPC calls and exceptions
|
78
|
+
#A reconnection system is used to work around what seems to be a ruby bug :
|
79
|
+
#When waiting during 15 seconds between calls, a timeout is reached and the RPC handler starts throwing various exceptions
|
80
|
+
#EOFError, Errno::EPIPE, then OpenSSL::SSL::SSLError.
|
81
|
+
#When this happens, another handler and another session are created
|
82
|
+
#Exceptions are not handled if happening two times consecutively, or during a login call
|
83
|
+
#TODO: This method may be optimized by only creating another handler and keeping the session id.
|
84
|
+
#In this case a server timeout of 12 hours (see the Gandi documentation) may be reached more easily and should be handled.
|
85
|
+
def raw_call(*args)
|
86
|
+
begin
|
87
|
+
raise "no connexion handler is set" unless @handler
|
88
|
+
result = @handler.call(*args)
|
89
|
+
@reconnected = false unless (args.first == 'login')
|
90
|
+
return result
|
91
|
+
rescue StandardError => e
|
92
|
+
case e
|
93
|
+
when XMLRPC::FaultException
|
94
|
+
raise (e.faultCode.to_s.chars.first == '5' ? Gandi::DataError : Gandi::ServerError), e.faultString
|
95
|
+
when *TIMEOUT_EXCEPTIONS
|
96
|
+
if @reconnected || (args.first == 'login')
|
97
|
+
raise e #only one retry, and no retries if logging in
|
98
|
+
else
|
99
|
+
@reconnected = true
|
100
|
+
args[1] = login #use the new session string
|
101
|
+
raw_call(*args)
|
102
|
+
end
|
103
|
+
else
|
104
|
+
@reconnected = false
|
105
|
+
raise e
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def logged_in?
|
111
|
+
@session_id.is_a? String
|
112
|
+
end
|
113
|
+
|
114
|
+
#Raises a NoMethodError exception.
|
115
|
+
#Used for methods that are presents in the API but not yet available
|
116
|
+
def not_supported
|
117
|
+
raise NoMethodError.new "This method is not supported and will be available in v1.10"
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
data/lib/gandi/domain.rb
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
modules_directory = File.expand_path(File.dirname(__FILE__))
|
2
|
+
require File.join(modules_directory, 'domain_modules/name_servers')
|
3
|
+
require File.join(modules_directory, 'domain_modules/host')
|
4
|
+
require File.join(modules_directory, 'domain_modules/redirection')
|
5
|
+
require File.join(modules_directory, 'domain_modules/contact')
|
6
|
+
require File.join(modules_directory, 'domain_modules/operations')
|
7
|
+
require File.join(modules_directory, 'domain_modules/mail')
|
8
|
+
|
9
|
+
module Gandi
|
10
|
+
class Domain < Gandi::Base
|
11
|
+
#Returns an array of domains for which the logged user is the reseller or a contact (owner, administrative, billing or technical).
|
12
|
+
#TODO: memoize results
|
13
|
+
def domain_list
|
14
|
+
call('domain_list')
|
15
|
+
end
|
16
|
+
|
17
|
+
#Check a domain availability.
|
18
|
+
#This implementation does not respect the original API specifications and allow for a single domain to be checked.
|
19
|
+
#In this case the domain can be provided as a string and a boolean will be returned.
|
20
|
+
def domain_available(domains)
|
21
|
+
available_domains = call('domain_available', domains.to_a)
|
22
|
+
return (domains.is_a?(String)) ? available_domains.values.first : available_domains
|
23
|
+
end
|
24
|
+
|
25
|
+
#Add a lock status (cf. domain_info) to avoid any fraudulent transfer.
|
26
|
+
#Return the operation attributed ID
|
27
|
+
def domain_lock(domain)
|
28
|
+
call('domain_lock', domain)
|
29
|
+
end
|
30
|
+
|
31
|
+
#Remove a lock status (cf. domain_info) to transfer the domain to another registrar.
|
32
|
+
#Return the operation attributed ID
|
33
|
+
def domain_unlock(domain)
|
34
|
+
call('domain_unlock', domain)
|
35
|
+
end
|
36
|
+
|
37
|
+
#Retrieve the informations linked to this domain (contacts, nameservers, redirections, weblogs...).
|
38
|
+
#This method only works on domains handled by Gandi.
|
39
|
+
#Return a hash with string keys containing domain informations (see API documentation)
|
40
|
+
#TODO: convert XMLRPC datetimes ?
|
41
|
+
def domain_info(domain)
|
42
|
+
call('domain_info', domain)
|
43
|
+
end
|
44
|
+
|
45
|
+
#Renew a domain for a number of years.
|
46
|
+
#The total number of years cannot exceed 10.
|
47
|
+
#Return the operation attributed ID
|
48
|
+
def domain_renew(domain, period)
|
49
|
+
raise ArgumentError.new("The total number of years cannot exceed 10") if period > 10
|
50
|
+
call('domain_renew', domain, period)
|
51
|
+
end
|
52
|
+
|
53
|
+
#Register a domain with Gandi and associate it to a list of contacts.
|
54
|
+
#Return the operation attributed ID
|
55
|
+
def domain_create(domain, period, owner_handle, admin_handle, tech_handle, billing_handle, nameservers, lang = nil)
|
56
|
+
args = [domain, period, owner_handle, admin_handle, tech_handle, billing_handle, nameservers, lang]
|
57
|
+
args.pop if lang.nil?
|
58
|
+
call('domain_create', *args)
|
59
|
+
end
|
60
|
+
|
61
|
+
#Get a domain out of its redemption period. See glossary, Restore.
|
62
|
+
#This function is available for domains in .COM, .NET, .BE or .EU.
|
63
|
+
#Return the operation attributed ID
|
64
|
+
#TODO: Check for domain correctness
|
65
|
+
def domain_restore(domain)
|
66
|
+
call('domain_restore', domain)
|
67
|
+
end
|
68
|
+
|
69
|
+
#Delete a domain.
|
70
|
+
#Return the operation attributed ID
|
71
|
+
#This method is not available yet and will be present in v1.10 of the API
|
72
|
+
def domain_del(domain)
|
73
|
+
not_supported
|
74
|
+
end
|
75
|
+
|
76
|
+
#Check if a domain can be transferred from another registrar. See glossary, Transfer.
|
77
|
+
def domain_transfer_in_available(domain)
|
78
|
+
call('domain_transfer_in_available', domain)
|
79
|
+
end
|
80
|
+
|
81
|
+
alias_method :domain_transfer_in_available?, :domain_transfer_in_available
|
82
|
+
|
83
|
+
#Transfer (see glossary, Transfer) a domain from another registrar to Gandi, or from a Gandi account to a Gandi reseller.
|
84
|
+
#If the domain is already at Gandi (internal transfer), owner_handle, admin_handle, tech_handle and billing_handle are maintained.
|
85
|
+
#Return the operation attributed ID
|
86
|
+
#TODO: check for auth_code if TLD is .fr
|
87
|
+
def domain_transfer_in(domain, owner_handle, admin_handle, tech_handle, billing_handle, nameservers, auth_code = nil)
|
88
|
+
args = [domain, owner_handle, admin_handle, tech_handle, billing_handle, nameservers, auth_code]
|
89
|
+
args.pop if auth_code.nil?
|
90
|
+
call('domain_transfer_in', *args)
|
91
|
+
end
|
92
|
+
|
93
|
+
#Accept or deny a transfer of a domain from Gandi to another registrar. See glossary, Transfer.
|
94
|
+
#This method is not available yet and will be present in v1.10 of the API
|
95
|
+
def domain_transfer_out(opid, allow)
|
96
|
+
not_supported
|
97
|
+
end
|
98
|
+
|
99
|
+
#Start the trade of a domain from another registrar to Gandi.
|
100
|
+
#Return the operation attributed ID
|
101
|
+
#This method is not available yet and will be present in v1.10 of the API
|
102
|
+
def domain_trade(domain, owner_handle, admin_handle, tech_handle, billing_handle, afnic_titularkey = nil)
|
103
|
+
not_supported
|
104
|
+
end
|
105
|
+
|
106
|
+
#Change the owner of a domain registered with Gandi and, optionally, the admin, tech and billing contacts. See glossary, Change of Ownership.
|
107
|
+
#Return the operation attributed ID
|
108
|
+
#This method is not available yet and will be present in v1.10 of the API
|
109
|
+
def domain_change_owner(domain, new_owner, new_admin = nil, new_tech = nil, new_billing = nil)
|
110
|
+
not_supported
|
111
|
+
end
|
112
|
+
|
113
|
+
#Change a given contact of a domain registered with Gandi.
|
114
|
+
#Return the operation attributed ID
|
115
|
+
def domain_change_contact(domain, type, new_contact)
|
116
|
+
call('domain_change_contact', domain, type, new_contact)
|
117
|
+
end
|
118
|
+
|
119
|
+
#Misc methods
|
120
|
+
|
121
|
+
#Return an array of active TLDs handled by the application.
|
122
|
+
#TODO: memoization
|
123
|
+
def tld_list
|
124
|
+
call('tld_list')
|
125
|
+
end
|
126
|
+
|
127
|
+
include Gandi::DomainModules::NameServers
|
128
|
+
include Gandi::DomainModules::Host
|
129
|
+
include Gandi::DomainModules::Redirection
|
130
|
+
include Gandi::DomainModules::Contact
|
131
|
+
include Gandi::DomainModules::Operations
|
132
|
+
include Gandi::DomainModules::Mail
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Gandi
|
2
|
+
module DomainModules
|
3
|
+
module Contact
|
4
|
+
CONTACT_CLASSES = ['individual', 'company', 'public', 'association']
|
5
|
+
|
6
|
+
#Create a Gandi contact of a given type. See glossary, Account.
|
7
|
+
#Return the Gandi handle of the created contact
|
8
|
+
#TODO check contact class
|
9
|
+
def contact_create(contact_class, firstname, lastname, address, zipcode, city, country, phone, email, params = {})
|
10
|
+
#Note: contact_class argument is used instead of class (due to a ruby keyword conflict)
|
11
|
+
args = [contact_class, firstname, lastname, address, zipcode, city, country, phone, email, params]
|
12
|
+
args.pop if params.empty?
|
13
|
+
|
14
|
+
call('contact_create', *args)
|
15
|
+
end
|
16
|
+
|
17
|
+
#Update a Gandi contact
|
18
|
+
#Return the operation attributed ID
|
19
|
+
#TODO: check for frozen params
|
20
|
+
def contact_update(handle, params)
|
21
|
+
call('contact_update', handle, params)
|
22
|
+
end
|
23
|
+
|
24
|
+
#Delete a Gandi contact
|
25
|
+
#Return the operation attributed ID
|
26
|
+
def contact_del(handle)
|
27
|
+
call('contact_del', handle)
|
28
|
+
end
|
29
|
+
|
30
|
+
#Retrieve a hash of Gandi contact informations
|
31
|
+
def contact_info(handle)
|
32
|
+
call('contact_info', handle)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Gandi
|
2
|
+
module DomainModules
|
3
|
+
module Host
|
4
|
+
#Returns the array of glue records for the specified domain.
|
5
|
+
def host_list(domain)
|
6
|
+
call('host_list', domain)
|
7
|
+
end
|
8
|
+
|
9
|
+
#Retrieve an array of the IP addresses linked to this hostname.
|
10
|
+
def host_info(fqdn)
|
11
|
+
call('host_info', fqdn)
|
12
|
+
end
|
13
|
+
|
14
|
+
#Create a glue record with the specified IP addresses.
|
15
|
+
#This implementation does not respect the original API specifications and allow for a single IP to be provided.
|
16
|
+
#An array of IPs can be provided but only the first IP is used (this is an API limitation).
|
17
|
+
#Return the operation attributed ID
|
18
|
+
def host_create(host, ip)
|
19
|
+
call('host_create', host, [ip].flatten)
|
20
|
+
end
|
21
|
+
|
22
|
+
#Delete a host.
|
23
|
+
#Return the operation attributed ID
|
24
|
+
def host_delete(host)
|
25
|
+
call('host_delete', host)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Gandi
|
2
|
+
module DomainModules
|
3
|
+
module Mail
|
4
|
+
|
5
|
+
#Enables the Gandimail service for one domain
|
6
|
+
def domain_gandimail_activate(domain)
|
7
|
+
call('domain_gandimail_activate', domain)
|
8
|
+
end
|
9
|
+
|
10
|
+
#Disables the Gandimail service for one domain: mail servers won't accept mail sent to this domain anymore
|
11
|
+
#Does not delete forwards, aliases or mailboxes
|
12
|
+
def domain_gandimail_deactivate(domain)
|
13
|
+
call('domain_gandimail_deactivate', domain)
|
14
|
+
end
|
15
|
+
|
16
|
+
#Returns a structure associating each forward with its destinations
|
17
|
+
def domain_forward_list(domain)
|
18
|
+
call('domain_forward_list', domain)
|
19
|
+
end
|
20
|
+
|
21
|
+
#Setup a forward to redirect to one or more destinations.
|
22
|
+
#Warning: it overwrites the forward (the source), so if you try to add one destination to a forward, you shall include the existing destinations
|
23
|
+
#TODO: keep existing forwards ?
|
24
|
+
def domain_forward_set(domain, source, destinations)
|
25
|
+
call('domain_forward_set', domain, source, destinations)
|
26
|
+
end
|
27
|
+
|
28
|
+
#Deletes a forward. This does the same thing as domain_forward_set(domain, [])
|
29
|
+
def domain_forward_delete(domain, source)
|
30
|
+
call('domain_forward_delete', domain, source)
|
31
|
+
end
|
32
|
+
|
33
|
+
#Return the list of mailboxes associated with a domain
|
34
|
+
def domain_mailbox_list(domain)
|
35
|
+
call('domain_mailbox_list', domain)
|
36
|
+
end
|
37
|
+
|
38
|
+
#Provides information about a mailbox
|
39
|
+
def domain_mailbox_info(domain, mailbox)
|
40
|
+
call('domain_mailbox_info', domain, mailbox)
|
41
|
+
end
|
42
|
+
|
43
|
+
#Creates a new mailbox
|
44
|
+
#Accepted options:
|
45
|
+
# integer quota
|
46
|
+
# boolean antivirus
|
47
|
+
# boolean antispam
|
48
|
+
# string fallback_email
|
49
|
+
def domain_mailbox_add(domain, mailbox, password, options = {})
|
50
|
+
call('domain_mailbox_add', domain, mailbox, password, options)
|
51
|
+
end
|
52
|
+
|
53
|
+
#Updates an existing mailbox
|
54
|
+
#Accepted options are the same as the ones for domain_mailbox_add, with password added
|
55
|
+
def domain_mailbox_update(domain, mailbox, options)
|
56
|
+
call('domain_mailbox_update', domain, mailbox, options)
|
57
|
+
end
|
58
|
+
|
59
|
+
#Deletes a mailbox
|
60
|
+
def domain_mailbox_delete(domain, mailbox)
|
61
|
+
call('domain_mailbox_delete', domain, mailbox)
|
62
|
+
end
|
63
|
+
|
64
|
+
#List the aliases of a mailbox
|
65
|
+
def domain_mailbox_alias_list(domain, mailbox)
|
66
|
+
call('domain_mailbox_alias_list', domain, mailbox)
|
67
|
+
end
|
68
|
+
|
69
|
+
#Affect aliases to a mailbox
|
70
|
+
def domain_mailbox_alias_set(domain, mailbox, aliases)
|
71
|
+
call('domain_mailbox_alias_set', domain, mailbox, aliases)
|
72
|
+
end
|
73
|
+
|
74
|
+
#Delete all messages from a mailbox
|
75
|
+
def domain_mailbox_purge(domain, mailbox)
|
76
|
+
call('domain_mailbox_purge', domain, mailbox)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Gandi
|
2
|
+
module DomainModules
|
3
|
+
module NameServers
|
4
|
+
#Retrieve an array of name servers for a domain
|
5
|
+
def domain_ns_list(domain)
|
6
|
+
call('domain_ns_list', domain)
|
7
|
+
end
|
8
|
+
|
9
|
+
#Add the specified name servers to the name servers list of a domain
|
10
|
+
#Return the operation attributed ID
|
11
|
+
def domain_ns_add(domain, ns_list)
|
12
|
+
call('domain_ns_add', domain, ns_list)
|
13
|
+
end
|
14
|
+
|
15
|
+
#Remove the specified name servers from the name servers list of a domain
|
16
|
+
#Return the operation attributed ID
|
17
|
+
def domain_ns_del(domain, ns_list)
|
18
|
+
call('domain_ns_del', domain, ns_list)
|
19
|
+
end
|
20
|
+
|
21
|
+
#Set a domain name servers list
|
22
|
+
#Return the operation attributed ID
|
23
|
+
def domain_ns_set(domain, ns_list)
|
24
|
+
call('domain_ns_set', domain, ns_list)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Gandi
|
2
|
+
module DomainModules
|
3
|
+
module Operations
|
4
|
+
#Retrieves an array of the last 300 operation IDs matching the optional criterias
|
5
|
+
def operation_list(filter = {})
|
6
|
+
unless filter.empty?
|
7
|
+
call('operation_list', filter)
|
8
|
+
else
|
9
|
+
call('operation_list')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
#Retrieve an operation details
|
14
|
+
def operation_details(opid)
|
15
|
+
call('operation_details', opid)
|
16
|
+
end
|
17
|
+
|
18
|
+
#Relaunch an operation, modifying the given parameters
|
19
|
+
#TODO: check param
|
20
|
+
def operation_relaunch(opid, param)
|
21
|
+
call('operation_relaunch', opid, param)
|
22
|
+
end
|
23
|
+
|
24
|
+
#Cancel an operation
|
25
|
+
def operation_cancel(opid)
|
26
|
+
call('operation_cancel', opid)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Gandi
|
2
|
+
module DomainModules
|
3
|
+
module Redirection
|
4
|
+
DOMAIN_WEB_REDIR_REDIRECTION_TYPES = ['http302', 'http301', 'cloak']
|
5
|
+
|
6
|
+
#Retrieve an array of web redirections for a domain
|
7
|
+
def domain_web_redir_list(domain)
|
8
|
+
call('domain_web_redir_list', domain)
|
9
|
+
end
|
10
|
+
|
11
|
+
#Add a web redirection to a domain. All HTTP requests to http://fqdn/ will be redirected to 'destination_url' with a HTTP redirection 'type'
|
12
|
+
#Return the operation attributed ID
|
13
|
+
def domain_web_redir_add(domain, fqdn, destination_url, type)
|
14
|
+
raise ArgumentError.new("Redirection type is invalid") unless DOMAIN_WEB_REDIR_REDIRECTION_TYPES.include?(type)
|
15
|
+
call('domain_web_redir_add', domain, fqdn, destination_url, type)
|
16
|
+
end
|
17
|
+
|
18
|
+
#Delete the web redirection of the fully qualified domain name fqdn
|
19
|
+
#Return the operation attributed ID
|
20
|
+
def domain_web_redir_del(fqdn)
|
21
|
+
call('domain_web_redir_del', fqdn)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/gandi.rb
ADDED