dnsimple-ruby 1.2.6 → 1.3.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/.gitignore +3 -0
- data/Gemfile +2 -13
- data/Gemfile.lock +7 -7
- data/Rakefile +2 -18
- data/dnsimple-ruby.gemspec +24 -178
- data/features/support/env.rb +5 -3
- data/lib/dnsimple-ruby.rb +1 -0
- data/lib/dnsimple.rb +1 -0
- data/lib/dnsimple/base.rb +8 -0
- data/lib/dnsimple/certificate.rb +95 -130
- data/lib/dnsimple/client.rb +94 -56
- data/lib/dnsimple/contact.rb +111 -144
- data/lib/dnsimple/domain.rb +145 -194
- data/lib/dnsimple/extended_attribute.rb +33 -60
- data/lib/dnsimple/record.rb +70 -103
- data/lib/dnsimple/service.rb +24 -47
- data/lib/dnsimple/template.rb +47 -75
- data/lib/dnsimple/template_record.rb +53 -84
- data/lib/dnsimple/transfer_order.rb +17 -34
- data/lib/dnsimple/user.rb +18 -32
- data/lib/dnsimple/version.rb +3 -0
- data/spec/commands/purchase_certificate_spec.rb +16 -4
- data/spec/dnsimple/client_spec.rb +58 -0
- data/spec/spec_helper.rb +4 -2
- metadata +59 -92
- data/.bundle/config +0 -3
- data/.rvmrc +0 -1
- data/VERSION +0 -1
data/.gitignore
ADDED
data/Gemfile
CHANGED
@@ -1,16 +1,5 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
|
-
|
3
|
+
gemspec
|
4
4
|
|
5
|
-
group :development
|
6
|
-
gem 'rake'
|
7
|
-
gem 'jeweler'
|
8
|
-
gem 'rspec', '>= 2.0.0'
|
9
|
-
gem 'mocha'
|
10
|
-
gem 'ruby-debug', :platforms => 'ruby_18'
|
11
|
-
gem 'cucumber'
|
12
|
-
gem 'aruba'
|
13
|
-
gem 'ruby-debug'
|
14
|
-
gem 'fakeweb'
|
15
|
-
gem 'vcr'
|
16
|
-
end
|
5
|
+
gem 'ruby-debug', :platform => :ruby_18, :group => :development
|
data/Gemfile.lock
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
dnsimple-ruby (1.3.0)
|
5
|
+
httparty
|
6
|
+
|
1
7
|
GEM
|
2
8
|
remote: http://rubygems.org/
|
3
9
|
specs:
|
@@ -21,14 +27,9 @@ GEM
|
|
21
27
|
ffi (1.0.9)
|
22
28
|
gherkin (2.6.3)
|
23
29
|
json (>= 1.4.6)
|
24
|
-
git (1.2.5)
|
25
30
|
httparty (0.8.1)
|
26
31
|
multi_json
|
27
32
|
multi_xml
|
28
|
-
jeweler (1.6.4)
|
29
|
-
bundler (~> 1.0)
|
30
|
-
git (>= 1.2.5)
|
31
|
-
rake
|
32
33
|
json (1.6.1)
|
33
34
|
linecache (0.46)
|
34
35
|
rbx-require-relative (> 0.0.4)
|
@@ -61,9 +62,8 @@ PLATFORMS
|
|
61
62
|
DEPENDENCIES
|
62
63
|
aruba
|
63
64
|
cucumber
|
65
|
+
dnsimple-ruby!
|
64
66
|
fakeweb
|
65
|
-
httparty
|
66
|
-
jeweler
|
67
67
|
mocha
|
68
68
|
rake
|
69
69
|
rspec (>= 2.0.0)
|
data/Rakefile
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'rake'
|
2
|
-
require 'rake/testtask'
|
3
2
|
require 'rake/rdoctask'
|
4
3
|
|
4
|
+
require 'bundler/gem_tasks'
|
5
|
+
|
5
6
|
desc 'Default: run tests.'
|
6
7
|
task :default => [:spec]
|
7
8
|
|
@@ -14,20 +15,3 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
14
15
|
rdoc.rdoc_files.include('lib/*.rb')
|
15
16
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
16
17
|
end
|
17
|
-
|
18
|
-
begin
|
19
|
-
require 'jeweler'
|
20
|
-
Jeweler::Tasks.new do |gemspec|
|
21
|
-
gemspec.name = "dnsimple-ruby"
|
22
|
-
gemspec.summary = "A ruby wrapper for the DNSimple API"
|
23
|
-
gemspec.description = "A ruby wrapper for the DNSimple API that also includes a command-line client."
|
24
|
-
gemspec.email = "anthony.eden@dnsimple.com"
|
25
|
-
gemspec.homepage = "http://github.com/aetrion/dnsimple-ruby"
|
26
|
-
gemspec.authors = ["Anthony Eden"]
|
27
|
-
gemspec.add_dependency "httparty"
|
28
|
-
gemspec.executables = 'dnsimple'
|
29
|
-
end
|
30
|
-
rescue LoadError
|
31
|
-
puts "Jeweler not available. Install it with: gem install jeweler"
|
32
|
-
end
|
33
|
-
|
data/dnsimple-ruby.gemspec
CHANGED
@@ -1,185 +1,31 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'dnsimple/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
6
|
+
s.name = 'dnsimple-ruby'
|
7
|
+
s.version = DNSimple::VERSION
|
8
|
+
s.authors = ['Anthony Eden']
|
9
|
+
s.email = ['anthony.eden@dnsimple.com']
|
10
|
+
s.homepage = 'http://github.com/aetrion/dnsimple-ruby'
|
11
|
+
s.summary = 'A ruby wrapper for the DNSimple API'
|
12
|
+
s.description = 'A ruby wrapper for the DNSimple API that also includes a command-line client.'
|
9
13
|
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
13
|
-
s.
|
14
|
-
s.
|
15
|
-
|
16
|
-
|
17
|
-
"LICENSE",
|
18
|
-
"README",
|
19
|
-
"README.rdoc",
|
20
|
-
"README.textile"
|
21
|
-
]
|
22
|
-
s.files = [
|
23
|
-
".bundle/config",
|
24
|
-
".rvmrc",
|
25
|
-
"Gemfile",
|
26
|
-
"Gemfile.lock",
|
27
|
-
"LICENSE",
|
28
|
-
"README",
|
29
|
-
"README.rdoc",
|
30
|
-
"README.textile",
|
31
|
-
"Rakefile",
|
32
|
-
"VERSION",
|
33
|
-
"bin/dnsimple",
|
34
|
-
"bin/dnsimple.rb",
|
35
|
-
"dnsimple-ruby.gemspec",
|
36
|
-
"features/README",
|
37
|
-
"features/cli/certificates/purchase_certificate.feature",
|
38
|
-
"features/cli/contacts/create_contact.feature",
|
39
|
-
"features/cli/domains/check_domain.feature",
|
40
|
-
"features/cli/domains/create_domain.feature",
|
41
|
-
"features/cli/domains/delete_domain.feature",
|
42
|
-
"features/cli/domains/register_domain.feature",
|
43
|
-
"features/cli/records/create_ptr_record.feature",
|
44
|
-
"features/cli/records/create_record.feature",
|
45
|
-
"features/cli/records/delete_record.feature",
|
46
|
-
"features/cli/templates/apply_template.feature",
|
47
|
-
"features/step_definitions/certificate_steps.rb",
|
48
|
-
"features/step_definitions/cli_steps.rb",
|
49
|
-
"features/step_definitions/domain_steps.rb",
|
50
|
-
"features/step_definitions/record_steps.rb",
|
51
|
-
"features/step_definitions/template_steps.rb",
|
52
|
-
"features/support/env.rb",
|
53
|
-
"fixtures/vcr_cassettes/DNSimple_Contact/a_new_contact.yml",
|
54
|
-
"fixtures/vcr_cassettes/DNSimple_Contact/an_existing_contact.yml",
|
55
|
-
"fixtures/vcr_cassettes/DNSimple_Domain/_all.yml",
|
56
|
-
"fixtures/vcr_cassettes/DNSimple_Domain/applying_templates.yml",
|
57
|
-
"fixtures/vcr_cassettes/DNSimple_Domain/creating_a_new_domain.yml",
|
58
|
-
"fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain.yml",
|
59
|
-
"fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain/by_id.yml",
|
60
|
-
"fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain/by_name.yml",
|
61
|
-
"fixtures/vcr_cassettes/DNSimple_Domain/registration/with_a_new_registrant_contact.yml",
|
62
|
-
"fixtures/vcr_cassettes/DNSimple_Domain/registration/with_an_existing_contact.yml",
|
63
|
-
"fixtures/vcr_cassettes/DNSimple_ExtendedAttribute/list_extended_attributes/for_ca.yml",
|
64
|
-
"fixtures/vcr_cassettes/DNSimple_ExtendedAttribute/list_extended_attributes/for_com.yml",
|
65
|
-
"fixtures/vcr_cassettes/DNSimple_Record/_all.yml",
|
66
|
-
"fixtures/vcr_cassettes/DNSimple_Record/creating_a_new_record.yml",
|
67
|
-
"fixtures/vcr_cassettes/DNSimple_Record/find_a_record.yml",
|
68
|
-
"fixtures/vcr_cassettes/DNSimple_Template/a_template.yml",
|
69
|
-
"fixtures/vcr_cassettes/DNSimple_User/_me.yml",
|
70
|
-
"lib/dnsimple.rb",
|
71
|
-
"lib/dnsimple/certificate.rb",
|
72
|
-
"lib/dnsimple/cli.rb",
|
73
|
-
"lib/dnsimple/client.rb",
|
74
|
-
"lib/dnsimple/commands/add_service.rb",
|
75
|
-
"lib/dnsimple/commands/add_template_record.rb",
|
76
|
-
"lib/dnsimple/commands/apply_template.rb",
|
77
|
-
"lib/dnsimple/commands/check_domain.rb",
|
78
|
-
"lib/dnsimple/commands/clear_domain.rb",
|
79
|
-
"lib/dnsimple/commands/create_contact.rb",
|
80
|
-
"lib/dnsimple/commands/create_domain.rb",
|
81
|
-
"lib/dnsimple/commands/create_record.rb",
|
82
|
-
"lib/dnsimple/commands/create_template.rb",
|
83
|
-
"lib/dnsimple/commands/delete_contact.rb",
|
84
|
-
"lib/dnsimple/commands/delete_domain.rb",
|
85
|
-
"lib/dnsimple/commands/delete_record.rb",
|
86
|
-
"lib/dnsimple/commands/delete_template.rb",
|
87
|
-
"lib/dnsimple/commands/delete_template_record.rb",
|
88
|
-
"lib/dnsimple/commands/describe_contact.rb",
|
89
|
-
"lib/dnsimple/commands/describe_domain.rb",
|
90
|
-
"lib/dnsimple/commands/describe_record.rb",
|
91
|
-
"lib/dnsimple/commands/describe_service.rb",
|
92
|
-
"lib/dnsimple/commands/describe_user.rb",
|
93
|
-
"lib/dnsimple/commands/list_applied_services.rb",
|
94
|
-
"lib/dnsimple/commands/list_available_services.rb",
|
95
|
-
"lib/dnsimple/commands/list_contacts.rb",
|
96
|
-
"lib/dnsimple/commands/list_domains.rb",
|
97
|
-
"lib/dnsimple/commands/list_extended_attributes.rb",
|
98
|
-
"lib/dnsimple/commands/list_records.rb",
|
99
|
-
"lib/dnsimple/commands/list_services.rb",
|
100
|
-
"lib/dnsimple/commands/list_template_records.rb",
|
101
|
-
"lib/dnsimple/commands/list_templates.rb",
|
102
|
-
"lib/dnsimple/commands/purchase_certificate.rb",
|
103
|
-
"lib/dnsimple/commands/register_domain.rb",
|
104
|
-
"lib/dnsimple/commands/remove_service.rb",
|
105
|
-
"lib/dnsimple/commands/transfer_domain.rb",
|
106
|
-
"lib/dnsimple/commands/update_contact.rb",
|
107
|
-
"lib/dnsimple/commands/update_record.rb",
|
108
|
-
"lib/dnsimple/contact.rb",
|
109
|
-
"lib/dnsimple/domain.rb",
|
110
|
-
"lib/dnsimple/error.rb",
|
111
|
-
"lib/dnsimple/extended_attribute.rb",
|
112
|
-
"lib/dnsimple/record.rb",
|
113
|
-
"lib/dnsimple/service.rb",
|
114
|
-
"lib/dnsimple/template.rb",
|
115
|
-
"lib/dnsimple/template_record.rb",
|
116
|
-
"lib/dnsimple/transfer_order.rb",
|
117
|
-
"lib/dnsimple/user.rb",
|
118
|
-
"spec/README",
|
119
|
-
"spec/certificate_spec.rb",
|
120
|
-
"spec/contact_spec.rb",
|
121
|
-
"spec/domain_spec.rb",
|
122
|
-
"spec/extended_attributes_spec.rb",
|
123
|
-
"spec/record_spec.rb",
|
124
|
-
"spec/spec_helper.rb",
|
125
|
-
"spec/template_spec.rb",
|
126
|
-
"spec/user_spec.rb"
|
127
|
-
]
|
128
|
-
s.homepage = "http://github.com/aetrion/dnsimple-ruby"
|
129
|
-
s.require_paths = ["lib"]
|
130
|
-
s.rubygems_version = "1.8.10"
|
131
|
-
s.summary = "A ruby wrapper for the DNSimple API"
|
132
|
-
s.test_files = [
|
133
|
-
"spec/certificate_spec.rb",
|
134
|
-
"spec/contact_spec.rb",
|
135
|
-
"spec/domain_spec.rb",
|
136
|
-
"spec/extended_attributes_spec.rb",
|
137
|
-
"spec/record_spec.rb",
|
138
|
-
"spec/spec_helper.rb",
|
139
|
-
"spec/template_spec.rb",
|
140
|
-
"spec/user_spec.rb"
|
141
|
-
]
|
14
|
+
s.require_paths = ['lib']
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.extra_rdoc_files = %w( LICENSE README README.rdoc README.textile )
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").collect { |f|
|
19
|
+
File.basename(f)
|
20
|
+
}
|
142
21
|
|
143
|
-
|
144
|
-
s.specification_version = 3
|
22
|
+
s.add_runtime_dependency 'httparty', '>= 0'
|
145
23
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
s.add_development_dependency(%q<aruba>, [">= 0"])
|
154
|
-
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
155
|
-
s.add_development_dependency(%q<fakeweb>, [">= 0"])
|
156
|
-
s.add_development_dependency(%q<vcr>, [">= 0"])
|
157
|
-
s.add_runtime_dependency(%q<httparty>, [">= 0"])
|
158
|
-
else
|
159
|
-
s.add_dependency(%q<httparty>, [">= 0"])
|
160
|
-
s.add_dependency(%q<rake>, [">= 0"])
|
161
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
162
|
-
s.add_dependency(%q<rspec>, [">= 2.0.0"])
|
163
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
164
|
-
s.add_dependency(%q<cucumber>, [">= 0"])
|
165
|
-
s.add_dependency(%q<aruba>, [">= 0"])
|
166
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
167
|
-
s.add_dependency(%q<fakeweb>, [">= 0"])
|
168
|
-
s.add_dependency(%q<vcr>, [">= 0"])
|
169
|
-
s.add_dependency(%q<httparty>, [">= 0"])
|
170
|
-
end
|
171
|
-
else
|
172
|
-
s.add_dependency(%q<httparty>, [">= 0"])
|
173
|
-
s.add_dependency(%q<rake>, [">= 0"])
|
174
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
175
|
-
s.add_dependency(%q<rspec>, [">= 2.0.0"])
|
176
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
177
|
-
s.add_dependency(%q<cucumber>, [">= 0"])
|
178
|
-
s.add_dependency(%q<aruba>, [">= 0"])
|
179
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
180
|
-
s.add_dependency(%q<fakeweb>, [">= 0"])
|
181
|
-
s.add_dependency(%q<vcr>, [">= 0"])
|
182
|
-
s.add_dependency(%q<httparty>, [">= 0"])
|
183
|
-
end
|
24
|
+
s.add_development_dependency 'aruba', '>= 0'
|
25
|
+
s.add_development_dependency 'cucumber', '>= 0'
|
26
|
+
s.add_development_dependency 'fakeweb', '>= 0'
|
27
|
+
s.add_development_dependency 'mocha', '>= 0'
|
28
|
+
s.add_development_dependency 'rake', '>= 0'
|
29
|
+
s.add_development_dependency 'rspec', '>= 2.0.0'
|
30
|
+
s.add_development_dependency 'vcr', '>= 0'
|
184
31
|
end
|
185
|
-
|
data/features/support/env.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
Bundler.require :default, :development
|
5
|
+
|
1
6
|
require 'aruba/cucumber'
|
2
|
-
$:.unshift('lib')
|
3
|
-
require 'dnsimple'
|
4
7
|
|
5
8
|
Before do
|
6
9
|
@aruba_timeout_seconds = 30
|
@@ -14,4 +17,3 @@ After do |scenario|
|
|
14
17
|
end
|
15
18
|
end
|
16
19
|
end
|
17
|
-
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'dnsimple'
|
data/lib/dnsimple.rb
CHANGED
data/lib/dnsimple/certificate.rb
CHANGED
@@ -1,158 +1,123 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
include HTTParty
|
7
|
-
#debug_output $stdout
|
1
|
+
# Represents an SSL certificate that has been purchased. The certificate
|
2
|
+
# must also be submitted using the #submit method before the Certificate
|
3
|
+
# Authority will issue a signed certificate.
|
4
|
+
class DNSimple::Certificate < DNSimple::Base
|
5
|
+
#debug_output $stdout
|
8
6
|
|
9
|
-
|
10
|
-
|
7
|
+
# The certificate ID in DNSimple
|
8
|
+
attr_accessor :id
|
11
9
|
|
12
|
-
|
10
|
+
attr_accessor :domain
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
# The private key, if DNSimple generated the Certificate Signing Request
|
18
|
-
attr_accessor :private_key
|
12
|
+
# The subdomain on the certificate
|
13
|
+
attr_accessor :name
|
19
14
|
|
20
|
-
|
21
|
-
|
15
|
+
# The private key, if DNSimple generated the Certificate Signing Request
|
16
|
+
attr_accessor :private_key
|
22
17
|
|
23
|
-
|
24
|
-
|
18
|
+
# The SSL certificate, if it has been issued by the Certificate Authority
|
19
|
+
attr_accessor :ssl_certificate
|
25
20
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
# The date the Certificate order was placed
|
30
|
-
attr_accessor :order_date
|
21
|
+
# The Certificate Signing Request
|
22
|
+
attr_accessor :csr
|
31
23
|
|
32
|
-
|
33
|
-
|
24
|
+
# The Certificate status
|
25
|
+
attr_accessor :certificate_status
|
34
26
|
|
35
|
-
|
36
|
-
|
27
|
+
# The date the Certificate order was placed
|
28
|
+
attr_accessor :order_date
|
37
29
|
|
38
|
-
|
39
|
-
|
30
|
+
# The date the Certificate will expire
|
31
|
+
attr_accessor :expiration_date
|
40
32
|
|
41
|
-
|
42
|
-
|
33
|
+
# The approver email address
|
34
|
+
attr_accessor :approver_email
|
43
35
|
|
44
|
-
|
45
|
-
|
36
|
+
# An array of all emails that can be used to approve the certificate
|
37
|
+
attr_accessor :available_approver_emails
|
46
38
|
|
47
|
-
|
39
|
+
# When the certificate was purchased
|
40
|
+
attr_accessor :created_at
|
48
41
|
|
49
|
-
|
50
|
-
|
51
|
-
attributes.each do |key, value|
|
52
|
-
m = "#{key}=".to_sym
|
53
|
-
self.send(m, value) if self.respond_to?(m)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# Get the fully-qualified domain name for the certificate. This is the
|
58
|
-
# domain.name joined with the certificate name, separated by a period.
|
59
|
-
def fqdn
|
60
|
-
[name, domain.name].delete_if { |p| p !~ DNSimple::BLANK_REGEX }.join(".")
|
61
|
-
end
|
42
|
+
# When the certificate was last updated
|
43
|
+
attr_accessor :updated_at
|
62
44
|
|
63
|
-
|
64
|
-
|
45
|
+
# Get the fully-qualified domain name for the certificate. This is the
|
46
|
+
# domain.name joined with the certificate name, separated by a period.
|
47
|
+
def fqdn
|
48
|
+
[name, domain.name].delete_if { |p| p !~ DNSimple::BLANK_REGEX }.join(".")
|
49
|
+
end
|
65
50
|
|
66
|
-
|
67
|
-
|
51
|
+
def submit(approver_email, options={})
|
52
|
+
raise DNSimple::Error, "Approver email is required" unless approver_email
|
68
53
|
|
69
|
-
|
54
|
+
options.merge!(:body => {:certificate => {:approver_email => approver_email}})
|
70
55
|
|
71
|
-
|
56
|
+
response = DNSimple::Client.put "domains/#{domain.name}/certificates/#{id}/submit", options
|
72
57
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
else
|
79
|
-
raise DNSimple::Error.new("Error submitting certificate: #{response["errors"]}")
|
80
|
-
end
|
58
|
+
case response.code
|
59
|
+
when 200
|
60
|
+
return DNSimple::Certificate.new({:domain => domain}.merge(response["certificate"]))
|
61
|
+
else
|
62
|
+
raise DNSimple::Error.new("Error submitting certificate: #{response["errors"]}")
|
81
63
|
end
|
64
|
+
end
|
82
65
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
raise DNSimple::AuthenticationFailed, "Authentication failed"
|
113
|
-
when 406
|
114
|
-
raise DNSimple::CertificateExists.new("#{name}.#{domain.name}", response["errors"])
|
115
|
-
else
|
116
|
-
raise DNSimple::Error.new("#{name}.#{domain.name}", response["errors"])
|
117
|
-
end
|
66
|
+
# Purchase a certificate under the given domain with the given name. The
|
67
|
+
# name will be appended to the domain name, and thus should only be the
|
68
|
+
# subdomain part.
|
69
|
+
#
|
70
|
+
# Example: DNSimple::Certificate.purchase(domain, 'www', contact)
|
71
|
+
#
|
72
|
+
# Please note that by invoking this method DNSimple will immediately charge
|
73
|
+
# your credit card on file at DNSimple for the full certificate price.
|
74
|
+
#
|
75
|
+
# For wildcard certificates an asterisk must appear in the name.
|
76
|
+
#
|
77
|
+
# Example: DNSimple::Certificate.purchase(domain, '*', contact)
|
78
|
+
def self.purchase(domain, name, contact, options={})
|
79
|
+
certificate_hash = {
|
80
|
+
:name => name,
|
81
|
+
:contact_id => contact.id
|
82
|
+
}
|
83
|
+
|
84
|
+
options.merge!({:body => {:certificate => certificate_hash}})
|
85
|
+
|
86
|
+
response = DNSimple::Client.post "domains/#{domain.name}/certificates", options
|
87
|
+
|
88
|
+
case response.code
|
89
|
+
when 201
|
90
|
+
return new({:domain => domain}.merge(response["certificate"]))
|
91
|
+
when 406
|
92
|
+
raise DNSimple::CertificateExists.new("#{name}.#{domain.name}", response["errors"])
|
93
|
+
else
|
94
|
+
raise DNSimple::Error.new("#{name}.#{domain.name}", response["errors"])
|
118
95
|
end
|
96
|
+
end
|
119
97
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
response = self.get("#{DNSimple::Client.base_uri}/domains/#{domain.name}/certificates", options)
|
125
|
-
|
126
|
-
pp response if DNSimple::Client.debug?
|
98
|
+
# Get an array of all certificates for the given domain.
|
99
|
+
def self.all(domain, options={})
|
100
|
+
response = DNSimple::Client.get "domains/#{domain.name}/certificates", options
|
127
101
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
else
|
134
|
-
raise DNSimple::Error.new("List certificates error: #{response["errors"]}")
|
135
|
-
end
|
102
|
+
case response.code
|
103
|
+
when 200
|
104
|
+
response.map { |r| new({:domain => domain}.merge(r["certificate"])) }
|
105
|
+
else
|
106
|
+
raise DNSimple::Error.new("List certificates error: #{response["errors"]}")
|
136
107
|
end
|
108
|
+
end
|
137
109
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
when 401
|
150
|
-
raise DNSimple::AuthenticationFailed, "Authentication failed"
|
151
|
-
when 404
|
152
|
-
raise DNSimple::CertificateNotFound, "Could not find certificate #{certificate_id} for domain #{domain.name}"
|
153
|
-
else
|
154
|
-
raise DNSimple::Error.new("Find certificate error: #{response["errors"]}")
|
155
|
-
end
|
110
|
+
# Find a specific certificate for the given domain.
|
111
|
+
def self.find(domain, certificate_id, options={})
|
112
|
+
response = DNSimple::Client.get "domains/#{domain.name}/certificates/#{certificate_id}", options
|
113
|
+
|
114
|
+
case response.code
|
115
|
+
when 200
|
116
|
+
new({:domain => domain}.merge(response["certificate"]))
|
117
|
+
when 404
|
118
|
+
raise DNSimple::CertificateNotFound, "Could not find certificate #{certificate_id} for domain #{domain.name}"
|
119
|
+
else
|
120
|
+
raise DNSimple::Error.new("Find certificate error: #{response["errors"]}")
|
156
121
|
end
|
157
122
|
end
|
158
123
|
end
|