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

Refs #37865 - Add multi cv env rabl to ak and turn off req for name #11166

Merged
merged 1 commit into from
Oct 21, 2024
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
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
7 changes: 4 additions & 3 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 @@ -16,7 +16,8 @@ child :content_view_environments => :content_view_environments do
content_view_version: cve.content_view_version&.version,
content_view_version_id: cve.content_view_version&.id,
content_view_version_latest: cve.content_view_version&.latest?,
content_view_default: cve.content_view&.default?
content_view_default: cve.content_view&.default?,
content_view_environment_id: cve.id
}
end
node :lifecycle_environment do |cve|
Expand All @@ -26,7 +27,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
Loading