Class: PDNS::API

Inherits:
Object
  • Object
show all
Defined in:
lib/pdns_api/api.rb

Overview

The superclass for all PDNS objects.

Direct Known Subclasses

Client, Config, CryptoKey, Metadata, Override, Server, Zone

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#classObject (readonly)

The class of the resource object.



32
33
34
# File 'lib/pdns_api/api.rb', line 32

def class
  @class
end

#urlObject (readonly)

The url of the resource object.



28
29
30
# File 'lib/pdns_api/api.rb', line 28

def url
  @url
end

Instance Method Details

#change(rrsets) ⇒ Object

Changes this object’s information on the server.

rrsets is used as changeset for the update.



38
39
40
# File 'lib/pdns_api/api.rb', line 38

def change(rrsets)
  @http.put(@url, rrsets)
end

#create(info = nil) ⇒ Object

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.



47
48
49
50
# File 'lib/pdns_api/api.rb', line 47

def create(info = nil)
  info(info)
  @http.post("#{@parent.url}/#{@class}", @info)
end

#deleteObject

Deletes this object



54
55
56
# File 'lib/pdns_api/api.rb', line 54

def delete
  @http.delete @url
end

#ensure_array(item) ⇒ Object

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



79
80
81
82
# File 'lib/pdns_api/api.rb', line 79

def ensure_array(item)
  return item if item.is_a? Array
  [item]
end

#getObject

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



61
62
63
# File 'lib/pdns_api/api.rb', line 61

def get
  @info = @http.get @url
end

#info(info = nil) ⇒ Object

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

If info is set this method updates the current information.



70
71
72
73
74
# File 'lib/pdns_api/api.rb', line 70

def info(info = nil)
  return @info if info.nil?

  @info.merge!(info)
end