Devices endpoint returns hyphenated field instead of snake_case

Bug #1675085 reported by Thomas Maddox
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
craton
New
Undecided
Unassigned

Bug Description

According to OpenStack API working group, API response fields are supposed to be snake_case, not hyphenated. We're currently returning a body that looks like:

{"hosts": [...], "network-devices": [...]} from GET /v1/devices. This needs to be changed to use "network_devices" as the field name instead.

https://specs.openstack.org/openstack/api-wg/guidelines/naming.html#fields-in-an-api-request-or-response-body

Example of issue:

$ http http://localhost:8080/v1/devices $CRATON_HTTP_HEADERS
{
    "devices": {
        "hosts": [
            {
                "active": true,
                "cell_id": 1,
                "cloud_id": 1,
                "created_at": "2017-03-22T16:13:58.000000",
                "device_type": "server",
                "id": 2,
                "ip_address": "192.168.1.5",
                "links": [
                    {
                        "href": "http://localhost:8080/v1/network-devices/1",
                        "rel": "up"
                    }
                ],
                "name": "host0.ORD135.C0001.C-1.example1.com",
                "note": null,
                "parent_id": 1,
                "project_id": "6319ff30-52de-4d09-8b21-d53d0054460a",
                "region_id": 1,
                "updated_at": null
            },
            ...
            {
                "active": true,
                "cell_id": 4,
                "cloud_id": 1,
                "created_at": "2017-03-22T16:14:00.000000",
                "device_type": "container",
                "id": 30,
                "ip_address": "172.0.0.14",
                "links": [
                    {
                        "href": "http://localhost:8080/v1/hosts/29",
                        "rel": "up"
                    }
                ],
                "name": "container_host0.DFW.C0002.C-1.example1.com",
                "note": null,
                "parent_id": 29,
                "project_id": "6319ff30-52de-4d09-8b21-d53d0054460a",
                "region_id": 2,
                "updated_at": null
            }
        ],
        "network-devices": [
            {
                "access_secret_id": null,
                "active": true,
                "cell_id": 1,
                "cloud_id": 1,
                "created_at": "2017-03-22T16:13:58.000000",
                "device_type": "switch",
                "id": 1,
                "ip_address": "10.10.1.1",
                "links": [
                    {
                        "href": "http://localhost:8080/v1/cells/1",
                        "rel": "up"
                    }
                ],
                "model_name": "model-x",
                "name": "switch1.C0001.ORD135.example.com",
                "os_version": "version-1",
                "parent_id": null,
                "project_id": "6319ff30-52de-4d09-8b21-d53d0054460a",
                "region_id": 1,
                "updated_at": null,
                "vlans": null
            },
            ...
            {
                "access_secret_id": null,
                "active": true,
                "cell_id": 4,
                "cloud_id": 1,
                "created_at": "2017-03-22T16:14:00.000000",
                "device_type": "switch",
                "id": 28,
                "ip_address": "10.10.1.1",
                "links": [
                    {
                        "href": "http://localhost:8080/v1/cells/4",
                        "rel": "up"
                    }
                ],
                "model_name": "model-x",
                "name": "switch1.C0002.DFW.example.com",
                "os_version": "version-1",
                "parent_id": null,
                "project_id": "6319ff30-52de-4d09-8b21-d53d0054460a",
                "region_id": 2,
                "updated_at": null,
                "vlans": null
            }
        ]
    },
    "links": [
        {
            "href": "http://localhost:8080/v1/devices?resolved-values=True&descendants=False&sort_dir=asc&details=False&limit=30&sort_keys=created_at%2Cid",
            "rel": "first"
        },
        {
            "href": "http://localhost:8080/v1/devices?resolved-values=True&descendants=False&sort_dir=asc&details=False&limit=30&sort_keys=created_at%2Cid",
            "rel": "prev"
        },
        {
            "href": "http://localhost:8080/v1/devices?resolved-values=True&descendants=False&sort_dir=asc&details=False&limit=30&sort_keys=created_at%2Cid",
            "rel": "self"
        },
        {
            "href": "http://localhost:8080/v1/devices?resolved-values=True&descendants=False&sort_dir=asc&marker=30&details=False&limit=30&sort_keys=created_at%2Cid",
            "rel": "next"
        }
    ]
}

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.