Class: Fog::DNS::AWS::Records

Inherits:
Collection show all
Defined in:
lib/fog/dns/models/aws/records.rb

Instance Attribute Summary

Attributes inherited from Collection

#connection

Instance Method Summary collapse

Methods inherited from Collection

#clear, #create, #initialize, #inspect, #load, model, #model, #reload, #table, #to_json

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::Collection

Instance Method Details

#all(options = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/dns/models/aws/records.rb', line 21

def all(options = {})
  requires :zone
  options['MaxItems'] ||= max_items
  options['Name']     ||= name
  options['Type']     ||= type
  data = connection.list_resource_record_sets(zone.id, options).body
  merge_attributes(data.reject {|key, value| !['IsTruncated', 'MaxItems', 'NextRecordName', 'NextRecordType'].include?(key)})
  # leave out the default, read only records
  data = data['ResourceRecordSets'].reject {|record| ['NS', 'SOA'].include?(record['Type'])}
  load(data)
end

#get(record_id) ⇒ Object



33
34
35
36
37
38
# File 'lib/fog/dns/models/aws/records.rb', line 33

def get(record_id)
  data = connection.get_change(record_id).body
  new(data)
rescue Excon::Errors::Forbidden
  nil
end

#new(attributes = {}) ⇒ Object



40
41
42
43
# File 'lib/fog/dns/models/aws/records.rb', line 40

def new(attributes = {})
  requires :zone
  super({ :zone => zone }.merge!(attributes))
end