dnsimple-ruby 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.bundle/config +2 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +36 -0
- data/README +38 -0
- data/README.rdoc +77 -0
- data/README.textile +40 -0
- data/VERSION +1 -1
- data/lib/dnsimple.rb +1 -0
- data/lib/dnsimple/cli.rb +12 -0
- data/lib/dnsimple/commands/create_contact.rb +21 -0
- data/lib/dnsimple/commands/delete_contact.rb +14 -0
- data/lib/dnsimple/commands/describe_contact.rb +25 -0
- data/lib/dnsimple/commands/list_contacts.rb +13 -0
- data/lib/dnsimple/commands/update_contact.rb +25 -0
- data/lib/dnsimple/contact.rb +171 -0
- data/lib/dnsimple/domain.rb +2 -0
- data/spec/contact_spec.rb +32 -0
- metadata +22 -4
data/.bundle/config
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
crack (0.1.8)
|
5
|
+
diff-lcs (1.1.2)
|
6
|
+
gemcutter (0.6.1)
|
7
|
+
git (1.2.5)
|
8
|
+
httparty (0.6.1)
|
9
|
+
crack (= 0.1.8)
|
10
|
+
jeweler (1.4.0)
|
11
|
+
gemcutter (>= 0.1.0)
|
12
|
+
git (>= 1.2.5)
|
13
|
+
rubyforge (>= 2.0.0)
|
14
|
+
json_pure (1.4.6)
|
15
|
+
rake (0.8.7)
|
16
|
+
rspec (2.0.0)
|
17
|
+
rspec-core (= 2.0.0)
|
18
|
+
rspec-expectations (= 2.0.0)
|
19
|
+
rspec-mocks (= 2.0.0)
|
20
|
+
rspec-core (2.0.0)
|
21
|
+
rspec-expectations (2.0.0)
|
22
|
+
diff-lcs (>= 1.1.2)
|
23
|
+
rspec-mocks (2.0.0)
|
24
|
+
rspec-core (= 2.0.0)
|
25
|
+
rspec-expectations (= 2.0.0)
|
26
|
+
rubyforge (2.0.4)
|
27
|
+
json_pure (>= 1.1.7)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
httparty
|
34
|
+
jeweler
|
35
|
+
rake
|
36
|
+
rspec (>= 2.0.0)
|
data/README
CHANGED
@@ -26,15 +26,53 @@ The following commands are available for domains:
|
|
26
26
|
* dnsimple list
|
27
27
|
* dnsimple describe domain.com
|
28
28
|
* dnsimple create domain.com
|
29
|
+
* dnsimple register domain.com registrant_id
|
30
|
+
* dnsimple transfer domain.com registrant_id [authinfo]
|
29
31
|
* dnsimple delete domain.com
|
30
32
|
* dnsimple apply domain.com template_short_name
|
31
33
|
|
34
|
+
Please note that domain registration and transfer can only be done through the API for domains that do not require extended attributes. A future version of the API will add support for extended attributes.
|
35
|
+
|
32
36
|
The following commands are available for records:
|
33
37
|
|
34
38
|
* dnsimple record:create [--prio=priority] domain.com name type content [ttl]
|
35
39
|
* dnsimple record:list domain.com
|
36
40
|
* dnsimple record:delete domain.com record_id
|
37
41
|
|
42
|
+
The following commands are available for custom templates:
|
43
|
+
|
44
|
+
* dnsimple template:list
|
45
|
+
* dnsimple template:create name short_name [description]
|
46
|
+
* dnsimple template:delete short_name
|
47
|
+
* dnsimple template:list_records short_name
|
48
|
+
* dnsimple template:add_record short_name name type content [ttl] [prio]
|
49
|
+
* dnsimple template:delete_record short_name template_record_id
|
50
|
+
|
51
|
+
The following commands are available for managing contacts:
|
52
|
+
|
53
|
+
* dnsimple contact:list
|
54
|
+
* dnsimple contact:describe id
|
55
|
+
* dnsimple contact:create [name:value name:value ...]
|
56
|
+
* dnsimple contact:update id [name:value name:value ...]
|
57
|
+
* dnsimple contact:delete id
|
58
|
+
|
59
|
+
The contact name/value pairs are:
|
60
|
+
|
61
|
+
* first_name
|
62
|
+
* last_name
|
63
|
+
* organization_name (optional)
|
64
|
+
* job_title (required if organization name is specified)
|
65
|
+
* address1
|
66
|
+
* address2 (optional)
|
67
|
+
* city
|
68
|
+
* state_province (also aliased as state)
|
69
|
+
* postal_code
|
70
|
+
* country
|
71
|
+
* email
|
72
|
+
* phone
|
73
|
+
* phone_ext (optional)
|
74
|
+
* fax (optional)
|
75
|
+
|
38
76
|
== Wrapper Classes
|
39
77
|
|
40
78
|
In addition to the command line utility you may also use the included Ruby
|
data/README.rdoc
CHANGED
@@ -9,6 +9,11 @@ In this file add the following:
|
|
9
9
|
username: YOUR_USERNAME
|
10
10
|
password: YOUR_PASSWORD
|
11
11
|
|
12
|
+
Alternatively you can pass the credentials via command-line arguments, as in:
|
13
|
+
|
14
|
+
dnsimple -u username -p password command
|
15
|
+
|
16
|
+
|
12
17
|
== Commands
|
13
18
|
|
14
19
|
The following commands are available for domains:
|
@@ -16,11 +21,83 @@ The following commands are available for domains:
|
|
16
21
|
* dnsimple list
|
17
22
|
* dnsimple describe domain.com
|
18
23
|
* dnsimple create domain.com
|
24
|
+
* dnsimple register domain.com registrant_id
|
25
|
+
* dnsimple transfer domain.com registrant_id [authinfo]
|
19
26
|
* dnsimple delete domain.com
|
20
27
|
* dnsimple apply domain.com template_short_name
|
21
28
|
|
29
|
+
Please note that domain registration and transfer can only be done through the API for domains that do not require extended attributes. A future version of the API will add support for extended attributes.
|
30
|
+
|
22
31
|
The following commands are available for records:
|
23
32
|
|
24
33
|
* dnsimple record:create [--prio=priority] domain.com name type content [ttl]
|
25
34
|
* dnsimple record:list domain.com
|
26
35
|
* dnsimple record:delete domain.com record_id
|
36
|
+
|
37
|
+
The following commands are available for custom templates:
|
38
|
+
|
39
|
+
* dnsimple template:list
|
40
|
+
* dnsimple template:create name short_name [description]
|
41
|
+
* dnsimple template:delete short_name
|
42
|
+
* dnsimple template:list_records short_name
|
43
|
+
* dnsimple template:add_record short_name name type content [ttl] [prio]
|
44
|
+
* dnsimple template:delete_record short_name template_record_id
|
45
|
+
|
46
|
+
The following commands are available for managing contacts:
|
47
|
+
|
48
|
+
* dnsimple contact:list
|
49
|
+
* dnsimple contact:describe id
|
50
|
+
* dnsimple contact:create [name:value name:value ...]
|
51
|
+
* dnsimple contact:update id [name:value name:value ...]
|
52
|
+
* dnsimple contact:delete id
|
53
|
+
|
54
|
+
=== Contact Attributes
|
55
|
+
|
56
|
+
The contact attributes that can be used in the name:value pairs are:
|
57
|
+
|
58
|
+
* first_name
|
59
|
+
* last_name
|
60
|
+
* organization_name (optional)
|
61
|
+
* job_title (required if organization name is specified)
|
62
|
+
* address1
|
63
|
+
* address2 (optional)
|
64
|
+
* city
|
65
|
+
* state_province (also aliased as state)
|
66
|
+
* postal_code
|
67
|
+
* country
|
68
|
+
* email
|
69
|
+
* phone
|
70
|
+
* phone_ext (optional)
|
71
|
+
* fax (optional)
|
72
|
+
|
73
|
+
== Wrapper Classes
|
74
|
+
|
75
|
+
In addition to the command line utility you may also use the included Ruby
|
76
|
+
classes directly in your Ruby applications.
|
77
|
+
|
78
|
+
Sample:
|
79
|
+
|
80
|
+
require 'rubygems'
|
81
|
+
require 'dnsimple'
|
82
|
+
|
83
|
+
DNSimple::Client.username = 'YOUR_USERNAME'
|
84
|
+
DNSimple::Client.password = 'YOUR_PASSWORD'
|
85
|
+
|
86
|
+
user = User.me
|
87
|
+
puts "#{user.domain_count} domains"
|
88
|
+
|
89
|
+
puts "Domains..."
|
90
|
+
Domain.all.each do |domain|
|
91
|
+
puts " #{domain.name}"
|
92
|
+
end
|
93
|
+
|
94
|
+
domain = Domain.find("example.com")
|
95
|
+
domain.apply("template") # applies a standard or custom template to the domain
|
96
|
+
|
97
|
+
domain = Domain.create("newdomain.com")
|
98
|
+
puts "Added #{domain.name}"
|
99
|
+
domain.delete # removes from DNSimple
|
100
|
+
|
101
|
+
The complete RDoc for the wrapper classes can be found here:
|
102
|
+
|
103
|
+
http://rdoc.info/projects/aetrion/dnsimple-ruby
|
data/README.textile
CHANGED
@@ -36,15 +36,55 @@ The following commands are available for domains:
|
|
36
36
|
* dnsimple list
|
37
37
|
* dnsimple describe domain.com
|
38
38
|
* dnsimple create domain.com
|
39
|
+
* dnsimple register domain.com registrant_id
|
40
|
+
* dnsimple transfer domain.com registrant_id [authinfo]
|
39
41
|
* dnsimple delete domain.com
|
40
42
|
* dnsimple apply domain.com template_short_name
|
41
43
|
|
44
|
+
Please note that domain registration and transfer can only be done through the API for domains that do not require extended attributes. A future version of the API will add support for extended attributes.
|
45
|
+
|
42
46
|
The following commands are available for records:
|
43
47
|
|
44
48
|
* dnsimple record:create [--prio=priority] domain.com name type content [ttl]
|
45
49
|
* dnsimple record:list domain.com
|
46
50
|
* dnsimple record:delete domain.com record_id
|
47
51
|
|
52
|
+
The following commands are available for custom templates:
|
53
|
+
|
54
|
+
* dnsimple template:list
|
55
|
+
* dnsimple template:create name short_name [description]
|
56
|
+
* dnsimple template:delete short_name
|
57
|
+
* dnsimple template:list_records short_name
|
58
|
+
* dnsimple template:add_record short_name name type content [ttl] [prio]
|
59
|
+
* dnsimple template:delete_record short_name template_record_id
|
60
|
+
|
61
|
+
The following commands are available for managing contacts:
|
62
|
+
|
63
|
+
* dnsimple contact:list
|
64
|
+
* dnsimple contact:describe id
|
65
|
+
* dnsimple contact:create [name:value name:value ...]
|
66
|
+
* dnsimple contact:update id [name:value name:value ...]
|
67
|
+
* dnsimple contact:delete id
|
68
|
+
|
69
|
+
h3. Contact Attributes
|
70
|
+
|
71
|
+
The contact attributes that can be used in the name:value pairs are:
|
72
|
+
|
73
|
+
* first_name
|
74
|
+
* last_name
|
75
|
+
* organization_name (optional)
|
76
|
+
* job_title (required if organization name is specified)
|
77
|
+
* address1
|
78
|
+
* address2 (optional)
|
79
|
+
* city
|
80
|
+
* state_province (also aliased as state)
|
81
|
+
* postal_code
|
82
|
+
* country
|
83
|
+
* email
|
84
|
+
* phone
|
85
|
+
* phone_ext (optional)
|
86
|
+
* fax (optional)
|
87
|
+
|
48
88
|
h2. Wrapper Classes
|
49
89
|
|
50
90
|
In addition to the command line utility you may also use the included Ruby
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/lib/dnsimple.rb
CHANGED
data/lib/dnsimple/cli.rb
CHANGED
@@ -51,6 +51,12 @@ module DNSimple
|
|
51
51
|
'template:list_records' => DNSimple::Commands::ListTemplateRecords,
|
52
52
|
'template:add_record' => DNSimple::Commands::AddTemplateRecord,
|
53
53
|
'template:delete_record' => DNSimple::Commands::DeleteTemplateRecord,
|
54
|
+
|
55
|
+
'contact:create' => DNSimple::Commands::CreateContact,
|
56
|
+
'contact:list' => DNSimple::Commands::ListContacts,
|
57
|
+
'contact:describe' => DNSimple::Commands::DescribeContact,
|
58
|
+
'contact:update' => DNSimple::Commands::UpdateContact,
|
59
|
+
'contact:delete' => DNSimple::Commands::DeleteContact,
|
54
60
|
}
|
55
61
|
end
|
56
62
|
|
@@ -81,3 +87,9 @@ require 'dnsimple/commands/delete_template'
|
|
81
87
|
require 'dnsimple/commands/list_template_records'
|
82
88
|
require 'dnsimple/commands/add_template_record'
|
83
89
|
require 'dnsimple/commands/delete_template_record'
|
90
|
+
|
91
|
+
require 'dnsimple/commands/create_contact'
|
92
|
+
require 'dnsimple/commands/list_contacts'
|
93
|
+
require 'dnsimple/commands/describe_contact'
|
94
|
+
require 'dnsimple/commands/update_contact'
|
95
|
+
require 'dnsimple/commands/delete_contact'
|
@@ -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.name} (id: #{contact.id})"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
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}" unless contact.organization_name.blank?
|
12
|
+
puts "\tJob Title: #{contact.job_title}" unless contact.job_title.blank?
|
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}" unless contact.phone_ext.blank?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
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 UpdateContact
|
4
|
+
# Execute the contact:update command.
|
5
|
+
#
|
6
|
+
# Args expected:
|
7
|
+
# id [name:value name:value ...]
|
8
|
+
def execute(args, options={})
|
9
|
+
attributes = {}
|
10
|
+
id = args.shift
|
11
|
+
args.each do |arg|
|
12
|
+
name, value = arg.split(":")
|
13
|
+
attributes[Contact.resolve(name)] = value
|
14
|
+
end
|
15
|
+
|
16
|
+
contact = Contact.find(id)
|
17
|
+
attributes.each do |name, value|
|
18
|
+
contact.send("#{name}=", value)
|
19
|
+
end
|
20
|
+
contact.save
|
21
|
+
puts "Updated contact #{contact.name} (id: #{contact.id})"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
module DNSimple #:nodoc:
|
2
|
+
# CLass representing a contact in DNSimple
|
3
|
+
class Contact
|
4
|
+
include HTTParty
|
5
|
+
|
6
|
+
# The contact ID in DNSimple
|
7
|
+
attr_accessor :id
|
8
|
+
|
9
|
+
# The name of the organization in which the contact works
|
10
|
+
# (may be omitted)
|
11
|
+
attr_accessor :organization_name
|
12
|
+
|
13
|
+
# The contact first name
|
14
|
+
attr_accessor :first_name
|
15
|
+
|
16
|
+
# The contact last name
|
17
|
+
attr_accessor :last_name
|
18
|
+
|
19
|
+
# The contact's job title (may be omitted)
|
20
|
+
attr_accessor :job_title
|
21
|
+
|
22
|
+
# The contact street address
|
23
|
+
attr_accessor :address1
|
24
|
+
|
25
|
+
# Apartment or suite number
|
26
|
+
attr_accessor :address2
|
27
|
+
|
28
|
+
# The city name
|
29
|
+
attr_accessor :city
|
30
|
+
|
31
|
+
# The state or province name
|
32
|
+
attr_accessor :state_province
|
33
|
+
|
34
|
+
# The contact postal code
|
35
|
+
attr_accessor :postal_code
|
36
|
+
|
37
|
+
# The contact country (as a 2-character country code)
|
38
|
+
attr_accessor :country
|
39
|
+
|
40
|
+
# The contact email address
|
41
|
+
attr_accessor :email_address
|
42
|
+
|
43
|
+
# The contact phone number
|
44
|
+
attr_accessor :phone
|
45
|
+
|
46
|
+
# The contact phone extension (may be omitted)
|
47
|
+
attr_accessor :phone_ext
|
48
|
+
|
49
|
+
# The contact fax number (may be omitted)
|
50
|
+
attr_accessor :fax
|
51
|
+
|
52
|
+
# When the contact was created in DNSimple
|
53
|
+
attr_accessor :created_at
|
54
|
+
|
55
|
+
# When the contact was last updated in DNSimple
|
56
|
+
attr_accessor :updated_at
|
57
|
+
|
58
|
+
#:nodoc:
|
59
|
+
def initialize(attributes)
|
60
|
+
attributes.each do |key, value|
|
61
|
+
m = "#{key}=".to_sym
|
62
|
+
self.send(m, value) if self.respond_to?(m)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def name
|
67
|
+
[first_name, last_name].join(' ')
|
68
|
+
end
|
69
|
+
|
70
|
+
def save(options={})
|
71
|
+
contact_hash = {}
|
72
|
+
%w(first_name last_name organization_name job_title address1 address2 city
|
73
|
+
state_province postal_code country email_address phone phone_ext fax).each do |attribute|
|
74
|
+
contact_hash[Contact.resolve(attribute)] = self.send(attribute)
|
75
|
+
end
|
76
|
+
|
77
|
+
options.merge!({:basic_auth => Client.credentials})
|
78
|
+
options.merge!({:body => {:contact => contact_hash}})
|
79
|
+
|
80
|
+
response = self.class.put("#{Client.base_uri}/contacts/#{id}.json", options)
|
81
|
+
|
82
|
+
pp response if Client.debug?
|
83
|
+
|
84
|
+
case response.code
|
85
|
+
when 200
|
86
|
+
return self
|
87
|
+
when 401
|
88
|
+
raise RuntimeError, "Authentication failed"
|
89
|
+
else
|
90
|
+
raise RuntimeError, "Failed to update contact: #{response.inspect}"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Delete the contact from DNSimple. WARNING: this cannot be undone.
|
95
|
+
def delete(options={})
|
96
|
+
options.merge!({:basic_auth => Client.credentials})
|
97
|
+
self.class.delete("#{Client.base_uri}/contacts/#{id}.json", options)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Map an aliased field name to it's real name. For example, if you
|
101
|
+
# pass "first" it will be resolved to "first_name", "email" is resolved
|
102
|
+
# to "email_address" and so on.
|
103
|
+
def self.resolve(name)
|
104
|
+
aliases = {
|
105
|
+
'first' => 'first_name',
|
106
|
+
'last' => 'last_name',
|
107
|
+
'state' => 'state_province',
|
108
|
+
'province' => 'state_province',
|
109
|
+
'email' => 'email_address',
|
110
|
+
}
|
111
|
+
aliases[name] || name
|
112
|
+
end
|
113
|
+
|
114
|
+
# Create the contact with the given attributes in DNSimple.
|
115
|
+
# This method returns a Contact instance of the contact is created
|
116
|
+
# and raises an error otherwise.
|
117
|
+
def self.create(attributes, options={})
|
118
|
+
contact_hash = attributes
|
119
|
+
|
120
|
+
options.merge!({:body => {:contact => contact_hash}})
|
121
|
+
options.merge!({:basic_auth => Client.credentials})
|
122
|
+
|
123
|
+
response = self.post("#{Client.base_uri}/contacts.json", options)
|
124
|
+
|
125
|
+
pp response if Client.debug?
|
126
|
+
|
127
|
+
case response.code
|
128
|
+
when 201
|
129
|
+
return Contact.new(response["contact"])
|
130
|
+
when 401
|
131
|
+
raise RuntimeError, "Authentication failed"
|
132
|
+
else
|
133
|
+
raise RuntimeError, "Failed to create contact: #{response.inspect}"
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.find(id, options={})
|
138
|
+
options.merge!({:basic_auth => Client.credentials})
|
139
|
+
response = self.get("#{Client.base_uri}/contacts/#{id}.json", options)
|
140
|
+
|
141
|
+
pp response if Client.debug?
|
142
|
+
|
143
|
+
case response.code
|
144
|
+
when 200
|
145
|
+
return Contact.new(response["contact"])
|
146
|
+
when 401
|
147
|
+
raise RuntimeError, "Authentication failed"
|
148
|
+
when 404
|
149
|
+
raise RuntimeError, "Could not find contact #{id}"
|
150
|
+
else
|
151
|
+
raise DNSimple::Error.new(id, response["errors"])
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def self.all(options={})
|
156
|
+
options.merge!({:basic_auth => Client.credentials})
|
157
|
+
response = self.get("#{Client.base_uri}/contacts.json", options)
|
158
|
+
|
159
|
+
pp response if Client.debug?
|
160
|
+
|
161
|
+
case response.code
|
162
|
+
when 200
|
163
|
+
response.map { |r| Contact.new(r["contact"]) }
|
164
|
+
when 401
|
165
|
+
raise RuntimeError, "Authentication failed"
|
166
|
+
else
|
167
|
+
raise RuntimeError, "Error: #{response.code}"
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
data/lib/dnsimple/domain.rb
CHANGED
@@ -34,6 +34,8 @@ module DNSimple #:nodoc:
|
|
34
34
|
end
|
35
35
|
alias :destroy :delete
|
36
36
|
|
37
|
+
# Apply the given named template to the domain. This will add
|
38
|
+
# all of the records in the template to the domain.
|
37
39
|
def apply(template_name, options={})
|
38
40
|
template = DNSimple::Template.find(template_name)
|
39
41
|
options.merge!({:basic_auth => Client.credentials})
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DNSimple::Contact do
|
4
|
+
describe "a new contact" do
|
5
|
+
let(:contact_attributes) {
|
6
|
+
{
|
7
|
+
:first_name => 'John',
|
8
|
+
:last_name => 'Doe',
|
9
|
+
:address1 => '1 SW 1st Street',
|
10
|
+
:city => 'Miami',
|
11
|
+
:state_province => 'FL',
|
12
|
+
:postal_code => '33143',
|
13
|
+
:country => 'US',
|
14
|
+
:email_address => 'john.doe@example.com',
|
15
|
+
:phone => '305 111 2222'
|
16
|
+
}
|
17
|
+
}
|
18
|
+
before do
|
19
|
+
@contact = DNSimple::Contact.create(contact_attributes)
|
20
|
+
end
|
21
|
+
after do
|
22
|
+
@contact.delete
|
23
|
+
end
|
24
|
+
it "has specific attributes" do
|
25
|
+
@contact.first_name.should eql(contact_attributes[:first_name])
|
26
|
+
@contact.id.should_not be_nil
|
27
|
+
end
|
28
|
+
it "can be found by id" do
|
29
|
+
contact = DNSimple::Contact.find(@contact.id)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dnsimple-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 7
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
+
- 6
|
8
9
|
- 0
|
9
|
-
version: 0.
|
10
|
+
version: 0.6.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Anthony Eden
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-10-19 00:00:00 +02:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: httparty
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
version: "0"
|
@@ -42,7 +45,10 @@ extra_rdoc_files:
|
|
42
45
|
- README.rdoc
|
43
46
|
- README.textile
|
44
47
|
files:
|
48
|
+
- .bundle/config
|
45
49
|
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- Gemfile.lock
|
46
52
|
- LICENSE
|
47
53
|
- README
|
48
54
|
- README.rdoc
|
@@ -57,21 +63,27 @@ files:
|
|
57
63
|
- lib/dnsimple/commands/add_template_record.rb
|
58
64
|
- lib/dnsimple/commands/apply_template.rb
|
59
65
|
- lib/dnsimple/commands/clear_domain.rb
|
66
|
+
- lib/dnsimple/commands/create_contact.rb
|
60
67
|
- lib/dnsimple/commands/create_domain.rb
|
61
68
|
- lib/dnsimple/commands/create_record.rb
|
62
69
|
- lib/dnsimple/commands/create_template.rb
|
70
|
+
- lib/dnsimple/commands/delete_contact.rb
|
63
71
|
- lib/dnsimple/commands/delete_domain.rb
|
64
72
|
- lib/dnsimple/commands/delete_record.rb
|
65
73
|
- lib/dnsimple/commands/delete_template.rb
|
66
74
|
- lib/dnsimple/commands/delete_template_record.rb
|
75
|
+
- lib/dnsimple/commands/describe_contact.rb
|
67
76
|
- lib/dnsimple/commands/describe_domain.rb
|
68
77
|
- lib/dnsimple/commands/describe_user.rb
|
78
|
+
- lib/dnsimple/commands/list_contacts.rb
|
69
79
|
- lib/dnsimple/commands/list_domains.rb
|
70
80
|
- lib/dnsimple/commands/list_records.rb
|
71
81
|
- lib/dnsimple/commands/list_template_records.rb
|
72
82
|
- lib/dnsimple/commands/list_templates.rb
|
73
83
|
- lib/dnsimple/commands/register_domain.rb
|
74
84
|
- lib/dnsimple/commands/transfer_domain.rb
|
85
|
+
- lib/dnsimple/commands/update_contact.rb
|
86
|
+
- lib/dnsimple/contact.rb
|
75
87
|
- lib/dnsimple/domain.rb
|
76
88
|
- lib/dnsimple/error.rb
|
77
89
|
- lib/dnsimple/record.rb
|
@@ -80,6 +92,7 @@ files:
|
|
80
92
|
- lib/dnsimple/transfer_order.rb
|
81
93
|
- lib/dnsimple/user.rb
|
82
94
|
- spec/README
|
95
|
+
- spec/contact_spec.rb
|
83
96
|
- spec/domain_spec.rb
|
84
97
|
- spec/record_spec.rb
|
85
98
|
- spec/spec_helper.rb
|
@@ -95,27 +108,32 @@ rdoc_options:
|
|
95
108
|
require_paths:
|
96
109
|
- lib
|
97
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
98
112
|
requirements:
|
99
113
|
- - ">="
|
100
114
|
- !ruby/object:Gem::Version
|
115
|
+
hash: 3
|
101
116
|
segments:
|
102
117
|
- 0
|
103
118
|
version: "0"
|
104
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
105
121
|
requirements:
|
106
122
|
- - ">="
|
107
123
|
- !ruby/object:Gem::Version
|
124
|
+
hash: 3
|
108
125
|
segments:
|
109
126
|
- 0
|
110
127
|
version: "0"
|
111
128
|
requirements: []
|
112
129
|
|
113
130
|
rubyforge_project:
|
114
|
-
rubygems_version: 1.3.
|
131
|
+
rubygems_version: 1.3.7
|
115
132
|
signing_key:
|
116
133
|
specification_version: 3
|
117
134
|
summary: A ruby wrapper for the DNSimple API
|
118
135
|
test_files:
|
136
|
+
- spec/contact_spec.rb
|
119
137
|
- spec/domain_spec.rb
|
120
138
|
- spec/record_spec.rb
|
121
139
|
- spec/spec_helper.rb
|