dnsimple 3.0.0 → 3.1.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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -2
  3. data/README.md +5 -4
  4. data/dnsimple.gemspec +3 -3
  5. data/lib/dnsimple.rb +1 -0
  6. data/lib/dnsimple/client.rb +37 -11
  7. data/lib/dnsimple/client/accounts.rb +26 -0
  8. data/lib/dnsimple/client/clients.rb +15 -1
  9. data/lib/dnsimple/client/contacts.rb +16 -7
  10. data/lib/dnsimple/client/domains.rb +20 -6
  11. data/lib/dnsimple/client/domains_email_forwards.rb +17 -8
  12. data/lib/dnsimple/client/identity.rb +2 -5
  13. data/lib/dnsimple/client/registrar.rb +1 -1
  14. data/lib/dnsimple/client/registrar_auto_renewal.rb +2 -2
  15. data/lib/dnsimple/client/services.rb +15 -3
  16. data/lib/dnsimple/client/templates.rb +16 -4
  17. data/lib/dnsimple/client/templates_records.rb +135 -0
  18. data/lib/dnsimple/client/tlds.rb +13 -4
  19. data/lib/dnsimple/client/webhooks.rb +11 -2
  20. data/lib/dnsimple/client/zones.rb +19 -5
  21. data/lib/dnsimple/client/zones_records.rb +48 -11
  22. data/lib/dnsimple/default.rb +2 -2
  23. data/lib/dnsimple/extra.rb +3 -3
  24. data/lib/dnsimple/options.rb +53 -0
  25. data/lib/dnsimple/struct.rb +2 -0
  26. data/lib/dnsimple/struct/account.rb +3 -0
  27. data/lib/dnsimple/struct/contact.rb +0 -3
  28. data/lib/dnsimple/struct/record.rb +2 -2
  29. data/lib/dnsimple/struct/template_record.rb +34 -0
  30. data/lib/dnsimple/struct/whoami.rb +30 -0
  31. data/lib/dnsimple/version.rb +1 -1
  32. data/spec/dnsimple/client/accounts_spec.rb +31 -0
  33. data/spec/dnsimple/client/contacts_spec.rb +19 -2
  34. data/spec/dnsimple/client/domains_email_forwards_spec.rb +18 -1
  35. data/spec/dnsimple/client/domains_spec.rb +30 -1
  36. data/spec/dnsimple/client/identity_spec.rb +6 -6
  37. data/spec/dnsimple/client/services_spec.rb +30 -1
  38. data/spec/dnsimple/client/templates_records_spec.rb +226 -0
  39. data/spec/dnsimple/client/templates_spec.rb +30 -1
  40. data/spec/dnsimple/client/tlds_spec.rb +18 -1
  41. data/spec/dnsimple/client/webhooks_spec.rb +6 -0
  42. data/spec/dnsimple/client/zones_records_spec.rb +30 -1
  43. data/spec/dnsimple/client/zones_spec.rb +30 -1
  44. data/spec/dnsimple/client_spec.rb +35 -14
  45. data/spec/dnsimple/options/base_spec.rb +22 -0
  46. data/spec/dnsimple/options/list_options_spec.rb +100 -0
  47. data/spec/fixtures.http/accounts/success-account.http +21 -0
  48. data/spec/fixtures.http/accounts/success-user.http +21 -0
  49. data/spec/fixtures.http/createContact/created.http +1 -1
  50. data/spec/fixtures.http/createTemplateRecord/created.http +17 -0
  51. data/spec/fixtures.http/deleteTemplateRecord/success.http +13 -0
  52. data/spec/fixtures.http/getContact/success.http +1 -1
  53. data/spec/fixtures.http/getTemplateRecord/success.http +17 -0
  54. data/spec/fixtures.http/listContacts/success.http +1 -1
  55. data/spec/fixtures.http/listTemplateRecords/success.http +17 -0
  56. data/spec/fixtures.http/notfound-template.http +12 -0
  57. data/spec/fixtures.http/updateContact/success.http +1 -1
  58. data/spec/spec_helper.rb +0 -11
  59. metadata +35 -2
@@ -7,15 +7,12 @@ module Dnsimple
7
7
  # @see https://developer.dnsimple.com/v2/identity/#whoami
8
8
  #
9
9
  # @param [Hash] options
10
- # @return [Dnsimple::Response<Hash>]
10
+ # @return [Dnsimple::Response<Dnsimple::Struct::Whoami>]
11
11
  # @raise [Dnsimple::RequestError]
12
12
  def whoami(options = {})
13
13
  response = client.get(Client.versioned("/whoami"), options)
14
14
 
15
- data = response["data"]
16
- account = data["account"] ? Struct::Account.new(data["account"]) : nil
17
- user = data["user"] ? Struct::User.new(data["user"]) : nil
18
- Response.new(response, account: account, user: user)
15
+ Dnsimple::Response.new(response, Struct::Whoami.new(response["data"]))
19
16
  end
20
17
 
21
18
 
@@ -28,7 +28,7 @@ module Dnsimple
28
28
  #
29
29
  # @example Initiate the registration of example.com using the contact 1234 as registrant
30
30
  # including WHOIS privacy for the domain and enabling auto renewal:
31
- # client.registrar.register(1010, "example.com", registrant_id: 1234, privacy: true, auto_renew: true)
31
+ # client.registrar.register(1010, "example.com", registrant_id: 1234, private_whois: true, auto_renew: true)
32
32
  #
33
33
  # @param [Fixnum] account_id the account ID
34
34
  # @param [#to_s] domain_name the domain name to register
@@ -6,7 +6,7 @@ module Dnsimple
6
6
  #
7
7
  # @see https://developer.dnsimple.com/v2/registrar/auto-renewal/
8
8
  #
9
- # @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
9
+ # @param [Fixnum] account_id the account ID
10
10
  # @param [#to_s] domain_name the domain name
11
11
  # @param [Hash] options
12
12
  # @return [Dnsimple::Response<nil>]
@@ -23,7 +23,7 @@ module Dnsimple
23
23
  #
24
24
  # @see https://developer.dnsimple.com/v2/registrar/auto-renewal/
25
25
  #
26
- # @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
26
+ # @param [Fixnum] account_id the account ID
27
27
  # @param [#to_s] domain_name the domain name
28
28
  # @param [Hash] options
29
29
  # @return [Dnsimple::Response<nil>]
@@ -9,13 +9,22 @@ module Dnsimple
9
9
  # @example List one-click services:
10
10
  # client.services.list_services
11
11
  #
12
- # @param [Hash] options
12
+ # @example List one-click services, provide a specific page:
13
+ # client.services.list_services(page: 2)
14
+ #
15
+ # @example List one-click services, provide a sorting policy:
16
+ # client.services.list_services(sort: "short_name:asc")
17
+ #
18
+ # @param [Hash] options the filtering and sorting options
19
+ # @option options [Integer] :page current page (pagination)
20
+ # @option options [Integer] :per_page number of entries to return (pagination)
21
+ # @option options [String] :sort sorting policy
13
22
  # @return [Dnsimple::PaginatedResponse<Dnsimple::Struct::Service>]
14
23
  #
15
24
  # @raise [RequestError] When the request fails.
16
25
  def services(options = {})
17
26
  endpoint = Client.versioned("/services")
18
- response = client.get(endpoint, options)
27
+ response = client.get(endpoint, Options::ListOptions.new(options))
19
28
 
20
29
  Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::Service.new(r) })
21
30
  end
@@ -36,7 +45,10 @@ module Dnsimple
36
45
  # @see https://developer.dnsimple.com/v2/services/#list
37
46
  # @see #services
38
47
  #
39
- # @param [Hash] options
48
+ # @param [Hash] options the filtering and sorting options
49
+ # @option options [Integer] :page current page (pagination)
50
+ # @option options [Integer] :per_page number of entries to return (pagination)
51
+ # @option options [String] :sort sorting policy
40
52
  # @return [Dnsimple::PaginatedResponse<Dnsimple::Struct::Service>]
41
53
  #
42
54
  # @raise [RequestError] When the request fails.
@@ -9,14 +9,23 @@ module Dnsimple
9
9
  # @example List the templates for account 1010:
10
10
  # client.templates.list_templates(1010)
11
11
  #
12
+ # @example List the templates for account 1010, provide a specific page:
13
+ # client.templates.list_templates(1010, page: 2)
14
+ #
15
+ # @example List the templates for account 1010, provide sorting policy:
16
+ # client.templates.list_templates(1010, sort: "short_name:asc")
17
+ #
12
18
  # @param [Fixnum] account_id the account ID
13
- # @param [Hash] options
19
+ # @param [Hash] options the filtering and sorting options
20
+ # @option options [Integer] :page current page (pagination)
21
+ # @option options [Integer] :per_page number of entries to return (pagination)
22
+ # @option options [String] :sort sorting policy
14
23
  # @return [Dnsimple::PaginatedResponse<Dnsimple::Struct::Template>]
15
24
  #
16
25
  # @raise [RequestError] When the request fails.
17
26
  def templates(account_id, options = {})
18
27
  endpoint = Client.versioned("/%s/templates" % [account_id])
19
- response = client.get(endpoint, options)
28
+ response = client.get(endpoint, Options::ListOptions.new(options))
20
29
 
21
30
  Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::Template.new(r) })
22
31
  end
@@ -38,7 +47,10 @@ module Dnsimple
38
47
  # @see #templates
39
48
  #
40
49
  # @param [Fixnum] account_id the account ID
41
- # @param [Hash] options
50
+ # @param [Hash] options the filtering and sorting options
51
+ # @option options [Integer] :page current page (pagination)
52
+ # @option options [Integer] :per_page number of entries to return (pagination)
53
+ # @option options [String] :sort sorting policy
42
54
  # @return [Dnsimple::PaginatedResponse<Dnsimple::Struct::Template>]
43
55
  #
44
56
  # @raise [RequestError] When the request fails.
@@ -95,7 +107,7 @@ module Dnsimple
95
107
  # @example Change the name of template 1 in account 1010:
96
108
  # client.templates.update_template(1010, 1, name: "New name")
97
109
  #
98
- # @param [Fixnum] account_iduthe account ID
110
+ # @param [Fixnum] account_id the account ID
99
111
  # @param [#to_s] template_id The template ID
100
112
  # @param [Hash] attributes
101
113
  # @param [Hash] options
@@ -0,0 +1,135 @@
1
+ module Dnsimple
2
+ class Client
3
+ module TemplatesRecords
4
+
5
+ # Lists the records in the template.
6
+ #
7
+ # @see https://developer.dnsimple.com/v2/templates/records/#list
8
+ # @see #all_records
9
+ #
10
+ # @example List the first page of records for the template "alpha"
11
+ # client.templates.records(1010, "alpha")
12
+ #
13
+ # @example List records for the template "alpha", providing a specific page
14
+ # client.templates.records(1010, "alpha", page: 2)
15
+ #
16
+ # @example List records for the template "alpha", providing sorting policy
17
+ # client.templates.records(1010, "alpha", sort: "type:asc")
18
+ #
19
+ # @param [Fixnum] account_id the account ID
20
+ # @param [String] template_id the template name
21
+ # @param [Hash] options the filtering and sorting options
22
+ # @option options [Integer] :page current page (pagination)
23
+ # @option options [Integer] :per_page number of entries to return (pagination)
24
+ # @option options [String] :sort sorting policy
25
+ # @return [Dnsimple::PaginatedResponse<Dnsimple::Struct::TemplateRecord>]
26
+ #
27
+ # @raise [Dnsimple::NotFoundError]
28
+ # @raise [Dnsimple::RequestError]
29
+ def records(account_id, template_id, options = {})
30
+ endpoint = Client.versioned("/%s/templates/%s/records" % [account_id, template_id])
31
+ response = client.get(endpoint, Options::ListOptions.new(options))
32
+
33
+ Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::TemplateRecord.new(r) })
34
+ end
35
+ alias list_records records
36
+
37
+ # Lists ALL the records in the template.
38
+ #
39
+ # This method is similar to {#records}, but instead of returning the results of a specific page
40
+ # it iterates all the pages and returns the entire collection.
41
+ #
42
+ # Please use this method carefully, as fetching the entire collection will increase the number of requests
43
+ # you send to the API server and you may eventually risk to hit the throttle limit.
44
+ #
45
+ # @see https://developer.dnsimple.com/v2/templates/records/#list
46
+ # @see #all_records
47
+ #
48
+ # @example List all the records for "alpha template
49
+ # client.templates.all_records(1010, "alpha")
50
+ #
51
+ # @param [Fixnum] account_id the account ID
52
+ # @param [String] template_id the template name
53
+ # @param [Hash] options the filtering and sorting options
54
+ # @option options [Integer] :page current page (pagination)
55
+ # @option options [Integer] :per_page number of entries to return (pagination)
56
+ # @option options [String] :sort sorting policy
57
+ # @return [Dnsimple::CollectionResponse<Dnsimple::Struct::TemplateRecord>]
58
+ #
59
+ # @raise [Dnsimple::NotFoundError]
60
+ # @raise [Dnsimple::RequestError]
61
+ def all_records(account_id, template_id, options = {})
62
+ paginate(:records, account_id, template_id, options)
63
+ end
64
+
65
+ # Creates a record in the template.
66
+ #
67
+ # @see https://developer.dnsimple.com/v2/templates/records/#create
68
+ #
69
+ # @example Create an A record for "alpha" template
70
+ # client.templates.create_record(1010, "alpha", name: "", type: "A", content: "192.168.1.1", ttl: 600)
71
+ #
72
+ # @param [Fixnum] account_id the account ID
73
+ # @param [String] template_id the template name
74
+ # @param [Hash] attributes
75
+ # @param [Hash] options
76
+ # @return [Dnsimple::Response<Dnsimple::Struct::TemplateRecord>]
77
+ #
78
+ # @raise [Dnsimple::NotFoundError]
79
+ # @raise [Dnsimple::RequestError]
80
+ def create_record(account_id, template_id, attributes, options = {})
81
+ Extra.validate_mandatory_attributes(attributes, [:type, :name, :content])
82
+ endpoint = Client.versioned("/%s/templates/%s/records" % [account_id, template_id])
83
+ response = client.post(endpoint, attributes, options)
84
+
85
+ Dnsimple::Response.new(response, Struct::TemplateRecord.new(response["data"]))
86
+ end
87
+
88
+ # Gets a record from the template.
89
+ #
90
+ # @see https://developer.dnsimple.com/v2/templates/records/#get
91
+ #
92
+ # @example Get record 123 in "alpha template
93
+ # client.templates.record(1010, "alpha", 123)
94
+ #
95
+ # @param [Fixnum] account_id the account ID
96
+ # @param [String] template_id the template name
97
+ # @param [Fixnum] record_id the record ID
98
+ # @param [Hash] options
99
+ # @return [Dnsimple::Response<Dnsimple::Struct::TemplateRecord>]
100
+ #
101
+ # @raise [Dnsimple::NotFoundError]
102
+ # @raise [Dnsimple::RequestError]
103
+ def record(account_id, template_id, record_id, options = {})
104
+ endpoint = Client.versioned("/%s/templates/%s/records/%s" % [account_id, template_id, record_id])
105
+ response = client.get(endpoint, options)
106
+
107
+ Dnsimple::Response.new(response, Struct::TemplateRecord.new(response["data"]))
108
+ end
109
+
110
+ # Deletes a record from the template.
111
+ #
112
+ # WARNING: this cannot be undone.
113
+ #
114
+ # @see https://developer.dnsimple.com/v2/templates/records/#delete
115
+ #
116
+ # @example Delete record 123 in "alpha template
117
+ # client.templates.delete_record(1010, "alpha", 123)
118
+ #
119
+ # @param [Fixnum] account_id the account ID
120
+ # @param [String] template_id the template name
121
+ # @param [Fixnum] record_id the record ID
122
+ # @param [Hash] options
123
+ # @return [Dnsimple::Response<nil>]
124
+ #
125
+ # @raise [Dnsimple::NotFoundError]
126
+ # @raise [Dnsimple::RequestError]
127
+ def delete_record(account_id, template_id, record_id, options = {})
128
+ endpoint = Client.versioned("/%s/templates/%s/records/%s" % [account_id, template_id, record_id])
129
+ response = client.delete(endpoint, options)
130
+
131
+ Dnsimple::Response.new(response, nil)
132
+ end
133
+ end
134
+ end
135
+ end
@@ -9,14 +9,20 @@ module Dnsimple
9
9
  # client.tlds.list
10
10
  #
11
11
  # @example List TLDs, providing a specific page
12
- # client.tlds.list(query: { page: 2 })
12
+ # client.tlds.list(page: 2)
13
13
  #
14
- # @param [Hash] options the filtering and sorting option
14
+ # @example List TLDs, providing sorting policy
15
+ # client.tlds.list(sort: "tld:asc")
16
+ #
17
+ # @param [Hash] options the filtering and sorting options
18
+ # @option options [Integer] :page current page (pagination)
19
+ # @option options [Integer] :per_page number of entries to return (pagination)
20
+ # @option options [String] :sort sorting policy
15
21
  # @return [Dnsimple::PaginatedResponse<Dnsimple::Struct::Tld>]
16
22
  #
17
23
  # @raise [Dnsimple::RequestError]
18
24
  def tlds(options = {})
19
- response = client.get(Client.versioned("/tlds"), options)
25
+ response = client.get(Client.versioned("/tlds"), Options::ListOptions.new(options))
20
26
 
21
27
  Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::Tld.new(r) })
22
28
  end
@@ -37,7 +43,10 @@ module Dnsimple
37
43
  # @example List all TLDs in DNSimple
38
44
  # client.tlds.all
39
45
  #
40
- # @param [Hash] options the filtering and sorting option
46
+ # @param [Hash] options the filtering and sorting options
47
+ # @option options [Integer] :page current page (pagination)
48
+ # @option options [Integer] :per_page number of entries to return (pagination)
49
+ # @option options [String] :sort sorting policy
41
50
  # @return [Dnsimple::CollectionResponse<Dnsimple::Struct::Tld>]
42
51
  #
43
52
  # @raise [Dnsimple::RequestError]
@@ -9,13 +9,22 @@ module Dnsimple
9
9
  # @example List all webhooks
10
10
  # client.webhooks.list(1010)
11
11
  #
12
+ # @example List all webhooks, provide a specific page
13
+ # client.webhooks.list(1010, page: 2)
14
+ #
15
+ # @example List all webhooks, provide sorting policy
16
+ # client.webhooks.list(1010, sort: "id:asc")
17
+ #
12
18
  # @param [Fixnum] account_id the account ID
13
- # @param [Hash] options the filtering and sorting option
19
+ # @param [Hash] options the filtering and sorting options
20
+ # @option options [Integer] :page current page (pagination)
21
+ # @option options [Integer] :per_page number of entries to return (pagination)
22
+ # @option options [String] :sort sorting policy
14
23
  # @return [Dnsimple::CollectionResponse<Dnsimple::Struct::Webhook>]
15
24
  #
16
25
  # @raise [Dnsimple::RequestError]
17
26
  def webhooks(account_id, options = {})
18
- response = client.get(Client.versioned("/%s/webhooks" % [account_id]), options)
27
+ response = client.get(Client.versioned("/%s/webhooks" % [account_id]), Options::ListOptions.new(options))
19
28
 
20
29
  Dnsimple::CollectionResponse.new(response, response["data"].map { |r| Struct::Webhook.new(r) })
21
30
  end
@@ -11,15 +11,25 @@ module Dnsimple
11
11
  # client.zones.list(1010, "example.com")
12
12
  #
13
13
  # @example List zones, provide a specific page
14
- # client.zones.list(1010, "example.com", query: { page: 2 })
14
+ # client.zones.list(1010, "example.com", page: 2)
15
+ #
16
+ # @example List zones, provide sorting policy
17
+ # client.zones.list(1010, "example.com", sort: "name:desc")
18
+ #
19
+ # @example List zones, provide filtering policy
20
+ # client.zones.list(1010, "example.com", filter: { name_like: "example" })
15
21
  #
16
22
  # @param [Fixnum] account_id the account ID
17
- # @param [Hash] options the filtering and sorting option
23
+ # @param [Hash] options the filtering and sorting options
24
+ # @option options [Integer] :page current page (pagination)
25
+ # @option options [Integer] :per_page number of entries to return (pagination)
26
+ # @option options [String] :sort sorting policy
27
+ # @option options [Hash] :filter filtering policy
18
28
  # @return [Dnsimple::PaginatedResponse<Dnsimple::Struct::Zone>]
19
29
  #
20
30
  # @raise [Dnsimple::RequestError]
21
31
  def zones(account_id, options = {})
22
- response = client.get(Client.versioned("/%s/zones" % [account_id]), options)
32
+ response = client.get(Client.versioned("/%s/zones" % [account_id]), Options::ListOptions.new(options))
23
33
 
24
34
  Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::Zone.new(r) })
25
35
  end
@@ -38,7 +48,11 @@ module Dnsimple
38
48
  # @see #zones
39
49
  #
40
50
  # @param [Fixnum] account_id the account ID
41
- # @param [Hash] options the filtering and sorting option
51
+ # @param [Hash] options the filtering and sorting options
52
+ # @option options [Integer] :page current page (pagination)
53
+ # @option options [Integer] :per_page number of entries to return (pagination)
54
+ # @option options [String] :sort sorting policy
55
+ # @option options [Hash] :filter filtering policy
42
56
  # @return [Dnsimple::CollectionResponse<Dnsimple::Struct::Zone>]
43
57
  #
44
58
  # @raise [Dnsimple::RequestError]
@@ -50,7 +64,7 @@ module Dnsimple
50
64
  #
51
65
  # @see https://developer.dnsimple.com/v2/zones/#get
52
66
  #
53
- # @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
67
+ # @param [Fixnum] account_id the account ID
54
68
  # @param [#to_s] zone_id the zone name
55
69
  # @param [Hash] options
56
70
  # @return [Dnsimple::Response<Dnsimple::Struct::Zone>]
@@ -11,19 +11,31 @@ module Dnsimple
11
11
  # client.zones.records(1010, "example.com")
12
12
  #
13
13
  # @example List records for the zone "example.com", provide a specific page
14
- # client.zones.records(1010, "example.com", query: { page: 2 })
14
+ # client.zones.records(1010, "example.com", page: 2)
15
15
  #
16
- # @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
16
+ # @example List records for the zone "example.com", provide sorting policy
17
+ # client.zones.records(1010, "example.com", sort: "type:asc")
18
+ #
19
+ # @example List records for the zone "example.com", provide filtering policy
20
+ # client.zones.records(1010, "example.com", sort: "type:asc")
21
+ #
22
+ # @param [Fixnum] account_id the account ID
17
23
  # @param [String] zone_id the zone name
18
- # @param [Hash] options the filtering and sorting option
24
+ # @param [Hash] options the filtering and sorting options
25
+ # @option options [Integer] :page current page (pagination)
26
+ # @option options [Integer] :per_page number of entries to return (pagination)
27
+ # @option options [String] :sort sorting policy
28
+ # @option options [Hash] :filter filtering policy
19
29
  # @return [Dnsimple::PaginatedResponse<Dnsimple::Struct::Record>]
20
30
  #
31
+ # @raise [Dnsimple::NotFoundError]
21
32
  # @raise [Dnsimple::RequestError]
22
33
  def records(account_id, zone_id, options = {})
23
- response = client.get(Client.versioned("/%s/zones/%s/records" % [account_id, zone_id]), options)
34
+ response = client.get(Client.versioned("/%s/zones/%s/records" % [account_id, zone_id]), Options::ListOptions.new(options))
24
35
 
25
36
  Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::Record.new(r) })
26
37
  end
38
+ alias list records
27
39
  alias list_records records
28
40
 
29
41
  # Lists ALL the zone records in the account.
@@ -37,26 +49,39 @@ module Dnsimple
37
49
  # @see https://developer.dnsimple.com/v2/zones/records/#list
38
50
  # @see #records
39
51
  #
40
- # @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
52
+ # @example List all records for the zone "example.com"
53
+ # client.zones.all_records(1010, "example.com")
54
+ #
55
+ # @param [Fixnum] account_id the account ID
41
56
  # @param [String] zone_id the zone name
42
- # @param [Hash] options the filtering and sorting option
57
+ # @param [Hash] options the filtering and sorting options
58
+ # @option options [Integer] :page current page (pagination)
59
+ # @option options [Integer] :per_page number of entries to return (pagination)
60
+ # @option options [String] :sort sorting policy
61
+ # @option options [Hash] :filter filtering policy
43
62
  # @return [Dnsimple::CollectionResponse<Dnsimple::Struct::Record>]
44
63
  #
64
+ # @raise [Dnsimple::NotFoundError]
45
65
  # @raise [Dnsimple::RequestError]
46
66
  def all_records(account_id, zone_id, options = {})
47
67
  paginate(:records, account_id, zone_id, options)
48
68
  end
69
+ alias all all_records
49
70
 
50
71
  # Creates a zone record in the account.
51
72
  #
52
73
  # @see https://developer.dnsimple.com/v2/zones/records/#create
53
74
  #
54
- # @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
75
+ # @example Create a URL record in zone "example.com"
76
+ # client.zones.create_record(1010, "example.com", name: "www", type: "url", content: "example.com")
77
+ #
78
+ # @param [Fixnum] account_id the account ID
55
79
  # @param [String] zone_id the zone name
56
80
  # @param [Hash] attributes
57
81
  # @param [Hash] options
58
82
  # @return [Dnsimple::Response<Dnsimple::Struct::Record>]
59
83
  #
84
+ # @raise [Dnsimple::NotFoundError]
60
85
  # @raise [Dnsimple::RequestError]
61
86
  def create_record(account_id, zone_id, attributes, options = {})
62
87
  Extra.validate_mandatory_attributes(attributes, [:type, :name, :content])
@@ -64,16 +89,20 @@ module Dnsimple
64
89
 
65
90
  Dnsimple::Response.new(response, Struct::Record.new(response["data"]))
66
91
  end
92
+ alias create create_record
67
93
 
68
94
  # Gets a zone record from the account.
69
95
  #
70
96
  # @see https://developer.dnsimple.com/v2/zones/records/#get
71
97
  #
72
- # @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
98
+ # @example Get record 123 in zone "example.com"
99
+ # client.zones.record(1010, "example.com", 123)
100
+ #
101
+ # @param [Fixnum] account_id the account ID
73
102
  # @param [String] zone_id the zone name
74
103
  # @param [Fixnum] record_id the record ID
75
104
  # @param [Hash] options
76
- # @return [Dnsimple::Response<Dnsimple::Struct::Domain>]
105
+ # @return [Dnsimple::Response<Dnsimple::Struct::Record>]
77
106
  #
78
107
  # @raise [Dnsimple::NotFoundError]
79
108
  # @raise [Dnsimple::RequestError]
@@ -87,7 +116,10 @@ module Dnsimple
87
116
  #
88
117
  # @see https://developer.dnsimple.com/v2/zones/records/#update
89
118
  #
90
- # @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
119
+ # @example Update the TTL to 600 of record 123 in zone "example.com"
120
+ # client.zones.update_record(1010, "example.com", 123, ttl: 600)
121
+ #
122
+ # @param [Fixnum] account_id the account ID
91
123
  # @param [String] zone_id the zone name
92
124
  # @param [Fixnum] record_id the record ID
93
125
  # @param [Hash] attributes
@@ -101,6 +133,7 @@ module Dnsimple
101
133
 
102
134
  Dnsimple::Response.new(response, Struct::Record.new(response["data"]))
103
135
  end
136
+ alias update update_record
104
137
 
105
138
  # Deletes a zone record from the account.
106
139
  #
@@ -108,7 +141,10 @@ module Dnsimple
108
141
  #
109
142
  # @see https://developer.dnsimple.com/v2/zones/records/#delete
110
143
  #
111
- # @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard
144
+ # @example Delete record 123 in zone "example.com"
145
+ # client.zones.delete_record(1010, "example.com", 123)
146
+ #
147
+ # @param [Fixnum] account_id the account ID
112
148
  # @param [String] zone_id the zone name
113
149
  # @param [Fixnum] record_id the record ID
114
150
  # @param [Hash] options
@@ -121,6 +157,7 @@ module Dnsimple
121
157
 
122
158
  Dnsimple::Response.new(response, nil)
123
159
  end
160
+ alias delete delete_record
124
161
 
125
162
  end
126
163
  end