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 1151240 - Some API URLs emit a list of IDs, and others emit a list of hashes.
Summary: Some API URLs emit a list of IDs, and others emit a list of hashes.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: API
Version: Nightly
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: Partha Aji
QA Contact: jaudet
URL:
Whiteboard:
: 1122267 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-10-09 21:21 UTC by jaudet
Modified: 2017-02-23 20:52 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-08-12 05:17:50 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 jaudet 2014-10-09 21:21:18 UTC
Description of problem:
Some API responses contain a list of IDs, and others contain a list of hashes. 

For example, a GET request to `/gpgkeys/:id` returns data in this format:

    {u'name': u'foo', u'organization': {u'name': u'ACME', u'label': '...'}}

No organization ID is listed. This means that it is impossible to discover what organization this GPG key belongs to except by issuing a follow-up search to the `/organizations` URL (and hopefully coming up with only one result).

As a second example, a GET request to `/architectures/:id` returns data in this format:

    {
        u'name': u'i386',
        u'operatingsystems': [
            {u'id': 1, u'name': u'rhel65'},
            {u'id': 2, u'name': u'rhel7'},
        ]
    }

This is awkward. In this case, the client can compile a list of associated operating systems by iterating through the returned hashes and fetching through their IDs. It is much easier to deal with a straight list of IDs:

    {u'name': u'i386', u'operatingsystem_ids': [1, 2]}

The API should return either an ID or a list of IDs for all foreign key relationships. Client code can be simple and straightforward if a list of IDs is returned.

Version-Release number of selected component (if applicable):
This has been tested against multiple versions of Satellite. Most recently, this has been tested against a system running Satellite 6.0.4 with the following software installed:

* candlepin-0.9.23-1.el7.noarch
* candlepin-common-1.0.1-1.el7.noarch
* candlepin-guice-3.0-2_redhat_1.el7.noarch
* candlepin-scl-1-5.el7.noarch
* candlepin-scl-quartz-2.1.5-6.el7.noarch
* candlepin-scl-rhino-1.7R3-3.el7.noarch
* candlepin-scl-runtime-1-5.el7.noarch
* candlepin-selinux-0.9.23-1.el7.noarch
* candlepin-tomcat-0.9.23-1.el7.noarch
* elasticsearch-0.90.10-6.el7sat.noarch
* foreman-1.6.0.46-1.el7sat.noarch
* foreman-compute-1.6.0.46-1.el7sat.noarch
* foreman-gce-1.6.0.46-1.el7sat.noarch
* foreman-libvirt-1.6.0.46-1.el7sat.noarch
* foreman-ovirt-1.6.0.46-1.el7sat.noarch
* foreman-postgresql-1.6.0.46-1.el7sat.noarch
* foreman-proxy-1.6.0.30-1.el7sat.noarch
* foreman-selinux-1.6.0.14-1.el7sat.noarch
* foreman-vmware-1.6.0.46-1.el7sat.noarch
* katello-1.5.0-30.el7sat.noarch
* katello-certs-tools-1.5.6-1.el7sat.noarch
* katello-default-ca-1.0-1.noarch
* katello-installer-0.0.64-1.el7sat.noarch
* katello-server-ca-1.0-1.noarch
* openldap-2.4.39-3.el7.x86_64
* pulp-katello-0.3-4.el7sat.noarch
* pulp-nodes-common-2.4.1-0.7.beta.el7sat.noarch
* pulp-nodes-parent-2.4.1-0.7.beta.el7sat.noarch
* pulp-puppet-plugins-2.4.1-0.7.beta.el7sat.noarch
* pulp-puppet-tools-2.4.1-0.7.beta.el7sat.noarch
* pulp-rpm-plugins-2.4.1-0.7.beta.el7sat.noarch
* pulp-selinux-2.4.1-0.7.beta.el7sat.noarch
* pulp-server-2.4.1-0.7.beta.el7sat.noarch
* python-ldap-2.4.6-6.el7.x86_64
* ruby193-rubygem-net-ldap-0.3.1-3.el7sat.noarch
* ruby193-rubygem-runcible-1.1.0-2.el7sat.noarch

How reproducible:
100%, but the exact response of each API URL varies.

Steps to Reproduce:
See the "Description of problem" section of this bug report.

Actual results:
A hash or list of hashes that may or may not contain IDs.

Expected results:
An ID or list of IDs.

Additional info:
n/a

Comment 1 jaudet 2014-10-09 21:29:02 UTC
A test which targets this bug for one of the API URLs has been submitted. See: https://github.com/SatelliteQE/robottelo/pull/1545

Comment 2 jaudet 2014-10-09 21:31:19 UTC
This bug report claims that "Client code can be simple and straightforward if a list of IDs is returned." For an example of the workarounds that are required when hashes are returned, search for the phrase "1151240" in this file: https://github.com/SatelliteQE/robottelo/blob/master/robottelo/entities.py

Searching for that phrase may not work until pull request #1545 is merged.

Comment 3 jaudet 2014-10-09 21:32:44 UTC
*** Bug 1122267 has been marked as a duplicate of this bug. ***

Comment 4 RHEL Program Management 2014-10-09 21:33:05 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 6 Dominic Cleal 2014-10-21 15:55:07 UTC
The first example of gpgkeys is the problem here, it should include the ID in the output for an individual organisation.

The latter format may be standardised in APIv3 in the future.

Comment 7 jaudet 2014-10-23 18:29:40 UTC
I'm happy to hear that this may be included in APIv3.

Comment 11 jaudet 2015-03-04 16:20:47 UTC
Tested against Satellite-6.1.0-RHEL-6-20150303.0 and Satellite-6.1.0-RHEL-7-20150303.0.

Comment 12 Bryan Kearney 2015-08-11 13:20:44 UTC
This bug is slated to be released with Satellite 6.1.

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