Class: Nifcloud::DNS::Record
- Defined in:
- lib/nifcloud/dns/record.rb
Overview
Class that manages DNS record information
Constant Summary collapse
- RECORD_SET_WITH_ID =
'hostedzone/%s/rrset'- RECORD_SET_WITH_PARAMS =
'hostedzone/%s/rrset?%s'
Constants inherited from Client
Client::AUTHORIZATION_HEADER, Client::DATE_HEADER, Client::ENDPOINT, Client::NAMESPACE, Client::VERSION
Constants inherited from Auth
Instance Attribute Summary
Attributes inherited from Auth
Instance Method Summary collapse
- #add(name, type, value, ttl: 86_400, comment: '') ⇒ Object
- #del(name, type, value, ttl: 86_400, comment: '') ⇒ Object
-
#initialize(zone_id, access_key: nil, secret_key: nil) ⇒ Record
constructor
A new instance of Record.
- #list(options: nil) ⇒ Object
Methods inherited from Client
Methods inherited from Auth
Constructor Details
#initialize(zone_id, access_key: nil, secret_key: nil) ⇒ Record
Returns a new instance of Record.
14 15 16 17 |
# File 'lib/nifcloud/dns/record.rb', line 14 def initialize(zone_id, access_key: nil, secret_key: nil) super(access_key, secret_key) @zone_id = zone_id end |
Instance Method Details
#add(name, type, value, ttl: 86_400, comment: '') ⇒ Object
30 31 32 |
# File 'lib/nifcloud/dns/record.rb', line 30 def add(name, type, value, ttl: 86_400, comment: '') post(RECORD_SET_WITH_ID % @zone_id, xml('CREATE', name, type, value, ttl, comment)) end |
#del(name, type, value, ttl: 86_400, comment: '') ⇒ Object
34 35 36 |
# File 'lib/nifcloud/dns/record.rb', line 34 def del(name, type, value, ttl: 86_400, comment: '') post(RECORD_SET_WITH_ID % @zone_id, xml('DELETE', name, type, value, ttl, comment)) end |
#list(options: nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/nifcloud/dns/record.rb', line 19 def list(options: nil) if .nil? || !.instance_of?(Hash) get(RECORD_SET_WITH_ID % @zone_id) else list_path = format(RECORD_SET_WITH_PARAMS, @zone_id, .collect { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')) get(list_path) end end |