Class: Nifcloud::DNS::Zone

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

Overview

Class that manages DNS zone information

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.



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

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

Instance Method Details

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

rubocop:disable Metrics/MethodLength



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/nifcloud/dns/zone.rb', line 25

def add(zone, comment: '') # rubocop:disable Metrics/MethodLength
  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



41
42
43
# File 'lib/nifcloud/dns/zone.rb', line 41

def del(zone_id)
  delete(HOSTED_ZONE_WITH_ID % zone_id)
end

#listObject



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

def list
  get HOSTED_ZONE
end

#show(zone_id) ⇒ Object



21
22
23
# File 'lib/nifcloud/dns/zone.rb', line 21

def show(zone_id)
  get(HOSTED_ZONE_WITH_ID % zone_id)
end