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
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
Instance Method Details
#cancel_repo_discover ⇒ Object
116
117
118
119
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 116
def cancel_repo_discover
task = @organization.cancel_repo_discovery
respond_for_async :resource => task
end
|
#cdn_configuration ⇒ Object
153
154
155
156
157
158
159
160
161
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 153
def cdn_configuration
config_keys = [:url, :username, :password, :upstream_organization_label, :ssl_ca_credential_id, :type,
:upstream_lifecycle_environment_label, :upstream_content_view_label]
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 73
def create
@organization = Organization.new(resource_params)
sca = params.key?(:simple_content_access) ? ::Foreman::Cast.to_bool(params[:simple_content_access]) : true
creator = ::Katello::OrganizationCreator.new(@organization, sca: sca)
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
93
94
95
96
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 93
def destroy
task = async_task(::Actions::Katello::Organization::Destroy, @organization, nil)
respond_for_async :resource => task
end
|
#download_debug_certificate ⇒ Object
123
124
125
126
127
128
129
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 123
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
44
45
46
47
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 44
def index
@render_template = 'katello/api/v2/organizations/index'
super
end
|
#local_find_taxonomy ⇒ Object
37
38
39
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 37
def local_find_taxonomy
find_taxonomy
end
|
#redhat_provider ⇒ Object
164
165
166
167
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 164
def redhat_provider
respond_for_show(:resource => @organization.redhat_provider,
:resource_name => "providers")
end
|
#releases ⇒ Object
133
134
135
136
137
138
139
140
141
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 133
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
105
106
107
108
109
110
111
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 105
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
51
52
53
54
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 51
def show
@render_template = 'katello/api/v2/organizations/show'
super
end
|
#update ⇒ Object
60
61
62
63
64
65
|
# File 'app/controllers/katello/api/v2/organizations_controller.rb', line 60
def update
if params[:redhat_repository_url]
sync_task(::Actions::Katello::CdnConfiguration::Update, @organization.cdn_configuration, url: params[:redhat_repository_url])
end
super
end
|