Bug 1257588 - [RFE] API routes for repositories in consistent with filter on per product and per organization
Summary: [RFE] API routes for repositories in consistent with filter on per product an...
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: API
Version: 6.1.0
Hardware: Unspecified
OS: Unspecified
medium vote
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact: Jitendra Yejare
Depends On:
Blocks: 260381 1122832
TreeView+ depends on / blocked
Reported: 2015-08-27 12:12 UTC by Peter Vreman
Modified: 2021-03-11 14:22 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Last Closed: 2018-02-21 12:30:53 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2018:0336 0 normal SHIPPED_LIVE Important: Satellite 6.3 security, bug fix, and enhancement update 2018-02-21 22:43:42 UTC

Description Peter Vreman 2015-08-27 12:12:56 UTC
Description of problem:
The API routes for repositories are inconsistent there is no URL path to filter per organization and per product.

See below the difference in routes for repositories, content_views and products:
- The repositories does not have a /organizations/ route
- The repositories does not have a /products/

  api :GET, "/repositories", N_("List of enabled repositories")
  api :GET, "/content_views/:id/repositories", N_("List of repositories for a content view")
  param :organization_id, :number, :required => true, :desc => N_("ID of an organization to show repositories in")
  param :product_id, :number, :desc => N_("ID of a product to show repositories of")

For example the content_views has a route with /organizations/

    api :GET, "/organizations/:organization_id/content_views", N_("List content views")
    api :GET, "/content_views", N_("List content views")
    param :organization_id, :number, :desc => N_("organization identifier"), :required => true

And products has even more routes:

    api :GET, "/products", N_("List products")
    api :GET, "/subscriptions/:subscription_id/products", N_("List of subscription products in a subscription")
    api :GET, "/activation_keys/:activation_key_id/products", N_("List of subscription products in an activation key")
    api :GET, "/organizations/:organization_id/products", N_("List of products in an organization")
    param :organization_id, :number, :desc => N_("Filter products by organization"), :required => true

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. API Call "/organizations/:organization_id/repositories"
2. API Call "/products/:product_id/repositories"

Actual results:

Expected results:
Return list of repositories

Additional info:
Followup from BZ1127589 that did not address the inconsistency in the API

Comment 1 Bryan Kearney 2016-07-08 20:47:43 UTC
Per 6.3 planning, moving out non acked bugs to the backlog

Comment 3 Peter Vreman 2016-07-11 12:40:28 UTC
This is fixed in 6.2.0Beta2. The repositories controller contains already more routes:

[crash] root@li-lc-1578:/opt/theforeman/tfm/root/usr/share/gems/gems/katello- grep 'GET.*/repositories' controllers/katello/api/v2/repositories_controller.rb                                           api :GET, "/repositories", N_("List of enabled repositories")
    api :GET, "/content_views/:id/repositories", N_("List of repositories for a content view")
    api :GET, "/organizations/:organization_id/environments/:environment_id/repositories", _("List repositories in the environment")
    api :GET, "/products/:product_id/repositories", N_("List of repositories for a product")
    api :GET, "/environments/:environment_id/products/:product_id/repositories", N_("List of repositories belonging to a product in an environment")
    api :GET, "/repositories/repository_types", N_("Show the available repository types")
    api :GET, "/repositories/:id", N_("Show a repository")
    api :GET, "/repositories/:id/gpg_key_content", N_("Return the content of a repo gpg key, used directly by yum")

Comment 4 Peter Vreman 2016-08-08 13:55:59 UTC
Correction, this is not fully fixed in Sat6.2.0 GA.

It still requires https://github.com/Katello/katello/pull/5999

Comment 6 Peter Vreman 2017-10-04 08:04:37 UTC
In 6.2.12 the PR 5999 is still missing even that https://projects.theforeman.org/issues/14825 has release katello 3.0.0.

I think the PR5999 is also included in 6.3

Comment 7 Bryan Kearney 2017-11-28 18:08:38 UTC
Per Peter's comment, moving to 6.3 for verification. Jake, can you ack this please?

Comment 9 Peter Vreman 2017-11-29 15:32:52 UTC
I verified it, it was still broken, below is the patch

--- controllers/katello/api/v2/repositories_controller.rb.171129-1      2017-11-28 13:59:07.795809864 +0000
+++ controllers/katello/api/v2/repositories_controller.rb       2017-11-29 15:19:46.639184122 +0000
@@ -394,6 +394,7 @@

     def find_product
       @product = Product.find(params[:product_id]) if params[:product_id]
+      find_organization_from_product if @organization.nil? && @product

     def find_product_for_create


Comment 10 Bryan Kearney 2017-11-29 16:12:45 UTC
Thanks.. I will send this off ot the triage group

Comment 12 Peter Vreman 2017-11-30 08:23:09 UTC
Sorry, my failure. I mixed up with remove/apply my custom patches.
The patch in comment 9 is not needed.

For verification test 'GET /products/:product_id/repositories' of is enough to make sure the PR 5999 is applied.


Comment 13 Brad Buckingham 2017-12-07 21:06:24 UTC
Moving to ON_QA for verification.

Comment 17 errata-xmlrpc 2018-02-21 12:30:53 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.