From 10eaab324289faa2aed2ac47165f2a65ec85a7b5 Mon Sep 17 00:00:00 2001 From: Hongbin Lu Date: Thu, 19 Jul 2018 03:58:14 +0000 Subject: [PATCH] Add is_filter to network_ip_availability Change-Id: Ie1d69c3575210c99f9f4c3e9f709da5d3f972c06 --- api-ref/source/v2/network-ip-availability.inc | 8 ++++++++ api-ref/source/v2/parameters.yaml | 13 +++++++++++++ .../api/definitions/network_ip_availability.py | 18 +++++++++++++++--- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/api-ref/source/v2/network-ip-availability.inc b/api-ref/source/v2/network-ip-availability.inc index 22c9fabee..ecb1ad572 100644 --- a/api-ref/source/v2/network-ip-availability.inc +++ b/api-ref/source/v2/network-ip-availability.inc @@ -70,6 +70,14 @@ Error response codes: 401 Request ------- +.. rest_parameters:: parameters.yaml + + - network_id: network_ip_availability-network_id-query + - network_name: network-name-query + - tenant_id: project_id-query + - project_id: project_id-query + - ip_version: ip_version-query + Response Parameters ------------------- diff --git a/api-ref/source/v2/parameters.yaml b/api-ref/source/v2/parameters.yaml index e0d514445..c4f3a7686 100644 --- a/api-ref/source/v2/parameters.yaml +++ b/api-ref/source/v2/parameters.yaml @@ -755,6 +755,12 @@ name-query: in: query required: false type: string +network-name-query: + description: | + Filter the list result by the human-readable name of the network. + in: query + required: false + type: string network-shared-query: description: | Filter the network list result based on if the network is shared across @@ -791,6 +797,13 @@ network_id-query: in: query required: false type: string +network_ip_availability-network_id-query: + description: | + Filter the list result by the ID of the network whose IP availability + detail is reported. + in: query + required: false + type: string network_is_default-query: description: | Filter the network list result based on if the network is default pool diff --git a/neutron_lib/api/definitions/network_ip_availability.py b/neutron_lib/api/definitions/network_ip_availability.py index ba732e701..3aa74defa 100644 --- a/neutron_lib/api/definitions/network_ip_availability.py +++ b/neutron_lib/api/definitions/network_ip_availability.py @@ -27,15 +27,15 @@ RESOURCE_ATTRIBUTE_MAP = { RESOURCE_PLURAL: { 'network_id': { 'allow_post': False, 'allow_put': False, - 'is_visible': True + 'is_visible': True, 'is_filter': True }, 'network_name': { 'allow_post': False, 'allow_put': False, - 'is_visible': True + 'is_visible': True, 'is_filter': True }, 'tenant_id': { 'allow_post': False, 'allow_put': False, - 'is_visible': True + 'is_visible': True, 'is_filter': True }, 'total_ips': { 'allow_post': False, 'allow_put': False, @@ -48,6 +48,18 @@ RESOURCE_ATTRIBUTE_MAP = { 'subnet_ip_availability': { 'allow_post': False, 'allow_put': False, 'is_visible': True + }, + # NOTE(hongbin): This 'ip_version' attribute (top-level) is only used + # as a filter on listing the resources. There is another 'ip_version' + # attribute nested inside the 'subnet_ip_availability'. + # The difference is that the top-level attribute is used as input + # and the nested attribute is an output. + # In here, 'allow_post', 'allow_put' and 'is_visible' are set to False + # because this attribute should be used as filter only. Please do not + # set it to True to avoid introducing inconsistency. + 'ip_version': { + 'allow_post': False, 'allow_put': False, + 'is_visible': False, 'is_filter': True } # TODO(wwriverrat) Make composite attribute for subnet_ip_availability }