Class: Katello::Api::V2::ContentUploadsController

Inherits:
ApiController
  • Object
show all
Includes:
Foreman::Controller::FilterParameters
Defined in:
app/controllers/katello/api/v2/content_uploads_controller.rb

Instance Method Summary collapse

Methods inherited from ApiController

#check_katello_agent_not_disabled, #deprecate_katello_agent, #empty_search_query?, #full_result_response, #katello_agent_removal_release, #resource_class, #scoped_search, #skip_session

Methods included from Rendering

#respond_for_async, #respond_for_bulk_async, #respond_for_create, #respond_for_destroy, #respond_for_index, #respond_for_show, #respond_for_status, #respond_for_update, #respond_with_template, #respond_with_template_collection, #respond_with_template_resource, #try_specific_collection_template, #try_specific_resource_template

Methods included from Katello::Api::Version2

#api_version

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/katello/api/v2/content_uploads_controller.rb', line 16

def create
  fail Katello::Errors::InvalidRepositoryContent, _("Cannot upload Ansible collections.") if @repository.ansible_collection?
  content_type = params[:content_type] || ::Katello::RepositoryTypeManager.find(@repository.content_type)&.default_managed_content_type&.label
  RepositoryTypeManager.check_content_matches_repo_type!(@repository, content_type)
  if ::Katello::RepositoryTypeManager.generic_content_type?(content_type)
    unit_type_id = content_type
  else
    unit_type_id = SmartProxy.pulp_primary.content_service(content_type).content_type
  end
  render :json => @repository.backend_content_service(::SmartProxy.pulp_primary).create_upload(params[:size], params[:checksum], unit_type_id, @repository)
end

#destroyObject



43
44
45
46
# File 'app/controllers/katello/api/v2/content_uploads_controller.rb', line 43

def destroy
  @repository.backend_content_service(::SmartProxy.pulp_primary).delete_upload(params[:id])
  head :no_content
end

#updateObject



34
35
36
37
38
# File 'app/controllers/katello/api/v2/content_uploads_controller.rb', line 34

def update
  @repository.backend_content_service(::SmartProxy.pulp_primary)
    .upload_chunk(params[:id], params[:offset], params[:content], params[:size])
  head :no_content
end