dnsimple-ruby 1.3.2 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +9 -2
- data/.rspec +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +20 -0
- data/Gemfile +0 -2
- data/LICENSE +2 -2
- data/README.md +121 -0
- data/Rakefile +30 -14
- data/bin/dnsimple.rb +1 -1
- data/dnsimple-ruby.gemspec +9 -8
- data/features/README +1 -1
- data/features/step_definitions/cli_steps.rb +1 -1
- data/features/support/env.rb +4 -4
- data/fixtures/vcr_cassettes/DNSimple_Certificate/_all.yml +45 -32
- data/fixtures/vcr_cassettes/DNSimple_Certificate/_purchase.yml +45 -32
- data/fixtures/vcr_cassettes/DNSimple_Certificate/_submit.yml +45 -32
- data/fixtures/vcr_cassettes/DNSimple_Contact/a_new_contact.yml +39 -31
- data/fixtures/vcr_cassettes/DNSimple_Contact/an_existing_contact.yml +39 -31
- data/fixtures/vcr_cassettes/DNSimple_Domain/_all.yml +113 -94
- data/fixtures/vcr_cassettes/DNSimple_Domain/applying_templates.yml +186 -156
- data/fixtures/vcr_cassettes/DNSimple_Domain/creating_a_new_domain.yml +39 -32
- data/fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain/by_id.yml +39 -32
- data/fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain/by_name.yml +39 -32
- data/fixtures/vcr_cassettes/DNSimple_Domain/registration/with_a_new_registrant_contact.yml +40 -32
- data/fixtures/vcr_cassettes/DNSimple_Domain/registration/with_an_existing_contact.yml +40 -32
- data/fixtures/vcr_cassettes/DNSimple_ExtendedAttribute/list_extended_attributes/for_ca.yml +262 -29
- data/fixtures/vcr_cassettes/DNSimple_ExtendedAttribute/list_extended_attributes/for_com.yml +35 -29
- data/fixtures/vcr_cassettes/DNSimple_Record/_all.yml +147 -125
- data/fixtures/vcr_cassettes/DNSimple_Record/creating_a_new_record.yml +39 -32
- data/fixtures/vcr_cassettes/DNSimple_Record/find_a_record.yml +39 -32
- data/fixtures/vcr_cassettes/DNSimple_Template/a_template.yml +41 -32
- data/fixtures/vcr_cassettes/DNSimple_User/_me.yml +38 -31
- data/lib/dnsimple.rb +14 -1
- data/lib/dnsimple/base.rb +7 -5
- data/lib/dnsimple/certificate.rb +100 -95
- data/lib/dnsimple/cli.rb +92 -93
- data/lib/dnsimple/client.rb +109 -99
- data/lib/dnsimple/commands/{describe_certificate.rb → certificate_describe.rb} +2 -2
- data/lib/dnsimple/commands/{list_certificates.rb → certificate_list.rb} +2 -2
- data/lib/dnsimple/commands/{purchase_certificate.rb → certificate_purchase.rb} +3 -5
- data/lib/dnsimple/commands/{submit_certificate.rb → certificate_submit.rb} +3 -5
- data/lib/dnsimple/commands/{create_contact.rb → contact_create.rb} +8 -6
- data/lib/dnsimple/commands/{delete_contact.rb → contact_delete.rb} +2 -2
- data/lib/dnsimple/commands/{describe_contact.rb → contact_describe.rb} +2 -2
- data/lib/dnsimple/commands/{list_contacts.rb → contact_list.rb} +2 -2
- data/lib/dnsimple/commands/{update_contact.rb → contact_update.rb} +2 -2
- data/lib/dnsimple/commands/{apply_template.rb → domain_apply_template.rb} +2 -2
- data/lib/dnsimple/commands/{check_domain.rb → domain_check.rb} +2 -2
- data/lib/dnsimple/commands/{clear_domain.rb → domain_clear.rb} +2 -2
- data/lib/dnsimple/commands/{create_domain.rb → domain_create.rb} +2 -2
- data/lib/dnsimple/commands/{delete_domain.rb → domain_delete.rb} +2 -2
- data/lib/dnsimple/commands/{describe_domain.rb → domain_describe.rb} +2 -2
- data/lib/dnsimple/commands/{list_domains.rb → domain_list.rb} +2 -2
- data/lib/dnsimple/commands/{register_domain.rb → domain_register.rb} +2 -2
- data/lib/dnsimple/commands/{transfer_domain.rb → domain_transfer.rb} +2 -2
- data/lib/dnsimple/commands/{list_extended_attributes.rb → extended_attribute_list.rb} +2 -2
- data/lib/dnsimple/commands/{describe_user.rb → me.rb} +2 -2
- data/lib/dnsimple/commands/{create_record.rb → record_create.rb} +5 -7
- data/lib/dnsimple/commands/{delete_record.rb → record_delete.rb} +2 -2
- data/lib/dnsimple/commands/{describe_record.rb → record_describe.rb} +2 -2
- data/lib/dnsimple/commands/{list_records.rb → record_list.rb} +4 -6
- data/lib/dnsimple/commands/{update_record.rb → record_update.rb} +2 -2
- data/lib/dnsimple/commands/{add_service.rb → service_add.rb} +3 -5
- data/lib/dnsimple/commands/{describe_service.rb → service_describe.rb} +2 -2
- data/lib/dnsimple/commands/{list_services.rb → service_list.rb} +2 -2
- data/lib/dnsimple/commands/{list_applied_services.rb → service_list_applied.rb} +2 -2
- data/lib/dnsimple/commands/{list_available_services.rb → service_list_available.rb} +2 -2
- data/lib/dnsimple/commands/{remove_service.rb → service_remove.rb} +2 -2
- data/lib/dnsimple/commands/{create_template.rb → template_create.rb} +2 -2
- data/lib/dnsimple/commands/{delete_template.rb → template_delete.rb} +2 -2
- data/lib/dnsimple/commands/{add_template_record.rb → template_record_create.rb} +2 -2
- data/lib/dnsimple/commands/{delete_template_record.rb → template_record_delete.rb} +2 -2
- data/lib/dnsimple/commands/{list_template_records.rb → template_record_list.rb} +2 -2
- data/lib/dnsimple/commands/{list_templates.rb → templates_list.rb} +2 -2
- data/lib/dnsimple/contact.rb +115 -110
- data/lib/dnsimple/domain.rb +134 -132
- data/lib/dnsimple/error.rb +8 -19
- data/lib/dnsimple/extended_attribute.rb +39 -33
- data/lib/dnsimple/record.rb +71 -67
- data/lib/dnsimple/service.rb +31 -24
- data/lib/dnsimple/template.rb +52 -46
- data/lib/dnsimple/template_record.rb +61 -53
- data/lib/dnsimple/transfer_order.rb +24 -18
- data/lib/dnsimple/user.rb +22 -18
- data/lib/dnsimple/version.rb +1 -1
- data/spec/README +1 -1
- data/spec/ci/.dnsimple.test +3 -0
- data/spec/commands/{purchase_certificate_spec.rb → certificate_purchase_spec.rb} +3 -4
- data/spec/commands/{submit_certificate_spec.rb → certificate_submit_spec.rb} +3 -4
- data/spec/commands/{create_record_spec.rb → record_create_spec.rb} +4 -4
- data/spec/commands/{list_records_spec.rb → records_list_spec.rb} +2 -13
- data/spec/commands/{add_service_spec.rb → service_add_spec.rb} +3 -12
- data/spec/{certificate_spec.rb → dnsimple/certificate_spec.rb} +0 -0
- data/spec/dnsimple/client_spec.rb +45 -18
- data/spec/{contact_spec.rb → dnsimple/contact_spec.rb} +3 -1
- data/spec/{domain_spec.rb → dnsimple/domain_spec.rb} +2 -0
- data/spec/{extended_attributes_spec.rb → dnsimple/extended_attributes_spec.rb} +4 -0
- data/spec/{record_spec.rb → dnsimple/record_spec.rb} +2 -0
- data/spec/{template_spec.rb → dnsimple/template_spec.rb} +0 -0
- data/spec/{user_spec.rb → dnsimple/user_spec.rb} +2 -0
- data/spec/spec_helper.rb +24 -10
- metadata +96 -99
- data/Gemfile.lock +0 -71
- data/README +0 -108
- data/README.rdoc +0 -108
- data/README.textile +0 -138
- data/lib/dnsimple/command.rb +0 -10
- data/spec/command_spec.rb +0 -19
data/lib/dnsimple/cli.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
1
|
module DNSimple
|
4
|
-
|
2
|
+
|
5
3
|
class CommandNotFound < RuntimeError
|
6
4
|
end
|
7
5
|
|
@@ -25,98 +23,99 @@ module DNSimple
|
|
25
23
|
|
26
24
|
def commands
|
27
25
|
{
|
28
|
-
'info' => DNSimple::Commands::
|
29
|
-
|
30
|
-
'
|
31
|
-
'
|
32
|
-
'
|
33
|
-
'
|
34
|
-
'
|
35
|
-
'
|
36
|
-
'delete' => DNSimple::Commands::
|
37
|
-
'clear' => DNSimple::Commands::
|
38
|
-
'apply' => DNSimple::Commands::
|
39
|
-
|
40
|
-
'record:describe' => DNSimple::Commands::
|
41
|
-
'record:create' => DNSimple::Commands::
|
42
|
-
'record:list' => DNSimple::Commands::
|
43
|
-
'record:update' => DNSimple::Commands::
|
44
|
-
'record:delete' => DNSimple::Commands::
|
45
|
-
|
46
|
-
'template:create' => DNSimple::Commands::
|
47
|
-
'template:list' => DNSimple::Commands::
|
48
|
-
'template:delete' => DNSimple::Commands::
|
49
|
-
|
50
|
-
'template:list_records' => DNSimple::Commands::
|
51
|
-
'template:add_record' => DNSimple::Commands::
|
52
|
-
'template:delete_record' => DNSimple::Commands::
|
53
|
-
|
54
|
-
'contact:create' => DNSimple::Commands::
|
55
|
-
'contact:list' => DNSimple::Commands::
|
56
|
-
'contact:describe' => DNSimple::Commands::
|
57
|
-
'contact:update' => DNSimple::Commands::
|
58
|
-
'contact:delete' => DNSimple::Commands::
|
59
|
-
|
60
|
-
'extended-attributes:list' => DNSimple::Commands::
|
61
|
-
|
62
|
-
'service:list' => DNSimple::Commands::
|
63
|
-
'service:describe' => DNSimple::Commands::
|
64
|
-
|
65
|
-
'service:applied' => DNSimple::Commands::
|
66
|
-
'service:available' => DNSimple::Commands::
|
67
|
-
'service:add' => DNSimple::Commands::
|
68
|
-
'service:remove' => DNSimple::Commands::
|
69
|
-
|
70
|
-
'certificate:list' => DNSimple::Commands::
|
71
|
-
'certificate:describe' => DNSimple::Commands::
|
72
|
-
'certificate:purchase' => DNSimple::Commands::
|
73
|
-
'certificate:submit' => DNSimple::Commands::
|
26
|
+
'info' => DNSimple::Commands::Me,
|
27
|
+
|
28
|
+
'list' => DNSimple::Commands::DomainList,
|
29
|
+
'describe' => DNSimple::Commands::DomainDescribe,
|
30
|
+
'check' => DNSimple::Commands::DomainCheck,
|
31
|
+
'create' => DNSimple::Commands::DomainCreate,
|
32
|
+
'register' => DNSimple::Commands::DomainRegister,
|
33
|
+
'transfer' => DNSimple::Commands::DomainTransfer,
|
34
|
+
'delete' => DNSimple::Commands::DomainDelete,
|
35
|
+
'clear' => DNSimple::Commands::DomainClear,
|
36
|
+
'apply' => DNSimple::Commands::DomainApplyTemplate,
|
37
|
+
|
38
|
+
'record:describe' => DNSimple::Commands::RecordDescribe,
|
39
|
+
'record:create' => DNSimple::Commands::RecordCreate,
|
40
|
+
'record:list' => DNSimple::Commands::RecordList,
|
41
|
+
'record:update' => DNSimple::Commands::RecordUpdate,
|
42
|
+
'record:delete' => DNSimple::Commands::RecordDelete,
|
43
|
+
|
44
|
+
'template:create' => DNSimple::Commands::TemplateCreate,
|
45
|
+
'template:list' => DNSimple::Commands::TemplateList,
|
46
|
+
'template:delete' => DNSimple::Commands::TemplateDelete,
|
47
|
+
|
48
|
+
'template:list_records' => DNSimple::Commands::TemplateRecordList,
|
49
|
+
'template:add_record' => DNSimple::Commands::TemplateRecordCreate,
|
50
|
+
'template:delete_record' => DNSimple::Commands::TemplateRecordDelete,
|
51
|
+
|
52
|
+
'contact:create' => DNSimple::Commands::ContactCreate,
|
53
|
+
'contact:list' => DNSimple::Commands::ContactList,
|
54
|
+
'contact:describe' => DNSimple::Commands::ContactDescribe,
|
55
|
+
'contact:update' => DNSimple::Commands::ContactUpdate,
|
56
|
+
'contact:delete' => DNSimple::Commands::ContactDelete,
|
57
|
+
|
58
|
+
'extended-attributes:list' => DNSimple::Commands::ExtendedAttributeList,
|
59
|
+
|
60
|
+
'service:list' => DNSimple::Commands::ServiceList,
|
61
|
+
'service:describe' => DNSimple::Commands::ServiceDescribe,
|
62
|
+
|
63
|
+
'service:applied' => DNSimple::Commands::ServiceListApplied,
|
64
|
+
'service:available' => DNSimple::Commands::ServiceListAvailable,
|
65
|
+
'service:add' => DNSimple::Commands::ServiceAdd,
|
66
|
+
'service:remove' => DNSimple::Commands::ServiceRemove,
|
67
|
+
|
68
|
+
'certificate:list' => DNSimple::Commands::CertificateList,
|
69
|
+
'certificate:describe' => DNSimple::Commands::CertificateDescribe,
|
70
|
+
'certificate:purchase' => DNSimple::Commands::CertificatePurchase,
|
71
|
+
'certificate:submit' => DNSimple::Commands::CertificateSubmit,
|
74
72
|
}
|
75
73
|
end
|
76
74
|
end
|
77
75
|
end
|
78
76
|
|
79
|
-
require 'dnsimple/commands/
|
80
|
-
|
81
|
-
require 'dnsimple/commands/
|
82
|
-
require 'dnsimple/commands/
|
83
|
-
require 'dnsimple/commands/
|
84
|
-
require 'dnsimple/commands/
|
85
|
-
require 'dnsimple/commands/
|
86
|
-
require 'dnsimple/commands/
|
87
|
-
require 'dnsimple/commands/
|
88
|
-
require 'dnsimple/commands/
|
89
|
-
|
90
|
-
|
91
|
-
require 'dnsimple/commands/
|
92
|
-
require 'dnsimple/commands/
|
93
|
-
require 'dnsimple/commands/
|
94
|
-
require 'dnsimple/commands/
|
95
|
-
|
96
|
-
|
97
|
-
require 'dnsimple/commands/
|
98
|
-
require 'dnsimple/commands/
|
99
|
-
require 'dnsimple/commands/
|
100
|
-
require 'dnsimple/commands/
|
101
|
-
require 'dnsimple/commands/
|
102
|
-
|
103
|
-
|
104
|
-
require 'dnsimple/commands/
|
105
|
-
require 'dnsimple/commands/
|
106
|
-
require 'dnsimple/commands/
|
107
|
-
require 'dnsimple/commands/
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
require 'dnsimple/commands/
|
113
|
-
|
114
|
-
|
115
|
-
require 'dnsimple/commands/
|
116
|
-
require 'dnsimple/commands/
|
117
|
-
require 'dnsimple/commands/
|
118
|
-
|
119
|
-
|
120
|
-
require 'dnsimple/commands/
|
121
|
-
require 'dnsimple/commands/
|
122
|
-
require 'dnsimple/commands/
|
77
|
+
require 'dnsimple/commands/me'
|
78
|
+
|
79
|
+
require 'dnsimple/commands/domain_list'
|
80
|
+
require 'dnsimple/commands/domain_describe'
|
81
|
+
require 'dnsimple/commands/domain_check'
|
82
|
+
require 'dnsimple/commands/domain_create'
|
83
|
+
require 'dnsimple/commands/domain_register'
|
84
|
+
require 'dnsimple/commands/domain_transfer'
|
85
|
+
require 'dnsimple/commands/domain_delete'
|
86
|
+
require 'dnsimple/commands/domain_clear'
|
87
|
+
require 'dnsimple/commands/domain_apply_template'
|
88
|
+
|
89
|
+
require 'dnsimple/commands/record_list'
|
90
|
+
require 'dnsimple/commands/record_describe'
|
91
|
+
require 'dnsimple/commands/record_create'
|
92
|
+
require 'dnsimple/commands/record_update'
|
93
|
+
require 'dnsimple/commands/record_delete'
|
94
|
+
|
95
|
+
require 'dnsimple/commands/template_list'
|
96
|
+
require 'dnsimple/commands/template_create'
|
97
|
+
require 'dnsimple/commands/template_delete'
|
98
|
+
require 'dnsimple/commands/template_record_list'
|
99
|
+
require 'dnsimple/commands/template_record_create'
|
100
|
+
require 'dnsimple/commands/template_record_delete'
|
101
|
+
|
102
|
+
require 'dnsimple/commands/contact_list'
|
103
|
+
require 'dnsimple/commands/contact_describe'
|
104
|
+
require 'dnsimple/commands/contact_create'
|
105
|
+
require 'dnsimple/commands/contact_update'
|
106
|
+
require 'dnsimple/commands/contact_delete'
|
107
|
+
|
108
|
+
require 'dnsimple/commands/extended_attribute_list'
|
109
|
+
|
110
|
+
require 'dnsimple/commands/service_list'
|
111
|
+
require 'dnsimple/commands/service_describe'
|
112
|
+
|
113
|
+
require 'dnsimple/commands/service_list_available'
|
114
|
+
require 'dnsimple/commands/service_list_applied'
|
115
|
+
require 'dnsimple/commands/service_add'
|
116
|
+
require 'dnsimple/commands/service_remove'
|
117
|
+
|
118
|
+
require 'dnsimple/commands/certificate_list'
|
119
|
+
require 'dnsimple/commands/certificate_describe'
|
120
|
+
require 'dnsimple/commands/certificate_purchase'
|
121
|
+
require 'dnsimple/commands/certificate_submit'
|
data/lib/dnsimple/client.rb
CHANGED
@@ -1,131 +1,141 @@
|
|
1
|
-
|
2
|
-
def self.debug?
|
3
|
-
@debug
|
4
|
-
end
|
1
|
+
require 'yaml'
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
end
|
3
|
+
module DNSimple
|
4
|
+
class Client
|
9
5
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
def self.username=(username)
|
15
|
-
@username = username
|
16
|
-
end
|
6
|
+
def self.debug?
|
7
|
+
@debug
|
8
|
+
end
|
17
9
|
|
18
|
-
|
19
|
-
|
20
|
-
|
10
|
+
def self.debug=(debug)
|
11
|
+
@debug = debug
|
12
|
+
end
|
21
13
|
|
22
|
-
|
23
|
-
|
24
|
-
|
14
|
+
def self.username
|
15
|
+
@username
|
16
|
+
end
|
25
17
|
|
26
|
-
|
27
|
-
|
28
|
-
|
18
|
+
def self.username=(username)
|
19
|
+
@username = username
|
20
|
+
end
|
29
21
|
|
30
|
-
|
31
|
-
|
32
|
-
|
22
|
+
def self.password
|
23
|
+
@password
|
24
|
+
end
|
33
25
|
|
34
|
-
|
35
|
-
|
36
|
-
|
26
|
+
def self.password=(password)
|
27
|
+
@password = password
|
28
|
+
end
|
37
29
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
30
|
+
def self.api_token
|
31
|
+
@api_token
|
32
|
+
end
|
42
33
|
|
43
|
-
|
44
|
-
|
45
|
-
|
34
|
+
def self.api_token=(api_token)
|
35
|
+
@api_token = api_token
|
36
|
+
end
|
46
37
|
|
47
|
-
|
48
|
-
|
49
|
-
|
38
|
+
# Gets the qualified API base uri.
|
39
|
+
#
|
40
|
+
# @return [String] The qualified API base uri.
|
41
|
+
def self.base_uri
|
42
|
+
@base_uri ||= "https://dnsimple.com"
|
43
|
+
end
|
50
44
|
|
51
|
-
|
52
|
-
|
53
|
-
|
45
|
+
# Sets the qualified API base uri.
|
46
|
+
#
|
47
|
+
# @param [String] value The qualified API base uri.
|
48
|
+
def self.base_uri=(value)
|
49
|
+
@base_uri = value.to_s.chomp("/")
|
50
|
+
end
|
54
51
|
|
55
|
-
|
56
|
-
|
57
|
-
|
52
|
+
def self.http_proxy
|
53
|
+
@http_proxy
|
54
|
+
end
|
58
55
|
|
59
|
-
|
60
|
-
|
61
|
-
credentials = YAML.load(File.new(File.expand_path(path)))
|
62
|
-
self.username ||= credentials['username']
|
63
|
-
self.password ||= credentials['password']
|
64
|
-
self.api_token ||= credentials['api_token']
|
65
|
-
self.base_uri ||= credentials['site']
|
66
|
-
self.http_proxy = { :addr => credentials['proxy_addr'], :port => credentials['proxy_port'] }
|
67
|
-
@credentials_loaded = true
|
68
|
-
"Credentials loaded from #{path}"
|
69
|
-
rescue
|
70
|
-
puts "Error loading your credentials: #{$!.message}"
|
71
|
-
exit 1
|
56
|
+
def self.http_proxy=(http_proxy)
|
57
|
+
@http_proxy = http_proxy
|
72
58
|
end
|
73
|
-
end
|
74
59
|
|
75
|
-
|
76
|
-
|
77
|
-
|
60
|
+
def self.load_credentials_if_necessary
|
61
|
+
load_credentials unless credentials_loaded?
|
62
|
+
end
|
78
63
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
:headers => {'Accept' => 'application/json'},
|
83
|
-
}
|
64
|
+
def self.config_path
|
65
|
+
ENV['DNSIMPLE_CONFIG'] || '~/.dnsimple'
|
66
|
+
end
|
84
67
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
68
|
+
def self.load_credentials(path = config_path)
|
69
|
+
begin
|
70
|
+
credentials = YAML.load(File.new(File.expand_path(path)))
|
71
|
+
self.username ||= credentials['username']
|
72
|
+
self.password ||= credentials['password']
|
73
|
+
self.api_token ||= credentials['api_token']
|
74
|
+
self.base_uri = credentials['site'] if credentials['site']
|
75
|
+
self.base_uri = credentials['base_uri'] if credentials['base_uri']
|
76
|
+
self.http_proxy = { :addr => credentials['proxy_addr'], :port => credentials['proxy_port'] }
|
77
|
+
@credentials_loaded = true
|
78
|
+
puts "Credentials loaded from #{path}"
|
79
|
+
rescue => error
|
80
|
+
puts "Error loading your credentials: #{error.message}"
|
81
|
+
exit 1
|
82
|
+
end
|
90
83
|
end
|
91
84
|
|
92
|
-
|
93
|
-
|
94
|
-
elsif api_token
|
95
|
-
options[:headers]['X-DNSimple-Token'] = "#{username}:#{api_token}"
|
96
|
-
else
|
97
|
-
raise RuntimeError, 'A password or API token is required for all API requests.'
|
85
|
+
def self.credentials_loaded?
|
86
|
+
(@credentials_loaded ||= false) or (username and (password or api_token))
|
98
87
|
end
|
99
88
|
|
100
|
-
|
101
|
-
|
89
|
+
def self.standard_options
|
90
|
+
options = {
|
91
|
+
:format => :json,
|
92
|
+
:headers => {'Accept' => 'application/json'},
|
93
|
+
}
|
94
|
+
|
95
|
+
if http_proxy
|
96
|
+
options.merge!(
|
97
|
+
:http_proxyaddr => self.http_proxy[:addr],
|
98
|
+
:http_proxyport => self.http_proxy[:port]
|
99
|
+
)
|
100
|
+
end
|
101
|
+
|
102
|
+
if password
|
103
|
+
options[:basic_auth] = {:username => username, :password => password}
|
104
|
+
elsif api_token
|
105
|
+
options[:headers]['X-DNSimple-Token'] = "#{username}:#{api_token}"
|
106
|
+
else
|
107
|
+
raise Error, 'A password or API token is required for all API requests.'
|
108
|
+
end
|
109
|
+
|
110
|
+
options
|
111
|
+
end
|
102
112
|
|
103
|
-
|
104
|
-
|
105
|
-
|
113
|
+
def self.get(path, options = {})
|
114
|
+
request :get, path, options
|
115
|
+
end
|
106
116
|
|
107
|
-
|
108
|
-
|
109
|
-
|
117
|
+
def self.post(path, options = {})
|
118
|
+
request :post, path, options
|
119
|
+
end
|
110
120
|
|
111
|
-
|
112
|
-
|
113
|
-
|
121
|
+
def self.put(path, options = {})
|
122
|
+
request :put, path, options
|
123
|
+
end
|
114
124
|
|
115
|
-
|
116
|
-
|
117
|
-
|
125
|
+
def self.delete(path, options = {})
|
126
|
+
request :delete, path, options
|
127
|
+
end
|
118
128
|
|
119
|
-
|
120
|
-
|
121
|
-
|
129
|
+
def self.request(method, path, options)
|
130
|
+
response = HTTParty.send(method, "#{base_uri}/#{path}",
|
131
|
+
standard_options.merge(options))
|
122
132
|
|
123
|
-
|
133
|
+
if response.code == 401
|
134
|
+
raise AuthenticationFailed
|
135
|
+
end
|
124
136
|
|
125
|
-
|
126
|
-
raise DNSimple::AuthenticationFailed, 'Authentication failed'
|
137
|
+
response
|
127
138
|
end
|
128
139
|
|
129
|
-
response
|
130
140
|
end
|
131
141
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module DNSimple
|
2
2
|
module Commands
|
3
|
-
class
|
4
|
-
def execute(args, options={})
|
3
|
+
class CertificateList
|
4
|
+
def execute(args, options = {})
|
5
5
|
domain_name = args.shift
|
6
6
|
domain = DNSimple::Domain.find(domain_name)
|
7
7
|
certificates = DNSimple::Certificate.all(domain)
|