Sha256: bbc15a778dbe524b9ebdb4bc4b70b31fa66c22c4a95ad99b249a821a61d26eaf

Contents?: true

Size: 1.5 KB

Versions: 27

Compression:

Stored size: 1.5 KB

Contents

require 'fog/core/model'

module Fog
  module Compute
    class Brightbox

      class Image < Fog::Model

        identity :id
        attribute :url
        attribute :resource_type

        attribute :name
        attribute :username
        attribute :status
        attribute :description

        attribute :source
        attribute :source_type
        attribute :arch
        attribute :virtual_size
        attribute :disk_size
        attribute :licence_name

        # Boolean flags
        attribute :public
        attribute :official
        attribute :compatibility_mode

        # Times
        attribute :created_at, :type => :time

        # Links - to be replaced
        attribute :ancestor_id, :aliases => "ancestor", :squash => "id"
        attribute :owner_id, :aliases => "owner", :squash => "id"

        def ready?
          status == "available"
        end

        def save
          raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
          requires :source, :arch
          options = {
            :source => source,
            :arch => arch,
            :name => name,
            :username => username,
            :description => description
          }.delete_if { |k, v| v.nil? || v == "" }
          data = service.create_image(options)
          merge_attributes(data)
          true
        end

        def destroy
          requires :identity
          service.destroy_image(identity)
          true
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 3 rubygems

Version Path
fog-brightbox-0.1.0.dev2 lib/fog/brightbox/models/compute/image.rb
fog-brightbox-0.1.0.dev1 lib/fog/brightbox/models/compute/image.rb
fog-brightbox-0.0.2 lib/fog/brightbox/models/compute/image.rb
fog-1.21.0 providers/brightbox/lib/fog/brightbox/models/compute/image.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/brightbox/models/compute/image.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/brightbox/models/compute/image.rb
fog-brightbox-0.0.1 lib/fog/brightbox/models/compute/image.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/brightbox/models/compute/image.rb
fog-1.20.0 lib/fog/brightbox/models/compute/image.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/brightbox/models/compute/image.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/brightbox/models/compute/image.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/brightbox/models/compute/image.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/brightbox/models/compute/image.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/brightbox/models/compute/image.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/brightbox/models/compute/image.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/brightbox/models/compute/image.rb
fog-1.19.0 lib/fog/brightbox/models/compute/image.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/brightbox/models/compute/image.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/brightbox/models/compute/image.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/brightbox/models/compute/image.rb