Bug 1257588 - [RFE] API routes for repositories in consistent with filter on per product and per organization
[RFE] API routes for repositories in consistent with filter on per product an...
Product: Red Hat Satellite 6
Classification: Red Hat
Component: API (Show other bugs)
Unspecified Unspecified
medium Severity medium (vote)
: GA
: --
Assigned To: satellite6-bugs
Jitendra Yejare
: FutureFeature, Triaged
Depends On:
Blocks: 260381 1122832
  Show dependency treegraph
Reported: 2015-08-27 08:12 EDT by Peter Vreman
Modified: 2017-12-13 03:42 EST (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Peter Vreman 2015-08-27 08:12:56 EDT
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 16:47:43 EDT
Per 6.3 planning, moving out non acked bugs to the backlog
Comment 3 Peter Vreman 2016-07-11 08:40:28 EDT
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 09:55:59 EDT
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 04:04:37 EDT
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 13:08:38 EST
Per Peter's comment, moving to 6.3 for verification. Jake, can you ack this please?
Comment 9 Peter Vreman 2017-11-29 10:32:52 EST
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 11:12:45 EST
Thanks.. I will send this off ot the triage group
Comment 12 Peter Vreman 2017-11-30 03:23:09 EST
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 16:06:24 EST
Moving to ON_QA for verification.

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