Module: Dnsimple::Client::Zones

Included in:
ZonesService
Defined in:
lib/dnsimple/client/zones.rb

Instance Method Summary collapse

Instance Method Details

#all_zones(account_id, options = {}) ⇒ Dnsimple::CollectionResponse<Dnsimple::Struct::Zone>

Lists ALL the zones in the account.

This method is similar to #zones, 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.

Parameters:

  • account_id (Fixnum)

    the account ID

  • options (Hash) (defaults to: {})

    the filtering and sorting option

Returns:

Raises:

See Also:



45
46
47
# File 'lib/dnsimple/client/zones.rb', line 45

def all_zones(, options = {})
  paginate(:zones, , options)
end

#zone(account_id, zone_id, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Zone>

Gets a zone from the account.

Parameters:

Returns:

Raises:

See Also:



60
61
62
63
64
# File 'lib/dnsimple/client/zones.rb', line 60

def zone(, zone_id, options = {})
  response = client.get(Client.versioned("/%s/zones/%s" % [, zone_id]), options)

  Dnsimple::Response.new(response, Struct::Zone.new(response["data"]))
end

#zones(account_id, options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::Zone> Also known as: list, list_zones

Lists the zones in the account.

Examples:

List zones in the first page

client.zones.list(1010, "example.com")

List zones, provide a specific page

client.zones.list(1010, "example.com", query: { page: 2 })

Parameters:

  • account_id (Fixnum)

    the account ID

  • options (Hash) (defaults to: {})

    the filtering and sorting option

Returns:

Raises:

See Also:



21
22
23
24
25
# File 'lib/dnsimple/client/zones.rb', line 21

def zones(, options = {})
  response = client.get(Client.versioned("/%s/zones" % []), options)

  Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::Zone.new(r) })
end