Class: Gandi::Domain::Host
- Inherits:
-
Object
- Object
- Gandi::Domain::Host
- Includes:
- GandiObjectMethods
- Defined in:
- lib/gandi/domain/host.rb
Instance Attribute Summary collapse
-
#hostname ⇒ Object
readonly
The hostname of the Host.
Class Method Summary collapse
-
.count(fqdn, opts = {}) ⇒ Object
Count the glue records / hosts of a domain.
-
.create(hostname, ips) ⇒ Object
Create a host.
-
.list(fqdn, opts = {}) ⇒ Object
List the glue records / hosts for a given domain.
Instance Method Summary collapse
-
#delete ⇒ Object
Delete a host.
-
#info ⇒ Object
Display host information for a given domain.
-
#initialize(hostname, attributes = nil) ⇒ Host
constructor
A new instance of Host.
-
#ips ⇒ Object
Return the host IP adresses.
-
#update(ips) ⇒ Object
Update a host.
Methods included from GandiObjectMethods
#[], included, #inspect, #to_hash
Constructor Details
#initialize(hostname, attributes = nil) ⇒ Host
Returns a new instance of Host.
9 10 11 12 |
# File 'lib/gandi/domain/host.rb', line 9 def initialize(hostname, attributes = nil) @hostname = hostname @attributes = attributes || info end |
Instance Attribute Details
#hostname ⇒ Object (readonly)
The hostname of the Host
7 8 9 |
# File 'lib/gandi/domain/host.rb', line 7 def hostname @hostname end |
Class Method Details
.count(fqdn, opts = {}) ⇒ Object
Count the glue records / hosts of a domain. TODO: accept a Domain object.
48 49 50 |
# File 'lib/gandi/domain/host.rb', line 48 def count(fqdn, opts = {}) call('domain.host.count', fqdn, opts) end |
.create(hostname, ips) ⇒ Object
Create a host. Returns a Gandi::Operation object.
41 42 43 44 |
# File 'lib/gandi/domain/host.rb', line 41 def create(hostname, ips) operation_hash = call('domain.host.create', hostname, ips) Gandi::Operation.new(operation_hash['id'], operation_hash) end |
.list(fqdn, opts = {}) ⇒ Object
List the glue records / hosts for a given domain. Return an array of Host objects. TODO: accept a Domain object.
55 56 57 58 59 |
# File 'lib/gandi/domain/host.rb', line 55 def list(fqdn, opts = {}) call('domain.host.list', fqdn, opts).map do |host| self.new(host['name'], host) end end |
Instance Method Details
#delete ⇒ Object
Delete a host. Returns a Gandi::Operation object.
16 17 18 19 |
# File 'lib/gandi/domain/host.rb', line 16 def delete operation_hash = self.class.call('domain.host.delete', @hostname) Gandi::Operation.new(operation_hash['id'], operation_hash) end |
#info ⇒ Object
Display host information for a given domain.
22 23 24 |
# File 'lib/gandi/domain/host.rb', line 22 def info self.class.call('domain.host.info', @hostname) end |
#ips ⇒ Object
Return the host IP adresses.
27 28 29 |
# File 'lib/gandi/domain/host.rb', line 27 def ips @attributes['ips'] end |