Class: Katello::Api::V2::ContentViewEnvironmentsController
- Inherits:
-
ApiController
- Object
- Api::V2::BaseController
- ApiController
- Katello::Api::V2::ContentViewEnvironmentsController
show all
- Defined in:
- app/controllers/katello/api/v2/content_view_environments_controller.rb
Instance Method Summary
collapse
#empty_search_query?, #full_result_response, #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
#find_activation_key ⇒ Object
65
66
67
68
|
# File 'app/controllers/katello/api/v2/content_view_environments_controller.rb', line 65
def find_activation_key
return unless params.key?(:activation_key_id)
@activation_key = ActivationKey.readable.find(params[:activation_key_id])
end
|
#find_content_source ⇒ Object
75
76
77
78
|
# File 'app/controllers/katello/api/v2/content_view_environments_controller.rb', line 75
def find_content_source
return unless params.key?(:content_source_id)
@content_source = SmartProxy.authorized(:view_smart_proxies).find(params[:content_source_id])
end
|
#find_content_view ⇒ Object
60
61
62
63
|
# File 'app/controllers/katello/api/v2/content_view_environments_controller.rb', line 60
def find_content_view
return unless params.key?(:content_view_id)
@content_view = ContentView.readable.find(params[:content_view_id])
end
|
#find_environment ⇒ Object
55
56
57
58
|
# File 'app/controllers/katello/api/v2/content_view_environments_controller.rb', line 55
def find_environment
return unless params.key?(:lifecycle_environment_id)
@environment = KTEnvironment.readable.find(params[:lifecycle_environment_id])
end
|
#find_host ⇒ Object
70
71
72
73
|
# File 'app/controllers/katello/api/v2/content_view_environments_controller.rb', line 70
def find_host
return unless params.key?(:host_id)
@host = ::Host::Managed.authorized("view_hosts").find(params[:host_id])
end
|
#find_hostgroup ⇒ Object
80
81
82
83
|
# File 'app/controllers/katello/api/v2/content_view_environments_controller.rb', line 80
def find_hostgroup
return unless params.key?(:hostgroup_id)
@hostgroup = ::Hostgroup.authorized(:view_hostgroups).find(params[:hostgroup_id])
end
|
#index ⇒ Object
25
26
27
28
29
|
# File 'app/controllers/katello/api/v2/content_view_environments_controller.rb', line 25
def index
respond(:collection => scoped_search(index_relation.distinct, :id, :asc,
:resource_class => ContentViewEnvironment,
:includes => {:hostgroup_content_facets => :hostgroup}))
end
|
#index_relation ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'app/controllers/katello/api/v2/content_view_environments_controller.rb', line 37
def index_relation
content_view_environments = ContentViewEnvironment.readable.non_generated
content_view_environments = content_view_environments.in_organization(@organization) if @organization
content_view_environments = content_view_environments.where(environment: @environment) if @environment
content_view_environments = content_view_environments.where(content_view: @content_view) if @content_view
content_view_environments = content_view_environments.where(id: @activation_key.content_view_environments) if @activation_key
content_view_environments = content_view_environments.where(id: @host.content_view_environments) if @host
content_view_environments = content_view_environments.where(id: @hostgroup.content_view_environment) if @hostgroup
if @content_source.present? && !@content_source.pulp_primary?
available_env_ids = @content_source.lifecycle_environments.pluck(:id)
content_view_environments = content_view_environments.where(environment_id: available_env_ids) if available_env_ids.any?
end
content_view_environments
end
|
#show ⇒ Object
33
34
35
|
# File 'app/controllers/katello/api/v2/content_view_environments_controller.rb', line 33
def show
respond_for_show(:resource => @content_view_environment)
end
|