Class: Katello::Api::V2::RepositoriesBulkActionsController
- Inherits:
-
ApiController
- Object
- Api::V2::BaseController
- ApiController
- Katello::Api::V2::RepositoriesBulkActionsController
show all
- Defined in:
- app/controllers/katello/api/v2/repositories_bulk_actions_controller.rb
Instance Method Summary
collapse
#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
#api_version
Instance Method Details
#destroy_repositories ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/controllers/katello/api/v2/repositories_bulk_actions_controller.rb', line 7
def destroy_repositories
deletion_authorized_repositories = @repositories.deletable
unpromoted_repos = deletion_authorized_repositories.reject { |repo| repo.promoted? && repo.content_views.generated_for_none.exists? }
messages1 = format_bulk_action_messages(
:success => "",
:error => _("You do not have permissions to delete %s"),
:models => @repositories,
:authorized => deletion_authorized_repositories
)
messages2 = format_bulk_action_messages(
:success => "",
:error => _("Repository %s cannot be deleted since it has already been included in a published Content View."),
:models => deletion_authorized_repositories,
:authorized => unpromoted_repos
)
errors = messages1[:error] + messages2[:error]
task = nil
if unpromoted_repos.any?
task = async_task(::Actions::BulkAction, ::Actions::Katello::Repository::Destroy, unpromoted_repos)
else
status = 400
end
respond_for_bulk_async :resource => OpenStruct.new(:task => task, :errors => errors), :status => status
end
|
#reclaim_space_from_repositories ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'app/controllers/katello/api/v2/repositories_bulk_actions_controller.rb', line 55
def reclaim_space_from_repositories
if @repositories.empty?
fail _("No repositories selected.")
end
repositories = @repositories.select { |repo| repo.download_policy == ::Katello::RootRepository::DOWNLOAD_ON_DEMAND }
if repositories.empty?
fail _("Only On Demand repositories may have space reclaimed.")
end
task = async_task(::Actions::BulkAction,
::Actions::Pulp3::Repository::ReclaimSpace,
repositories)
respond_for_async :resource => task
end
|
#sync_repositories ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'app/controllers/katello/api/v2/repositories_bulk_actions_controller.rb', line 38
def sync_repositories
syncable_repositories = @repositories.syncable.has_url
if syncable_repositories.empty?
msg = _("Unable to synchronize any repository. You either do not have the permission to"\
" synchronize or the selected repositories do not have a feed url.")
fail HttpErrors::UnprocessableEntity, msg
else
task = async_task(::Actions::BulkAction,
::Actions::Katello::Repository::Sync,
syncable_repositories)
respond_for_async :resource => task
end
end
|