Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1127589 - API Missing routes for repositories
Summary: API Missing routes for repositories
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: API
Version: 6.0.3
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: Bryan Kearney
QA Contact: jaudet
URL:
Whiteboard:
Depends On:
Blocks: 1122832
TreeView+ depends on / blocked
 
Reported: 2014-08-07 08:20 UTC by Peter Vreman
Modified: 2017-02-23 21:07 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-08-12 05:13:44 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2015:1592 0 normal SHIPPED_LIVE Important: Red Hat Satellite 6.1.1 on RHEL 6 2015-08-12 09:04:35 UTC

Description Peter Vreman 2014-08-07 08:20:29 UTC
Description of problem:

Working with repositories does not support Routes to access the data with
organizations/<id>/repositories
products/<id>/repositories
environments/<id>/repositories

# curl -K /opt/hoici/etc/curl-hoici.conf -H 'Content-Type: application/json' -d '{"per_page":"9999"}' -XGET https://localhost/katello/api/v2/repositories
{"displayMessage":"One of parameters [ organization_id ] required but not specified.","errors":["One of parameters [ organization_id ] required but not specified."]}

# curl -K /opt/hoici/etc/curl-hoici.conf -H 'Content-Type: application/json' -d '{"per_page":"9999"}' -XGET https://localhost/katello/api/v2/organizations/4/repositories
orepositories
  <title>The page you were looking for doesn't exist (404)</title>
# curl -K /opt/hoici/etc/curl-hoici.conf -H 'Content-Type: application/json' -d '{"per_page":"9999"}' -XGET https://localhost/katello/api/v2/products/5/repositories
{"displayMessage":"undefined method `[]' for nil:NilClass","errors":["undefined method `[]' for nil:NilClass"]}


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


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 RHEL Program Management 2014-08-07 08:44:18 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 3 Bryan Kearney 2014-10-31 20:40:39 UTC
I believe that these can be addressed upstream. I am moving to ON_QE to verify.

organizations/<id>/repositories is expressed as
http://localhost:3330/katello/api/v2/repositories?organization_id=<id>

products/<id>/repositories is expressed as
http://localhost:3330/katello/api/v2/repositories?organization_id=<id>&product_id=<id>

products/<id>/repositories is expressed as
http://localhost:3330/katello/api/v2/repositories?organization_id=<id>&environment_id=<id>

Comment 4 jaudet 2015-01-06 22:30:56 UTC
It is possible to fetch a set of repositories filtered according to the organization, product and environment that the repositories belong to.

As proof, here's a python script that I executed:

    #!/usr/bin/env python
    from robottelo import entities
    from nailgun import client
    from robottelo.common.helpers import get_server_credentials

    # Start by creating an organization, product and repository.
    ORG_ID = entities.Organization().create_json()['id']
    PROD_ID = entities.Product(organization=ORG_ID).create_json()['id']
    REPO_ID = entities.Repository(product=PROD_ID).create_json()['id']

    # Read back data from the server using suggested paths. First provide just an
    # organization ID.
    response = client.get(
        entities.Repository().path(),
        verify=False,
        auth=get_server_credentials(),
        data={'organization_id': ORG_ID}
    )
    print(response.status_code)
    print(response.json()['total'])

    # Second, provide an organization and product ID.
    response = client.get(
        entities.Repository().path(),
        verify=False,
        auth=get_server_credentials(),
        data={'organization_id': ORG_ID, 'product_id': PROD_ID}
    )
    print(response.status_code)
    print(response.json()['total'])

    # Third, provide an organization and environment ID. The environment ID should
    # not match anything.
    response = client.get(
        entities.Repository().path(),
        verify=False,
        auth=get_server_credentials(),
        data={'organization_id': ORG_ID, 'environment_id': 123456}
    )
    print(response.status_code)
    print(response.json()['total'])

And here's the output:

    200
    1
    200
    1
    200
    0

Comment 5 Peter Vreman 2015-01-12 09:52:09 UTC
This bugzilla is about inconsistency in the API routes.

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

  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

Comment 6 Peter Vreman 2015-07-20 14:43:57 UTC
Still open, also for Sat6.1.0 that has only content_views/ route

/opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0.51/app/controllers/katello/api/v2# grep GET 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, "/repositories/:id", N_("Show a custom repository")
    api :GET, "/repositories/:id/gpg_key_content", N_("Return the content of a repo gpg key, used directly by yum")

Comment 7 Bryan Kearney 2015-08-11 13:28:02 UTC
This bug is slated to be released with Satellite 6.1.

Comment 8 errata-xmlrpc 2015-08-12 05:13:44 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.

https://access.redhat.com/errata/RHSA-2015:1592


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