Class: Katello::Api::V2::EnvironmentsController
Constant Summary
Concerns::FilteredAutoCompleteSearch::PAGE_SIZE
Instance Method Summary
collapse
#auto_complete_search
#check_katello_agent_not_disabled, #deprecate_katello_agent, #empty_search_query?, #full_result_response, #katello_agent_removal_release, #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
#create ⇒ Object
87
88
89
90
91
92
93
|
# File 'app/controllers/katello/api/v2/environments_controller.rb', line 87
def create
create_params = environment_params
create_params[:label] = labelize_params(create_params)
create_params[:organization] = @organization
@environment = @prior.insert_successor(create_params, @path)
respond
end
|
#destroy ⇒ Object
126
127
128
129
130
131
|
# File 'app/controllers/katello/api/v2/environments_controller.rb', line 126
def destroy
sync_task(::Actions::Katello::Environment::Destroy, @environment)
respond_for_destroy
rescue RuntimeError => e
raise HttpErrors::BadRequest, e.message
end
|
#index ⇒ Object
54
55
56
|
# File 'app/controllers/katello/api/v2/environments_controller.rb', line 54
def index
respond(:collection => scoped_search(index_relation.distinct, :name, :asc, :resource_class => KTEnvironment))
end
|
#index_relation ⇒ Object
58
59
60
61
62
63
64
65
|
# File 'app/controllers/katello/api/v2/environments_controller.rb', line 58
def index_relation
query = KTEnvironment.readable
query = query.where(organization: @organization) if @organization
query = query.where(:name => params[:name]) if params[:name]
query = query.where(:label => params[:label]) if params[:label]
query = query.where(:library => params[:library]) if params[:library]
query
end
|
#paths ⇒ Object
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
# File 'app/controllers/katello/api/v2/environments_controller.rb', line 139
def paths
env_paths = if params[:permission_type] == "promotable"
@organization.promotable_promotion_paths
else
@organization.readable_promotion_paths
end
paths = env_paths.inject([]) do |result, path|
result << { :environments => [@organization.library] + path.select(&:readable?) }
end
paths = [{ :environments => [@organization.library] }] if paths.empty?
collection = {
:results => paths,
:total => paths.size,
:subtotal => paths.size
}
respond_for_index(:collection => collection, :template => :paths)
end
|
#resource_class ⇒ Object
163
164
165
|
# File 'app/controllers/katello/api/v2/environments_controller.rb', line 163
def resource_class
Katello::KTEnvironment
end
|
#resource_name ⇒ Object
159
160
161
|
# File 'app/controllers/katello/api/v2/environments_controller.rb', line 159
def resource_name
'environment'
end
|
#show ⇒ Object
71
72
73
|
# File 'app/controllers/katello/api/v2/environments_controller.rb', line 71
def show
respond(resource: @environment)
end
|
#update ⇒ Object
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'app/controllers/katello/api/v2/environments_controller.rb', line 104
def update
async = ::Foreman::Cast.to_bool(params.fetch(:async, true))
update_params = environment_params
fail HttpErrors::BadRequest, _("Can't update the '%s' environment") % "Library" if @environment.library? && update_params.empty?
update_params[:name] = params[:environment][:new_name] if params[:environment][:new_name]
@environment.update!(update_params)
if update_params[:registry_name_pattern] || update_params[:registry_unauthenticated_pull]
task = send(async ? :async_task : :sync_task, ::Actions::Katello::Environment::PublishRepositories,
@environment, content_type: Katello::Repository::DOCKER_TYPE)
end
if params.include?(:async) && async && task
respond_for_async(resource: task)
else
respond
end
end
|