-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add listZoneRecords() and allZoneRecords()
- Loading branch information
Showing
8 changed files
with
158 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,50 @@ | ||
module Dnsimple | ||
class Client | ||
module ZonesRecords | ||
|
||
# Lists the zone records in the account. | ||
# | ||
# @see https://developer.dnsimple.com/v2/zones/records/#list | ||
# @see #all_records | ||
# | ||
# @example List records for the zone "example.com" in the first page | ||
# client.zones.records(1010, "example.com") | ||
# | ||
# @example List records for the zone "example.com", provide a specific page | ||
# client.zones.records(1010, "example.com", query: { page: 2 }) | ||
# | ||
# @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard | ||
# @param [String] zone_id the zone name | ||
# @param [Hash] options the filtering and sorting option | ||
# @return [Dnsimple::PaginatedResponse<Dnsimple::Struct::Record>] | ||
# @raise [Dnsimple::RequestError] | ||
def records(account_id, zone_id, options = {}) | ||
response = client.get(Client.versioned("/%s/zones/%s/records" % [account_id, zone_id]), options) | ||
|
||
Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::Record.new(r) }) | ||
end | ||
alias :list_records :records | ||
|
||
# Lists ALL the zone records in the account. | ||
# | ||
# This method is similar to {#records}, but instead of returning the results of a specific page | ||
# it iterates all the pages and returns the entire collection. | ||
# | ||
# Please use this method carefully, as fetching the entire collection will increase the number of requests | ||
# you send to the API server and you may eventually risk to hit the throttle limit. | ||
# | ||
# @see https://developer.dnsimple.com/v2/zones/records/#list | ||
# @see #records | ||
# | ||
# @param [Fixnum] account_id the account ID | ||
# @param [String] zone_id the zone name | ||
# @param [Hash] options the filtering and sorting option | ||
# @return [Dnsimple::CollectionResponse<Dnsimple::Struct::Record>] | ||
# @raise [Dnsimple::RequestError] | ||
def all_records(account_id, zone_id, options = {}) | ||
paginate(:records, account_id, zone_id, options) | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 11 additions & 11 deletions
22
spec/files/domains/notfound-domain.http → spec/files/notfound-domain.http
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
HTTP/1.1 404 Not Found | ||
Server: nginx | ||
Date: Wed, 16 Dec 2015 22:07:20 GMT | ||
Content-Type: application/json; charset=utf-8 | ||
Transfer-Encoding: chunked | ||
Connection: keep-alive | ||
Strict-Transport-Security: max-age=31536000 | ||
Cache-Control: no-cache | ||
X-Request-Id: bc587ea7-bcd5-4c10-a940-a9b4c8339824 | ||
X-Runtime: 0.059966 | ||
|
||
HTTP/1.1 404 Not Found | ||
Server: nginx | ||
Date: Wed, 16 Dec 2015 22:07:20 GMT | ||
Content-Type: application/json; charset=utf-8 | ||
Transfer-Encoding: chunked | ||
Connection: keep-alive | ||
Strict-Transport-Security: max-age=31536000 | ||
Cache-Control: no-cache | ||
X-Request-Id: bc587ea7-bcd5-4c10-a940-a9b4c8339824 | ||
X-Runtime: 0.059966 | ||
|
||
{"message":"Domain `0' not found"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
HTTP/1.1 500 Internal Server Error | ||
Server: nginx | ||
Date: Thu, 07 Jan 2016 16:35:37 GMT | ||
Content-Type: application/json; charset=utf-8 | ||
Transfer-Encoding: chunked | ||
Connection: keep-alive | ||
Status: 500 Internal Server Error | ||
Cache-Control: no-cache | ||
X-Request-Id: 0de115b1-2143-44e5-b117-c7f9c51ea2ff | ||
X-Runtime: 0.022304 | ||
|
||
{"message":"Internal Server Error"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
HTTP/1.1 200 OK | ||
Server: nginx | ||
Date: Thu, 07 Jan 2016 16:33:47 GMT | ||
Content-Type: application/json; charset=utf-8 | ||
Transfer-Encoding: chunked | ||
Connection: keep-alive | ||
Status: 200 OK | ||
X-RateLimit-Limit: 4000 | ||
X-RateLimit-Remaining: 3994 | ||
X-RateLimit-Reset: 1452184426 | ||
ETag: W/"1ae3e2e65dbcc2c2a7237e3e564129dd" | ||
Cache-Control: max-age=0, private, must-revalidate | ||
X-Request-Id: 9b361b57-43e2-47df-9f00-e7c252bc4d41 | ||
X-Runtime: 0.107990 | ||
Strict-Transport-Security: max-age=31536000 | ||
|
||
{"data":[{"id":64779,"domain_id":5841,"parent_id":null,"name":"","content":"ns1.dnsimple.com admin.dnsimple.com 1452184205 86400 7200 604800 300","ttl":3600,"priority":null,"type":"SOA","system_record":true,"created_at":"2016-01-07T16:30:05.379Z","updated_at":"2016-01-07T16:30:05.379Z"},{"id":64780,"domain_id":5841,"parent_id":null,"name":"","content":"ns1.dnsimple.com","ttl":3600,"priority":null,"type":"NS","system_record":true,"created_at":"2016-01-07T16:30:05.422Z","updated_at":"2016-01-07T16:30:05.422Z"},{"id":64781,"domain_id":5841,"parent_id":null,"name":"","content":"ns2.dnsimple.com","ttl":3600,"priority":null,"type":"NS","system_record":true,"created_at":"2016-01-07T16:30:05.433Z","updated_at":"2016-01-07T16:30:05.433Z"},{"id":64782,"domain_id":5841,"parent_id":null,"name":"","content":"ns3.dnsimple.com","ttl":3600,"priority":null,"type":"NS","system_record":true,"created_at":"2016-01-07T16:30:05.445Z","updated_at":"2016-01-07T16:30:05.445Z"},{"id":64783,"domain_id":5841,"parent_id":null,"name":"","content":"ns4.dnsimple.com","ttl":3600,"priority":null,"type":"NS","system_record":true,"created_at":"2016-01-07T16:30:05.457Z","updated_at":"2016-01-07T16:30:05.457Z"}],"pagination":{"current_page":1,"per_page":30,"total_entries":5,"total_pages":1}} |