Class: Katello::Api::V2::ExportsController
- Inherits:
-
ApiController
- Object
- Api::V2::BaseController
- ApiController
- Katello::Api::V2::ExportsController
show all
- Defined in:
- app/controllers/katello/api/v2/exports_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
#export_content_view_version ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
|
# File 'app/controllers/katello/api/v2/exports_controller.rb', line 54
def export_content_view_version
tasks = async_task(Actions::Katello::ContentViewVersion::Export,
content_view_version: @version,
destination_server: params[:destination_server],
chunk_size: params[:chunk_size_gb],
from_history: @history,
format: find_export_format,
fail_on_missing_content: ::Foreman::Cast.to_bool(params[:fail_on_missing_content]))
respond_for_async :resource => tasks
end
|
#export_library ⇒ Object
66
67
68
69
70
71
72
73
74
75
|
# File 'app/controllers/katello/api/v2/exports_controller.rb', line 66
def export_library
tasks = async_task(::Actions::Pulp3::Orchestration::ContentViewVersion::ExportLibrary,
@organization,
destination_server: params[:destination_server],
chunk_size: params[:chunk_size_gb],
from_history: @history,
format: find_export_format,
fail_on_missing_content: ::Foreman::Cast.to_bool(params[:fail_on_missing_content]))
respond_for_async :resource => tasks
end
|
#export_repository ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'app/controllers/katello/api/v2/exports_controller.rb', line 45
def export_repository
tasks = async_task(::Actions::Pulp3::Orchestration::ContentViewVersion::ExportRepository,
@repository,
chunk_size: params[:chunk_size_gb],
from_history: @history,
format: find_export_format)
respond_for_async :resource => tasks
end
|
77
78
79
80
81
82
83
84
85
86
87
|
# File 'app/controllers/katello/api/v2/exports_controller.rb', line 77
def find_export_format
if params[:format]
unless ::Katello::Pulp3::ContentViewVersion::Export::FORMATS.include?(params[:format])
fail HttpErrors::UnprocessableEntity, _('Invalid export format provided. Format must be one of %s ') %
::Katello::Pulp3::ContentViewVersion::Export::FORMATS.join(',')
end
params[:format]
else
Setting[:default_export_format]
end
end
|
#find_exportable_content_view_version ⇒ Object
107
108
109
110
111
|
# File 'app/controllers/katello/api/v2/exports_controller.rb', line 107
def find_exportable_content_view_version
@version = ContentViewVersion.exportable.find_by_id(params[:id])
throw_resource_not_found(name: 'content view version', id: params[:id]) if @version.blank?
@view = @version.content_view
end
|
#find_exportable_organization ⇒ Object
100
101
102
103
104
105
|
# File 'app/controllers/katello/api/v2/exports_controller.rb', line 100
def find_exportable_organization
find_organization
unless @organization.can_export_content?
throw_resource_not_found(name: 'organization', id: params[:organization_id])
end
end
|
#find_exportable_repository ⇒ Object
89
90
91
92
93
94
95
96
97
98
|
# File 'app/controllers/katello/api/v2/exports_controller.rb', line 89
def find_exportable_repository
@repository = Repository.find_by_id(params[:id])
if @repository.blank?
throw_resource_not_found(name: 'repository', id: params[:id])
end
unless @repository.organization.can_export_content?
throw_resource_not_found(name: 'organization', id: @repository.organization.id)
end
end
|
#find_history ⇒ Object
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'app/controllers/katello/api/v2/exports_controller.rb', line 113
def find_history
if params[:from_history_id].present?
@history = ::Katello::ContentViewVersionExportHistory.find(params[:from_history_id])
if @history.blank?
throw_resource_not_found(name: 'export history',
id: params[:from_history_id])
end
else
@history = ::Katello::ContentViewVersionExportHistory.
latest(@view, destination_server: params[:destination_server])
if @history.blank?
msg = _("No existing export history was found to perform an incremental export. A full export must be performed")
fail HttpErrors::NotFound, msg
end
end
end
|