Skip to content

Commit

Permalink
Refs #37865 - Add multi cv env rabl to ak and turn off req for name
Browse files Browse the repository at this point in the history
  • Loading branch information
chris1984 committed Oct 7, 2024
1 parent fe178dd commit 6c2e8b0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/controllers/katello/api/v2/activation_keys_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class Api::V2::ActivationKeysController < Api::V2::ApiController # rubocop:disa

def_param_group :activation_key do
param :organization_id, :number, :desc => N_("organization identifier"), :required => true
param :name, String, :desc => N_("name"), :required => true
param :description, String, :desc => N_("description")
param :max_hosts, :number, :desc => N_("maximum number of registered content hosts")
param :unlimited_hosts, :bool, :desc => N_("can the activation key have unlimited hosts")
Expand Down Expand Up @@ -63,6 +62,7 @@ def index
end

api :POST, "/activation_keys", N_("Create an activation key")
param :name, String, :desc => N_("name"), :required => true
param_group :activation_key
def create
@activation_key = ActivationKey.new(activation_key_params) do |activation_key|
Expand All @@ -79,6 +79,7 @@ def create
api :PUT, "/activation_keys/:id", N_("Update an activation key")
param_group :activation_key
param :id, :number, :desc => N_("ID of the activation key"), :required => true
param :name, String, :desc => N_("name"), :required => false
def update
if @content_view_environments.present? || update_cves?
if single_assignment? && @content_view_environments.length == 1
Expand Down
4 changes: 4 additions & 0 deletions app/models/katello/activation_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ def available_releases
releases
end

def content_view_environment_labels
content_view_environment_names.join(',')
end

def available_subscriptions
all_pools = self.get_pools.map { |pool| pool["id"] }
added_pools = self.pools.pluck(:cp_id)
Expand Down
4 changes: 2 additions & 2 deletions app/views/katello/api/v2/activation_keys/base.json.rabl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extends 'katello/api/v2/common/org_reference'
extends 'katello/api/v2/common/timestamps'

attributes :id, :name, :description, :unlimited_hosts, :auto_attach
attributes :id, :name, :description, :unlimited_hosts, :auto_attach, :content_view_environment_labels

node :multi_content_view_environment do |ak|
ak.multi_content_view_environment?
Expand All @@ -26,7 +26,7 @@ child :content_view_environments => :content_view_environments do
lifecycle_environment_library: cve.lifecycle_environment&.library?
}
end
node :candlepin_name do |cve|
node :label do |cve|
cve.candlepin_name
end
end
Expand Down

0 comments on commit 6c2e8b0

Please sign in to comment.