dnsimple-ruby 1.3.2 → 1.4.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.
- 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
@@ -1,44 +1,51 @@
|
|
1
|
-
---
|
2
|
-
|
3
|
-
|
4
|
-
method:
|
5
|
-
uri:
|
6
|
-
body:
|
7
|
-
|
8
|
-
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://<USERNAME>:<PASSWORD>@test.dnsimple.com/domains/example.com/records/70
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
9
11
|
- application/json
|
10
|
-
|
12
|
+
Authorization:
|
11
13
|
- Basic YW50aG9ueWVkZW5AZ21haWwuY29tOmxldG1laW4=
|
12
|
-
response:
|
13
|
-
status:
|
14
|
+
response:
|
15
|
+
status:
|
14
16
|
code: 200
|
15
17
|
message: OK
|
16
|
-
headers:
|
17
|
-
|
18
|
+
headers:
|
19
|
+
X-Ua-Compatible:
|
18
20
|
- IE=Edge
|
19
|
-
|
21
|
+
Access-Control-Allow-Headers:
|
20
22
|
- Authorization,Accepts,Content-Type
|
21
|
-
|
23
|
+
X-Dnsimple-Api-Version:
|
22
24
|
- 1.0.0
|
23
|
-
|
24
|
-
- "
|
25
|
-
|
25
|
+
Etag:
|
26
|
+
- ! '"e44e23e8947baa8e4e07637aaae785a2"'
|
27
|
+
Access-Control-Allow-Methods:
|
26
28
|
- OPTIONS
|
27
|
-
|
29
|
+
Content-Type:
|
28
30
|
- application/json; charset=utf-8
|
29
|
-
|
30
|
-
-
|
31
|
-
|
31
|
+
Access-Control-Allow-Origin:
|
32
|
+
- ! '*'
|
33
|
+
Date:
|
32
34
|
- Fri, 11 Nov 2011 20:23:36 GMT
|
33
|
-
|
35
|
+
Server:
|
34
36
|
- WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
|
35
|
-
|
36
|
-
-
|
37
|
-
|
38
|
-
-
|
39
|
-
|
40
|
-
- _dnsimple_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlMWJiN2NjM2IzYTM5MzMzOTUyNzllYjk5MzJlYmQ2YWFJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA1YzI0ZTYzOGYwNjFkZWRmN2Y5YTNiYjY3MTdiZjUxMjliZmUwYjdjODg5OGZkZTVhNmEzNGMxZDkwOWUyMmNlNmIzMTc4MzRlZTdmY2RkYjllYjQ3ODdhYjZlMDM1Y2E0ZmEyYmY0MWVkYzJiOWMxZGEwNzYwZDdjMzhmNzY1OAY7AFRJIhh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkG--a2cdbda5d90cb97836aa557e8d2511b91c1b1b80;
|
41
|
-
|
37
|
+
X-Runtime:
|
38
|
+
- '0.599019'
|
39
|
+
Content-Length:
|
40
|
+
- '245'
|
41
|
+
Set-Cookie:
|
42
|
+
- _dnsimple_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlMWJiN2NjM2IzYTM5MzMzOTUyNzllYjk5MzJlYmQ2YWFJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA1YzI0ZTYzOGYwNjFkZWRmN2Y5YTNiYjY3MTdiZjUxMjliZmUwYjdjODg5OGZkZTVhNmEzNGMxZDkwOWUyMmNlNmIzMTc4MzRlZTdmY2RkYjllYjQ3ODdhYjZlMDM1Y2E0ZmEyYmY0MWVkYzJiOWMxZGEwNzYwZDdjMzhmNzY1OAY7AFRJIhh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkG--a2cdbda5d90cb97836aa557e8d2511b91c1b1b80;
|
43
|
+
path=/; HttpOnly
|
44
|
+
Cache-Control:
|
42
45
|
- max-age=0, private, must-revalidate
|
43
|
-
body:
|
44
|
-
|
46
|
+
body:
|
47
|
+
encoding: UTF-8
|
48
|
+
string: ! '{"record":{"content":"1.2.3.4","created_at":"2011-11-11T20:22:26Z","domain_id":39,"domain_service_id":null,"id":70,"name":"","pdns_identifier":null,"prio":null,"record_type":"A","special_type":null,"ttl":600,"updated_at":"2011-11-11T20:22:26Z"}}'
|
49
|
+
http_version: '1.1'
|
50
|
+
recorded_at: Thu, 06 Sep 2012 18:52:19 GMT
|
51
|
+
recorded_with: VCR 2.2.5
|
@@ -1,44 +1,53 @@
|
|
1
|
-
---
|
2
|
-
|
3
|
-
|
4
|
-
method:
|
5
|
-
uri:
|
6
|
-
body:
|
7
|
-
|
8
|
-
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://<USERNAME>:<PASSWORD>@test.dnsimple.com/templates/googleapps
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
9
11
|
- application/json
|
10
|
-
|
12
|
+
Authorization:
|
11
13
|
- Basic YW50aG9ueWVkZW5AZ21haWwuY29tOmxldG1laW4=
|
12
|
-
response:
|
13
|
-
status:
|
14
|
+
response:
|
15
|
+
status:
|
14
16
|
code: 200
|
15
17
|
message: OK
|
16
|
-
headers:
|
17
|
-
|
18
|
+
headers:
|
19
|
+
X-Ua-Compatible:
|
18
20
|
- IE=Edge
|
19
|
-
|
21
|
+
Access-Control-Allow-Headers:
|
20
22
|
- Authorization,Accepts,Content-Type
|
21
|
-
|
23
|
+
X-Dnsimple-Api-Version:
|
22
24
|
- 1.0.0
|
23
|
-
|
24
|
-
- "
|
25
|
-
|
25
|
+
Etag:
|
26
|
+
- ! '"3649a89c5333cc5c491e30a29901f286"'
|
27
|
+
Access-Control-Allow-Methods:
|
26
28
|
- OPTIONS
|
27
|
-
|
29
|
+
Content-Type:
|
28
30
|
- application/json; charset=utf-8
|
29
|
-
|
30
|
-
-
|
31
|
-
|
31
|
+
Access-Control-Allow-Origin:
|
32
|
+
- ! '*'
|
33
|
+
Date:
|
32
34
|
- Fri, 11 Nov 2011 20:26:05 GMT
|
33
|
-
|
35
|
+
Server:
|
34
36
|
- WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
|
35
|
-
|
36
|
-
-
|
37
|
-
|
38
|
-
-
|
39
|
-
|
40
|
-
- _dnsimple_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYjMyMDBiMjQwNDdiN2FlMjE4OTUxMDU5ZGYzY2EyMjNJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA1YzI0ZTYzOGYwNjFkZWRmN2Y5YTNiYjY3MTdiZjUxMjliZmUwYjdjODg5OGZkZTVhNmEzNGMxZDkwOWUyMmNlNmIzMTc4MzRlZTdmY2RkYjllYjQ3ODdhYjZlMDM1Y2E0ZmEyYmY0MWVkYzJiOWMxZGEwNzYwZDdjMzhmNzY1OAY7AFRJIhh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkG--f1d49fb81f9ca5dae40e254e327c1c69b5352921;
|
41
|
-
|
37
|
+
X-Runtime:
|
38
|
+
- '0.301433'
|
39
|
+
Content-Length:
|
40
|
+
- '266'
|
41
|
+
Set-Cookie:
|
42
|
+
- _dnsimple_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYjMyMDBiMjQwNDdiN2FlMjE4OTUxMDU5ZGYzY2EyMjNJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA1YzI0ZTYzOGYwNjFkZWRmN2Y5YTNiYjY3MTdiZjUxMjliZmUwYjdjODg5OGZkZTVhNmEzNGMxZDkwOWUyMmNlNmIzMTc4MzRlZTdmY2RkYjllYjQ3ODdhYjZlMDM1Y2E0ZmEyYmY0MWVkYzJiOWMxZGEwNzYwZDdjMzhmNzY1OAY7AFRJIhh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkG--f1d49fb81f9ca5dae40e254e327c1c69b5352921;
|
43
|
+
path=/; HttpOnly
|
44
|
+
Cache-Control:
|
42
45
|
- max-age=0, private, must-revalidate
|
43
|
-
body:
|
44
|
-
|
46
|
+
body:
|
47
|
+
encoding: UTF-8
|
48
|
+
string: ! '{"dns_template":{"created_at":"2011-09-04T01:08:50Z","description":"The
|
49
|
+
Google Mail Servers and Google Apps CNAME records in a single template.","id":3,"name":"Google
|
50
|
+
Apps","short_name":"googleapps","updated_at":"2011-09-04T01:08:50Z","user_id":null,"visible":true}}'
|
51
|
+
http_version: '1.1'
|
52
|
+
recorded_at: Thu, 06 Sep 2012 18:52:19 GMT
|
53
|
+
recorded_with: VCR 2.2.5
|
@@ -1,42 +1,49 @@
|
|
1
|
-
---
|
2
|
-
|
3
|
-
|
4
|
-
method:
|
5
|
-
uri:
|
6
|
-
body:
|
7
|
-
|
8
|
-
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://<USERNAME>:<PASSWORD>@test.dnsimple.com/users/me
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Authorization:
|
9
11
|
- Basic YW50aG9ueWVkZW5AZ21haWwuY29tOmxldG1laW4=
|
10
|
-
response:
|
11
|
-
status:
|
12
|
+
response:
|
13
|
+
status:
|
12
14
|
code: 200
|
13
15
|
message: OK
|
14
|
-
headers:
|
15
|
-
|
16
|
+
headers:
|
17
|
+
X-Ua-Compatible:
|
16
18
|
- IE=Edge
|
17
|
-
|
19
|
+
Access-Control-Allow-Headers:
|
18
20
|
- Authorization,Accepts,Content-Type
|
19
|
-
|
21
|
+
X-Dnsimple-Api-Version:
|
20
22
|
- 1.0.0
|
21
|
-
|
22
|
-
- "
|
23
|
-
|
23
|
+
Etag:
|
24
|
+
- ! '"3aec1a878ad478216d54579f95258697"'
|
25
|
+
Access-Control-Allow-Methods:
|
24
26
|
- OPTIONS
|
25
|
-
|
27
|
+
Content-Type:
|
26
28
|
- application/json; charset=utf-8
|
27
|
-
|
28
|
-
-
|
29
|
-
|
29
|
+
Access-Control-Allow-Origin:
|
30
|
+
- ! '*'
|
31
|
+
Date:
|
30
32
|
- Fri, 11 Nov 2011 20:33:01 GMT
|
31
|
-
|
33
|
+
Server:
|
32
34
|
- WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
|
33
|
-
|
34
|
-
-
|
35
|
-
|
36
|
-
-
|
37
|
-
|
38
|
-
- _dnsimple_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlZTBlZTI5ZGMzYmNkZDgxY2QzMjZmMTQwZWEwOTdmMDVJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA1YzI0ZTYzOGYwNjFkZWRmN2Y5YTNiYjY3MTdiZjUxMjliZmUwYjdjODg5OGZkZTVhNmEzNGMxZDkwOWUyMmNlNmIzMTc4MzRlZTdmY2RkYjllYjQ3ODdhYjZlMDM1Y2E0ZmEyYmY0MWVkYzJiOWMxZGEwNzYwZDdjMzhmNzY1OAY7AFRJIhh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkG--ec4d0fa610542fdbeb1dca4838d8b4bb91e8597a;
|
39
|
-
|
35
|
+
X-Runtime:
|
36
|
+
- '5.589996'
|
37
|
+
Content-Length:
|
38
|
+
- '325'
|
39
|
+
Set-Cookie:
|
40
|
+
- _dnsimple_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlZTBlZTI5ZGMzYmNkZDgxY2QzMjZmMTQwZWEwOTdmMDVJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA1YzI0ZTYzOGYwNjFkZWRmN2Y5YTNiYjY3MTdiZjUxMjliZmUwYjdjODg5OGZkZTVhNmEzNGMxZDkwOWUyMmNlNmIzMTc4MzRlZTdmY2RkYjllYjQ3ODdhYjZlMDM1Y2E0ZmEyYmY0MWVkYzJiOWMxZGEwNzYwZDdjMzhmNzY1OAY7AFRJIhh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkG--ec4d0fa610542fdbeb1dca4838d8b4bb91e8597a;
|
41
|
+
path=/; HttpOnly
|
42
|
+
Cache-Control:
|
40
43
|
- max-age=0, private, must-revalidate
|
41
|
-
body:
|
42
|
-
|
44
|
+
body:
|
45
|
+
encoding: UTF-8
|
46
|
+
string: ! '{"user":{"access_code":null,"created_at":"2011-09-25T09:11:23Z","default_contact_id":null,"email":"anthonyeden@gmail.com","failed_login_count":0,"first_name":null,"id":1,"last_name":null,"login_count":2,"referral_token":"a93b6fa7c98483","style":"light","updated_at":"2011-11-11T20:32:56Z","domain_count":5,"domain_limit":10}}'
|
47
|
+
http_version: '1.1'
|
48
|
+
recorded_at: Thu, 06 Sep 2012 18:52:19 GMT
|
49
|
+
recorded_with: VCR 2.2.5
|
data/lib/dnsimple.rb
CHANGED
@@ -1,8 +1,21 @@
|
|
1
|
-
require 'pp'
|
2
1
|
require 'httparty'
|
3
2
|
|
4
3
|
module DNSimple
|
4
|
+
|
5
5
|
BLANK_REGEX = /\S+/
|
6
|
+
|
7
|
+
# Echoes a deprecation warning message.
|
8
|
+
#
|
9
|
+
# @param [String] message The message to display.
|
10
|
+
# @return [void]
|
11
|
+
#
|
12
|
+
# @api internal
|
13
|
+
# @private
|
14
|
+
def self.deprecate(message = nil)
|
15
|
+
message ||= "You are using deprecated behavior which will be removed from the next major or minor release."
|
16
|
+
warn("DEPRECATION WARNING: #{message}")
|
17
|
+
end
|
18
|
+
|
6
19
|
end
|
7
20
|
|
8
21
|
require 'dnsimple/base'
|
data/lib/dnsimple/base.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
attributes
|
4
|
-
|
5
|
-
|
1
|
+
module DNSimple
|
2
|
+
class Base
|
3
|
+
def initialize(attributes = {})
|
4
|
+
attributes.each do |key, value|
|
5
|
+
m = "#{key}=".to_sym
|
6
|
+
self.send(m, value) if self.respond_to?(m)
|
7
|
+
end
|
6
8
|
end
|
7
9
|
end
|
8
10
|
end
|
data/lib/dnsimple/certificate.rb
CHANGED
@@ -1,123 +1,128 @@
|
|
1
|
-
|
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
|
1
|
+
module DNSimple
|
6
2
|
|
7
|
-
#
|
8
|
-
|
3
|
+
# Represents an SSL certificate that has been purchased.
|
4
|
+
#
|
5
|
+
# The certificate must also be submitted using the #submit method
|
6
|
+
# before the Certificate Authority will issue a signed certificate.
|
7
|
+
class Certificate < Base
|
9
8
|
|
10
|
-
|
9
|
+
# The certificate ID in DNSimple
|
10
|
+
attr_accessor :id
|
11
11
|
|
12
|
-
|
13
|
-
attr_accessor :name
|
12
|
+
attr_accessor :domain
|
14
13
|
|
15
|
-
|
16
|
-
|
14
|
+
# The subdomain on the certificate
|
15
|
+
attr_accessor :name
|
17
16
|
|
18
|
-
|
19
|
-
|
17
|
+
# The private key, if DNSimple generated the Certificate Signing Request
|
18
|
+
attr_accessor :private_key
|
20
19
|
|
21
|
-
|
22
|
-
|
20
|
+
# The SSL certificate, if it has been issued by the Certificate Authority
|
21
|
+
attr_accessor :ssl_certificate
|
23
22
|
|
24
|
-
|
25
|
-
|
23
|
+
# The Certificate Signing Request
|
24
|
+
attr_accessor :csr
|
26
25
|
|
27
|
-
|
28
|
-
|
26
|
+
# The Certificate status
|
27
|
+
attr_accessor :certificate_status
|
29
28
|
|
30
|
-
|
31
|
-
|
29
|
+
# The date the Certificate order was placed
|
30
|
+
attr_accessor :order_date
|
32
31
|
|
33
|
-
|
34
|
-
|
32
|
+
# The date the Certificate will expire
|
33
|
+
attr_accessor :expiration_date
|
35
34
|
|
36
|
-
|
37
|
-
|
35
|
+
# The approver email address
|
36
|
+
attr_accessor :approver_email
|
38
37
|
|
39
|
-
|
40
|
-
|
38
|
+
# An array of all emails that can be used to approve the certificate
|
39
|
+
attr_accessor :available_approver_emails
|
41
40
|
|
42
|
-
|
43
|
-
|
41
|
+
# When the certificate was purchased
|
42
|
+
attr_accessor :created_at
|
44
43
|
|
45
|
-
|
46
|
-
|
47
|
-
def fqdn
|
48
|
-
[name, domain.name].delete_if { |p| p !~ DNSimple::BLANK_REGEX }.join(".")
|
49
|
-
end
|
44
|
+
# When the certificate was last updated
|
45
|
+
attr_accessor :updated_at
|
50
46
|
|
51
|
-
def submit(approver_email, options={})
|
52
|
-
raise DNSimple::Error, "Approver email is required" unless approver_email
|
53
47
|
|
54
|
-
|
48
|
+
# Get the fully-qualified domain name for the certificate. This is the
|
49
|
+
# domain.name joined with the certificate name, separated by a period.
|
50
|
+
def fqdn
|
51
|
+
[name, domain.name].delete_if { |p| p !~ DNSimple::BLANK_REGEX }.join(".")
|
52
|
+
end
|
53
|
+
|
54
|
+
def submit(approver_email, options={})
|
55
|
+
raise DNSimple::Error, "Approver email is required" unless approver_email
|
55
56
|
|
56
|
-
|
57
|
+
options.merge!(:body => {:certificate => {:approver_email => approver_email}})
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
response = DNSimple::Client.put("domains/#{domain.name}/certificates/#{id}/submit", options)
|
60
|
+
|
61
|
+
case response.code
|
62
|
+
when 200
|
63
|
+
Certificate.new({ :domain => domain }.merge(response["certificate"]))
|
64
|
+
else
|
65
|
+
raise RequestError.new("Error submitting certificate", response)
|
66
|
+
end
|
63
67
|
end
|
64
|
-
end
|
65
68
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
69
|
+
# Purchase a certificate under the given domain with the given name. The
|
70
|
+
# name will be appended to the domain name, and thus should only be the
|
71
|
+
# subdomain part.
|
72
|
+
#
|
73
|
+
# Example: DNSimple::Certificate.purchase(domain, 'www', contact)
|
74
|
+
#
|
75
|
+
# Please note that by invoking this method DNSimple will immediately charge
|
76
|
+
# your credit card on file at DNSimple for the full certificate price.
|
77
|
+
#
|
78
|
+
# For wildcard certificates an asterisk must appear in the name.
|
79
|
+
#
|
80
|
+
# Example: DNSimple::Certificate.purchase(domain, '*', contact)
|
81
|
+
def self.purchase(domain, name, contact, options={})
|
82
|
+
certificate_hash = {
|
83
|
+
:name => name,
|
84
|
+
:contact_id => contact.id
|
85
|
+
}
|
86
|
+
|
87
|
+
options.merge!({:body => {:certificate => certificate_hash}})
|
88
|
+
|
89
|
+
response = DNSimple::Client.post("domains/#{domain.name}/certificates", options)
|
90
|
+
|
91
|
+
case response.code
|
92
|
+
when 201
|
93
|
+
new({ :domain => domain }.merge(response["certificate"]))
|
94
|
+
when 406
|
95
|
+
raise RecordExists, "Certificate for #{domain.name} already exists"
|
96
|
+
else
|
97
|
+
raise RequestError.new("Error purchasing certificate", response)
|
98
|
+
end
|
95
99
|
end
|
96
|
-
end
|
97
100
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
+
# Get an array of all certificates for the given domain.
|
102
|
+
def self.all(domain, options={})
|
103
|
+
response = DNSimple::Client.get("domains/#{domain.name}/certificates", options)
|
101
104
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
105
|
+
case response.code
|
106
|
+
when 200
|
107
|
+
response.map { |r| new({:domain => domain}.merge(r["certificate"])) }
|
108
|
+
else
|
109
|
+
raise RequestError.new("Error listing certificates", response)
|
110
|
+
end
|
107
111
|
end
|
108
|
-
end
|
109
112
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
113
|
+
# Find a specific certificate for the given domain.
|
114
|
+
def self.find(domain, id, options = {})
|
115
|
+
response = DNSimple::Client.get("domains/#{domain.name}/certificates/#{id}", options)
|
116
|
+
|
117
|
+
case response.code
|
118
|
+
when 200
|
119
|
+
new({:domain => domain}.merge(response["certificate"]))
|
120
|
+
when 404
|
121
|
+
raise RecordNotFound, "Could not find certificate #{id} for domain #{domain.name}"
|
122
|
+
else
|
123
|
+
raise RequestError.new("Error finding certificate", response)
|
124
|
+
end
|
121
125
|
end
|
126
|
+
|
122
127
|
end
|
123
128
|
end
|