class Ultradns::Api::Zone

Attributes

zone_name[R]

Public Class Methods

new(client, zone_name) click to toggle source
Calls superclass method Ultradns::Api::ClientAccessor::new
# File lib/ultradns/api/zone.rb, line 13
def initialize(client, zone_name)
  super(client)
  @zone_name = zone_name
end

Public Instance Methods

create(account_name, options = {}) click to toggle source

Create a zone

Required Parameters

  • account_name - The account that the zone will be created under. The user must have write access for zones in that account.

Optional Parameters

  • type - The type of zone to be created, one of three possible values: PRIMARY, SECONDARY, or ALIAS.

See documentation section: Primary Zone DTO or Secondary Zone DTO for further options.

Examples

c.create('my_account')
# File lib/ultradns/api/zone.rb, line 41
def create(account_name, options = {})
  zone_properties = {name: @zone_name, accountName: account_name, type: 'PRIMARY'}

  primary_zone_info = {}
  if options[:properties][:type] == 'PRIMARY' || options[:properties][:type] == nil
    primary_zone_info = {forceImport: true, createType: 'NEW'}
  end

  zone_data = {properties: zone_properties,
               primaryCreateInfo: primary_zone_info}.merge(options)

  with_auth_retry {|c| c.post '/zones', request_options({body: zone_data.to_json}) }
end
create_rrset(rtype, owner_name, ttl, rdata) click to toggle source

Creates a new RRSet in the specified zone.

Required Parameters

  • zone_name - The zone that contains the RRSet.The trailing dot is optional.

  • rtype - The type of the RRSet.This can be numeric (1) or

    if a well-known name is defined for the type (A), you can use it instead.
  • owner_name - The owner name for the RRSet.

    If no trailing dot is supplied, the owner_name is assumed to be relative (foo).
    If a trailing dot is supplied, the owner name is assumed to be absolute (foo.zonename.com.)
  • ttl - The updated TTL value for the RRSet.

  • rdata - The updated BIND data for the RRSet as a string.

    If there is a single resource record in the RRSet, you can pass in the single string or an array with a single element.
    If there are multiple resource records in this RRSet, pass in a list of strings.

Examples

c.zone('zone.invalid.').create_rrset('A', 'foo', 300, '1.2.3.4')
# File lib/ultradns/api/zone.rb, line 132
def create_rrset(rtype, owner_name, ttl, rdata)
  rrset(rtype, owner_name).create(ttl, rdata)
end
delete() click to toggle source

Delete a zone

Examples

c.zone('foo.invalid.').delete
# File lib/ultradns/api/zone.rb, line 60
def delete
  client.with_auth_retry {|c| c.delete "/zones/#{@zone_name}", request_options }
end
metadata() click to toggle source

Get zone metadata

Examples

c.zone('foo.invalid.').metadata
# File lib/ultradns/api/zone.rb, line 23
def metadata
  client.with_auth_retry {|c| c.get "/zones/#{@zone_name}", request_options }
end
rrset(rtype, owner_name) click to toggle source

Required Parameters

  • rtype - The type of the RRSet.This can be numeric (1) or if a well-known name

    is defined for the type (A), you can use it instead.
  • owner_name - The owner name for the RRSet.

    If no trailing dot is supplied, the owner_name is assumed to be relative (foo).
    If a trailing dot is supplied, the owner name is assumed to be absolute (foo.zonename.com.)

Examples

c.rrset('A', 'foo')
# File lib/ultradns/api/zone.rb, line 110
def rrset(rtype, owner_name)
  Ultradns::Api::Rrset.new(self, rtype, owner_name)
end
rrsets(rtype = nil, options={}) click to toggle source

Returns the list of RRSets in the specified zone of the (optional) specified type.

Optional Parameters

  • rtype - The type of the RRSets. This can be numeric (1) or

    if a well-known name is defined for the type (A), you can use it instead.

Optional Parameters

  • :q - The search parameters, in a hash. Valid keys are:

    ttl - must match the TTL for the rrset
    owner - substring match of the owner name
    value - substring match of the first BIND field value
  • :sort - The sort column used to order the list. Valid values for the sort field are:

    OWNER
    TTL
    TYPE
    
  • :reverse - Whether the list is ascending(false) or descending(true). Defaults to true

  • :offset - The position in the list for the first returned element(0 based)

  • :limit - The maximum number of zones to be returned.

Examples

c.zone('foo.invalid.').rrsets() # all types returned
c.zone('foo.invalid.').rrsets('A')
c.zone('foo.invalid.').rrsets('TXT', q: {value: 'cheese', ttl:300}, offset:5, limit:10)
# File lib/ultradns/api/zone.rb, line 92
def rrsets(rtype = nil, options={})
  rrsets_path = "/zones/#{@zone_name}/rrsets"
  rrsets_path += "/#{rtype}" if rtype != nil

  client.with_auth_retry {|c| c.get(rrsets_path, request_options(options)) }
end