Inconsistent meaning of flavor_ref in requests vs. responses

Bug #1392573 reported by Shaunak Kashyap
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Poppy
Fix Released
Medium
Shaunak Kashyap

Bug Description

In the "Create service" API (POST /services), the "flavor_ref" property is used to indicate a flavor ID (e.g. "asia"), not a flavor href (e.g. "http://192.168.59.103:81/v1.0/flavors/asia").

In the "Get service" API (GET /services/{service_id}), the "flavor_ref" property is used to indicate a flavor href, not a flavor ID.

This inconsistency will make things difficult for consumers of the API (such as SDKs and other client code) since such software often uses a common model for serializing request representations and deserializing response representations.

My suggestion would be:
* to use "flavor_id" (instead of "flavor_ref") to indicate flavor IDs in request and response representations of all resources that require/return flavors, and
* to add a new link with rel = "flavor" and href = "<flavor resource URL>" (e.g. "http://192.168.59.103:81/v1.0/flavors/asia") in response representations of all resources that return flavors.

Tags: api
description: updated
description: updated
description: updated
description: updated
description: updated
Revision history for this message
Amit Gandhi (amit-gandhi) wrote :

I would like to get the API-WG take on this item. Should flavors be referred to by their ID's, and contain a link in the links section to it. Or should it be referred to by flavor_ref which is always an href to follow.

Changed in poppy:
status: New → Incomplete
Revision history for this message
Shaunak Kashyap (ycombinator-o) wrote :

I have posted this as a question to the API-WG on the openstack-dev@ mailing list: http://lists.openstack.org/pipermail/openstack-dev/2014-November/050798.html

Revision history for this message
Shaunak Kashyap (ycombinator-o) wrote :

There hasn't been any activity on the mailing list thread for the past couple of days now. Based on the discussion there, I would suggest using "flavor_id" (instead of "flavor_ref") to indicate bare flavor IDs (e.g. "asia") in request and response representations of all resources that require/return flavors . Thoughts?

Revision history for this message
Amit Gandhi (amit-gandhi) wrote :

yes. I would recommend "flavor_id" in the normal section, and then have a link in the links section with a "rel" = "flavor_ref" so that users can still follow the link to get flavor information.

Revision history for this message
Shaunak Kashyap (ycombinator-o) wrote :

Nit: should it be "rel" = "flavor_ref", or "rel" = "flavor" (because all links are refs)?

Revision history for this message
Malini Kamalambal (malini-pk) wrote :

In terms of making the API user friendly, I agree with Shaunak's suggestion - though my vote is to simply use flavor instead of flavor_id and link in the links section with a "rel" = "flavor_ref"

But this will make us inconsistent with some of the Openstak APIs (not a big deal IMO, since there seems to be no consistency across APIs as is - unfortunately!! ).

1. Per Compute V2 API http://developer.openstack.org/api-ref-compute-v2.html
'flavorRef plain csapi:string
The flavor reference for the desired flavor for your server instance.

2. Per DB API http://developer.openstack.org/api-ref-databases-v1.html

'flavorRef plain xsd:string
Reference (href) to a flavor as specified in the response from the list Flavors API call. This is the actual URI as specified by the href field in the link.

Rather than the flavor URI, you can also pass the flavor id (integer) as the value for flavorRef. For example, the flavor id for the flavor URI shown above is "1".'

Revision history for this message
Shaunak Kashyap (ycombinator-o) wrote :

I would recommend naming the bare ID property as "flavor_id", instead of "flavor". This way, in the future if you decide to compose a flavor's representation inside another resource's representation, you can name _that_ property "flavor". That said, I realize this is veering towards the bikeshed so I'm happy to go with either right now :)

Revision history for this message
Shaunak Kashyap (ycombinator-o) wrote :

To make things a bit more concrete, here's what I'm proposing for flavor references in other resources' representations:

When referencing a flavor in another resource's REQUEST representation:

{
  "flavor_id": "asia",
  // ... other resource properties
}

When referencing a flavor in another resource's RESPONSE representation:

{
  "flavor_id": "asia",
  "links": [
    {
      "rel": "flavor",
      "href": "{base_uri}/flavors/asia"
    }
  ],
  // ... other resource properties
}

Please let me know if this is acceptable and I'll send in a patch with the necessary changes.

Revision history for this message
Amit Gandhi (amit-gandhi) wrote :
Changed in poppy:
importance: Undecided → Medium
assignee: nobody → Shaunak Kashyap (ycombinator-o)
milestone: none → kilo-2
status: Incomplete → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to poppy (master)

Reviewed: https://review.openstack.org/138674
Committed: https://git.openstack.org/cgit/stackforge/poppy/commit/?id=b3bc5f6c321f847533cfd9349d9327889fe89b9c
Submitter: Jenkins
Branch: master

commit b3bc5f6c321f847533cfd9349d9327889fe89b9c
Author: Shaunak Kashyap <email address hidden>
Date: Wed Dec 3 01:48:52 2014 -0800

    flavor_ref -> flavor_id

    Change-Id: I3578f906ddec69b062d18c9d37a8b764df067602
    Closes-Bug: 1392573

Changed in poppy:
status: In Progress → Fix Committed
Changed in poppy:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.