Module: Dnsimple::Client::Zones

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

Instance Method Summary collapse

Instance Method Details

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

Activate DNS resolution for the zone in the account.

Parameters:

  • account_id (#to_s)

    the account ID

  • zone_id (#to_s)

    the zone name

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

Returns:

Raises:

See Also:



109
110
111
112
113
# File 'lib/dnsimple/client/zones.rb', line 109

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

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

#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

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

Deactivate DNS resolution for the zone in the account.

Parameters:

  • account_id (#to_s)

    the account ID

  • zone_id (#to_s)

    the zone name

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

Returns:

Raises:

See Also:



126
127
128
129
130
# File 'lib/dnsimple/client/zones.rb', line 126

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

  Dnsimple::Response.new(response, Struct::Zone.new(response["data"]))
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