Sha256: bf4d325c0190e66f36133ec2db1502367299badd62356ead18f755a6f132ec23

Contents?: true

Size: 1017 Bytes

Versions: 2

Compression:

Stored size: 1017 Bytes

Contents

module Brightbox
  class Image < Api

    def to_row
      o = fog_model.attributes
      o[:id] = fog_model.id
      if status == "available"
        o[:status] = (public ? 'public' : 'private')
      else
        o[:status] = status
      end
      o[:arch] = arch
      o[:name] = name.to_s + " (#{arch})"
      o[:owner] = owner_id
      if official
        o[:type] = "official"
        o[:owner] = "brightbox"
      else
        o[:type] = source_type
      end
      o[:created_at] = created_at
      o[:created_on] = created_at.to_s.split('T').first
      o[:description] = description if description
      o[:size] = virtual_size
      o
    end

    def self.register(options = {})
      image = conn.create_image(options)
      find image['id']
    end

    def public?
      public
    end

    def self.all
      conn.images
    end

    def self.get(id)
      conn.images.get(id)
    end

    def self.default_field_order
      [:id, :owner, :type, :created_on, :status, :size, :name]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
brightbox-cli-0.13.1 lib/brightbox-cli/images.rb
brightbox-cli-0.13.0 lib/brightbox-cli/images.rb