gandi 2.0.10 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +61 -0
- data/lib/gandi.rb +10 -8
- data/lib/gandi/session.rb +20 -7
- metadata +11 -10
- data/README +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5b019af545582d4c85c903050bee4b255b3c859
|
4
|
+
data.tar.gz: 424f6f7f25648c730a5f3f7e559f3a2059e44509
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76b8fb3d9cf6ae1d1fcc5074e70d0ad90598f9fdac2ba3f91e2a21577c50067df99b37824c684b39bb0b70d2d389bde8926abee3e43ce9f11aaf1ed9fdd8c750
|
7
|
+
data.tar.gz: 5383179b5e9d0704fb4a85249ef6b4780c42aba15e15a59132a403450e2fae1a08ecd296e098e0293eb67e27cbf5757ec6fe08a66668ce9d7950b7d54f467b72
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Gandi
|
2
|
+
|
3
|
+
This is a Ruby interface to the [Gandi](http://gandi.net) XML-RPC API.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add to your `Gemfile`:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'gandi'
|
11
|
+
```
|
12
|
+
|
13
|
+
Then `bundle install`.
|
14
|
+
|
15
|
+
Otherwise
|
16
|
+
|
17
|
+
```bash
|
18
|
+
gem install gandi
|
19
|
+
```
|
20
|
+
|
21
|
+
## Basic Usage
|
22
|
+
|
23
|
+
Every call to the Gandi API is authenticated so sessions are required to have a unique API key. If you don’t have it already, you can retrieve your API key from your Gandi account page.
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'gandi'
|
27
|
+
|
28
|
+
api = Gandi::Session.new("24-character API key") # Endpoint: https://rpc.gandi.net/xmlrpc/
|
29
|
+
|
30
|
+
api.domain.list
|
31
|
+
api.domain.info('mydomain.com')
|
32
|
+
api.catalog.list(product: {type: 'domains'})
|
33
|
+
...
|
34
|
+
api.domain.zone.clone_zone('zone_id') # instead of api.domain.zone.clone
|
35
|
+
api.domain.zone.version.new_version('zone_id') # instead of domain.zone.version.new
|
36
|
+
...
|
37
|
+
```
|
38
|
+
|
39
|
+
### Operational Test and Evaluation (OT&E) Endpoint
|
40
|
+
|
41
|
+
Alongside the production API, Gandi provides an Operational Test and Evaluation (OT&E) system.
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
require 'gandi'
|
45
|
+
|
46
|
+
api = Gandi::Session.new("24-character API key", env: :test)
|
47
|
+
|
48
|
+
api.domain.list
|
49
|
+
...
|
50
|
+
```
|
51
|
+
|
52
|
+
For further information see the Gandi API documention at http://doc.rpc.gandi.net/
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
|
56
|
+
1. Fork it
|
57
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
58
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
59
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
60
|
+
5. Create new Pull Request
|
61
|
+
|
data/lib/gandi.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
# Add the directory containing this file to the start of the load path if it
|
2
|
-
|
3
|
-
$:.unshift(File.dirname(__FILE__)) unless
|
4
|
-
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
1
|
+
# Add the directory containing this file to the start of the load path if it isn't there already.
|
2
|
+
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
5
3
|
|
6
4
|
require 'hashie'
|
7
5
|
require 'xmlrpc/client'
|
@@ -9,19 +7,23 @@ require 'gandi/session'
|
|
9
7
|
require 'gandi/errors'
|
10
8
|
|
11
9
|
module Gandi
|
12
|
-
VERSION = '2.0
|
13
|
-
|
10
|
+
VERSION = '2.1.0'
|
11
|
+
|
12
|
+
ENDPOINT = {
|
13
|
+
test: 'https://rpc.ote.gandi.net/xmlrpc/',
|
14
|
+
production: 'https://rpc.gandi.net/xmlrpc/',
|
15
|
+
}
|
16
|
+
|
14
17
|
def self.silence_warnings
|
15
18
|
old_verbose, $VERBOSE = $VERBOSE, nil
|
16
19
|
yield
|
17
20
|
ensure
|
18
21
|
$VERBOSE = old_verbose
|
19
22
|
end
|
20
|
-
|
23
|
+
|
21
24
|
silence_warnings do
|
22
25
|
# gandi sometimes return <nil/> values so let's accept them to prevent exceptions
|
23
26
|
XMLRPC::Config::ENABLE_NIL_PARSER = true
|
24
27
|
XMLRPC::Config::ENABLE_NIL_CREATE = true
|
25
28
|
end
|
26
|
-
|
27
29
|
end
|
data/lib/gandi/session.rb
CHANGED
@@ -74,7 +74,6 @@ module Gandi
|
|
74
74
|
domain.webredir.list
|
75
75
|
domain.webredir.update
|
76
76
|
domain.zone.clone
|
77
|
-
domain.zone.clone_zone
|
78
77
|
domain.zone.count
|
79
78
|
domain.zone.create
|
80
79
|
domain.zone.delete
|
@@ -91,7 +90,6 @@ module Gandi
|
|
91
90
|
domain.zone.version.count
|
92
91
|
domain.zone.version.delete
|
93
92
|
domain.zone.version.new
|
94
|
-
domain.zone.version.new_version
|
95
93
|
domain.zone.version.set
|
96
94
|
domain.zone.version.list
|
97
95
|
hosting.datacenter.list
|
@@ -164,6 +162,7 @@ module Gandi
|
|
164
162
|
operation.info
|
165
163
|
operation.list
|
166
164
|
operation.relaunch
|
165
|
+
version.info
|
167
166
|
)
|
168
167
|
|
169
168
|
class ProxyCall
|
@@ -176,12 +175,12 @@ module Gandi
|
|
176
175
|
self
|
177
176
|
end
|
178
177
|
|
178
|
+
undef_method :clone
|
179
|
+
|
179
180
|
def method_missing(method, *args)
|
180
181
|
self.chained << method
|
181
182
|
method_name = chained.join(".")
|
182
183
|
if Gandi::VALID_METHODS.include?(method_name)
|
183
|
-
method_name.sub!('clone_zone','clone')
|
184
|
-
method_name.sub!('new_version','new')
|
185
184
|
res = self.server.call(method_name, api_key, *args)
|
186
185
|
if res.is_a?(Array)
|
187
186
|
res.collect! { |x| x.is_a?(Hash) ? Hashie::Mash.new(x) : x }
|
@@ -199,18 +198,32 @@ module Gandi
|
|
199
198
|
class Session
|
200
199
|
attr_reader :api_key
|
201
200
|
|
202
|
-
def initialize(api_key,
|
201
|
+
def initialize(api_key, options = {})
|
202
|
+
endpoint = options.is_a?(Hash) ? (ENDPOINT[options[:env]] || ENDPOINT[:production]) : options
|
203
|
+
|
203
204
|
@api_key = api_key
|
204
205
|
@server = XMLRPC::Client.new2(endpoint)
|
205
206
|
# fix a bug in ruby 2.0, http://bugs.ruby-lang.org/issues/8182
|
206
|
-
@server.http_header_extra = {"accept-encoding" => "identity"}
|
207
|
+
@server.http_header_extra = { "accept-encoding" => "identity" }
|
207
208
|
@server
|
208
209
|
end
|
209
210
|
|
211
|
+
def list_methods
|
212
|
+
server.call('system.listMethods')
|
213
|
+
end
|
214
|
+
|
215
|
+
def method_signature(name)
|
216
|
+
server.call('system.methodSignature', name)
|
217
|
+
end
|
218
|
+
|
219
|
+
def method_help(name)
|
220
|
+
server.call('system.methodHelp', name)
|
221
|
+
end
|
222
|
+
|
210
223
|
def method_missing(method, *args)
|
211
224
|
ProxyCall.new(@server, self.api_key).send(method, *args)
|
212
225
|
rescue XMLRPC::FaultException => exception
|
213
|
-
raise(exception.faultCode <
|
226
|
+
raise(exception.faultCode < 500_000 ? Gandi::ServerError : Gandi::DataError, exception.faultString)
|
214
227
|
end
|
215
228
|
end
|
216
229
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gandi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Olivier Ruffin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
description: Wrapper around gandi xml-rpc API v3
|
@@ -30,12 +30,13 @@ executables: []
|
|
30
30
|
extensions: []
|
31
31
|
extra_rdoc_files: []
|
32
32
|
files:
|
33
|
-
- README
|
33
|
+
- README.md
|
34
|
+
- lib/gandi.rb
|
34
35
|
- lib/gandi/errors.rb
|
35
36
|
- lib/gandi/session.rb
|
36
|
-
- lib/gandi.rb
|
37
37
|
homepage: https://github.com/veilleperso/gandi
|
38
|
-
licenses:
|
38
|
+
licenses:
|
39
|
+
- MIT
|
39
40
|
metadata: {}
|
40
41
|
post_install_message:
|
41
42
|
rdoc_options: []
|
@@ -43,17 +44,17 @@ require_paths:
|
|
43
44
|
- lib
|
44
45
|
required_ruby_version: !ruby/object:Gem::Requirement
|
45
46
|
requirements:
|
46
|
-
- -
|
47
|
+
- - ">="
|
47
48
|
- !ruby/object:Gem::Version
|
48
49
|
version: '0'
|
49
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
51
|
requirements:
|
51
|
-
- -
|
52
|
+
- - ">="
|
52
53
|
- !ruby/object:Gem::Version
|
53
54
|
version: '0'
|
54
55
|
requirements: []
|
55
56
|
rubyforge_project:
|
56
|
-
rubygems_version: 2.
|
57
|
+
rubygems_version: 2.2.2
|
57
58
|
signing_key:
|
58
59
|
specification_version: 4
|
59
60
|
summary: Gandi XML RPC API v3
|
data/README
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
DOCUMENTATION
|
2
|
-
=============
|
3
|
-
|
4
|
-
See http://doc.rpc.gandi.net/
|
5
|
-
|
6
|
-
API endpoint:
|
7
|
-
|
8
|
-
* Test: https://rpc.ote.gandi.net/xmlrpc/
|
9
|
-
* Production: https://rpc.gandi.net/xmlrpc/
|
10
|
-
|
11
|
-
Feel free to fork it and fix it you need to.
|
12
|
-
|
13
|
-
USAGE
|
14
|
-
=====
|
15
|
-
|
16
|
-
require 'gandi'
|
17
|
-
|
18
|
-
# test env
|
19
|
-
api = Gandi::Session.new("24-character API key", "https://rpc.gandi.net/xmlrpc/")
|
20
|
-
|
21
|
-
api.domain.list
|
22
|
-
api.domain.info('mydomain.com')
|
23
|
-
api.hosting.list
|
24
|
-
api.catalog.list(product: {type: 'domains'})
|
25
|
-
...
|
26
|
-
|
27
|
-
|
28
|
-
# production env
|
29
|
-
api = Gandi::Session.new("24-character API key")
|
30
|
-
api.domain.list
|
31
|
-
api.domain.info('mydomain.com')
|
32
|
-
api.hosting.list
|
33
|
-
api.catalog.list(product: {type: 'domains'})
|
34
|
-
...
|
35
|
-
api.domain.zone.clone_zone('zone_id') # instead of api.domain.zone.clone
|
36
|
-
api.domain.zone.version.new_version('zone_id') # instead of domain.zone.version.new
|
37
|
-
...
|