class PDNS::Metadata
Metadata
for a zone.
Attributes
kind[RW]
@return [name] the kind of metadata.
Public Class Methods
new(http, parent, kind, value = [])
click to toggle source
Creates a configuration option object.
@param http [HTTP] An HTTP
object for interaction with the PowerDNS server. @param parent [API] This object's parent. @param kind [String] Kind of the metadata. @param value [String] Optional value of the metadata.
# File lib/pdns_api/metadata.rb, line 36 def initialize(http, parent, kind, value = []) @class = :metadata @http = http @parent = parent @kind = kind @url = "#{parent.url}/#{@class}/#{kind}" @value = get if value.empty? value(@value) end
Public Instance Methods
change(value = nil)
click to toggle source
Changes this object's information on the server.
@param value [String, nil] Value to change the object to.
- If +value+ is set, the current +value+ is used. - If +value+ is not set, +value+ is updated and then used.
@return [Hash] result of the change.
@example
metadata = zone.metadata('ALLOW-AXFR-FROM') metadata.change('AUTO-NS')
# File lib/pdns_api/metadata.rb, line 89 def change(value = nil) value(value) @http.put(@url, @info) end
get()
click to toggle source
Gets the current information. This also updates value
.
@return [Hash] the object's information from the API
.
# File lib/pdns_api/metadata.rb, line 70 def get res = @http.get @url value(res[:value]) if res.key? :value res end
value(value = nil)
click to toggle source
Gets or sets the value
attribute.
@param value [String, nil] the value of the object. @return [String] the value of the object.
If +value+ is set the object's +value+ is updated.
# File lib/pdns_api/metadata.rb, line 53 def value(value = nil) return @info[:metadata] if value.nil? # Convert to array if value is string value = ensure_array(value) # Set value and info @info = { type: 'Metadata', kind: @kind, metadata: value } @value = value end