Class: Katello::Api::V2::EnvironmentsController
Constant Summary
Concerns::FilteredAutoCompleteSearch::PAGE_SIZE
Instance Method Summary
collapse
#auto_complete_search
#full_result_response, #resource_class, #scoped_search
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
79
80
81
82
83
84
85
86
|
# File 'app/controllers/katello/api/v2/environments_controller.rb', line 79
def create
create_params = environment_params
create_params[:label] = labelize_params(create_params)
create_params[:organization] = @organization
create_params[:prior] = @prior
@environment = KTEnvironment.create!(create_params)
respond
end
|
#destroy ⇒ Object
106
107
108
109
110
111
|
# File 'app/controllers/katello/api/v2/environments_controller.rb', line 106
def destroy
sync_task(::Actions::Katello::Environment::Destroy, @environment)
respond_for_destroy
rescue RuntimeError => e
raise HttpErrors::BadRequest, e.message
end
|
#index ⇒ Object
50
51
52
|
# File 'app/controllers/katello/api/v2/environments_controller.rb', line 50
def index
respond(:collection => scoped_search(index_relation.uniq, :name, :desc, :resource_class => KTEnvironment))
end
|
#index_relation ⇒ Object
54
55
56
57
58
59
|
# File 'app/controllers/katello/api/v2/environments_controller.rb', line 54
def index_relation
query = KTEnvironment.readable.where(:organization_id => @organization.id)
query = query.where(:name => params[:name]) if params[:name]
query = query.where(:library => params[:library]) if params[:library]
query
end
|
#paths ⇒ Object
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'app/controllers/katello/api/v2/environments_controller.rb', line 119
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 }
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
|
#repositories ⇒ Object
143
144
145
146
147
148
149
150
151
152
153
|
# File 'app/controllers/katello/api/v2/environments_controller.rb', line 143
def repositories
if !@environment.library? && @content_view.nil?
fail HttpErrors::BadRequest,
_("Cannot retrieve repos from non-library environment '%s' without a content view.") % @environment.name
end
@repositories = @environment.products.readable(@organization).flat_map do |p|
p.repos(@environment, @content_view)
end
respond_for_index :collection => @repositories
end
|
#show ⇒ Object
65
66
67
|
# File 'app/controllers/katello/api/v2/environments_controller.rb', line 65
def show
respond
end
|
#update ⇒ Object
94
95
96
97
98
99
100
|
# File 'app/controllers/katello/api/v2/environments_controller.rb', line 94
def update
fail HttpErrors::BadRequest, _("Can't update the '%s' environment") % "Library" if @environment.library?
update_params = environment_params
update_params[:name] = params[:environment][:new_name] if params[:environment][:new_name]
@environment.update_attributes!(update_params)
respond
end
|