sparqcode-dnsimple-ruby 1.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. data/.bundle/config +3 -0
  2. data/.rvmrc +1 -0
  3. data/Gemfile +16 -0
  4. data/Gemfile.lock +71 -0
  5. data/LICENSE +22 -0
  6. data/README +125 -0
  7. data/README.rdoc +125 -0
  8. data/README.textile +161 -0
  9. data/Rakefile +33 -0
  10. data/VERSION +1 -0
  11. data/bin/dnsimple +4 -0
  12. data/bin/dnsimple.rb +153 -0
  13. data/dnsimple-ruby.gemspec +191 -0
  14. data/features/README +12 -0
  15. data/features/cli/certificates/purchase_certificate.feature +10 -0
  16. data/features/cli/contacts/create_contact.feature +10 -0
  17. data/features/cli/domains/check_domain.feature +10 -0
  18. data/features/cli/domains/create_domain.feature +10 -0
  19. data/features/cli/domains/delete_domain.feature +11 -0
  20. data/features/cli/domains/register_domain.feature +10 -0
  21. data/features/cli/records/create_ptr_record.feature +11 -0
  22. data/features/cli/records/create_record.feature +12 -0
  23. data/features/cli/records/delete_record.feature +14 -0
  24. data/features/cli/templates/apply_template.feature +11 -0
  25. data/features/step_definitions/certificate_steps.rb +3 -0
  26. data/features/step_definitions/cli_steps.rb +8 -0
  27. data/features/step_definitions/domain_steps.rb +32 -0
  28. data/features/step_definitions/record_steps.rb +38 -0
  29. data/features/step_definitions/template_steps.rb +9 -0
  30. data/features/support/env.rb +17 -0
  31. data/fixtures/vcr_cassettes/DNSimple_Certificate/_all.yml +44 -0
  32. data/fixtures/vcr_cassettes/DNSimple_Certificate/_purchase.yml +44 -0
  33. data/fixtures/vcr_cassettes/DNSimple_Certificate/_submit.yml +44 -0
  34. data/fixtures/vcr_cassettes/DNSimple_Contact/a_new_contact.yml +42 -0
  35. data/fixtures/vcr_cassettes/DNSimple_Contact/an_existing_contact.yml +42 -0
  36. data/fixtures/vcr_cassettes/DNSimple_Domain/_all.yml +130 -0
  37. data/fixtures/vcr_cassettes/DNSimple_Domain/applying_templates.yml +216 -0
  38. data/fixtures/vcr_cassettes/DNSimple_Domain/creating_a_new_domain.yml +44 -0
  39. data/fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain/by_id.yml +44 -0
  40. data/fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain/by_name.yml +44 -0
  41. data/fixtures/vcr_cassettes/DNSimple_Domain/registration/with_a_new_registrant_contact.yml +44 -0
  42. data/fixtures/vcr_cassettes/DNSimple_Domain/registration/with_an_existing_contact.yml +44 -0
  43. data/fixtures/vcr_cassettes/DNSimple_Domain/setting_name_servers.yml +30 -0
  44. data/fixtures/vcr_cassettes/DNSimple_ExtendedAttribute/list_extended_attributes/for_ca.yml +40 -0
  45. data/fixtures/vcr_cassettes/DNSimple_ExtendedAttribute/list_extended_attributes/for_com.yml +40 -0
  46. data/fixtures/vcr_cassettes/DNSimple_Record/_all.yml +173 -0
  47. data/fixtures/vcr_cassettes/DNSimple_Record/creating_a_new_record.yml +44 -0
  48. data/fixtures/vcr_cassettes/DNSimple_Record/find_a_record.yml +44 -0
  49. data/fixtures/vcr_cassettes/DNSimple_Template/a_template.yml +44 -0
  50. data/fixtures/vcr_cassettes/DNSimple_User/_me.yml +42 -0
  51. data/lib/dnsimple.rb +19 -0
  52. data/lib/dnsimple/certificate.rb +158 -0
  53. data/lib/dnsimple/cli.rb +122 -0
  54. data/lib/dnsimple/client.rb +74 -0
  55. data/lib/dnsimple/command.rb +10 -0
  56. data/lib/dnsimple/commands/add_service.rb +16 -0
  57. data/lib/dnsimple/commands/add_template_record.rb +18 -0
  58. data/lib/dnsimple/commands/apply_template.rb +15 -0
  59. data/lib/dnsimple/commands/check_domain.rb +11 -0
  60. data/lib/dnsimple/commands/clear_domain.rb +16 -0
  61. data/lib/dnsimple/commands/create_contact.rb +21 -0
  62. data/lib/dnsimple/commands/create_domain.rb +16 -0
  63. data/lib/dnsimple/commands/create_record.rb +20 -0
  64. data/lib/dnsimple/commands/create_template.rb +14 -0
  65. data/lib/dnsimple/commands/delete_contact.rb +14 -0
  66. data/lib/dnsimple/commands/delete_domain.rb +14 -0
  67. data/lib/dnsimple/commands/delete_record.rb +16 -0
  68. data/lib/dnsimple/commands/delete_template.rb +13 -0
  69. data/lib/dnsimple/commands/delete_template_record.rb +16 -0
  70. data/lib/dnsimple/commands/describe_certificate.rb +34 -0
  71. data/lib/dnsimple/commands/describe_contact.rb +25 -0
  72. data/lib/dnsimple/commands/describe_domain.rb +14 -0
  73. data/lib/dnsimple/commands/describe_record.rb +16 -0
  74. data/lib/dnsimple/commands/describe_service.rb +12 -0
  75. data/lib/dnsimple/commands/describe_user.rb +18 -0
  76. data/lib/dnsimple/commands/list_applied_services.rb +16 -0
  77. data/lib/dnsimple/commands/list_available_services.rb +16 -0
  78. data/lib/dnsimple/commands/list_certificates.rb +15 -0
  79. data/lib/dnsimple/commands/list_contacts.rb +13 -0
  80. data/lib/dnsimple/commands/list_domains.rb +13 -0
  81. data/lib/dnsimple/commands/list_extended_attributes.rb +25 -0
  82. data/lib/dnsimple/commands/list_records.rb +21 -0
  83. data/lib/dnsimple/commands/list_services.rb +14 -0
  84. data/lib/dnsimple/commands/list_template_records.rb +17 -0
  85. data/lib/dnsimple/commands/list_templates.rb +13 -0
  86. data/lib/dnsimple/commands/purchase_certificate.rb +19 -0
  87. data/lib/dnsimple/commands/register_domain.rb +33 -0
  88. data/lib/dnsimple/commands/remove_service.rb +14 -0
  89. data/lib/dnsimple/commands/submit_certificate.rb +19 -0
  90. data/lib/dnsimple/commands/transfer_domain.rb +21 -0
  91. data/lib/dnsimple/commands/update_contact.rb +25 -0
  92. data/lib/dnsimple/commands/update_record.rb +23 -0
  93. data/lib/dnsimple/contact.rb +181 -0
  94. data/lib/dnsimple/domain.rb +246 -0
  95. data/lib/dnsimple/error.rb +32 -0
  96. data/lib/dnsimple/extended_attribute.rb +73 -0
  97. data/lib/dnsimple/record.rb +128 -0
  98. data/lib/dnsimple/service.rb +58 -0
  99. data/lib/dnsimple/template.rb +91 -0
  100. data/lib/dnsimple/template_record.rb +103 -0
  101. data/lib/dnsimple/transfer_order.rb +45 -0
  102. data/lib/dnsimple/user.rb +44 -0
  103. data/spec/README +10 -0
  104. data/spec/certificate_spec.rb +46 -0
  105. data/spec/command_spec.rb +19 -0
  106. data/spec/commands/add_service_spec.rb +29 -0
  107. data/spec/commands/create_record_spec.rb +23 -0
  108. data/spec/commands/list_records_spec.rb +34 -0
  109. data/spec/commands/purchase_certificate_spec.rb +24 -0
  110. data/spec/commands/submit_certificate_spec.rb +19 -0
  111. data/spec/contact_spec.rb +35 -0
  112. data/spec/domain_spec.rb +97 -0
  113. data/spec/extended_attributes_spec.rb +19 -0
  114. data/spec/record_spec.rb +59 -0
  115. data/spec/spec_helper.rb +22 -0
  116. data/spec/template_spec.rb +11 -0
  117. data/spec/user_spec.rb +23 -0
  118. metadata +353 -0
@@ -0,0 +1,158 @@
1
+ module DNSimple #:nodoc:
2
+ # Represents an SSL certificate that has been purchased. The certificate
3
+ # must also be submitted using the #submit method before the Certificate
4
+ # Authority will issue a signed certificate.
5
+ class Certificate
6
+ include HTTParty
7
+ #debug_output $stdout
8
+
9
+ # The certificate ID in DNSimple
10
+ attr_accessor :id
11
+
12
+ attr_accessor :domain
13
+
14
+ # The subdomain on the certificate
15
+ attr_accessor :name
16
+
17
+ # The private key, if DNSimple generated the Certificate Signing Request
18
+ attr_accessor :private_key
19
+
20
+ # The SSL certificate, if it has been issued by the Certificate Authority
21
+ attr_accessor :ssl_certificate
22
+
23
+ # The Certificate Signing Request
24
+ attr_accessor :csr
25
+
26
+ # The Certificate status
27
+ attr_accessor :certificate_status
28
+
29
+ # The date the Certificate order was placed
30
+ attr_accessor :order_date
31
+
32
+ # The date the Certificate will expire
33
+ attr_accessor :expiration_date
34
+
35
+ # The approver email address
36
+ attr_accessor :approver_email
37
+
38
+ # An array of all emails that can be used to approve the certificate
39
+ attr_accessor :available_approver_emails
40
+
41
+ # When the certificate was purchased
42
+ attr_accessor :created_at
43
+
44
+ # When the certificate was last updated
45
+ attr_accessor :updated_at
46
+
47
+
48
+
49
+ #:nodoc:
50
+ def initialize(attributes)
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
62
+
63
+ def submit(approver_email, options={})
64
+ raise DNSimple::Error, "Approver email is required" unless approver_email
65
+
66
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
67
+ options.merge!(:body => {:certificate => {:approver_email => approver_email}})
68
+
69
+ response = self.class.put("#{DNSimple::Client.base_uri}/domains/#{domain.name}/certificates/#{id}/submit", options)
70
+
71
+ pp response if DNSimple::Client.debug?
72
+
73
+ case response.code
74
+ when 200
75
+ return DNSimple::Certificate.new({:domain => domain}.merge(response["certificate"]))
76
+ when 401
77
+ raise DNSimple::AuthenticationFailed, "Authentication failed"
78
+ else
79
+ raise DNSimple::Error.new("Error submitting certificate: #{response["errors"]}")
80
+ end
81
+ end
82
+
83
+ # Purchase a certificate under the given domain with the given name. The
84
+ # name will be appended to the domain name, and thus should only be the
85
+ # subdomain part.
86
+ #
87
+ # Example: DNSimple::Certificate.purchase(domain, 'www', contact)
88
+ #
89
+ # Please note that by invoking this method DNSimple will immediately charge
90
+ # your credit card on file at DNSimple for the full certificate price.
91
+ #
92
+ # For wildcard certificates an asterisk must appear in the name.
93
+ #
94
+ # Example: DNSimple::Certificate.purchase(domain, '*', contact)
95
+ def self.purchase(domain, name, contact, options={})
96
+ certificate_hash = {
97
+ :name => name,
98
+ :contact_id => contact.id
99
+ }
100
+
101
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
102
+ options.merge!({:body => {:certificate => certificate_hash}})
103
+
104
+ response = self.post("#{DNSimple::Client.base_uri}/domains/#{domain.name}/certificates", options)
105
+
106
+ pp response if DNSimple::Client.debug?
107
+
108
+ case response.code
109
+ when 201
110
+ return DNSimple::Certificate.new({:domain => domain}.merge(response["certificate"]))
111
+ when 401
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
118
+ end
119
+
120
+ # Get an array of all certificates for the given domain.
121
+ def self.all(domain, options={})
122
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
123
+
124
+ response = self.get("#{DNSimple::Client.base_uri}/domains/#{domain.name}/certificates", options)
125
+
126
+ pp response if DNSimple::Client.debug?
127
+
128
+ case response.code
129
+ when 200
130
+ response.map { |r| DNSimple::Certificate.new({:domain => domain}.merge(r["certificate"])) }
131
+ when 401
132
+ raise DNSimple::AuthenticationFailed, "Authentication failed"
133
+ else
134
+ raise DNSimple::Error.new("List certificates error: #{response["errors"]}")
135
+ end
136
+ end
137
+
138
+ # Find a specific certificate for the given domain.
139
+ def self.find(domain, certificate_id, options={})
140
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
141
+
142
+ response = self.get("#{DNSimple::Client.base_uri}/domains/#{domain.name}/certificates/#{certificate_id}", options)
143
+
144
+ pp response if DNSimple::Client.debug?
145
+
146
+ case response.code
147
+ when 200
148
+ DNSimple::Certificate.new({:domain => domain}.merge(response["certificate"]))
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
156
+ end
157
+ end
158
+ end
@@ -0,0 +1,122 @@
1
+ require 'yaml'
2
+
3
+ module DNSimple
4
+
5
+ class CommandNotFound < RuntimeError
6
+ end
7
+
8
+ class CLI
9
+
10
+ def execute(command_name, args, options={})
11
+ DNSimple::Client.load_credentials_if_necessary
12
+ command = commands[command_name]
13
+ if command
14
+ begin
15
+ command.new.execute(args, options)
16
+ rescue DNSimple::Error => e
17
+ puts "An error occurred: #{e.message}"
18
+ rescue RuntimeError => e
19
+ puts "An error occurred: #{e.message}"
20
+ end
21
+ else
22
+ raise CommandNotFound, "Unknown command: #{command_name}"
23
+ end
24
+ end
25
+
26
+ def commands
27
+ {
28
+ 'info' => DNSimple::Commands::DescribeUser,
29
+
30
+ 'check' => DNSimple::Commands::CheckDomain,
31
+ 'create' => DNSimple::Commands::CreateDomain,
32
+ 'register' => DNSimple::Commands::RegisterDomain,
33
+ 'transfer' => DNSimple::Commands::TransferDomain,
34
+ 'describe' => DNSimple::Commands::DescribeDomain,
35
+ 'list' => DNSimple::Commands::ListDomains,
36
+ 'delete' => DNSimple::Commands::DeleteDomain,
37
+ 'clear' => DNSimple::Commands::ClearDomain,
38
+ 'apply' => DNSimple::Commands::ApplyTemplate,
39
+
40
+ 'record:describe' => DNSimple::Commands::DescribeRecord,
41
+ 'record:create' => DNSimple::Commands::CreateRecord,
42
+ 'record:list' => DNSimple::Commands::ListRecords,
43
+ 'record:update' => DNSimple::Commands::UpdateRecord,
44
+ 'record:delete' => DNSimple::Commands::DeleteRecord,
45
+
46
+ 'template:create' => DNSimple::Commands::CreateTemplate,
47
+ 'template:list' => DNSimple::Commands::ListTemplates,
48
+ 'template:delete' => DNSimple::Commands::DeleteTemplate,
49
+
50
+ 'template:list_records' => DNSimple::Commands::ListTemplateRecords,
51
+ 'template:add_record' => DNSimple::Commands::AddTemplateRecord,
52
+ 'template:delete_record' => DNSimple::Commands::DeleteTemplateRecord,
53
+
54
+ 'contact:create' => DNSimple::Commands::CreateContact,
55
+ 'contact:list' => DNSimple::Commands::ListContacts,
56
+ 'contact:describe' => DNSimple::Commands::DescribeContact,
57
+ 'contact:update' => DNSimple::Commands::UpdateContact,
58
+ 'contact:delete' => DNSimple::Commands::DeleteContact,
59
+
60
+ 'extended-attributes:list' => DNSimple::Commands::ListExtendedAttributes,
61
+
62
+ 'service:list' => DNSimple::Commands::ListServices,
63
+ 'service:describe' => DNSimple::Commands::DescribeService,
64
+
65
+ 'service:applied' => DNSimple::Commands::ListAppliedServices,
66
+ 'service:available' => DNSimple::Commands::ListAvailableServices,
67
+ 'service:add' => DNSimple::Commands::AddService,
68
+ 'service:remove' => DNSimple::Commands::RemoveService,
69
+
70
+ 'certificate:list' => DNSimple::Commands::ListCertificates,
71
+ 'certificate:describe' => DNSimple::Commands::DescribeCertificate,
72
+ 'certificate:purchase' => DNSimple::Commands::PurchaseCertificate,
73
+ 'certificate:submit' => DNSimple::Commands::SubmitCertificate
74
+ }
75
+ end
76
+ end
77
+ end
78
+
79
+ require 'dnsimple/commands/describe_user'
80
+ require 'dnsimple/commands/check_domain'
81
+ require 'dnsimple/commands/create_domain'
82
+ require 'dnsimple/commands/register_domain'
83
+ require 'dnsimple/commands/transfer_domain'
84
+ require 'dnsimple/commands/describe_domain'
85
+ require 'dnsimple/commands/list_domains'
86
+ require 'dnsimple/commands/delete_domain'
87
+ require 'dnsimple/commands/clear_domain'
88
+ require 'dnsimple/commands/apply_template'
89
+
90
+ require 'dnsimple/commands/describe_record'
91
+ require 'dnsimple/commands/create_record'
92
+ require 'dnsimple/commands/list_records'
93
+ require 'dnsimple/commands/update_record'
94
+ require 'dnsimple/commands/delete_record'
95
+
96
+ require 'dnsimple/commands/create_template'
97
+ require 'dnsimple/commands/list_templates'
98
+ require 'dnsimple/commands/delete_template'
99
+ require 'dnsimple/commands/list_template_records'
100
+ require 'dnsimple/commands/add_template_record'
101
+ require 'dnsimple/commands/delete_template_record'
102
+
103
+ require 'dnsimple/commands/create_contact'
104
+ require 'dnsimple/commands/list_contacts'
105
+ require 'dnsimple/commands/describe_contact'
106
+ require 'dnsimple/commands/update_contact'
107
+ require 'dnsimple/commands/delete_contact'
108
+
109
+ require 'dnsimple/commands/list_extended_attributes'
110
+
111
+ require 'dnsimple/commands/list_services'
112
+ require 'dnsimple/commands/describe_service'
113
+
114
+ require 'dnsimple/commands/list_available_services'
115
+ require 'dnsimple/commands/list_applied_services'
116
+ require 'dnsimple/commands/add_service'
117
+ require 'dnsimple/commands/remove_service'
118
+
119
+ require 'dnsimple/commands/list_certificates'
120
+ require 'dnsimple/commands/describe_certificate'
121
+ require 'dnsimple/commands/purchase_certificate'
122
+ require 'dnsimple/commands/submit_certificate'
@@ -0,0 +1,74 @@
1
+ module DNSimple
2
+ class Client
3
+ def self.debug?
4
+ @debug
5
+ end
6
+ def self.debug=(debug)
7
+ @debug = debug
8
+ end
9
+
10
+ def self.username
11
+ raise RuntimeError, "You must set your username first: DNSimple::Client.username = 'username'" unless defined?(@@username)
12
+ @@username
13
+ end
14
+
15
+ def self.username=(username)
16
+ @@username = username
17
+ end
18
+
19
+ def self.password
20
+ raise RuntimeError, "You must set your password first: DNSimple::Client.password = 'password'" unless defined?(@@password)
21
+ @@password
22
+ end
23
+
24
+ def self.password=(password)
25
+ @@password = password
26
+ end
27
+
28
+ def self.credentials
29
+ {:username => self.username, :password => self.password}
30
+ end
31
+
32
+ def self.base_uri
33
+ @@base_uri ||= "https://dnsimple.com"
34
+ end
35
+
36
+ def self.base_uri=(base_uri)
37
+ @@base_uri = base_uri ? base_uri.gsub(/\/$/, '') : nil
38
+ end
39
+
40
+ def self.load_credentials_if_necessary
41
+ load_credentials unless credentials_loaded?
42
+ end
43
+
44
+ def self.config_path
45
+ ENV['DNSIMPLE_CONFIG'] || '~/.dnsimple'
46
+ end
47
+
48
+ def self.load_credentials(path=config_path)
49
+ begin
50
+ credentials = YAML.load(File.new(File.expand_path(path)))
51
+ self.username = credentials['username']
52
+ self.password = credentials['password']
53
+ self.base_uri = credentials['site']
54
+ @@credentials_loaded = true
55
+ "Credentials loaded from #{path}"
56
+ rescue
57
+ puts "Error loading your credentials: #{$!.message}"
58
+ exit 1
59
+ end
60
+ end
61
+
62
+ def self.credentials_loaded?
63
+ (@@credentials_loaded ||= false) or (defined?(@@username) and defined?(@@password))
64
+ end
65
+
66
+ def self.standard_options
67
+ {:format => :json, :headers => {'Accept' => 'application/json'}}
68
+ end
69
+
70
+ def self.standard_options_with_credentials
71
+ standard_options.merge({:basic_auth => credentials})
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,10 @@
1
+ module DNSimple
2
+ class Command
3
+ def initialize(out=$stdout)
4
+ @out = out
5
+ end
6
+ def say(message)
7
+ @out.write("#{message}\n")
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,16 @@
1
+ require 'dnsimple/command'
2
+
3
+ module DNSimple
4
+ module Commands
5
+ class AddService < Command
6
+ def execute(args, options={})
7
+ domain_name = args.shift
8
+ domain = Domain.find(domain_name)
9
+ short_name = args.shift
10
+ service = Service.find(short_name)
11
+ domain.add_service(short_name)
12
+ say "Added #{service.name} to #{domain_name}"
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ module DNSimple
2
+ module Commands
3
+ class AddTemplateRecord
4
+ def execute(args, options={})
5
+ short_name = args.shift
6
+ record_name = args.shift
7
+ record_type = args.shift
8
+ content = args.shift
9
+ ttl = args.shift
10
+
11
+ template = Template.find(short_name)
12
+ record = TemplateRecord.create(template.short_name, record_name, record_type, content, :ttl => ttl, :prio => options[:prio])
13
+
14
+ puts "Created #{record.record_type} with content '#{record.content}' record for template #{template.name}"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ module DNSimple
2
+ module Commands
3
+ class ApplyTemplate
4
+ def execute(args, options={})
5
+ domain_name = args.shift
6
+ template_name = args.shift
7
+
8
+ domain = Domain.find(domain_name)
9
+ domain.apply(template_name)
10
+
11
+ puts "Applied template #{template_name} to #{domain.name}"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ module DNSimple
2
+ module Commands
3
+ class CheckDomain
4
+ def execute(args, options={})
5
+ name = args.shift
6
+ response = Domain.check(name)
7
+ puts "Check domain result for #{name}: #{response}"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ module DNSimple
2
+ module Commands
3
+ class ClearDomain
4
+ def execute(args, options={})
5
+ name = args.shift
6
+
7
+ records = Record.all(name)
8
+ records.each do |record|
9
+ record.delete
10
+ end
11
+
12
+ puts "Deleted #{records.length} records from #{name}"
13
+ end
14
+ end
15
+ end
16
+ end