Class: Ultradns::Api::Zone
- Inherits:
-
ClientAccessor
- Object
- ClientAccessor
- Ultradns::Api::Zone
- Defined in:
- lib/ultradns/api/zone.rb
Instance Attribute Summary collapse
-
#zone_name ⇒ Object
readonly
Returns the value of attribute zone_name.
Instance Method Summary collapse
-
#create(account_name, options = {}) ⇒ Object
Create a zone.
-
#create_rrset(rtype, owner_name, ttl, rdata) ⇒ Object
Creates a new RRSet in the specified zone.
-
#delete ⇒ Object
Delete a zone.
-
#initialize(client, zone_name) ⇒ Zone
constructor
A new instance of Zone.
-
#metadata ⇒ Object
Get zone metadata.
-
#rrset(rtype, owner_name) ⇒ Object
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. -
#rrsets(rtype = nil, options = {}) ⇒ Object
Returns the list of RRSets in the specified zone of the (optional) specified type.
Constructor Details
#initialize(client, zone_name) ⇒ Zone
Returns a new instance of Zone.
13 14 15 16 |
# File 'lib/ultradns/api/zone.rb', line 13 def initialize(client, zone_name) super(client) @zone_name = zone_name end |
Instance Attribute Details
#zone_name ⇒ Object (readonly)
Returns the value of attribute zone_name.
11 12 13 |
# File 'lib/ultradns/api/zone.rb', line 11 def zone_name @zone_name end |
Instance Method Details
#create(account_name, options = {}) ⇒ Object
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')
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ultradns/api/zone.rb', line 41 def create(account_name, = {}) zone_properties = {name: @zone_name, accountName: account_name, type: 'PRIMARY'} primary_zone_info = {} if [:properties][:type] == 'PRIMARY' || [:properties][:type] == nil primary_zone_info = {forceImport: true, createType: 'NEW'} end zone_data = {properties: zone_properties, primaryCreateInfo: primary_zone_info}.merge() with_auth_retry {|c| c.post '/zones', ({body: zone_data.to_json}) } end |
#create_rrset(rtype, owner_name, ttl, rdata) ⇒ Object
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) orif 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')
132 133 134 |
# 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 ⇒ Object
Delete a zone
Examples
c.zone('foo.invalid.').delete
60 61 62 |
# File 'lib/ultradns/api/zone.rb', line 60 def delete client.with_auth_retry {|c| c.delete "/zones/#{@zone_name}", } end |
#metadata ⇒ Object
Get zone metadata
Examples
c.zone('foo.invalid.').
23 24 25 |
# File 'lib/ultradns/api/zone.rb', line 23 def client.with_auth_retry {|c| c.get "/zones/#{@zone_name}", } end |
#rrset(rtype, owner_name) ⇒ Object
Required Parameters
-
rtype
- The type of the RRSet.This can be numeric (1) or if a well-known nameis 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')
110 111 112 |
# 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 = {}) ⇒ Object
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) orif 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)
92 93 94 95 96 97 |
# File 'lib/ultradns/api/zone.rb', line 92 def rrsets(rtype = nil, ={}) rrsets_path = "/zones/#{@zone_name}/rrsets" rrsets_path += "/#{rtype}" if rtype != nil client.with_auth_retry {|c| c.get(rrsets_path, ()) } end |