Actions
Bug #31714
openKatello should not call LCEs "environment" in the API
Status:
New
Priority:
Normal
Assignee:
-
Category:
API
Target version:
-
Description
In Foreman, there are multiple things that can be called "environment": Puppet Env, Katello Lifecycle Env, …
This makes it hard to write API clients, as it's not clear which environment an "environment_id" is referring to.
I ask Katello to start using "lifecycle_environment_id" in the API (probably with still looking at "environment_id" if l_e_id is not set, for backwards compatibility.
A quick grep shows the following offenders (limited to the v2 API, I think the rhsm API really needs "environment" for sub-man compat).
% git grep ":environment_id" app/controllers/katello/api/v2/ app/controllers/katello/api/v2/activation_keys_controller.rb: api :GET, "/environments/:environment_id/activation_keys" app/controllers/katello/api/v2/activation_keys_controller.rb: param :environment_id, :number, :desc => N_("environment identifier") app/controllers/katello/api/v2/activation_keys_controller.rb: param :environment_id, :number, :desc => N_("environment id") app/controllers/katello/api/v2/activation_keys_controller.rb: param :environment_id, :number, :desc => N_("environment id") app/controllers/katello/api/v2/activation_keys_controller.rb: activation_keys = activation_keys.where(:environment_id => @environment) if @environment app/controllers/katello/api/v2/activation_keys_controller.rb: environment_id = params[:environment_id] app/controllers/katello/api/v2/activation_keys_controller.rb: fail HttpErrors::NotFound, _("Couldn't find environment '%s'") % params[:environment_id] if @environment.nil? app/controllers/katello/api/v2/activation_keys_controller.rb: return if params.key?(:organization_id) || params.key?(:environment_id) app/controllers/katello/api/v2/activation_keys_controller.rb: :environment_id, app/controllers/katello/api/v2/activation_keys_controller.rb: key_params[:environment_id] = params[:environment][:id] if params[:environment].try(:[], :id) app/controllers/katello/api/v2/capsule_content_controller.rb: param :environment_id, Integer, :desc => N_('Id of the lifecycle environment'), :required => true app/controllers/katello/api/v2/capsule_content_controller.rb: api :DELETE, '/capsules/:id/content/lifecycle_environments/:environment_id', N_('Remove lifecycle environments from the smart proxy') app/controllers/katello/api/v2/capsule_content_controller.rb: param :environment_id, Integer, :desc => N_('Id of the environment to limit the synchronization on') app/controllers/katello/api/v2/capsule_content_controller.rb: find_environment if params[:environment_id] app/controllers/katello/api/v2/capsule_content_controller.rb: :environment_id => @environment.try(:id), app/controllers/katello/api/v2/capsule_content_controller.rb: @environment = Katello::KTEnvironment.readable.find(params[:environment_id]) app/controllers/katello/api/v2/content_view_versions_controller.rb: param :environment_id, :number, :desc => N_("Filter versions by environment"), :required => false app/controllers/katello/api/v2/content_view_versions_controller.rb: param :environment_ids, Array, :desc => N_("Identifiers for Lifecycle Environment") app/controllers/katello/api/v2/content_view_versions_controller.rb: param :environment_ids, Array, :desc => N_("The list of environments to promote the specified Content View Version to (replacing the older version)") app/controllers/katello/api/v2/content_view_versions_controller.rb: any_environments = params[:content_view_version_environments].any? { |cvve| cvve[:environment_ids].try(:any?) } app/controllers/katello/api/v2/content_view_versions_controller.rb: :environments => KTEnvironment.where(:id => combination[:environment_ids]) app/controllers/katello/api/v2/content_view_versions_controller.rb: unless combination[:environment_ids].blank? app/controllers/katello/api/v2/content_view_versions_controller.rb: not_found = combination[:environment_ids].map(&:to_s) - version_environment[:environments].map { |env| env.id.to_s } app/controllers/katello/api/v2/content_view_versions_controller.rb: return unless params.key?(:environment_id) app/controllers/katello/api/v2/content_view_versions_controller.rb: @environment = KTEnvironment.find(params[:environment_id]) app/controllers/katello/api/v2/content_view_versions_controller.rb: @environments = KTEnvironment.where(:id => params[:environment_ids]) app/controllers/katello/api/v2/content_views_controller.rb: param :environment_id, :number, :desc => N_("environment identifier") app/controllers/katello/api/v2/content_views_controller.rb: api :DELETE, "/content_views/:id/environments/:environment_id", N_("Remove a content view from an environment") app/controllers/katello/api/v2/content_views_controller.rb: param :environment_id, :number, :desc => N_("environment numeric identifier"), :required => true app/controllers/katello/api/v2/content_views_controller.rb: param :environment_ids, :number, :desc => N_("environment numeric identifiers to be removed") app/controllers/katello/api/v2/content_views_controller.rb: cv_envs = ContentViewEnvironment.where(:environment_id => params[:environment_ids], app/controllers/katello/api/v2/content_views_controller.rb: return if !params.key?(:environment_id) && params[:action] == "index" app/controllers/katello/api/v2/content_views_controller.rb: @environment = KTEnvironment.readable.find(params[:environment_id]) app/controllers/katello/api/v2/environments_controller.rb: api :GET, "/organizations/:organization_id/environments/:environment_id", N_("Show an environment") app/controllers/katello/api/v2/errata_controller.rb: param :environment_id, :number, :desc => N_("Environment identifier") app/controllers/katello/api/v2/errata_controller.rb: param :environment_id, :number, :desc => N_("Environment identifier") app/controllers/katello/api/v2/host_errata_controller.rb: param :environment_id, :number, :desc => N_("Calculate Applicable Errata based on a particular Environment"), :required => false app/controllers/katello/api/v2/host_errata_controller.rb: if (params[:content_view_id] && params[:environment_id].nil?) || (params[:environment_id] && params[:content_view_id].nil?) app/controllers/katello/api/v2/host_errata_controller.rb: @environment = KTEnvironment.readable.find(params[:environment_id]) if params[:environment_id] app/controllers/katello/api/v2/host_subscriptions_controller.rb: :environment_id => params[:lifecycle_environment_id]).first app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb: param :environment_id, Integer app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb: @environment = KTEnvironment.editable.find(params[:environment_id]) app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb: throw_resource_not_found(name: 'lifecycle environment', id: params[:environment_id]) unless @environment app/controllers/katello/api/v2/organizations_controller.rb: param :environment_ids, Array, N_("Environment IDs"), :required => false app/controllers/katello/api/v2/packages_controller.rb: param :environment_id, :number, :desc => N_("Environment identifier") app/controllers/katello/api/v2/repositories_controller.rb: api :GET, "/organizations/:organization_id/environments/:environment_id/repositories", _("List repositories in the environment") app/controllers/katello/api/v2/repositories_controller.rb: api :GET, "/environments/:environment_id/products/:product_id/repositories", N_("List of repositories belonging to a product in an environment") app/controllers/katello/api/v2/repositories_controller.rb: param :environment_id, :number, :desc => N_("ID of an environment to show repositories in") app/controllers/katello/api/v2/repositories_controller.rb: query = filter_by_content_view(query, params[:content_view_id], params[:environment_id], params[:available_for] == 'content_view') app/controllers/katello/api/v2/repositories_controller.rb: if params[:environment_id] && !params[:library] app/controllers/katello/api/v2/repositories_controller.rb: query = query.where(:environment_id => params[:environment_id]) app/controllers/katello/api/v2/repositories_controller.rb: elsif params[:environment_id] && params[:library] app/controllers/katello/api/v2/repositories_controller.rb: instances = query.where(:environment_id => params[:environment_id]) app/controllers/katello/api/v2/repositories_controller.rb: elsif (params[:library] && !params[:environment_id]) || (params[:environment_id].blank? && params[:content_view_version_id].blank? && params[:content_view_id].blank?) app/controllers/katello/api/v2/repositories_controller.rb: query = query.where.not(:content_view_version_id => nil, :environment_id => nil) app/controllers/katello/api/v2/srpms_controller.rb: param :environment_id, :number, :desc => N_("Environment identifier")
For comparison, there are just two places using the "correct" term:
% git grep ":lifecycle_environment_id" app/controllers/katello/api/v2/ app/controllers/katello/api/v2/host_contents_controller.rb: param :lifecycle_environment_id, Integer app/controllers/katello/api/v2/host_subscriptions_controller.rb: param :lifecycle_environment_id, Integer, :desc => N_("Lifecycle Environment ID"), :required => true app/controllers/katello/api/v2/host_subscriptions_controller.rb: :environment_id => params[:lifecycle_environment_id]).first app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb: version_environment[:content_host_count] += content_facets.where(:content_view_id => cve.content_view).where(:lifecycle_environment_id => cve.environment).count
Actions