Sha256: 692384f49c5f320781298098b505e594a19de04cd1e31fbabb90982256fbec46

Contents?: true

Size: 1.28 KB

Versions: 29

Compression:

Stored size: 1.28 KB

Contents

require 'fog/core/model'

module Fog
  module HP
    class DNS
      class Record < Fog::Model
        identity :id

        attribute :name
        attribute :description
        attribute :domain_id
        attribute :type
        attribute :ttl
        attribute :data
        attribute :priority
        attribute :created_at
        attribute :updated_at

        def initialize(new_attributes = {})
          super(new_attributes)
          self.domain_id = domain.id if domain
          self
        end

        def destroy
          requires :id, :domain_id
          service.delete_record(self.domain_id, id)
          true
        end

        def save
          identity ? update : create
        end

        private

        def domain
          collection.domain
        end

        def create
          requires :domain_id
          ### Inconsistent API behavior - does not return 'record'
          merge_attributes(service.create_record(self.domain_id, self.name, self.type, self.data, attributes).body)
          true
        end

        def update
          requires :id, :domain_id
          ### Inconsistent API behavior - does not return 'record'
          merge_attributes(service.update_record(self.domain_id, id, attributes).body)
          true
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 4 rubygems

Version Path
fog-1.37.0 lib/fog/hp/models/dns/record.rb
fog-1.36.0 lib/fog/hp/models/dns/record.rb
fog-1.35.0 lib/fog/hp/models/dns/record.rb
fog-2.0.0.pre.0 lib/fog/hp/models/dns/record.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/hp/models/dns/record.rb
fog-1.34.0 lib/fog/hp/models/dns/record.rb
fog-1.33.0 lib/fog/hp/models/dns/record.rb
fog-1.32.0 lib/fog/hp/models/dns/record.rb
fog-1.31.0 lib/fog/hp/models/dns/record.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/hp/models/dns/record.rb
fog-1.30.0 lib/fog/hp/models/dns/record.rb
fog-1.29.0 lib/fog/hp/models/dns/record.rb
fog-1.28.0 lib/fog/hp/models/dns/record.rb
fog-1.27.0 lib/fog/hp/models/dns/record.rb
fog-1.26.0 lib/fog/hp/models/dns/record.rb
fog-1.25.0 lib/fog/hp/models/dns/record.rb
nsidc-fog-1.24.1 lib/fog/hp/models/dns/record.rb
fog-1.24.0 lib/fog/hp/models/dns/record.rb
ns-fog-1.22.11 lib/fog/hp/models/dns/record.rb
ns-fog-1.22.10 lib/fog/hp/models/dns/record.rb