gandi 1.0.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/README ADDED
@@ -0,0 +1,31 @@
1
+ USAGE
2
+ =====
3
+
4
+ require 'gandi'
5
+ session = Gandi::Session.connect(:login => "FO1234-GANDI", :password => "foobar")
6
+
7
+ session.password("new_password")
8
+ session.domain_list
9
+ session.account_balance
10
+
11
+ domain = "example.org"
12
+ period = 1
13
+ owner_handle = "AA1234-GANDI"
14
+ admin_handle = "BB2345-GANDI"
15
+ tech_handle = "CC3456-GANDI"
16
+ billing_handle = "DD4567-GANDI"
17
+ ns_list = ["ns1.example.net", "ns2.example.net", "ns1.example.com"]
18
+
19
+ operation = session.domain_create( domain, period,
20
+ owner_handle, admin_handle,
21
+ tech_handle, billing_handle,
22
+ ns_list)
23
+
24
+ session.operation_list :state => "PENDING"
25
+
26
+ TODO
27
+ ====
28
+ Tests
29
+ Gem release
30
+ Argument checking for all Gandi methods
31
+ Documentation
data/lib/gandi.rb ADDED
@@ -0,0 +1,24 @@
1
+ # Add the directory containing this file to the start of the load path if it
2
+ # isn't there already.
3
+ $:.unshift(File.dirname(__FILE__)) unless
4
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
5
+
6
+ require 'xmlrpc/client'
7
+ require 'gandi/session'
8
+ require 'gandi/errors'
9
+
10
+ # Gandi/Ruby Library
11
+ #
12
+ # Author:: Jérôme Lipowicz (mailto:jerome@yayel.com)
13
+ # License:: MIT License
14
+
15
+ class Array
16
+ # from ActiveSupport::CoreExtensions::Array::ExtractOptions
17
+ def extract_options!
18
+ last.is_a?(::Hash) ? pop : {}
19
+ end
20
+ end
21
+
22
+ module Gandi
23
+ VERSION = '1.0.0'
24
+ end
@@ -0,0 +1,4 @@
1
+ module Gandi
2
+ class DataError < ArgumentError ; end
3
+ class ServerError < RuntimeError ; end
4
+ end
@@ -0,0 +1,48 @@
1
+ module Gandi
2
+
3
+ class Session
4
+ HOST = "https://api.gandi.net/xmlrpc/"
5
+
6
+ attr_reader :handler, :session_id
7
+
8
+ def initialize(login, password, host, safe_mode = true)
9
+ @login = login
10
+ @password = password
11
+ @host = host
12
+ @safe_mode = safe_mode
13
+ end
14
+
15
+ def connect
16
+ @handler = XMLRPC::Client.new2(@host)
17
+ @session_id = call("login", @login, @password, @safe_mode)
18
+ end
19
+ alias login connect
20
+
21
+ def call(*args)
22
+ raise LoadError, "no connexion handler is set." unless @handler.is_a?(XMLRPC::Client)
23
+ @handler.call(*args)
24
+ rescue XMLRPC::FaultException => exception
25
+ raise ( exception.faultCode < 500000 ? Gandi::ServerError : Gandi::DataError ), exception.faultString
26
+ end
27
+
28
+ def method_missing(method, *args)
29
+ if %w(password account_currency account_balance domain_list domain_available domain_lock domain_unlock domain_info domain_renew domain_create domain_restore domain_del domain_transfer_in_available domain_transfer_in domain_transfer_out domain_trade domain_change_owner domain_change_contact domain_ns_list domain_ns_add domain_ns_del domain_ns_set host_list host_info host_create host_delete domain_gandimail_activate domain_gandimail_deactivate domain_forward_list domain_forward_set domain_forward_delete domain_mailbox_list domain_mailbox_info domain_mailbox_add domain_mailbox_update domain_mailbox_delete domain_mailbox_alias_list domain_mailbox_alias_set domain_mailbox_purge domain_web_redir_list domain_web_redir_add domain_web_redir_del contact_create contact_update contact_del contact_info operation_list operation_details operation_relaunch operation_cancel tld_list).include?(method.to_s)
30
+ call(method, @session_id, *args)
31
+ else
32
+ raise NoMethodError, "method #{method} is not available in the GANDI API."
33
+ end
34
+ end
35
+
36
+ # Accepted arguments are:
37
+ # :host, :login, :password and :safe_mode (defaults to true)
38
+ def self.connect(*args)
39
+ config = { :host => HOST, :safe_mode => true }.merge(args.extract_options!)
40
+ unless config[:login] && config[:password]
41
+ raise ArgumentError, "login and password needed"
42
+ end
43
+ client = self.new(config[:login], config[:password], config[:host], config[:safe_mode])
44
+ client.connect
45
+ return client
46
+ end
47
+ end
48
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gandi
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors: []
13
+
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-02-26 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Wrapper around gandi xml-rpc API
23
+ email:
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - README
32
+ - lib/gandi/errors.rb
33
+ - lib/gandi/session.rb
34
+ - lib/gandi.rb
35
+ has_rdoc: true
36
+ homepage: https://github.com/veilleperso/gandi
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ hash: 3
50
+ segments:
51
+ - 0
52
+ version: "0"
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ requirements: []
63
+
64
+ rubyforge_project:
65
+ rubygems_version: 1.5.2
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: Gandi XML RPC API
69
+ test_files: []
70
+