sparqcode-dnsimple-ruby 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.bundle/config +3 -0
- data/.rvmrc +1 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +71 -0
- data/LICENSE +22 -0
- data/README +125 -0
- data/README.rdoc +125 -0
- data/README.textile +161 -0
- data/Rakefile +33 -0
- data/VERSION +1 -0
- data/bin/dnsimple +4 -0
- data/bin/dnsimple.rb +153 -0
- data/dnsimple-ruby.gemspec +191 -0
- data/features/README +12 -0
- data/features/cli/certificates/purchase_certificate.feature +10 -0
- data/features/cli/contacts/create_contact.feature +10 -0
- data/features/cli/domains/check_domain.feature +10 -0
- data/features/cli/domains/create_domain.feature +10 -0
- data/features/cli/domains/delete_domain.feature +11 -0
- data/features/cli/domains/register_domain.feature +10 -0
- data/features/cli/records/create_ptr_record.feature +11 -0
- data/features/cli/records/create_record.feature +12 -0
- data/features/cli/records/delete_record.feature +14 -0
- data/features/cli/templates/apply_template.feature +11 -0
- data/features/step_definitions/certificate_steps.rb +3 -0
- data/features/step_definitions/cli_steps.rb +8 -0
- data/features/step_definitions/domain_steps.rb +32 -0
- data/features/step_definitions/record_steps.rb +38 -0
- data/features/step_definitions/template_steps.rb +9 -0
- data/features/support/env.rb +17 -0
- data/fixtures/vcr_cassettes/DNSimple_Certificate/_all.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_Certificate/_purchase.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_Certificate/_submit.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_Contact/a_new_contact.yml +42 -0
- data/fixtures/vcr_cassettes/DNSimple_Contact/an_existing_contact.yml +42 -0
- data/fixtures/vcr_cassettes/DNSimple_Domain/_all.yml +130 -0
- data/fixtures/vcr_cassettes/DNSimple_Domain/applying_templates.yml +216 -0
- data/fixtures/vcr_cassettes/DNSimple_Domain/creating_a_new_domain.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain/by_id.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain/by_name.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_Domain/registration/with_a_new_registrant_contact.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_Domain/registration/with_an_existing_contact.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_Domain/setting_name_servers.yml +30 -0
- data/fixtures/vcr_cassettes/DNSimple_ExtendedAttribute/list_extended_attributes/for_ca.yml +40 -0
- data/fixtures/vcr_cassettes/DNSimple_ExtendedAttribute/list_extended_attributes/for_com.yml +40 -0
- data/fixtures/vcr_cassettes/DNSimple_Record/_all.yml +173 -0
- data/fixtures/vcr_cassettes/DNSimple_Record/creating_a_new_record.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_Record/find_a_record.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_Template/a_template.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_User/_me.yml +42 -0
- data/lib/dnsimple.rb +19 -0
- data/lib/dnsimple/certificate.rb +158 -0
- data/lib/dnsimple/cli.rb +122 -0
- data/lib/dnsimple/client.rb +74 -0
- data/lib/dnsimple/command.rb +10 -0
- data/lib/dnsimple/commands/add_service.rb +16 -0
- data/lib/dnsimple/commands/add_template_record.rb +18 -0
- data/lib/dnsimple/commands/apply_template.rb +15 -0
- data/lib/dnsimple/commands/check_domain.rb +11 -0
- data/lib/dnsimple/commands/clear_domain.rb +16 -0
- data/lib/dnsimple/commands/create_contact.rb +21 -0
- data/lib/dnsimple/commands/create_domain.rb +16 -0
- data/lib/dnsimple/commands/create_record.rb +20 -0
- data/lib/dnsimple/commands/create_template.rb +14 -0
- data/lib/dnsimple/commands/delete_contact.rb +14 -0
- data/lib/dnsimple/commands/delete_domain.rb +14 -0
- data/lib/dnsimple/commands/delete_record.rb +16 -0
- data/lib/dnsimple/commands/delete_template.rb +13 -0
- data/lib/dnsimple/commands/delete_template_record.rb +16 -0
- data/lib/dnsimple/commands/describe_certificate.rb +34 -0
- data/lib/dnsimple/commands/describe_contact.rb +25 -0
- data/lib/dnsimple/commands/describe_domain.rb +14 -0
- data/lib/dnsimple/commands/describe_record.rb +16 -0
- data/lib/dnsimple/commands/describe_service.rb +12 -0
- data/lib/dnsimple/commands/describe_user.rb +18 -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_certificates.rb +15 -0
- data/lib/dnsimple/commands/list_contacts.rb +13 -0
- data/lib/dnsimple/commands/list_domains.rb +13 -0
- data/lib/dnsimple/commands/list_extended_attributes.rb +25 -0
- data/lib/dnsimple/commands/list_records.rb +21 -0
- data/lib/dnsimple/commands/list_services.rb +14 -0
- data/lib/dnsimple/commands/list_template_records.rb +17 -0
- data/lib/dnsimple/commands/list_templates.rb +13 -0
- data/lib/dnsimple/commands/purchase_certificate.rb +19 -0
- data/lib/dnsimple/commands/register_domain.rb +33 -0
- data/lib/dnsimple/commands/remove_service.rb +14 -0
- data/lib/dnsimple/commands/submit_certificate.rb +19 -0
- data/lib/dnsimple/commands/transfer_domain.rb +21 -0
- data/lib/dnsimple/commands/update_contact.rb +25 -0
- data/lib/dnsimple/commands/update_record.rb +23 -0
- data/lib/dnsimple/contact.rb +181 -0
- data/lib/dnsimple/domain.rb +246 -0
- data/lib/dnsimple/error.rb +32 -0
- data/lib/dnsimple/extended_attribute.rb +73 -0
- data/lib/dnsimple/record.rb +128 -0
- data/lib/dnsimple/service.rb +58 -0
- data/lib/dnsimple/template.rb +91 -0
- data/lib/dnsimple/template_record.rb +103 -0
- data/lib/dnsimple/transfer_order.rb +45 -0
- data/lib/dnsimple/user.rb +44 -0
- data/spec/README +10 -0
- data/spec/certificate_spec.rb +46 -0
- data/spec/command_spec.rb +19 -0
- data/spec/commands/add_service_spec.rb +29 -0
- data/spec/commands/create_record_spec.rb +23 -0
- data/spec/commands/list_records_spec.rb +34 -0
- data/spec/commands/purchase_certificate_spec.rb +24 -0
- data/spec/commands/submit_certificate_spec.rb +19 -0
- data/spec/contact_spec.rb +35 -0
- data/spec/domain_spec.rb +97 -0
- data/spec/extended_attributes_spec.rb +19 -0
- data/spec/record_spec.rb +59 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/template_spec.rb +11 -0
- data/spec/user_spec.rb +23 -0
- metadata +353 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class CreateContact
|
4
|
+
# Execute the contact:create command.
|
5
|
+
#
|
6
|
+
# Args expected to be:
|
7
|
+
# [name:value name:value ...]
|
8
|
+
def execute(args, options={})
|
9
|
+
attributes = {}
|
10
|
+
attributes['state_province_choice'] = 'S'
|
11
|
+
args.each do |arg|
|
12
|
+
name, value = arg.split(":")
|
13
|
+
attributes[Contact.resolve(name)] = value
|
14
|
+
end
|
15
|
+
|
16
|
+
contact = Contact.create(attributes, options)
|
17
|
+
puts "Created contact #{contact.name} (id: #{contact.id})"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class CreateDomain
|
4
|
+
def execute(args, options={})
|
5
|
+
name = args.shift
|
6
|
+
domain = Domain.create(name)
|
7
|
+
puts "Created #{domain.name}"
|
8
|
+
|
9
|
+
if template = options.delete(:template)
|
10
|
+
domain.apply(template)
|
11
|
+
puts "Applied template #{template} to #{domain.name}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'dnsimple/command'
|
2
|
+
|
3
|
+
module DNSimple
|
4
|
+
module Commands
|
5
|
+
class CreateRecord < Command
|
6
|
+
def execute(args, options={})
|
7
|
+
name = args.shift
|
8
|
+
record_name = args.shift
|
9
|
+
record_type = args.shift
|
10
|
+
content = args.shift
|
11
|
+
ttl = args.shift
|
12
|
+
|
13
|
+
domain = Domain.find(name)
|
14
|
+
record = Record.create(domain, record_name, record_type, content, :ttl => ttl, :prio => options[:prio])
|
15
|
+
|
16
|
+
say "Created #{record.record_type} record for #{domain.name} (id:#{record.id})"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class CreateTemplate
|
4
|
+
def execute(args, options={})
|
5
|
+
name = args.shift
|
6
|
+
short_name = args.shift
|
7
|
+
description = args.shift unless args.empty?
|
8
|
+
|
9
|
+
template = Template.create(name, short_name, description)
|
10
|
+
puts "Created #{template.name} (short_name:#{template.short_name})"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class DeleteRecord
|
4
|
+
def execute(args, options={})
|
5
|
+
domain_name = args.shift
|
6
|
+
id = args.shift
|
7
|
+
|
8
|
+
domain = Domain.find(domain_name)
|
9
|
+
record = Record.find(domain.name, id)
|
10
|
+
record.delete
|
11
|
+
|
12
|
+
puts "Deleted #{record.id} from #{domain.name}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class DeleteTemplateRecord
|
4
|
+
def execute(args, options={})
|
5
|
+
short_name = args.shift
|
6
|
+
id = args.shift
|
7
|
+
|
8
|
+
template = Template.find(short_name)
|
9
|
+
record = TemplateRecord.find(template.short_name, id)
|
10
|
+
record.delete
|
11
|
+
|
12
|
+
puts "Deleted #{record.id} from template #{short_name}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class DescribeCertificate
|
4
|
+
def execute(args, options={})
|
5
|
+
domain_name = args.shift
|
6
|
+
certificate_id = args.shift
|
7
|
+
domain = Domain.find(domain_name)
|
8
|
+
certificate = Certificate.find(domain, certificate_id)
|
9
|
+
puts "Certificate: #{certificate.fqdn}"
|
10
|
+
puts "\tID: #{certificate.id}"
|
11
|
+
puts "\tStatus: #{certificate.certificate_status}"
|
12
|
+
puts "\tCreated: #{certificate.created_at}"
|
13
|
+
puts "\tOrder Date: #{certificate.order_date}"
|
14
|
+
puts "\tExpires: #{certificate.expiration_date}"
|
15
|
+
|
16
|
+
if certificate.approver_email =~ /\S+/
|
17
|
+
puts "\tApprover email: #{certificate.approver_email}"
|
18
|
+
else
|
19
|
+
puts "\tAvailable approver emails:"
|
20
|
+
certificate.available_approver_emails.split(",").each do |email|
|
21
|
+
puts "\t\t#{email}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
puts
|
26
|
+
puts "#{certificate.csr}"
|
27
|
+
puts
|
28
|
+
puts "#{certificate.private_key}"
|
29
|
+
puts
|
30
|
+
puts "#{certificate.ssl_certificate}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class DescribeContact
|
4
|
+
def execute(args, options={})
|
5
|
+
id = args.shift
|
6
|
+
contact = Contact.find(id)
|
7
|
+
puts "Contact: #{contact.name}:"
|
8
|
+
puts "\tID: #{contact.id}"
|
9
|
+
puts "\tFirst Name: #{contact.first_name}"
|
10
|
+
puts "\tLast Name: #{contact.last_name}"
|
11
|
+
puts "\tOrganization Name: #{contact.organization_name}" if contact.organization_name
|
12
|
+
puts "\tJob Title: #{contact.job_title}" if contact.job_title
|
13
|
+
puts "\tAddress 1: #{contact.address1}"
|
14
|
+
puts "\tAddress 2: #{contact.address2}"
|
15
|
+
puts "\tCity: #{contact.city}"
|
16
|
+
puts "\tState or Province: #{contact.state_province}"
|
17
|
+
puts "\tPostal Code: #{contact.postal_code}"
|
18
|
+
puts "\tCountry: #{contact.country}"
|
19
|
+
puts "\tEmail: #{contact.email_address}"
|
20
|
+
puts "\tPhone: #{contact.phone}"
|
21
|
+
puts "\tPhone Ext: #{contact.phone_ext}" if contact.phone_ext
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class DescribeDomain
|
4
|
+
def execute(args, options={})
|
5
|
+
name = args.shift
|
6
|
+
domain = Domain.find(name)
|
7
|
+
puts "Domain #{domain.name}:"
|
8
|
+
puts "\tID: #{domain.id}"
|
9
|
+
puts "\tCreated: #{domain.created_at}"
|
10
|
+
puts "\tName Server Status: #{domain.name_server_status}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class DescribeRecord
|
4
|
+
def execute(args, options={})
|
5
|
+
name = args.shift
|
6
|
+
id = args.shift
|
7
|
+
record = Record.find(name, id)
|
8
|
+
puts "Record #{record.fqdn}:"
|
9
|
+
puts "\tID: #{record.id}"
|
10
|
+
puts "\tTTL: #{record.ttl}"
|
11
|
+
puts "\tPrio: #{record.prio}"
|
12
|
+
puts "\tContent: #{record.content}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
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,18 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class DescribeUser
|
4
|
+
def execute(args, options={})
|
5
|
+
puts "Connecting to #{Client.base_uri}"
|
6
|
+
user = User.me
|
7
|
+
puts "User details:"
|
8
|
+
puts "\tID:#{user.id}"
|
9
|
+
puts "\tCreated: #{user.created_at}"
|
10
|
+
puts "\tEmail: #{user.email}"
|
11
|
+
puts "\tSuccessful logins: #{user.login_count}"
|
12
|
+
puts "\tFailed logins: #{user.failed_login_count}"
|
13
|
+
puts "\tDomains in account: #{user.domain_count}"
|
14
|
+
puts "\tDomains allowed: #{user.domain_limit}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
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,15 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class ListCertificates
|
4
|
+
def execute(args, options={})
|
5
|
+
domain_name = args.shift
|
6
|
+
domain = DNSimple::Domain.find(domain_name)
|
7
|
+
certificates = DNSimple::Certificate.all(domain)
|
8
|
+
puts "Found #{certificates.length} certificate for #{domain_name}"
|
9
|
+
certificates.each do |certificate|
|
10
|
+
puts "\t#{certificate.fqdn} (id: #{certificate.id}, status: #{certificate.certificate_status})"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class ListContacts
|
4
|
+
def execute(args, options={})
|
5
|
+
contacts = Contact.all
|
6
|
+
puts "Found #{contacts.length} contacts:"
|
7
|
+
contacts.each do |contact|
|
8
|
+
puts "\t#{contact.name} (id:#{contact.id})"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class ListExtendedAttributes
|
4
|
+
def execute(args, options={})
|
5
|
+
tld = args.shift
|
6
|
+
extended_attributes = ExtendedAttribute.find(tld)
|
7
|
+
puts "Extended attributes: "
|
8
|
+
extended_attributes.each do |extended_attribute|
|
9
|
+
o = " #{extended_attribute.name}"
|
10
|
+
o << " (required)" if extended_attribute.required
|
11
|
+
o << " : #{extended_attribute.description}\n"
|
12
|
+
unless extended_attribute.options.empty?
|
13
|
+
o << " Options:\n"
|
14
|
+
extended_attribute.options.each do |option|
|
15
|
+
o << " #{option.title}: #{option.value}"
|
16
|
+
o << " (#{option.description})" if option.description
|
17
|
+
o << "\n"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
puts o
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'dnsimple/command'
|
2
|
+
|
3
|
+
module DNSimple
|
4
|
+
module Commands
|
5
|
+
class ListRecords < Command
|
6
|
+
def execute(args, options={})
|
7
|
+
domain_name = args.shift
|
8
|
+
|
9
|
+
records = Record.all(DNSimple::Domain.new(:name => domain_name))
|
10
|
+
|
11
|
+
say "Found #{records.length} records for #{domain_name}"
|
12
|
+
records.each do |record|
|
13
|
+
extra = ["ttl:#{record.ttl}", "id:#{record.id}"]
|
14
|
+
extra << "prio:#{record.prio}" if record.record_type == "MX"
|
15
|
+
extra = "(#{extra.join(', ')})"
|
16
|
+
say "\t#{record.name}.#{record.domain.name} (#{record.record_type})-> #{record.content} #{extra}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
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,17 @@
|
|
1
|
+
module DNSimple
|
2
|
+
module Commands
|
3
|
+
class ListTemplateRecords
|
4
|
+
def execute(args, options={})
|
5
|
+
short_name = args.shift
|
6
|
+
template_records = TemplateRecord.all(short_name)
|
7
|
+
puts "Found #{template_records.length} records for #{short_name}"
|
8
|
+
template_records.each do |record|
|
9
|
+
extra = ["ttl:#{record.ttl}", "id:#{record.id}"]
|
10
|
+
extra << "prio:#{record.prio}" if record.record_type == "MX"
|
11
|
+
extra = "(#{extra.join(', ')})"
|
12
|
+
puts "\t#{record.name} (#{record.record_type})-> #{record.content} #{extra}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|