Sha256: 0b55e08343f2e384c025b0738fdab25e09a1a44a99dd47174e83488d1a3a26a2

Contents?: true

Size: 1.39 KB

Versions: 7

Compression:

Stored size: 1.39 KB

Contents

require 'fog/core/collection'
require 'fog/dns/models/aws/record'

module Fog
  module DNS
    class AWS

      class Records < Fog::Collection

        attribute :is_truncated,      :aliases => ['IsTruncated']
        attribute :max_items,         :aliases => ['MaxItems']
        attribute :name
        attribute :next_record_name,  :aliases => ['NextRecordName']
        attribute :next_record_type,  :aliases => ['NextRecordType']
        attribute :type

        attribute :zone

        model Fog::DNS::AWS::Record

        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

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

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

      end

    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
brightbox-cli-0.13.1 lib/brightbox-cli/vendor/fog/lib/fog/dns/models/aws/records.rb
brightbox-cli-0.13.0 lib/brightbox-cli/vendor/fog/lib/fog/dns/models/aws/records.rb
fog-0.11.0 lib/fog/dns/models/aws/records.rb
fog-0.10.0 lib/fog/dns/models/aws/records.rb
fog4encbs-0.9.0.1 lib/fog/dns/models/aws/records.rb
fog4encbs-0.9.0 lib/fog/dns/models/aws/records.rb
fog-0.9.0 lib/fog/dns/models/aws/records.rb