class PDNS::API

The superclass for all PDNS objects.

Attributes

class[R]

@return the class of the resource object.

url[R]

@return the url of the resource object.

Public Instance Methods

change(rrsets) click to toggle source

Changes this object's information on the server.

@param rrsets [Array] is used as changeset for the change. @return [Hash] result of the change.

# File lib/pdns_api/api.rb, line 40
def change(rrsets)
  @http.put(@url, rrsets)
end
create(info = nil) click to toggle source

Creates this object on the server

If info is set this method updates the current information. The current information is used to create the object.

@param info [Hash, nil] Information to set when creating the object. @return [Hash] result of the creation.

@example

zone.create(
  name: zone.id,
  kind: 'Native',
  dnssec: true,
  nameservers: %w( ns0.example.com. ns1.example.com. )
)
# File lib/pdns_api/api.rb, line 61
def create(info = nil)
  info(info)
  @http.post("#{@parent.url}/#{@class}", @info)
end
delete() click to toggle source

Deletes this object.

@return [Hash] result of the deletion.

# File lib/pdns_api/api.rb, line 71
def delete
  @http.delete @url
end
ensure_array(item) click to toggle source

Ensures the object is an array. If it is not, an array containing the item is returned.

@param item anything that might or might not be an Array. @return [Array] item as an array.

# File lib/pdns_api/api.rb, line 105
def ensure_array(item)
  return item if item.is_a? Array
  [item]
end
get() click to toggle source

Gets the information of this object from the API and use it to update the object's information.

@return [Hash] the object's information from the API.

# File lib/pdns_api/api.rb, line 81
def get
  @info = @http.get @url
end
info(info = nil) click to toggle source

Gets and sets the object information. This does not cause an API request.

@param info [Hash, nil] Information to change. @return [Hash] this object's information.

# File lib/pdns_api/api.rb, line 92
def info(info = nil)
  return @info if info.nil?

  @info.merge!(info)
end