From 3d82a3360d5eb199c45b2c0fc82c35ca5658d547 Mon Sep 17 00:00:00 2001 From: Lucy Fu Date: Tue, 3 Oct 2023 20:30:08 +0000 Subject: [PATCH] Fixes #36797 - Update API in preparation for SCA-only --- .../katello/api/v2/organizations_controller.rb | 4 ++-- .../katello/api/v2/simple_content_access_controller.rb | 10 +++++----- app/controllers/katello/concerns/api/api_controller.rb | 6 ++++++ .../concerns/organizations_controller_extensions.rb | 2 ++ 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/controllers/katello/api/v2/organizations_controller.rb b/app/controllers/katello/api/v2/organizations_controller.rb index 9501e9f444b..27f9102dbd0 100644 --- a/app/controllers/katello/api/v2/organizations_controller.rb +++ b/app/controllers/katello/api/v2/organizations_controller.rb @@ -56,7 +56,7 @@ def show api :PUT, '/organizations/:id', N_('Update organization') param :id, :number, :desc => N_("organization ID"), :required => true param :redhat_repository_url, String, :desc => N_("Red Hat CDN URL"), deprecated: true - param :simple_content_access, :bool, :desc => N_('Whether Simple Content Access should be enabled for the organization.'), :required => false, :default => true + param :simple_content_access, :bool, :desc => N_('Whether Simple Content Access should be enabled for the organization.'), :required => false, :default => true, deprecated: true param_group :resource def update if params[:redhat_repository_url] @@ -80,7 +80,7 @@ def update param :organization, Hash do param :label, String, :required => false end - param :simple_content_access, :bool, :desc => N_('Whether to turn on Simple Content Access for the organization.'), :required => false, :default => true + param :simple_content_access, :bool, :desc => N_('Whether to turn on Simple Content Access for the organization.'), :required => false, :default => true, deprecated: true def create @organization = Organization.new(resource_params) sca = params.key?(:simple_content_access) ? ::Foreman::Cast.to_bool(params[:simple_content_access]) : true diff --git a/app/controllers/katello/api/v2/simple_content_access_controller.rb b/app/controllers/katello/api/v2/simple_content_access_controller.rb index c1eb93fe928..d9ddc0b8fe2 100644 --- a/app/controllers/katello/api/v2/simple_content_access_controller.rb +++ b/app/controllers/katello/api/v2/simple_content_access_controller.rb @@ -8,15 +8,15 @@ class Api::V2::SimpleContentAccessController < Api::V2::ApiController end api :GET, "/organizations/:organization_id/simple_content_access/eligible", - N_("Check if the specified organization is eligible for Simple Content Access") + N_("Check if the specified organization is eligible for Simple Content Access. %s") % sca_only_deprecation_text, deprecated: true def eligible - ::Foreman::Deprecation.api_deprecation_warning("This endpoint is deprecated and will be removed in a future release. All organizations are now eligible for Simple Content Access.") + ::Foreman::Deprecation.api_deprecation_warning("This endpoint is deprecated and will be removed in Katello 4.12. All organizations are now eligible for Simple Content Access.") eligible = @organization.simple_content_access_eligible? render json: { simple_content_access_eligible: eligible } end api :GET, "/organizations/:organization_id/simple_content_access/status", - N_("Check if the specified organization has Simple Content Access enabled") + N_("Check if the specified organization has Simple Content Access enabled. %s") % sca_only_deprecation_text, deprecated: true param :organization_id, :number, :desc => N_("Organization ID"), :required => true def status status = @organization.simple_content_access? @@ -24,7 +24,7 @@ def status end api :PUT, "/organizations/:organization_id/simple_content_access/enable", - N_("Enable simple content access for a manifest") + N_("Enable simple content access for a manifest"), deprecated: true param :organization_id, :number, :desc => N_("Organization ID"), :required => true def enable task = async_task(::Actions::Katello::Organization::SimpleContentAccess::Enable, params[:organization_id]) @@ -32,7 +32,7 @@ def enable end api :PUT, "/organizations/:organization_id/simple_content_access/disable", - N_("Disable simple content access for a manifest") + N_("Disable simple content access for a manifest. %s") % sca_only_deprecation_text, deprecated: true param :organization_id, :number, :desc => N_("Organization ID"), :required => true def disable task = async_task(::Actions::Katello::Organization::SimpleContentAccess::Disable, params[:organization_id]) diff --git a/app/controllers/katello/concerns/api/api_controller.rb b/app/controllers/katello/concerns/api/api_controller.rb index 76a0dbff0c5..56e1ff85d9b 100644 --- a/app/controllers/katello/concerns/api/api_controller.rb +++ b/app/controllers/katello/concerns/api/api_controller.rb @@ -17,6 +17,12 @@ def current_user User.current end + class_methods do + def sca_only_deprecation_text + N_("WARNING: Simple Content Access will be required for all organizations in Katello 4.12.") + end + end + protected def request_from_katello_cli? diff --git a/app/controllers/katello/concerns/organizations_controller_extensions.rb b/app/controllers/katello/concerns/organizations_controller_extensions.rb index ff5af32bf12..2e5f759ff51 100644 --- a/app/controllers/katello/concerns/organizations_controller_extensions.rb +++ b/app/controllers/katello/concerns/organizations_controller_extensions.rb @@ -25,6 +25,7 @@ def create begin @taxonomy = Organization.new(resource_params) sca = ::Foreman::Cast.to_bool(params[:simple_content_access]) + ::Foreman::Deprecation.api_deprecation_warning("Simple Content Access will be required for all organizations in Katello 4.12.") ::Katello::OrganizationCreator.new(@taxonomy, sca: sca).create! @taxonomy.reload switch_taxonomy @@ -47,6 +48,7 @@ def create def update return if params[:simple_content_access].nil? sca_param = ::Foreman::Cast.to_bool(params[:simple_content_access]) + ::Foreman::Deprecation.api_deprecation_warning("Simple Content Access will be required for all organizations in Katello 4.12.") if sca_param && !@taxonomy.simple_content_access?(cached: false) # user has requested SCA enable sync_task(::Actions::Katello::Organization::SimpleContentAccess::Enable, params[:id])