diff --git a/api-ref/source/v2/intro.inc b/api-ref/source/v2/intro.inc index 518eb0b08..9c063c7fb 100644 --- a/api-ref/source/v2/intro.inc +++ b/api-ref/source/v2/intro.inc @@ -145,6 +145,16 @@ admin_state_up=True and shared=True and named ``foobar`` or ``bizbaz``: GET /v2.0/networks?name=foobar&name=bizbaz&admin_state_up=True&shared=True +Starting from Rocky release, the Networking API might support filtering +attributes with empty value. For example, the request below lists all ports +that have ``device_id`` attribute with empty value (which are unbound ports). + +.. code:: + + GET /v2.0/networks?device_id= + +To determine if this feature is supported, a user can check whether the +``empty-string-filtering`` extension API is available. Note ---- diff --git a/neutron_lib/api/definitions/__init__.py b/neutron_lib/api/definitions/__init__.py index af5e23243..a903af5e2 100644 --- a/neutron_lib/api/definitions/__init__.py +++ b/neutron_lib/api/definitions/__init__.py @@ -24,6 +24,7 @@ from neutron_lib.api.definitions import dhcpagentscheduler from neutron_lib.api.definitions import dns from neutron_lib.api.definitions import dns_domain_ports from neutron_lib.api.definitions import dvr +from neutron_lib.api.definitions import empty_string_filtering from neutron_lib.api.definitions import external_net from neutron_lib.api.definitions import extra_dhcp_opt from neutron_lib.api.definitions import extraroute @@ -96,6 +97,7 @@ _ALL_API_DEFINITIONS = { dns, dns_domain_ports, dvr, + empty_string_filtering, external_net, extra_dhcp_opt, extraroute, diff --git a/neutron_lib/api/definitions/base.py b/neutron_lib/api/definitions/base.py index f0cb08b3e..a955efc09 100644 --- a/neutron_lib/api/definitions/base.py +++ b/neutron_lib/api/definitions/base.py @@ -86,6 +86,7 @@ KNOWN_EXTENSIONS = ( 'dns-domain-ports', 'dns-integration', 'dvr', + 'empty-string-filtering', 'ext-gw-mode', 'external-net', 'extra_dhcp_opt', diff --git a/neutron_lib/api/definitions/empty_string_filtering.py b/neutron_lib/api/definitions/empty_string_filtering.py new file mode 100644 index 000000000..345a16883 --- /dev/null +++ b/neutron_lib/api/definitions/empty_string_filtering.py @@ -0,0 +1,25 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +ALIAS = 'empty-string-filtering' +IS_SHIM_EXTENSION = True +IS_STANDARD_ATTR_EXTENSION = False +NAME = 'Empty String Filtering Extension' +DESCRIPTION = 'Allow filtering by attributes with empty string value' +UPDATED_TIMESTAMP = '2018-05-01T10:00:00-00:00' +RESOURCE_ATTRIBUTE_MAP = {} +SUB_RESOURCE_ATTRIBUTE_MAP = {} +ACTION_MAP = {} +REQUIRED_EXTENSIONS = [] +OPTIONAL_EXTENSIONS = [] +ACTION_STATUS = {} diff --git a/neutron_lib/tests/unit/api/definitions/test_empty_string_filtering.py b/neutron_lib/tests/unit/api/definitions/test_empty_string_filtering.py new file mode 100644 index 000000000..f4188ec4e --- /dev/null +++ b/neutron_lib/tests/unit/api/definitions/test_empty_string_filtering.py @@ -0,0 +1,18 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from neutron_lib.api.definitions import empty_string_filtering +from neutron_lib.tests.unit.api.definitions import base + + +class EmptyStringFilteringDefinitionTestCase(base.DefinitionBaseTestCase): + extension_module = empty_string_filtering diff --git a/releasenotes/notes/add-empty-string-filtering-api-extension-44cb392025dc359c.yaml b/releasenotes/notes/add-empty-string-filtering-api-extension-44cb392025dc359c.yaml new file mode 100644 index 000000000..c19b89d06 --- /dev/null +++ b/releasenotes/notes/add-empty-string-filtering-api-extension-44cb392025dc359c.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Add ``empty-string-filtering`` API extension. This extension indicates + if the server supports filtering attributes with empty value.