Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #36797 - Update API in preparation for SCA-only #10760

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/katello/api/v2/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ 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?
render json: { simple_content_access: 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])
respond_for_async :resource => task
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])
Expand Down
6 changes: 6 additions & 0 deletions app/controllers/katello/concerns/api/api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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])
Expand Down