Class: Katello::Api::V2::OrganizationsController
- Inherits:
-
Api::V2::OrganizationsController
- Object
- Api::V2::OrganizationsController
- Katello::Api::V2::OrganizationsController
show all
- Includes:
- ForemanTasks::Triggers, Rendering
- Defined in:
- app/controllers/katello/api/v2/organizations_controller.rb
Constant Summary
collapse
- LOCAL_FIND_TAXONOMY_ACTIONS =
%w(repo_discover cancel_repo_discover download_debug_certificate
cdn_configuration redhat_provider update releases).freeze
Class Method Summary
collapse
Instance Method Summary
collapse
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
Class Method Details
.before_find_taxonomy_actions ⇒ Object
16
17
18
19
20
21
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 16
def self.before_find_taxonomy_actions
skip_before_action :local_find_taxonomy, :only => LOCAL_FIND_TAXONOMY_ACTIONS
yield
before_action :local_find_taxonomy, :only => LOCAL_FIND_TAXONOMY_ACTIONS
end
|
Instance Method Details
#cancel_repo_discover ⇒ Object
121
122
123
124
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 121
def cancel_repo_discover
task = @organization.cancel_repo_discovery
respond_for_async :resource => task
end
|
#cdn_configuration ⇒ Object
159
160
161
162
163
164
165
166
167
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 159
def cdn_configuration
config_keys = [:url, :username, :password, :upstream_organization_label, :ssl_ca_credential_id, :type,
:upstream_lifecycle_environment_label, :upstream_content_view_label, :custom_cdn_auth_enabled]
config_params = params.slice(*config_keys).permit!.to_h
task = sync_task(::Actions::Katello::CdnConfiguration::Update, @organization.cdn_configuration, config_params)
respond_for_async :resource => task
end
|
#create ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 79
def create
@organization = Organization.new(resource_params)
creator = ::Katello::OrganizationCreator.new(@organization)
creator.create!
@organization.reload
@taxonomy = @organization
respond_for_create :resource => @organization
rescue => e
::Foreman::Logging.exception('Could not create organization', e)
@organization&.valid?
process_resource_error(message: e.message, resource: @organization)
end
|
#destroy ⇒ Object
98
99
100
101
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 98
def destroy
task = async_task(::Actions::Katello::Organization::Destroy, @organization, nil)
respond_for_async :resource => task
end
|
#download_debug_certificate ⇒ Object
128
129
130
131
132
133
134
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 128
def download_debug_certificate
pem = @organization.debug_cert
data = "#{pem[:key]}\n\n#{pem[:cert]}"
send_data data,
:filename => "#{@organization.name}-key-cert.pem",
:type => "application/text"
end
|
#index ⇒ Object
50
51
52
53
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 50
def index
@render_template = 'katello/api/v2/organizations/index'
super
end
|
#local_find_taxonomy ⇒ Object
43
44
45
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 43
def local_find_taxonomy
find_taxonomy
end
|
#redhat_provider ⇒ Object
170
171
172
173
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 170
def redhat_provider
respond_for_show(:resource => @organization.redhat_provider,
:resource_name => "providers")
end
|
#releases ⇒ Object
138
139
140
141
142
143
144
145
146
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 138
def releases
available_releases = @organization.library.available_releases
response = {
:results => available_releases,
:total => available_releases.size,
:subtotal => available_releases.size,
}
respond_for_index :collection => response
end
|
#repo_discover ⇒ Object
110
111
112
113
114
115
116
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 110
def repo_discover
fail _("url not defined.") if params[:url].blank?
registry_search = params[:search].empty? ? '*' : params[:search]
task = async_task(::Actions::Katello::Repository::Discover, params[:url], params[:content_type],
params[:upstream_username], params[:upstream_password], registry_search)
respond_for_async :resource => task
end
|
#show ⇒ Object
57
58
59
60
61
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 57
def show
@render_template = 'katello/api/v2/organizations/show'
@organization.manifest_expiration_date(cached: false) if params[:force_manifest_expire_cache]
super
end
|
#update ⇒ Object
67
68
69
70
71
72
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 67
def update
if params[:redhat_repository_url]
sync_task(::Actions::Katello::CdnConfiguration::Update, @organization.cdn_configuration, url: params[:redhat_repository_url], type: CdnConfiguration::CUSTOM_CDN_TYPE)
end
super
end
|