Sha256: c7bd074471e6928f45f6c0cd324a5c202513e3730dd84697faf1694393a3d4ea

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

module Brightbox
  class Volume < Api
    def self.require_account?; true; end

    def self.all
      conn.volumes
    end

    def self.create(options)
      new(conn.volumes.create(options))
    end

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

    def self.default_field_order
      %i[
        id
        type
        size
        status
        server
        boot
        name
      ]
    end

    def self.detailed_fields
      %i[
        id
        name
        description
        type
        size
        status
        created_at
        encrypted
        serial
        locked
        filesystem_label
        filesystem_type
        image
        source
        source_type
        server
        boot
        delete_with_server
        zone
      ]
    end

    def attach(server:, boot: false)
      self.class.conn.attach_volume(id, server: server, boot: boot)
      reload
      self
    end

    def attributes
      super.merge(
        id: fog_model.id,
        image: image_id,
        locked: locked?,
        server: server_id,
        status: state,
        type: storage_type,
        zone: zone_id
      )
    end

    def update(options)
      self.class.conn.update_volume(id, options)
      reload
      self
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
brightbox-cli-5.0.0 lib/brightbox-cli/volume.rb
brightbox-cli-5.0.0.rc2 lib/brightbox-cli/volume.rb
brightbox-cli-5.0.0.rc1 lib/brightbox-cli/volume.rb