Sha256: 46d81587af0ffde5f6431df777d0c0d6f7d7ad3e07362db93315b77a19d457d4

Contents?: true

Size: 1.47 KB

Versions: 18

Compression:

Stored size: 1.47 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

        # 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 identity
          requires :source, :arch
          options = {
            :source => source,
            :arch => arch,
            :name => name,
            :username => username,
            :description => description
          }.delete_if {|k,v| v.nil? || v == "" }
          data = connection.create_image(options)
          merge_attributes(data)
          true
        end

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

      end

    end
  end
end

Version data entries

18 entries across 18 versions & 6 rubygems

Version Path
fog-1.5.0 lib/fog/brightbox/models/compute/image.rb
fog-1.4.0 lib/fog/brightbox/models/compute/image.rb
michiels-fog-1.3.1 lib/fog/brightbox/models/compute/image.rb
ftl-0.2.0 vendor/bundle/gems/fog-1.3.1/lib/fog/brightbox/models/compute/image.rb
fog-1.3.1 lib/fog/brightbox/models/compute/image.rb
fog-1.3.0 lib/fog/brightbox/models/compute/image.rb
fog-1.2.0 lib/fog/brightbox/models/compute/image.rb
ktheory-fog-1.1.2 lib/fog/brightbox/models/compute/image.rb
brightbox-cli-0.17.4 lib/brightbox-cli/vendor/fog/lib/fog/brightbox/models/compute/image.rb
brightbox-cli-0.17.3 lib/brightbox-cli/vendor/fog/lib/fog/brightbox/models/compute/image.rb
brightbox-cli-0.17.2 lib/brightbox-cli/vendor/fog/lib/fog/brightbox/models/compute/image.rb
brightbox-cli-0.17.1 lib/brightbox-cli/vendor/fog/lib/fog/brightbox/models/compute/image.rb
brightbox-cli-0.17.0 lib/brightbox-cli/vendor/fog/lib/fog/brightbox/models/compute/image.rb
fog-1.1.2 lib/fog/brightbox/models/compute/image.rb
fog_tractical-1.1.4 lib/fog/brightbox/models/compute/image.rb
fog_tractical-1.1.3 lib/fog/brightbox/models/compute/image.rb
brightbox-cli-0.16.0 lib/brightbox-cli/vendor/fog/lib/fog/brightbox/models/compute/image.rb
brightbox-cli-0.15.0 lib/brightbox-cli/vendor/fog/lib/fog/brightbox/models/compute/image.rb