dnsimple-ruby 1.0.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/.bundle/config +3 -2
  2. data/Gemfile +1 -0
  3. data/Gemfile.lock +38 -30
  4. data/README +5 -0
  5. data/README.rdoc +5 -0
  6. data/README.textile +18 -0
  7. data/VERSION +1 -1
  8. data/bin/dnsimple.rb +2 -0
  9. data/dnsimple-ruby.gemspec +64 -10
  10. data/fixtures/vcr_cassettes/DNSimple_Certificate/_all.yml +44 -0
  11. data/fixtures/vcr_cassettes/DNSimple_Certificate/_purchase.yml +44 -0
  12. data/fixtures/vcr_cassettes/DNSimple_Certificate/_submit.yml +44 -0
  13. data/fixtures/vcr_cassettes/DNSimple_Contact/a_new_contact.yml +16 -18
  14. data/fixtures/vcr_cassettes/DNSimple_Contact/an_existing_contact.yml +15 -17
  15. data/fixtures/vcr_cassettes/DNSimple_Domain/_all.yml +45 -96
  16. data/fixtures/vcr_cassettes/DNSimple_Domain/applying_templates.yml +69 -169
  17. data/fixtures/vcr_cassettes/DNSimple_Domain/creating_a_new_domain.yml +16 -18
  18. data/fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain/by_id.yml +15 -17
  19. data/fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain/by_name.yml +15 -17
  20. data/fixtures/vcr_cassettes/DNSimple_Domain/registration/with_a_new_registrant_contact.yml +16 -18
  21. data/fixtures/vcr_cassettes/DNSimple_Domain/registration/with_an_existing_contact.yml +16 -18
  22. data/fixtures/vcr_cassettes/DNSimple_ExtendedAttribute/list_extended_attributes/for_ca.yml +12 -14
  23. data/fixtures/vcr_cassettes/DNSimple_ExtendedAttribute/list_extended_attributes/for_com.yml +12 -14
  24. data/fixtures/vcr_cassettes/DNSimple_Record/_all.yml +59 -247
  25. data/fixtures/vcr_cassettes/DNSimple_Record/creating_a_new_record.yml +16 -63
  26. data/fixtures/vcr_cassettes/DNSimple_Record/find_a_record.yml +13 -60
  27. data/fixtures/vcr_cassettes/DNSimple_Template/a_template.yml +15 -17
  28. data/fixtures/vcr_cassettes/DNSimple_User/_me.yml +15 -17
  29. data/lib/dnsimple/certificate.rb +49 -6
  30. data/lib/dnsimple/command.rb +10 -0
  31. data/lib/dnsimple/commands/add_service.rb +4 -2
  32. data/lib/dnsimple/commands/purchase_certificate.rb +4 -2
  33. data/lib/dnsimple/commands/submit_certificate.rb +19 -0
  34. data/lib/dnsimple/domain.rb +5 -4
  35. data/lib/dnsimple/record.rb +11 -15
  36. data/spec/certificate_spec.rb +31 -3
  37. data/spec/command_spec.rb +19 -0
  38. data/spec/commands/add_service_spec.rb +29 -0
  39. data/spec/commands/purchase_certificate_spec.rb +14 -0
  40. data/spec/commands/submit_certificate_spec.rb +19 -0
  41. data/spec/contact_spec.rb +1 -1
  42. data/spec/domain_spec.rb +21 -19
  43. data/spec/record_spec.rb +10 -9
  44. data/spec/spec_helper.rb +1 -0
  45. data/spec/user_spec.rb +12 -12
  46. metadata +38 -12
  47. data/fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain.yml +0 -46
@@ -1,54 +1,9 @@
1
1
  ---
2
- - !ruby/struct:VCR::HTTPInteraction
3
- request: !ruby/struct:VCR::Request
4
- method: :get
5
- uri: https://<USERNAME>:<PASSWORD>@test.dnsimple.com:443/domains/testdomain.com
6
- body:
7
- headers:
8
- accept:
9
- - application/json
10
- authorization:
11
- - Basic YW50aG9ueWVkZW5AZ21haWwuY29tOmxldG1laW4=
12
- response: !ruby/struct:VCR::Response
13
- status: !ruby/struct:VCR::ResponseStatus
14
- code: 200
15
- message: OK
16
- headers:
17
- x-ua-compatible:
18
- - IE=Edge,chrome=1
19
- access-control-allow-headers:
20
- - Authorization
21
- x-dnsimple-api-version:
22
- - 1.0.0
23
- etag:
24
- - "\"a8559b2c4cd72b14d06e3074cb55827f\""
25
- access-control-allow-methods:
26
- - "[\"GET\", \"POST\", \"PUT\", \"DELETE\"]"
27
- access-control-allow-origin:
28
- - "*"
29
- content-type:
30
- - application/json; charset=utf-8
31
- x-runtime:
32
- - "0.505668"
33
- date:
34
- - Sun, 22 May 2011 20:58:12 GMT
35
- server:
36
- - nginx/1.0.2
37
- set-cookie:
38
- - _dnsimple_session=BAh7CUkiD3Nlc3Npb25faWQGOgZFRiIlMGY1Zjk2M2M0Y2NlYjc2ZGE3MjI4OTk1NDk4Mzk5Y2VJIg5yZXR1cm5fdG8GOwBGIhwvZG9tYWlucy90ZXN0ZG9tYWluLmNvbUkiFXVzZXJfY3JlZGVudGlhbHMGOwBGSSIBgDhjN2RlMjhiNDYyZjRhYjUzMzEwMzVkNWIzZTNkNGRlNWMyNDQ1NTU1NjNiMGEzOTE1YWM4OTgyZDlmMGFkYzRiNGI4OTA1MzVkZDJjNjA0MjI0NTM1NGE5NTRiOGNkNzczYjE3N2Q3ODA0OGU0ZTk4OGQ1Y2MzNDYwZTBhOTNmBjsAVEkiGHVzZXJfY3JlZGVudGlhbHNfaWQGOwBGaQc%3D--1af6b213e14b2afa15f656d47a2f3c131a2c6710; path=/; HttpOnly
39
- cache-control:
40
- - max-age=0, private, must-revalidate
41
- status:
42
- - 200 OK
43
- transfer-encoding:
44
- - chunked
45
- body: "{\"domain\":{\"created_at\":\"2011-05-22T18:40:47Z\",\"expires_at\":null,\"id\":141,\"lockable\":true,\"name\":\"testdomain.com\",\"name_server_status\":\"inactive\",\"real_time\":true,\"registrant_id\":null,\"registration_status\":\"hosted\",\"updated_at\":\"2011-05-22T20:10:29Z\",\"user_id\":2,\"uses_external_name_servers\":null,\"record_count\":13}}"
46
- http_version: "1.1"
47
2
  - !ruby/struct:VCR::HTTPInteraction
48
3
  request: !ruby/struct:VCR::Request
49
4
  method: :post
50
- uri: https://<USERNAME>:<PASSWORD>@test.dnsimple.com:443/domains/141/records?record[content]=1.2.3.4&record[prio]=&record[ttl]=600&record[name]=&record[record_type]=A
51
- body:
5
+ uri: http://<USERNAME>:<PASSWORD>@localhost:3000/domains/example.com/records
6
+ body: record[ttl]=600&record[prio]=&record[record_type]=A&record[name]=&record[content]=1.2.3.4
52
7
  headers:
53
8
  accept:
54
9
  - application/json
@@ -60,32 +15,30 @@
60
15
  message: Created
61
16
  headers:
62
17
  x-ua-compatible:
63
- - IE=Edge,chrome=1
18
+ - IE=Edge
64
19
  access-control-allow-headers:
65
- - Authorization
20
+ - Authorization,Accepts,Content-Type
66
21
  x-dnsimple-api-version:
67
22
  - 1.0.0
68
23
  location:
69
- - /domains/141/records/193
24
+ - http://localhost:3000/domains/example.com/records/70
70
25
  access-control-allow-methods:
71
- - "[\"GET\", \"POST\", \"PUT\", \"DELETE\"]"
72
- access-control-allow-origin:
73
- - "*"
26
+ - OPTIONS
74
27
  content-type:
75
28
  - application/json; charset=utf-8
76
- x-runtime:
77
- - "0.530016"
29
+ access-control-allow-origin:
30
+ - "*"
78
31
  date:
79
- - Sun, 22 May 2011 20:58:13 GMT
32
+ - Fri, 11 Nov 2011 20:22:26 GMT
80
33
  server:
81
- - nginx/1.0.2
34
+ - WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
35
+ x-runtime:
36
+ - "0.804759"
37
+ content-length:
38
+ - "245"
82
39
  set-cookie:
83
- - _dnsimple_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlM2VlNDRhMTVhM2ZlNGEwY2MwZDIyOGJiNzU3ZWQyMjBJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA4YzdkZTI4YjQ2MmY0YWI1MzMxMDM1ZDViM2UzZDRkZTVjMjQ0NTU1NTYzYjBhMzkxNWFjODk4MmQ5ZjBhZGM0YjRiODkwNTM1ZGQyYzYwNDIyNDUzNTRhOTU0YjhjZDc3M2IxNzdkNzgwNDhlNGU5ODhkNWNjMzQ2MGUwYTkzZgY7AFRJIhh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkH--a9cbf902ea81f9a2df4b211d55b01b119cf67607; path=/; HttpOnly
40
+ - _dnsimple_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlOGZlNTcwZDdlNzdjZGRkZmZjMzIxZjYzNzQwZGM4YjZJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA1YzI0ZTYzOGYwNjFkZWRmN2Y5YTNiYjY3MTdiZjUxMjliZmUwYjdjODg5OGZkZTVhNmEzNGMxZDkwOWUyMmNlNmIzMTc4MzRlZTdmY2RkYjllYjQ3ODdhYjZlMDM1Y2E0ZmEyYmY0MWVkYzJiOWMxZGEwNzYwZDdjMzhmNzY1OAY7AFRJIhh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkG--436bfd6056d83bfaa12a0017bfaefa3eb2cd22ac; path=/; HttpOnly
84
41
  cache-control:
85
42
  - no-cache
86
- status:
87
- - 201 Created
88
- transfer-encoding:
89
- - chunked
90
- body: "{\"record\":{\"content\":\"1.2.3.4\",\"created_at\":\"2011-05-22T20:58:13Z\",\"domain_id\":141,\"domain_service_id\":null,\"id\":193,\"name\":\"\",\"pdns_identifier\":null,\"prio\":null,\"record_type\":\"A\",\"special_type\":null,\"ttl\":600,\"updated_at\":\"2011-05-22T20:58:13Z\"}}"
43
+ body: "{\"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\"}}"
91
44
  http_version: "1.1"
@@ -2,7 +2,7 @@
2
2
  - !ruby/struct:VCR::HTTPInteraction
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: https://<USERNAME>:<PASSWORD>@test.dnsimple.com:443/domains/testdomain.com
5
+ uri: http://<USERNAME>:<PASSWORD>@localhost:3000/domains/example.com/records/70
6
6
  body:
7
7
  headers:
8
8
  accept:
@@ -15,77 +15,30 @@
15
15
  message: OK
16
16
  headers:
17
17
  x-ua-compatible:
18
- - IE=Edge,chrome=1
18
+ - IE=Edge
19
19
  access-control-allow-headers:
20
- - Authorization
20
+ - Authorization,Accepts,Content-Type
21
21
  x-dnsimple-api-version:
22
22
  - 1.0.0
23
23
  etag:
24
- - "\"3b0419b984d57a56633b5454b1f8a1d5\""
24
+ - "\"e44e23e8947baa8e4e07637aaae785a2\""
25
25
  access-control-allow-methods:
26
- - "[\"GET\", \"POST\", \"PUT\", \"DELETE\"]"
27
- access-control-allow-origin:
28
- - "*"
26
+ - OPTIONS
29
27
  content-type:
30
28
  - application/json; charset=utf-8
31
- x-runtime:
32
- - "0.478968"
33
- date:
34
- - Sun, 22 May 2011 20:59:51 GMT
35
- server:
36
- - nginx/1.0.2
37
- set-cookie:
38
- - _dnsimple_session=BAh7CUkiD3Nlc3Npb25faWQGOgZFRiIlN2FiMTZlNDY1NmRiMjg2NzU2Y2NiN2U3NzdhOWZmM2VJIg5yZXR1cm5fdG8GOwBGIhwvZG9tYWlucy90ZXN0ZG9tYWluLmNvbUkiFXVzZXJfY3JlZGVudGlhbHMGOwBGSSIBgDhjN2RlMjhiNDYyZjRhYjUzMzEwMzVkNWIzZTNkNGRlNWMyNDQ1NTU1NjNiMGEzOTE1YWM4OTgyZDlmMGFkYzRiNGI4OTA1MzVkZDJjNjA0MjI0NTM1NGE5NTRiOGNkNzczYjE3N2Q3ODA0OGU0ZTk4OGQ1Y2MzNDYwZTBhOTNmBjsAVEkiGHVzZXJfY3JlZGVudGlhbHNfaWQGOwBGaQc%3D--c55b618661e517b643e1a0822fc1f93ec03b177a; path=/; HttpOnly
39
- cache-control:
40
- - max-age=0, private, must-revalidate
41
- status:
42
- - 200 OK
43
- transfer-encoding:
44
- - chunked
45
- body: "{\"domain\":{\"created_at\":\"2011-05-22T18:40:47Z\",\"expires_at\":null,\"id\":141,\"lockable\":true,\"name\":\"testdomain.com\",\"name_server_status\":\"inactive\",\"real_time\":true,\"registrant_id\":null,\"registration_status\":\"hosted\",\"updated_at\":\"2011-05-22T20:58:17Z\",\"user_id\":2,\"uses_external_name_servers\":null,\"record_count\":14}}"
46
- http_version: "1.1"
47
- - !ruby/struct:VCR::HTTPInteraction
48
- request: !ruby/struct:VCR::Request
49
- method: :get
50
- uri: https://<USERNAME>:<PASSWORD>@test.dnsimple.com:443/domains/141/records/193
51
- body:
52
- headers:
53
- accept:
54
- - application/json
55
- authorization:
56
- - Basic YW50aG9ueWVkZW5AZ21haWwuY29tOmxldG1laW4=
57
- response: !ruby/struct:VCR::Response
58
- status: !ruby/struct:VCR::ResponseStatus
59
- code: 200
60
- message: OK
61
- headers:
62
- x-ua-compatible:
63
- - IE=Edge,chrome=1
64
- access-control-allow-headers:
65
- - Authorization
66
- x-dnsimple-api-version:
67
- - 1.0.0
68
- etag:
69
- - "\"923b04d81bd4e86149b420852f2a6b14\""
70
- access-control-allow-methods:
71
- - "[\"GET\", \"POST\", \"PUT\", \"DELETE\"]"
72
29
  access-control-allow-origin:
73
30
  - "*"
74
- content-type:
75
- - application/json; charset=utf-8
76
- x-runtime:
77
- - "0.237190"
78
31
  date:
79
- - Sun, 22 May 2011 20:59:52 GMT
32
+ - Fri, 11 Nov 2011 20:23:36 GMT
80
33
  server:
81
- - nginx/1.0.2
34
+ - WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
35
+ x-runtime:
36
+ - "0.599019"
37
+ content-length:
38
+ - "245"
82
39
  set-cookie:
83
- - _dnsimple_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlMDUxYzg5MmNlNjE5Njc5MzQ4ZmE1MzZhNzk3OWM0NWJJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA4YzdkZTI4YjQ2MmY0YWI1MzMxMDM1ZDViM2UzZDRkZTVjMjQ0NTU1NTYzYjBhMzkxNWFjODk4MmQ5ZjBhZGM0YjRiODkwNTM1ZGQyYzYwNDIyNDUzNTRhOTU0YjhjZDc3M2IxNzdkNzgwNDhlNGU5ODhkNWNjMzQ2MGUwYTkzZgY7AFRJIhh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkH--46258707ee461fd1b9c888077fc15e59bd586b87; path=/; HttpOnly
40
+ - _dnsimple_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlMWJiN2NjM2IzYTM5MzMzOTUyNzllYjk5MzJlYmQ2YWFJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA1YzI0ZTYzOGYwNjFkZWRmN2Y5YTNiYjY3MTdiZjUxMjliZmUwYjdjODg5OGZkZTVhNmEzNGMxZDkwOWUyMmNlNmIzMTc4MzRlZTdmY2RkYjllYjQ3ODdhYjZlMDM1Y2E0ZmEyYmY0MWVkYzJiOWMxZGEwNzYwZDdjMzhmNzY1OAY7AFRJIhh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkG--a2cdbda5d90cb97836aa557e8d2511b91c1b1b80; path=/; HttpOnly
84
41
  cache-control:
85
42
  - max-age=0, private, must-revalidate
86
- status:
87
- - 200 OK
88
- transfer-encoding:
89
- - chunked
90
- body: "{\"record\":{\"content\":\"1.2.3.4\",\"created_at\":\"2011-05-22T20:58:13Z\",\"domain_id\":141,\"domain_service_id\":null,\"id\":193,\"name\":\"\",\"pdns_identifier\":\"391\",\"prio\":null,\"record_type\":\"A\",\"special_type\":null,\"ttl\":600,\"updated_at\":\"2011-05-22T20:58:16Z\"}}"
43
+ body: "{\"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\"}}"
91
44
  http_version: "1.1"
@@ -2,7 +2,7 @@
2
2
  - !ruby/struct:VCR::HTTPInteraction
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: https://<USERNAME>:<PASSWORD>@test.dnsimple.com:443/templates/googleapps
5
+ uri: http://<USERNAME>:<PASSWORD>@localhost:3000/templates/googleapps
6
6
  body:
7
7
  headers:
8
8
  accept:
@@ -15,32 +15,30 @@
15
15
  message: OK
16
16
  headers:
17
17
  x-ua-compatible:
18
- - IE=Edge,chrome=1
18
+ - IE=Edge
19
19
  access-control-allow-headers:
20
- - Authorization
20
+ - Authorization,Accepts,Content-Type
21
21
  x-dnsimple-api-version:
22
22
  - 1.0.0
23
23
  etag:
24
- - "\"1d07d0160ffe08a33b74f9e1d6672408\""
24
+ - "\"3649a89c5333cc5c491e30a29901f286\""
25
25
  access-control-allow-methods:
26
- - "[\"GET\", \"POST\", \"PUT\", \"DELETE\"]"
27
- access-control-allow-origin:
28
- - "*"
26
+ - OPTIONS
29
27
  content-type:
30
28
  - application/json; charset=utf-8
31
- x-runtime:
32
- - "0.029187"
29
+ access-control-allow-origin:
30
+ - "*"
33
31
  date:
34
- - Sun, 22 May 2011 21:02:35 GMT
32
+ - Fri, 11 Nov 2011 20:26:05 GMT
35
33
  server:
36
- - nginx/1.0.2
34
+ - WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
35
+ x-runtime:
36
+ - "0.301433"
37
+ content-length:
38
+ - "266"
37
39
  set-cookie:
38
- - _dnsimple_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYzYzZmQyMzFhNGZkYTkyZDZkNDIxMDY2NzM3OTgxY2NJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA4YzdkZTI4YjQ2MmY0YWI1MzMxMDM1ZDViM2UzZDRkZTVjMjQ0NTU1NTYzYjBhMzkxNWFjODk4MmQ5ZjBhZGM0YjRiODkwNTM1ZGQyYzYwNDIyNDUzNTRhOTU0YjhjZDc3M2IxNzdkNzgwNDhlNGU5ODhkNWNjMzQ2MGUwYTkzZgY7AFRJIhh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkH--6986703e166c15ee9ccc6e49d60ccb52c46310fe; path=/; HttpOnly
40
+ - _dnsimple_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYjMyMDBiMjQwNDdiN2FlMjE4OTUxMDU5ZGYzY2EyMjNJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA1YzI0ZTYzOGYwNjFkZWRmN2Y5YTNiYjY3MTdiZjUxMjliZmUwYjdjODg5OGZkZTVhNmEzNGMxZDkwOWUyMmNlNmIzMTc4MzRlZTdmY2RkYjllYjQ3ODdhYjZlMDM1Y2E0ZmEyYmY0MWVkYzJiOWMxZGEwNzYwZDdjMzhmNzY1OAY7AFRJIhh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkG--f1d49fb81f9ca5dae40e254e327c1c69b5352921; path=/; HttpOnly
39
41
  cache-control:
40
42
  - max-age=0, private, must-revalidate
41
- status:
42
- - 200 OK
43
- transfer-encoding:
44
- - chunked
45
- body: "{\"dns_template\":{\"created_at\":\"2011-05-22T15:24:28Z\",\"description\":\"The Google Mail Servers and Google Apps CNAME records in a single template.\",\"id\":3,\"name\":\"Google Apps\",\"short_name\":\"googleapps\",\"updated_at\":\"2011-05-22T15:24:28Z\",\"user_id\":null}}"
43
+ body: "{\"dns_template\":{\"created_at\":\"2011-09-04T01:08:50Z\",\"description\":\"The Google Mail Servers and Google Apps CNAME records in a single template.\",\"id\":3,\"name\":\"Google Apps\",\"short_name\":\"googleapps\",\"updated_at\":\"2011-09-04T01:08:50Z\",\"user_id\":null,\"visible\":true}}"
46
44
  http_version: "1.1"
@@ -2,7 +2,7 @@
2
2
  - !ruby/struct:VCR::HTTPInteraction
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: https://<USERNAME>:<PASSWORD>@test.dnsimple.com:443/users/me.json
5
+ uri: http://<USERNAME>:<PASSWORD>@localhost:3000/users/me.json
6
6
  body:
7
7
  headers:
8
8
  authorization:
@@ -13,32 +13,30 @@
13
13
  message: OK
14
14
  headers:
15
15
  x-ua-compatible:
16
- - IE=Edge,chrome=1
16
+ - IE=Edge
17
17
  access-control-allow-headers:
18
- - Authorization
18
+ - Authorization,Accepts,Content-Type
19
19
  x-dnsimple-api-version:
20
20
  - 1.0.0
21
21
  etag:
22
- - "\"e4d5d4d9cb9dc76feeade806f3bd7279\""
22
+ - "\"3aec1a878ad478216d54579f95258697\""
23
23
  access-control-allow-methods:
24
- - "[\"GET\", \"POST\", \"PUT\", \"DELETE\"]"
25
- access-control-allow-origin:
26
- - "*"
24
+ - OPTIONS
27
25
  content-type:
28
26
  - application/json; charset=utf-8
29
- x-runtime:
30
- - "0.265082"
27
+ access-control-allow-origin:
28
+ - "*"
31
29
  date:
32
- - Sun, 22 May 2011 17:22:11 GMT
30
+ - Fri, 11 Nov 2011 20:33:01 GMT
33
31
  server:
34
- - nginx/1.0.2
32
+ - WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
33
+ x-runtime:
34
+ - "5.589996"
35
+ content-length:
36
+ - "325"
35
37
  set-cookie:
36
- - _dnsimple_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlMWU2YmZlM2RiMTYzYjVjMGU3MDkxNmJkNDQ2YzY1ODZJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA4YzdkZTI4YjQ2MmY0YWI1MzMxMDM1ZDViM2UzZDRkZTVjMjQ0NTU1NTYzYjBhMzkxNWFjODk4MmQ5ZjBhZGM0YjRiODkwNTM1ZGQyYzYwNDIyNDUzNTRhOTU0YjhjZDc3M2IxNzdkNzgwNDhlNGU5ODhkNWNjMzQ2MGUwYTkzZgY7AFRJIhh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkH--bf86feb7fc8ebc12478b58fb30b6da5a6c95ed01; path=/; HttpOnly
38
+ - _dnsimple_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlZTBlZTI5ZGMzYmNkZDgxY2QzMjZmMTQwZWEwOTdmMDVJIhV1c2VyX2NyZWRlbnRpYWxzBjsARkkiAYA1YzI0ZTYzOGYwNjFkZWRmN2Y5YTNiYjY3MTdiZjUxMjliZmUwYjdjODg5OGZkZTVhNmEzNGMxZDkwOWUyMmNlNmIzMTc4MzRlZTdmY2RkYjllYjQ3ODdhYjZlMDM1Y2E0ZmEyYmY0MWVkYzJiOWMxZGEwNzYwZDdjMzhmNzY1OAY7AFRJIhh1c2VyX2NyZWRlbnRpYWxzX2lkBjsARmkG--ec4d0fa610542fdbeb1dca4838d8b4bb91e8597a; path=/; HttpOnly
37
39
  cache-control:
38
40
  - max-age=0, private, must-revalidate
39
- status:
40
- - 200 OK
41
- transfer-encoding:
42
- - chunked
43
- body: "{\"user\":{\"access_code\":null,\"created_at\":\"2011-05-02T06:56:12Z\",\"default_contact_id\":2,\"email\":\"anthonyeden@gmail.com\",\"failed_login_count\":0,\"first_name\":null,\"id\":2,\"last_name\":null,\"login_count\":4,\"referral_token\":\"95cbf1f2231c8b\",\"style\":\"dark\",\"updated_at\":\"2011-05-22T17:22:11Z\",\"domain_count\":14,\"domain_limit\":500}}"
41
+ body: "{\"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}}"
44
42
  http_version: "1.1"
@@ -25,21 +25,45 @@ module DNSimple #:nodoc:
25
25
  end
26
26
  end
27
27
 
28
+ # Get the fully-qualified domain name for the certificate. This is the
29
+ # domain.name joined with the certificate name, separated by a period.
28
30
  def fqdn
29
31
  [name, domain.name].delete_if { |p| p !~ DNSimple::BLANK_REGEX }.join(".")
30
32
  end
31
33
 
32
- def self.purchase(domain_name, name, options={})
33
- domain = DNSimple::Domain.find(domain_name)
34
+ def submit(approver_email, options={})
35
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
36
+ options.merge!(:body => {:certificate => {:approver_email => approver_email}})
37
+
38
+ response = self.class.put("#{DNSimple::Client.base_uri}/domains/#{domain.name}/certificates/#{id}/submit", options)
39
+
40
+ pp response if DNSimple::Client.debug?
34
41
 
42
+ case response.code
43
+ when 200
44
+ return DNSimple::Certificate.new({:domain => domain}.merge(response["certificate"]))
45
+ when 401
46
+ raise RuntimeError, "Authentication failed"
47
+ else
48
+ raise DNSimple::Error.new("#{name}.#{domain.name}", response["errors"])
49
+ end
50
+ end
51
+
52
+ # Purchase a certificate under the given domain with the given name. The
53
+ # name will be appended to the domain name, and thus should only be the
54
+ # subdomain part.
55
+ #
56
+ # Example: DNSimple::Certificate.purchase(domain, 'www', contact)
57
+ def self.purchase(domain, name, contact, options={})
35
58
  certificate_hash = {
36
- :name => name
59
+ :name => name,
60
+ :contact_id => contact.id
37
61
  }
38
62
 
39
63
  options.merge!(DNSimple::Client.standard_options_with_credentials)
40
64
  options.merge!({:body => {:certificate => certificate_hash}})
41
65
 
42
- response = self.post("#{DNSimple::Client.base_uri}/domains/#{domain.id}/certificates", options)
66
+ response = self.post("#{DNSimple::Client.base_uri}/domains/#{domain.name}/certificates", options)
43
67
 
44
68
  pp response if DNSimple::Client.debug?
45
69
 
@@ -49,10 +73,29 @@ module DNSimple #:nodoc:
49
73
  when 401
50
74
  raise RuntimeError, "Authentication failed"
51
75
  when 406
52
- raise DNSimple::CertificateExists.new("#{name}.#{domain_name}", response["errors"])
76
+ raise DNSimple::CertificateExists.new("#{name}.#{domain.name}", response["errors"])
53
77
  else
54
- raise DNSimple::Error.new("#{name}.#{domain_name}", response["errors"])
78
+ raise DNSimple::Error.new("#{name}.#{domain.name}", response["errors"])
55
79
  end
56
80
  end
81
+
82
+ # Get an array of all certificates for the given domain.
83
+ def self.all(domain, options={})
84
+ options.merge!(DNSimple::Client.standard_options_with_credentials)
85
+
86
+ response = self.get("#{DNSimple::Client.base_uri}/domains/#{domain.name}/certificates", options)
87
+
88
+ pp response if DNSimple::Client.debug?
89
+
90
+ case response.code
91
+ when 200
92
+ response.map { |r| DNSimple::Certificate.new({:domain => domain}.merge(r["certificate"])) }
93
+ when 401
94
+ raise RuntimeError, "Authentication failed"
95
+ else
96
+ raise DNSimple::Error.new("#{name}.#{domain.name} list certificates error", response["errors"])
97
+ end
98
+ end
99
+
57
100
  end
58
101
  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
@@ -1,13 +1,15 @@
1
+ require 'dnsimple/command'
2
+
1
3
  module DNSimple
2
4
  module Commands
3
- class AddService
5
+ class AddService < Command
4
6
  def execute(args, options={})
5
7
  domain_name = args.shift
6
8
  domain = Domain.find(domain_name)
7
9
  short_name = args.shift
8
10
  service = Service.find(short_name)
9
11
  domain.add_service(short_name)
10
- puts "Added #{service.name} to #{domain_name}"
12
+ say "Added #{service.name} to #{domain_name}"
11
13
  end
12
14
  end
13
15
  end
@@ -1,12 +1,14 @@
1
+ require 'dnsimple/command'
2
+
1
3
  module DNSimple
2
4
  module Commands
3
- class PurchaseCertificate
5
+ class PurchaseCertificate < Command
4
6
  def execute(args, options={})
5
7
  domain_name = args.shift
6
8
  name = args.empty? ? '' : args.shift
7
9
 
8
10
  certificate = Certificate.purchase(domain_name, name)
9
- puts "Purchased certificate for #{certificate.fqdn}"
11
+ say "Purchased certificate for #{certificate.fqdn}"
10
12
  end
11
13
  end
12
14
  end
@@ -0,0 +1,19 @@
1
+ require 'dnsimple/command'
2
+
3
+ module DNSimple
4
+ module Commands
5
+ class SubmitCertificate < Command
6
+ def execute(args, options={})
7
+ domain_name = args.shift
8
+ certificate_id = args.shift
9
+ approver_email = args.shift
10
+
11
+ domain = DNSimple::Domain.find(domain_name)
12
+ certificate = DNSimple::Certificate.find(domain, certificate_id)
13
+ certificate.submit(approver_email)
14
+
15
+ say "Certificate submitted, authorization by email required"
16
+ end
17
+ end
18
+ end
19
+ end