Sha256: 6eb13a1d995a615812120e0ff1053b7f75f827b36a9244f0b891764d7c7f2834

Contents?: true

Size: 1.55 KB

Versions: 13

Compression:

Stored size: 1.55 KB

Contents

require 'fog/core/model'

module Fog
  module AWS
    class DNS

      class Record < Fog::Model

        identity :id,           :aliases => ['Id']

        attribute :ip,          :aliases => ['ResourceRecords']
        attribute :name,        :aliases => ['Name']
        attribute :ttl,         :aliases => ['TTL']
        attribute :type,        :aliases => ['Type']
        attribute :status,      :aliases => ['Status']
        attribute :created_at,  :aliases => ['SubmittedAt']

        def initialize(attributes={})
          self.ttl    ||= 3600
          super
        end

        def destroy
          requires :ip, :name, :ttl, :type, :zone
          options = {
            :action           => 'DELETE',
            :name             => name,
            :resource_records => [*ip],
            :ttl              => ttl,
            :type             => type
          }
          connection.change_resource_record_sets(zone.id, [options])
          true
        end

        def zone
          @zone
        end

        def save
          requires :ip, :name, :ttl, :type, :zone
          options = {
            :action           => 'CREATE',
            :name             => name,
            :resource_records => [*ip],
            :ttl              => ttl,
            :type             => type
          }
          data = connection.change_resource_record_sets(zone.id, [options]).body
          merge_attributes(data)
          true
        end

        private

        def zone=(new_zone)
          @zone = new_zone
        end

      end

    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
fog-0.7.1 lib/fog/dns/models/aws/record.rb
fog-0.7.0 lib/fog/dns/models/aws/record.rb
fog-0.6.0 lib/fog/dns/models/aws/record.rb
fog-0.5.3 lib/fog/dns/models/aws/record.rb
fog-0.5.2 lib/fog/dns/models/aws/record.rb
fog-0.5.1 lib/fog/dns/models/aws/record.rb
fog-0.5.0 lib/fog/dns/models/aws/record.rb
phpfog-fog-0.4.1.3 lib/fog/dns/models/aws/record.rb
phpfog-fog-0.4.1.2 lib/fog/dns/models/aws/record.rb
phpfog-fog-0.4.1.1 lib/fog/dns/models/aws/record.rb
phpfog-fog-0.4.1 lib/fog/dns/models/aws/record.rb
fog-0.4.1 lib/fog/dns/models/aws/record.rb
fog-0.4.0 lib/fog/aws/models/dns/record.rb