Class: Api::Rhsm::CandlepinDynflowProxyController
- Inherits:
-
V2::ApiController
- Object
- V2::ApiController
- Api::Rhsm::CandlepinDynflowProxyController
show all
- Includes:
- AbstractController::Callbacks, ForemanTasks::Triggers, Katello::Authentication::ClientAuthentication
- Defined in:
- app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb
Instance Method Summary
collapse
#add_candlepin_version_header, #authenticate_client, #cert_from_request, #cert_present?, #set_client_user
Instance Method Details
#authorize_client_or_user ⇒ Object
72
73
74
|
# File 'app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb', line 72
def authorize_client_or_user
client_authorized? || authorize
end
|
#client_authorized? ⇒ Boolean
76
77
78
79
80
|
# File 'app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb', line 76
def client_authorized?
authorized = authenticate_client && User.consumer?
authorized = (User.current.uuid == @host.subscription_facet.uuid) if @host && User.consumer?
authorized
end
|
#find_host(uuid = nil) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
|
# File 'app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb', line 50
def find_host(uuid = nil)
params = request.path_parameters
uuid ||= params[:id]
facet = Katello::Host::SubscriptionFacet.where(:uuid => uuid).first
if facet.nil?
User.as_anonymous_admin { Resources::Candlepin::Consumer.get(uuid) }
fail HttpErrors::NotFound, _("Couldn't find consumer '%s'") % uuid
end
@host = facet.host
end
|
#upload_package_profile ⇒ Object
api :PUT, “/consumers/:id/packages”, N_(“Update installed packages”) api :PUT, “/consumers/:id/profile”, N_(“Update installed packages”) param :id, String, :desc => N_(“UUID of the consumer”), :required => true
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb', line 16
def upload_package_profile
User.as_anonymous_admin do
if Setting['upload_profiles_without_dynflow']
uploader = ::Katello::Host::PackageProfileUploader.new(
host: @host,
profile_string: request.raw_post
)
uploader.upload
uploader.trigger_applicability_generation
else
async_task(::Actions::Katello::Host::UploadPackageProfile, @host, request.raw_post)
end
end
render :json => Resources::Candlepin::Consumer.get(@host.subscription_facet.uuid)
end
|
#upload_profiles ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb', line 34
def upload_profiles
User.as_anonymous_admin do
if Setting['upload_profiles_without_dynflow']
uploader = ::Katello::Host::ProfilesUploader.new(
host: @host,
profile_string: request.raw_post
)
uploader.upload
uploader.trigger_applicability_generation
else
async_task(::Actions::Katello::Host::UploadProfiles, @host, request.raw_post)
end
end
render :json => Resources::Candlepin::Consumer.get(@host.subscription_facet.uuid)
end
|