更新时间:2022-01-25 GMT+08:00

查询结果顺序

Neutron API v2.0提供对查询结果排序功能,通过在list请求的url中添加sort_key和sort_dir参数实现对返回列表信息依据制定的key值排序。sort_key参数制定排序的依据参数;sort_dir参数标示排序为升序(asc)还是降序(desc)。Neutron API v2.0的排序支持依据多个条件排序,此时sort_key和sort_dir参数的数目必须相同,数目不同response将响应错误码400。

请求样例

GET /v2.0/networks?sort_key=name&sort_dir=asc&sort_key=status&sort_dir=desc

响应样例

{
    "networks": [
        {
            "status": "ACTIVE",
            "subnets": [],
            "name": "liudongtest ",
            "admin_state_up": false,
            "tenant_id": "6fbe9263116a4b68818cf1edce16bc4f",
            "id": "60c809cb-6731-45d0-ace8-3bf5626421a9"
        },
        {
            "status": "ACTIVE",
            "subnets": [
                "132dc12d-c02a-4c90-9cd5-c31669aace04"
            ],
            "name": "publicnet",
            "admin_state_up": true,
            "tenant_id": "6fbe9263116a4b68818cf1edce16bc4f",
            "id": "9daeac7c-a98f-430f-8e38-67f9c044e299"
        },
        {
            "status": "ACTIVE",
            "subnets": [
                "e25189a8-54df-4948-9396-d8291ffc92a0"
            ],
            "name": "testnet01",
            "admin_state_up": true,
            "tenant_id": "6fbe9263116a4b68818cf1edce16bc4f",
            "id": "3d42a0d4-a980-4613-ae76-a2cddecff054"
        }
    ]
}