Class: Gandi::Domain::Host

Inherits:
Object
  • Object
show all
Includes:
GandiObjectMethods
Defined in:
lib/gandi/domain/host.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#hostnameObject (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

#deleteObject

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

#infoObject

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

#ipsObject

Return the host IP adresses.



27
28
29
# File 'lib/gandi/domain/host.rb', line 27

def ips
  @attributes['ips']
end

#update(ips) ⇒ Object

Update a host. Return a Gandi::Operation object.



33
34
35
36
# File 'lib/gandi/domain/host.rb', line 33

def update(ips)
  operation_hash = self.class.call('domain.host.update', @hostname, ips)
  Gandi::Operation.new(operation_hash['id'], operation_hash)
end