Project

General

Profile

Actions

Bug #27632

closed

Activation Key create API is lacking parameters that are possible during update

Added by Evgeni Golov over 5 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Normal
Category:
API
Target version:
Difficulty:
trivial
Triaged:
Yes
Fixed in Releases:
Found in Releases:

Description

When creating a new Activation Key, the following params are missing (compared to updating an existing one)

    param :release_version, String, :desc => N_("content release version")
    param :service_level, String, :desc => N_("service level")
    param :auto_attach, :bool, :desc => N_("auto attach subscriptions upon registration")

If I read the underlying Katello/Candlepin code correctly, this is because Candlepin cannot set these on create. I think Katello should "fix" that for the user and execute an update after create itself, like we already do in copy:

    api :POST, "/activation_keys/:id/copy", N_("Copy an activation key")
    param :new_name, String, :desc => N_("Name of new activation key"), :required => true
    param :id, :number, :desc => N_("ID of the activation key"), :required => true
    param :organization_id, :number, :desc => N_("organization identifier"), :required => false
    def copy
      fail HttpErrors::BadRequest, _("New name cannot be blank") unless params[:new_name]
      @new_activation_key = @activation_key.copy(params[:new_name])
      @new_activation_key.user = current_user
      sync_task(::Actions::Katello::ActivationKey::Create, @new_activation_key)
      @new_activation_key.reload
      sync_task(::Actions::Katello::ActivationKey::Update, @new_activation_key,
                  :service_level   => @activation_key.service_level,
                  :release_version => @activation_key.release_version,
                  :auto_attach     => @activation_key.auto_attach
               )
      @activation_key.pools.each do |pool|
        @new_activation_key.subscribe(pool[:id])
      end
      @new_activation_key.set_content_overrides(@activation_key.content_overrides) unless @activation_key.content_overrides.blank?
      respond_for_create(:resource => @new_activation_key)
    end

Related issues 1 (1 open0 closed)

Related to Foreman - Tracker #27680: API bugs that need workarounds in foreman-ansible-modulesNew

Actions
Actions

Also available in: Atom PDF