Sha256: 3cb1ab341f5185962b8b11cc117de4c9c8345efdce14b4f55cde8de0a96904e9

Contents?: true

Size: 1.87 KB

Versions: 4

Compression:

Stored size: 1.87 KB

Contents

require 'fog/compute/gridscale/models/storage'

module Fog
  module Compute
    class Gridscale
      class Storage < Fog::Model
        identity :object_uuid

        attribute :name
        attribute :object_uuid
        attribute :location_uuid
        attribute :storage_type
        attribute :license_product_no
        attribute :capacity
        attribute :labels
        attribute :status
        attribute :create_time
        attribute :change_time
        attribute :current_price
        attribute :location_uuid
        attribute :location_name
        attribute :location_country
        attribute :location_iata
        attribute :relations
        attribute :template
        attribute :template_uuid

        def delete
          requires :object_uuid
          response = service.storage_delete object_uuid
          response.body
        end

        def destroy
          requires :object_uuid
          response = service.storage_delete object_uuid
          response.body
        end

        def save
          raise Fog::Errors::Error.new('Re-saving an existing object may create a duplicate') if persisted?
          requires :name, :capacity

          options = {}

          if attributes[:template]
            options[:template] = template
          end

          if attributes[:labels]
            options[:labels] = labels
          end

          if attributes[:storage_type]
            options[:storage_type] = storage_type
          end

          if attributes[:location_uuid]
            options[:location_uuid] = location_uuid
          end

          data = service.storage_create(name, capacity, options)

          merge_attributes(data.body)
          true
        end

        def update
          requires :object_uuid
          data = service.storage_update(object_uuid)
          merge_attributes(data.body)
          true
        end

      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-gridscale-0.1.5 lib/fog/compute/gridscale/models/storage.rb
fog-gridscale-0.1.4 lib/fog/compute/gridscale/models/storage.rb
fog-gridscale-0.1.3 lib/fog/compute/gridscale/models/storage.rb
fog-gridscale-0.1.2 lib/fog/compute/gridscale/models/storage.rb