Sha256: bf9a31c898ce26764f9ba313744013ccdbe38dd2a542fe50a971ff593e7b6ded

Contents?: true

Size: 1.66 KB

Versions: 5

Compression:

Stored size: 1.66 KB

Contents

module Fog
  module Brightbox
    class Compute
      class Image < Fog::Brightbox::Model
        include Fog::Brightbox::Compute::ResourceLocking

        identity :id
        attribute :resource_type
        attribute :url

        attribute :name
        attribute :status
        attribute :description

        attribute :arch
        attribute :disk_size, type: :integer
        attribute :licence_name
        attribute :min_ram, type: :integer
        attribute :source
        attribute :source_trigger
        attribute :source_type
        attribute :username
        attribute :virtual_size, type: :integer

        # Boolean flags
        attribute :compatibility_mode, type: :boolean
        attribute :official, type: :boolean
        attribute :public, type: :boolean

        # Timestamps
        attribute :created_at, type: :time

        # Links
        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.delete_image(identity)
          true
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fog-brightbox-1.8.0 lib/fog/brightbox/models/compute/image.rb
fog-brightbox-1.7.3 lib/fog/brightbox/models/compute/image.rb
fog-brightbox-1.7.2 lib/fog/brightbox/models/compute/image.rb
fog-brightbox-1.7.1 lib/fog/brightbox/models/compute/image.rb
fog-brightbox-1.7.0 lib/fog/brightbox/models/compute/image.rb