Annotate network parameters for sort_key
Add a 'is_sort_key' keyword for each network's attribute that can be used as a sort_key. In the future, we will rely on this keyword to perform validation: https://review.openstack.org/#/c/554368/ . Change-Id: I6104a1b534a7ddc4856bd1a25d77e12b1ed5421f Related-Bug: #1749820
This commit is contained in:
parent
0abe67c6eb
commit
b03226d597
|
@ -85,6 +85,7 @@ The following are the defined keys for attribute maps:
|
|||
``convert_to`` transformation to apply to the value before it is returned
|
||||
``convert_list_to`` if the value is a list, apply this transformation to the value before it is returned
|
||||
``is_filter`` the attribute can be used in ``GET`` requests as filter
|
||||
``is_sort_key`` the attribute can be used in ``GET`` requests as sort_key
|
||||
``is_visible`` the attribute is returned in ``GET`` responses
|
||||
``required_by_policy`` the attribute is required by the policy engine and should therefore be filled by the API layer even if not present in request body
|
||||
``enforce_policy`` the attribute is actively part of the policy enforcing mechanism, ie: there might be rules which refer to this attribute
|
||||
|
|
|
@ -141,8 +141,9 @@ KNOWN_KEYWORDS = (
|
|||
'convert_list_to',
|
||||
'default',
|
||||
'enforce_policy',
|
||||
'is_visible',
|
||||
'is_filter',
|
||||
'is_sort_key',
|
||||
'is_visible',
|
||||
'primary_key',
|
||||
'required_by_policy',
|
||||
'validate',
|
||||
|
|
|
@ -37,11 +37,13 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'validate': {'type:uuid': None},
|
||||
'is_visible': True,
|
||||
'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'primary_key': True},
|
||||
'name': {'allow_post': True, 'allow_put': True,
|
||||
'validate': {
|
||||
'type:string': db_const.NAME_FIELD_SIZE},
|
||||
'default': '', 'is_visible': True, 'is_filter': True},
|
||||
'default': '', 'is_visible': True, 'is_filter': True,
|
||||
'is_sort_key': True},
|
||||
subnet.COLLECTION_NAME: {'allow_post': False, 'allow_put': False,
|
||||
'default': [],
|
||||
'is_visible': True},
|
||||
|
@ -49,14 +51,16 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
'default': True,
|
||||
'convert_to': converters.convert_to_boolean,
|
||||
'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'is_visible': True},
|
||||
'status': {'allow_post': False, 'allow_put': False,
|
||||
'is_visible': True, 'is_filter': True},
|
||||
'is_visible': True, 'is_filter': True, 'is_sort_key': True},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'required_by_policy': True,
|
||||
'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'is_visible': True},
|
||||
constants.SHARED: {
|
||||
'allow_post': True,
|
||||
|
|
|
@ -31,6 +31,7 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||
},
|
||||
az_def.AZ_HINTS: {
|
||||
'allow_post': True, 'allow_put': False, 'is_visible': True,
|
||||
'is_sort_key': True,
|
||||
'validate': {'type:availability_zone_hint_list': None},
|
||||
'default': []
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ UPDATED_TIMESTAMP = "2015-03-25T10:00:00-00:00"
|
|||
RESOURCE_ATTRIBUTE_MAP = {
|
||||
network.COLLECTION_NAME: {
|
||||
MTU: {'allow_post': False, 'allow_put': False,
|
||||
'is_visible': True, 'is_filter': True},
|
||||
'is_visible': True, 'is_filter': True, 'is_sort_key': True},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ ASSERT_FUNCTIONS = {
|
|||
'default': assert_converter,
|
||||
'enforce_policy': assert_bool,
|
||||
'is_filter': assert_bool,
|
||||
'is_sort_key': assert_bool,
|
||||
'is_visible': assert_bool,
|
||||
'primary_key': assert_true,
|
||||
'required_by_policy': assert_bool,
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
features:
|
||||
- |
|
||||
Add a new keyword ``is_sort_key`` to attribute maps. This keyword indicates
|
||||
that the attribute can be used as a sort key for sorting list result.
|
Loading…
Reference in New Issue