class StorageController

Controller class handling all storage-related requests. Implements listing, retrieval, creation, deletion and triggering actions on storage instances.

Public Instance Methods

create() click to toggle source

POST /storage/

# File app/controllers/storage_controller.rb, line 35
def create
  storage = request_occi_collection.resources.first
  storage_location = backend_instance.storage_create(storage)

  respond_with("#{server_url}/storage/#{storage_location}", status: 201, flag: :link_only)
end
delete() click to toggle source

DELETE /storage/ DELETE /storage/:id

# File app/controllers/storage_controller.rb, line 90
def delete
  if params[:id]
    result = backend_instance.storage_delete(params[:id])
  else
    result = backend_instance.storage_delete_all
  end

  if result
    respond_with(Occi::Collection.new)
  else
    respond_with(Occi::Collection.new, status: 304)
  end
end
index() click to toggle source

GET /storage/

# File app/controllers/storage_controller.rb, line 6
def index
  if INDEX_LINK_FORMATS.include?(request.format)
    @storages = backend_instance.storage_list_ids
    @storages.map! { |c| "#{server_url}/storage/#{c}" }
    options = { flag: :links_only }
  else
    @storages = Occi::Collection.new
    @storages.resources = backend_instance.storage_list
    update_mixins_in_coll(@storages)
    options = {}
  end

  respond_with(@storages, options)
end
partial_update() click to toggle source

POST /storage/:id

# File app/controllers/storage_controller.rb, line 62
def partial_update
  # TODO: impl
  respond_with(Occi::Collection.new, status: 501)
end
show() click to toggle source

GET /storage/:id

# File app/controllers/storage_controller.rb, line 22
def show
  @storage = Occi::Collection.new
  @storage << backend_instance.storage_get(params[:id])

  unless @storage.empty?
    update_mixins_in_coll(@storage)
    respond_with(@storage)
  else
    respond_with(Occi::Collection.new, status: 404)
  end
end
trigger() click to toggle source

POST /storage/?action=:action POST /storage/:id?action=:action

# File app/controllers/storage_controller.rb, line 44
def trigger
  ai = request_occi_collection(Occi::Core::ActionInstance).action
  check_ai!(ai, request.query_string)

  if params[:id]
    result = backend_instance.storage_trigger_action(params[:id], ai)
  else
    result = backend_instance.storage_trigger_action_on_all(ai)
  end

  if result
    respond_with(Occi::Collection.new)
  else
    respond_with(Occi::Collection.new, status: 304)
  end
end
update() click to toggle source

PUT /storage/:id

# File app/controllers/storage_controller.rb, line 68
def update
  storage = request_occi_collection.resources.first
  storage.id = params[:id] if storage
  result = backend_instance.storage_update(storage)

  if result
    storage = Occi::Collection.new
    storage << backend_instance.storage_get(params[:id])

    unless storage.empty?
      update_mixins_in_coll(storage)
      respond_with(storage)
    else
      respond_with(Occi::Collection.new, status: 404)
    end
  else
    respond_with(Occi::Collection.new, status: 304)
  end
end