Class: Katello::Api::V2::AlternateContentSourcesBulkActionsController

Inherits:
ApiController
  • Object
show all
Defined in:
app/controllers/katello/api/v2/alternate_content_sources_bulk_actions_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

#destroy_alternate_content_sourcesObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/katello/api/v2/alternate_content_sources_bulk_actions_controller.rb', line 7

def destroy_alternate_content_sources
  deletable_alternate_content_sources = @alternate_content_sources.deletable

  if deletable_alternate_content_sources.empty?
    msg = _("Unable to delete any alternate content source. You either do not have the permission to"\
      " delete, or none of the alternate content sources exist.")
    fail HttpErrors::UnprocessableEntity, msg
  end
  task = async_task(::Actions::BulkAction,
                    ::Actions::Katello::AlternateContentSource::Destroy,
                    deletable_alternate_content_sources)
  respond_for_async :resource => task
end

#refresh_alternate_content_sourcesObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/katello/api/v2/alternate_content_sources_bulk_actions_controller.rb', line 23

def refresh_alternate_content_sources
  refreshable_alternate_content_sources = @alternate_content_sources.editable
  if refreshable_alternate_content_sources.empty?
    msg = _("Unable to refresh any alternate content source. You either do not have the permission to"\
            " refresh, or none of the alternate content sources exist.")
    fail HttpErrors::UnprocessableEntity, msg
  else
    task = async_task(::Actions::BulkAction,
                      ::Actions::Katello::AlternateContentSource::Refresh,
                      refreshable_alternate_content_sources)
    respond_for_async resource: task
  end
end