dnsimple-ruby 0.8.4 → 0.9.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/.rvmrc +2 -0
- data/VERSION +1 -1
- data/bin/dnsimple.rb +8 -0
- data/lib/dnsimple.rb +1 -0
- data/lib/dnsimple/cli.rb +17 -1
- data/lib/dnsimple/commands/add_service.rb +14 -0
- data/lib/dnsimple/commands/describe_service.rb +12 -0
- data/lib/dnsimple/commands/list_applied_services.rb +16 -0
- data/lib/dnsimple/commands/list_available_services.rb +16 -0
- data/lib/dnsimple/commands/list_services.rb +14 -0
- data/lib/dnsimple/commands/remove_service.rb +14 -0
- data/lib/dnsimple/domain.rb +62 -0
- data/lib/dnsimple/service.rb +58 -0
- metadata +13 -5
data/.rvmrc
ADDED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.9.0
|
data/bin/dnsimple.rb
CHANGED
@@ -72,6 +72,14 @@ contact:delete contact_id # Delete the given c
|
|
72
72
|
|
73
73
|
extended-attributes:list tld # List all extended attributes for the given TLD
|
74
74
|
|
75
|
+
service:list # List all supported services
|
76
|
+
service:describe short_name # Describe a specific service
|
77
|
+
|
78
|
+
service:applied domain.com # List all of the services applied to the domain
|
79
|
+
service:available domain.com # List all of the services available for the domain
|
80
|
+
service:add domain.com short_name # Add the service to the domain
|
81
|
+
service:remove domain.com short_name # Remove the service from the domain
|
82
|
+
|
75
83
|
|
76
84
|
Please see the DNSimple documentation at https://dnsimple.com/documentation/api for additional
|
77
85
|
information on the commands that are available to DNSimple customers.
|
data/lib/dnsimple.rb
CHANGED
data/lib/dnsimple/cli.rb
CHANGED
@@ -61,7 +61,15 @@ module DNSimple
|
|
61
61
|
'contact:update' => DNSimple::Commands::UpdateContact,
|
62
62
|
'contact:delete' => DNSimple::Commands::DeleteContact,
|
63
63
|
|
64
|
-
'extended-attributes:list' => DNSimple::Commands::ListExtendedAttributes
|
64
|
+
'extended-attributes:list' => DNSimple::Commands::ListExtendedAttributes,
|
65
|
+
|
66
|
+
'service:list' => DNSimple::Commands::ListServices,
|
67
|
+
'service:describe' => DNSimple::Commands::DescribeService,
|
68
|
+
|
69
|
+
'service:applied' => DNSimple::Commands::ListAppliedServices,
|
70
|
+
'service:available' => DNSimple::Commands::ListAvailableServices,
|
71
|
+
'service:add' => DNSimple::Commands::AddService,
|
72
|
+
'service:remove' => DNSimple::Commands::RemoveService
|
65
73
|
}
|
66
74
|
end
|
67
75
|
|
@@ -103,3 +111,11 @@ require 'dnsimple/commands/update_contact'
|
|
103
111
|
require 'dnsimple/commands/delete_contact'
|
104
112
|
|
105
113
|
require 'dnsimple/commands/list_extended_attributes'
|
114
|
+
|
115
|
+
require 'dnsimple/commands/list_services'
|
116
|
+
require 'dnsimple/commands/describe_service'
|
117
|
+
|
118
|
+
require 'dnsimple/commands/list_available_services'
|
119
|
+
require 'dnsimple/commands/list_applied_services'
|
120
|
+
require 'dnsimple/commands/add_service'
|
121
|
+
require 'dnsimple/commands/remove_service'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class AddService
|
4
|
+
def execute(args, options={})
|
5
|
+
domain_name = args.shift
|
6
|
+
domain = Domain.find(domain_name)
|
7
|
+
short_name = args.shift
|
8
|
+
service = Service.find(short_name)
|
9
|
+
domain.add_service(short_name)
|
10
|
+
puts "Added #{service.name} to #{domain_name}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class DescribeService
|
4
|
+
def execute(args, options={})
|
5
|
+
short_name = args.shift
|
6
|
+
service = Service.find(short_name)
|
7
|
+
puts "\t#{service.name} (short: #{service.short_name}, id: #{service.id})"
|
8
|
+
puts "\t\t#{service.description}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class ListAppliedServices
|
4
|
+
def execute(args, options={})
|
5
|
+
domain_name = args.shift
|
6
|
+
domain = Domain.find(domain_name)
|
7
|
+
services = domain.applied_services
|
8
|
+
puts "Found #{services.length} applied services for #{domain_name}"
|
9
|
+
services.each do |service|
|
10
|
+
puts "\t#{service.name} (short: #{service.short_name}, id: #{service.id})"
|
11
|
+
puts "\t\t#{service.description}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class ListAvailableServices
|
4
|
+
def execute(args, options={})
|
5
|
+
domain_name = args.shift
|
6
|
+
domain = Domain.find(domain_name)
|
7
|
+
services = domain.available_services
|
8
|
+
puts "Found #{services.length} available services for #{domain_name}"
|
9
|
+
services.each do |service|
|
10
|
+
puts "\t#{service.name} (short: #{service.short_name}, id: #{service.id})"
|
11
|
+
puts "\t\t#{service.description}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class ListServices
|
4
|
+
def execute(args, options={})
|
5
|
+
services = Service.all
|
6
|
+
puts "Found #{services.length} services:"
|
7
|
+
services.each do |service|
|
8
|
+
puts "\t#{service.name} (short: #{service.short_name}, id: #{service.id})"
|
9
|
+
puts "\t\t#{service.description}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class RemoveService
|
4
|
+
def execute(args, options={})
|
5
|
+
domain_name = args.shift
|
6
|
+
domain = Domain.find(domain_name)
|
7
|
+
short_name = args.shift
|
8
|
+
service = Service.find(short_name)
|
9
|
+
domain.remove_service(service.id)
|
10
|
+
puts "Removed #{service.name} from #{domain_name}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/dnsimple/domain.rb
CHANGED
@@ -42,6 +42,7 @@ module DNSimple #:nodoc:
|
|
42
42
|
self.class.post("#{Client.base_uri}/domains/#{id}/templates/#{template.id}/apply.json", options)
|
43
43
|
end
|
44
44
|
|
45
|
+
#:nodoc:
|
45
46
|
def resolve_template(template)
|
46
47
|
case template
|
47
48
|
when DNSimple::Template
|
@@ -51,6 +52,64 @@ module DNSimple #:nodoc:
|
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
55
|
+
def applied_services(options={})
|
56
|
+
options.merge!({:basic_auth => Client.credentials})
|
57
|
+
response = self.class.get("#{Client.base_uri}/domains/#{id}/applied_services.json", options)
|
58
|
+
pp response if Client.debug?
|
59
|
+
case response.code
|
60
|
+
when 200
|
61
|
+
response.map { |r| Service.new(r["service"]) }
|
62
|
+
when 401
|
63
|
+
raise RuntimeError, "Authentication failed"
|
64
|
+
else
|
65
|
+
raise RuntimeError, "Error: #{response.code}"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def available_services(options={})
|
70
|
+
options.merge!({:basic_auth => Client.credentials})
|
71
|
+
response = self.class.get("#{Client.base_uri}/domains/#{id}/available_services.json", options)
|
72
|
+
pp response if Client.debug?
|
73
|
+
case response.code
|
74
|
+
when 200
|
75
|
+
response.map { |r| Service.new(r["service"]) }
|
76
|
+
when 401
|
77
|
+
raise RuntimeError, "Authentication failed"
|
78
|
+
else
|
79
|
+
raise RuntimeError, "Error: #{response.code}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def add_service(id_or_short_name, options={})
|
84
|
+
options.merge!(:basic_auth => Client.credentials)
|
85
|
+
options.merge!(:body => {:service => {:id => id_or_short_name}})
|
86
|
+
response = self.class.post("#{Client.base_uri}/domains/#{name}/applied_services.json", options)
|
87
|
+
pp response if Client.debug?
|
88
|
+
case response.code
|
89
|
+
when 200
|
90
|
+
true
|
91
|
+
when 401
|
92
|
+
raise RuntimeError, "Authentication failed"
|
93
|
+
else
|
94
|
+
raise "Error: #{response.code}"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def remove_service(id, options={})
|
99
|
+
options.merge!(:basic_auth => Client.credentials)
|
100
|
+
response = self.class.delete("#{Client.base_uri}/domains/#{name}/applied_services/#{id}.json", options)
|
101
|
+
pp response if Client.debug?
|
102
|
+
case response.code
|
103
|
+
when 200
|
104
|
+
true
|
105
|
+
when 401
|
106
|
+
raise RuntimeError, "Authentication failed"
|
107
|
+
else
|
108
|
+
raise "Error: #{response.code}"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# Check the availability of a name
|
54
113
|
def self.check(name, options={})
|
55
114
|
options.merge!(:basic_auth => Client.credentials)
|
56
115
|
response = self.get("#{Client.base_uri}/domains/#{name}/check.json", options)
|
@@ -118,6 +177,8 @@ module DNSimple #:nodoc:
|
|
118
177
|
end
|
119
178
|
end
|
120
179
|
|
180
|
+
# Find a specific domain in the account either by the numeric ID
|
181
|
+
# or by the fully-qualified domain name.
|
121
182
|
def self.find(id_or_name, options={})
|
122
183
|
options.merge!({:basic_auth => Client.credentials})
|
123
184
|
response = self.get("#{Client.base_uri}/domains/#{id_or_name}.json", options)
|
@@ -136,6 +197,7 @@ module DNSimple #:nodoc:
|
|
136
197
|
end
|
137
198
|
end
|
138
199
|
|
200
|
+
# Get all domains for the account.
|
139
201
|
def self.all(options={})
|
140
202
|
options.merge!({:basic_auth => Client.credentials})
|
141
203
|
response = self.get("#{Client.base_uri}/domains.json", options)
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module DNSimple #:nodoc:
|
2
|
+
# Class representing a service that can be applied to a domain
|
3
|
+
class Service
|
4
|
+
include HTTParty
|
5
|
+
|
6
|
+
attr_accessor :id
|
7
|
+
|
8
|
+
attr_accessor :name
|
9
|
+
|
10
|
+
attr_accessor :short_name
|
11
|
+
|
12
|
+
attr_accessor :description
|
13
|
+
|
14
|
+
#:nodoc:
|
15
|
+
def initialize(attributes)
|
16
|
+
attributes.each do |key, value|
|
17
|
+
m = "#{key}=".to_sym
|
18
|
+
self.send(m, value) if self.respond_to?(m)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Find a service by its ID or short name
|
23
|
+
def self.find(id_or_short_name, options={})
|
24
|
+
options.merge!({:basic_auth => Client.credentials})
|
25
|
+
response = self.get("#{Client.base_uri}/services/#{id_or_short_name}.json", options)
|
26
|
+
|
27
|
+
pp response if Client.debug?
|
28
|
+
|
29
|
+
case response.code
|
30
|
+
when 200
|
31
|
+
return Service.new(response["service"])
|
32
|
+
when 401
|
33
|
+
raise RuntimeError, "Authentication failed"
|
34
|
+
when 404
|
35
|
+
raise RuntimeError, "Could not find service #{id_or_short_name}"
|
36
|
+
else
|
37
|
+
raise DNSimple::Error.new(id_or_short_name, response["errors"])
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Get all of the services that can be applied to a domain
|
42
|
+
def self.all(options={})
|
43
|
+
options.merge!({:basic_auth => Client.credentials})
|
44
|
+
response = self.get("#{Client.base_uri}/services.json", options)
|
45
|
+
|
46
|
+
pp response if Client.debug?
|
47
|
+
|
48
|
+
case response.code
|
49
|
+
when 200
|
50
|
+
response.map { |r| Service.new(r["service"]) }
|
51
|
+
when 401
|
52
|
+
raise RuntimeError, "Authentication failed"
|
53
|
+
else
|
54
|
+
raise RuntimeError, "Error: #{response.code}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dnsimple-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 9
|
9
|
+
- 0
|
10
|
+
version: 0.9.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Anthony Eden
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-12-
|
18
|
+
date: 2010-12-19 00:00:00 +01:00
|
19
19
|
default_executable: dnsimple
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -117,6 +117,7 @@ extra_rdoc_files:
|
|
117
117
|
- README.textile
|
118
118
|
files:
|
119
119
|
- .bundle/config
|
120
|
+
- .rvmrc
|
120
121
|
- Gemfile
|
121
122
|
- Gemfile.lock
|
122
123
|
- LICENSE
|
@@ -130,6 +131,7 @@ files:
|
|
130
131
|
- lib/dnsimple.rb
|
131
132
|
- lib/dnsimple/cli.rb
|
132
133
|
- lib/dnsimple/client.rb
|
134
|
+
- lib/dnsimple/commands/add_service.rb
|
133
135
|
- lib/dnsimple/commands/add_template_record.rb
|
134
136
|
- lib/dnsimple/commands/apply_template.rb
|
135
137
|
- lib/dnsimple/commands/check_domain.rb
|
@@ -146,14 +148,19 @@ files:
|
|
146
148
|
- lib/dnsimple/commands/describe_contact.rb
|
147
149
|
- lib/dnsimple/commands/describe_domain.rb
|
148
150
|
- lib/dnsimple/commands/describe_record.rb
|
151
|
+
- lib/dnsimple/commands/describe_service.rb
|
149
152
|
- lib/dnsimple/commands/describe_user.rb
|
153
|
+
- lib/dnsimple/commands/list_applied_services.rb
|
154
|
+
- lib/dnsimple/commands/list_available_services.rb
|
150
155
|
- lib/dnsimple/commands/list_contacts.rb
|
151
156
|
- lib/dnsimple/commands/list_domains.rb
|
152
157
|
- lib/dnsimple/commands/list_extended_attributes.rb
|
153
158
|
- lib/dnsimple/commands/list_records.rb
|
159
|
+
- lib/dnsimple/commands/list_services.rb
|
154
160
|
- lib/dnsimple/commands/list_template_records.rb
|
155
161
|
- lib/dnsimple/commands/list_templates.rb
|
156
162
|
- lib/dnsimple/commands/register_domain.rb
|
163
|
+
- lib/dnsimple/commands/remove_service.rb
|
157
164
|
- lib/dnsimple/commands/transfer_domain.rb
|
158
165
|
- lib/dnsimple/commands/update_contact.rb
|
159
166
|
- lib/dnsimple/commands/update_record.rb
|
@@ -162,6 +169,7 @@ files:
|
|
162
169
|
- lib/dnsimple/error.rb
|
163
170
|
- lib/dnsimple/extended_attribute.rb
|
164
171
|
- lib/dnsimple/record.rb
|
172
|
+
- lib/dnsimple/service.rb
|
165
173
|
- lib/dnsimple/template.rb
|
166
174
|
- lib/dnsimple/template_record.rb
|
167
175
|
- lib/dnsimple/transfer_order.rb
|