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 (Integer)

    the account ID

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

    the filtering and sorting options

Options Hash (options):

  • :page (Integer)

    current page (pagination)

  • :per_page (Integer)

    number of entries to return (pagination)

  • :sort (String)

    sorting policy

  • :filter (Hash)

    filtering policy

Returns:

Raises:

See Also:



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

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:

  • account_id (Integer)

    the account ID

  • zone_id (#to_s)

    the zone name

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

Returns:

Raises:

See Also:



75
76
77
78
79
# File 'lib/dnsimple/client/zones.rb', line 75

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

#zone_file(account_id, zone_name, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::ZoneFile>

Gets a zone file from the account.

Parameters:

  • account_id (Integer)

    the account ID

  • zone_name (#to_s)

    the zone name

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

Returns:

Raises:

See Also:



92
93
94
95
96
# File 'lib/dnsimple/client/zones.rb', line 92

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

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

#zones(account_id, options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::Zone> Also known as: 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", page: 2)

List zones, provide sorting policy

client.zones.list(1010, "example.com", sort: "name:desc")

List zones, provide filtering policy

client.zones.list(1010, "example.com", filter: { name_like: "example" })

Parameters:

  • account_id (Integer)

    the account ID

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

    the filtering and sorting options

Options Hash (options):

  • :page (Integer)

    current page (pagination)

  • :per_page (Integer)

    number of entries to return (pagination)

  • :sort (String)

    sorting policy

  • :filter (Hash)

    filtering policy

Returns:

Raises:

See Also:



33
34
35
36
37
# File 'lib/dnsimple/client/zones.rb', line 33

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

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