Add shim extension sort-key-validation
Neutron patch: https://review.openstack.org/#/c/580217/ Change-Id: I00e2aafc271e67977105c866ed9f9f586605fdb4 Partial-Bug: #1749820
This commit is contained in:
parent
8cbab5756c
commit
befb16ed9e
@ -378,6 +378,12 @@ the background.
|
|||||||
To determine if sorting is supported, a user can check whether the 'sorting'
|
To determine if sorting is supported, a user can check whether the 'sorting'
|
||||||
extension API is available.
|
extension API is available.
|
||||||
|
|
||||||
|
Starting from Rocky release, the Networking API performs validation on
|
||||||
|
sorting attributes if the API extension ``sort-key-validation`` is available.
|
||||||
|
If an API request contains an unknown or unsupported sort key,
|
||||||
|
the server will return a ``400`` response instead of silently ignoring
|
||||||
|
the invalid input.
|
||||||
|
|
||||||
|
|
||||||
.. _Extensions:
|
.. _Extensions:
|
||||||
|
|
||||||
|
@ -79,6 +79,7 @@ from neutron_lib.api.definitions import segment
|
|||||||
from neutron_lib.api.definitions import segments_peer_subnet_host_routes
|
from neutron_lib.api.definitions import segments_peer_subnet_host_routes
|
||||||
from neutron_lib.api.definitions import servicetype
|
from neutron_lib.api.definitions import servicetype
|
||||||
from neutron_lib.api.definitions import sfc
|
from neutron_lib.api.definitions import sfc
|
||||||
|
from neutron_lib.api.definitions import sort_key_validation
|
||||||
from neutron_lib.api.definitions import sorting
|
from neutron_lib.api.definitions import sorting
|
||||||
from neutron_lib.api.definitions import standard_attr_segment
|
from neutron_lib.api.definitions import standard_attr_segment
|
||||||
from neutron_lib.api.definitions import subnet
|
from neutron_lib.api.definitions import subnet
|
||||||
@ -164,6 +165,7 @@ _ALL_API_DEFINITIONS = {
|
|||||||
segments_peer_subnet_host_routes,
|
segments_peer_subnet_host_routes,
|
||||||
servicetype,
|
servicetype,
|
||||||
sfc,
|
sfc,
|
||||||
|
sort_key_validation,
|
||||||
sorting,
|
sorting,
|
||||||
standard_attr_segment,
|
standard_attr_segment,
|
||||||
subnet,
|
subnet,
|
||||||
|
@ -116,6 +116,7 @@ KNOWN_EXTENSIONS = (
|
|||||||
'security-group',
|
'security-group',
|
||||||
'segment',
|
'segment',
|
||||||
'service-type',
|
'service-type',
|
||||||
|
'sort-key-validation',
|
||||||
'sorting',
|
'sorting',
|
||||||
'standard-attr-description',
|
'standard-attr-description',
|
||||||
'standard-attr-revisions',
|
'standard-attr-revisions',
|
||||||
|
27
neutron_lib/api/definitions/sort_key_validation.py
Normal file
27
neutron_lib/api/definitions/sort_key_validation.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# 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 sorting
|
||||||
|
|
||||||
|
|
||||||
|
ALIAS = 'sort-key-validation'
|
||||||
|
IS_SHIM_EXTENSION = True
|
||||||
|
IS_STANDARD_ATTR_EXTENSION = False
|
||||||
|
NAME = 'Sort keys validation'
|
||||||
|
DESCRIPTION = 'Provides validation on sort keys.'
|
||||||
|
UPDATED_TIMESTAMP = '2018-07-04T10:00:00-00:00'
|
||||||
|
RESOURCE_ATTRIBUTE_MAP = {}
|
||||||
|
SUB_RESOURCE_ATTRIBUTE_MAP = {}
|
||||||
|
ACTION_MAP = {}
|
||||||
|
REQUIRED_EXTENSIONS = [sorting.ALIAS]
|
||||||
|
OPTIONAL_EXTENSIONS = []
|
||||||
|
ACTION_STATUS = {}
|
@ -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 sort_key_validation as apidef
|
||||||
|
from neutron_lib.tests.unit.api.definitions import base
|
||||||
|
|
||||||
|
|
||||||
|
class SortKeyValidationiDefinitionTestCase(base.DefinitionBaseTestCase):
|
||||||
|
extension_module = apidef
|
@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add API extension ``sort-key-validation``. This extension indicates if the
|
||||||
|
server supports validation on sorting.
|
||||||
|
other:
|
||||||
|
- |
|
||||||
|
API extension ``sort-key-validation`` relies on the ``is_sort_key`` keyword
|
||||||
|
in the ``RESOURCE_ATTRIBUTE_MAP`` to judge if an attribute can be used as
|
||||||
|
sort key. Neutron plugins which want to support sort key validation
|
||||||
|
needs to set ``is_sort_key`` to ``True`` for each attribute in their
|
||||||
|
resource attribute map.
|
Loading…
Reference in New Issue
Block a user