Class: Fog::DNS::Dynect::Record

Inherits:
Model
  • Object
show all
Extended by:
Fog::Deprecation
Defined in:
lib/fog/dns/models/dynect/record.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods included from Fog::Deprecation

deprecate, self_deprecate

Methods inherited from Model

#initialize, #inspect, #reload, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#destroyObject



18
19
20
21
22
# File 'lib/fog/dns/models/dynect/record.rb', line 18

def destroy
  requires :identity, :name, :type, :zone
  connection.delete_record(type, zone.identity, name, identity)
  true
end

#saveObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fog/dns/models/dynect/record.rb', line 24

def save
  requires :name, :type, :value, :zone

  options = {
    :ttl => ttl
  }
  options.delete_if {|key, value| value.nil?}

  data = connection.post_record(type, zone.identity, name, {'address' => value}, options).body['data']
  # avoid overwriting zone object with zone string
  data = data.reject {|key, value| key == 'zone'}
  merge_attributes(data)

  zone.publish
  records = connection.get_record(type, zone.identity, name).body['data']
  # data in format ['/REST/xRecord/domain/fqdn/identity]
  records.map! do |record|
    tokens = record.split('/')
    {
      :identity => tokens.last,
      :type     => tokens[2][0...-6] # everything before 'Record'
    }
  end
  record = records.detect {|record| record[:type] == type}
  merge_attributes(record)

  true
end

#zoneObject



53
54
55
# File 'lib/fog/dns/models/dynect/record.rb', line 53

def zone
  @zone
end