Class: Nifcloud::DNS::Zone

Inherits:
Client show all
Defined in:
lib/nifcloud/dns/zone.rb

Constant Summary collapse

HOSTED_ZONE =
'hostedzone'
HOSTED_ZONE_WITH_ID =
'hostedzone/%s'

Constants inherited from Client

Client::AUTHORIZATION_HEADER, Client::DATE_HEADER, Client::ENDPOINT, Client::NAMESPACE, Client::VERSION

Constants inherited from Auth

Auth::ALGORITHM

Instance Attribute Summary

Attributes inherited from Auth

#time

Instance Method Summary collapse

Methods inherited from Client

#delete, #get, #post

Methods inherited from Auth

#signature_header

Constructor Details

#initialize(access_key: nil, secret_key: nil) ⇒ Zone

Returns a new instance of Zone.



10
11
12
# File 'lib/nifcloud/dns/zone.rb', line 10

def initialize(access_key: nil, secret_key: nil)
  super(access_key, secret_key)
end

Instance Method Details

#add(zone, comment: '') ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/nifcloud/dns/zone.rb', line 22

def add(zone, comment: '')
  body = { '@xmlns' => Nifcloud::Client::NAMESPACE,
    'Name' => ['content' => zone],
    'CallerReference' => ['content' => ''],
    'HostedZoneConfig' => ['content' => ''],
    'Comment' => ['content' => comment]
  }
  options = {
    'AttrPrefix' => true,
    'RootName' => 'CreateHostedZoneRequest',
    'ContentKey' => 'content'
  }
  post(HOSTED_ZONE, XmlSimple.xml_out(body, options))
end

#del(zone_id) ⇒ Object



37
38
39
# File 'lib/nifcloud/dns/zone.rb', line 37

def del zone_id
  delete(HOSTED_ZONE_WITH_ID % zone_id)
end

#listObject



14
15
16
# File 'lib/nifcloud/dns/zone.rb', line 14

def list
  get HOSTED_ZONE
end

#show(zone_id) ⇒ Object



18
19
20
# File 'lib/nifcloud/dns/zone.rb', line 18

def show zone_id
  get(HOSTED_ZONE_WITH_ID % zone_id)
end