Merge "Annotate network parameters for sort_key"

This commit is contained in:
Zuul 2018-04-16 18:22:38 +00:00 committed by Gerrit Code Review
commit 7c4e74a490
7 changed files with 17 additions and 4 deletions

View File

@ -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_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 ``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_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 ``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 ``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 ``enforce_policy`` the attribute is actively part of the policy enforcing mechanism, ie: there might be rules which refer to this attribute

View File

@ -146,8 +146,9 @@ KNOWN_KEYWORDS = (
'convert_list_to', 'convert_list_to',
'default', 'default',
'enforce_policy', 'enforce_policy',
'is_visible',
'is_filter', 'is_filter',
'is_sort_key',
'is_visible',
'primary_key', 'primary_key',
'required_by_policy', 'required_by_policy',
'validate', 'validate',

View File

@ -37,11 +37,13 @@ RESOURCE_ATTRIBUTE_MAP = {
'validate': {'type:uuid': None}, 'validate': {'type:uuid': None},
'is_visible': True, 'is_visible': True,
'is_filter': True, 'is_filter': True,
'is_sort_key': True,
'primary_key': True}, 'primary_key': True},
'name': {'allow_post': True, 'allow_put': True, 'name': {'allow_post': True, 'allow_put': True,
'validate': { 'validate': {
'type:string': db_const.NAME_FIELD_SIZE}, '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, subnet.COLLECTION_NAME: {'allow_post': False, 'allow_put': False,
'default': [], 'default': [],
'is_visible': True}, 'is_visible': True},
@ -49,14 +51,16 @@ RESOURCE_ATTRIBUTE_MAP = {
'default': True, 'default': True,
'convert_to': converters.convert_to_boolean, 'convert_to': converters.convert_to_boolean,
'is_filter': True, 'is_filter': True,
'is_sort_key': True,
'is_visible': True}, 'is_visible': True},
'status': {'allow_post': False, 'allow_put': False, '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, 'tenant_id': {'allow_post': True, 'allow_put': False,
'validate': { 'validate': {
'type:string': db_const.PROJECT_ID_FIELD_SIZE}, 'type:string': db_const.PROJECT_ID_FIELD_SIZE},
'required_by_policy': True, 'required_by_policy': True,
'is_filter': True, 'is_filter': True,
'is_sort_key': True,
'is_visible': True}, 'is_visible': True},
constants.SHARED: { constants.SHARED: {
'allow_post': True, 'allow_post': True,

View File

@ -31,6 +31,7 @@ RESOURCE_ATTRIBUTE_MAP = {
}, },
az_def.AZ_HINTS: { az_def.AZ_HINTS: {
'allow_post': True, 'allow_put': False, 'is_visible': True, 'allow_post': True, 'allow_put': False, 'is_visible': True,
'is_sort_key': True,
'validate': {'type:availability_zone_hint_list': None}, 'validate': {'type:availability_zone_hint_list': None},
'default': [] 'default': []
} }

View File

@ -49,7 +49,7 @@ UPDATED_TIMESTAMP = "2015-03-25T10:00:00-00:00"
RESOURCE_ATTRIBUTE_MAP = { RESOURCE_ATTRIBUTE_MAP = {
network.COLLECTION_NAME: { network.COLLECTION_NAME: {
MTU: {'allow_post': False, 'allow_put': False, MTU: {'allow_post': False, 'allow_put': False,
'is_visible': True, 'is_filter': True}, 'is_visible': True, 'is_filter': True, 'is_sort_key': True},
}, },
} }

View File

@ -59,6 +59,7 @@ ASSERT_FUNCTIONS = {
'default': assert_converter, 'default': assert_converter,
'enforce_policy': assert_bool, 'enforce_policy': assert_bool,
'is_filter': assert_bool, 'is_filter': assert_bool,
'is_sort_key': assert_bool,
'is_visible': assert_bool, 'is_visible': assert_bool,
'primary_key': assert_true, 'primary_key': assert_true,
'required_by_policy': assert_bool, 'required_by_policy': assert_bool,

View File

@ -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.