Annotate all the filter parameters for networks
Add a 'is_filter' keyword for each network's attribute that can be used as filter. In the future, we will rely on this to perform filter validation: https://review.openstack.org/#/c/554368/ . Change-Id: I0cdc1ff482d4ff7ec6afa391392c27c2c099cc0e Related-Bug: #1749820
This commit is contained in:
parent
ebf776ac85
commit
0abe67c6eb
@ -84,6 +84,7 @@ The following are the defined keys for attribute maps:
|
|||||||
``validate`` specifies rules for validating data in the attribute
|
``validate`` specifies rules for validating data in the attribute
|
||||||
``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_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
|
||||||
|
@ -43,6 +43,7 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||||||
'allow_post': True,
|
'allow_post': True,
|
||||||
'allow_put': True,
|
'allow_put': True,
|
||||||
'default': False,
|
'default': False,
|
||||||
|
'is_filter': True,
|
||||||
'is_visible': True,
|
'is_visible': True,
|
||||||
'convert_to': converters.convert_to_boolean,
|
'convert_to': converters.convert_to_boolean,
|
||||||
'enforce_policy': True,
|
'enforce_policy': True,
|
||||||
|
@ -142,6 +142,7 @@ KNOWN_KEYWORDS = (
|
|||||||
'default',
|
'default',
|
||||||
'enforce_policy',
|
'enforce_policy',
|
||||||
'is_visible',
|
'is_visible',
|
||||||
|
'is_filter',
|
||||||
'primary_key',
|
'primary_key',
|
||||||
'required_by_policy',
|
'required_by_policy',
|
||||||
'validate',
|
'validate',
|
||||||
|
@ -36,6 +36,7 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||||||
'allow_put': True,
|
'allow_put': True,
|
||||||
'default': False,
|
'default': False,
|
||||||
'is_visible': True,
|
'is_visible': True,
|
||||||
|
'is_filter': True,
|
||||||
'convert_to': converters.convert_to_boolean,
|
'convert_to': converters.convert_to_boolean,
|
||||||
'enforce_policy': True,
|
'enforce_policy': True,
|
||||||
'required_by_policy': True
|
'required_by_policy': True
|
||||||
|
@ -36,24 +36,27 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||||||
'id': {'allow_post': False, 'allow_put': False,
|
'id': {'allow_post': False, 'allow_put': False,
|
||||||
'validate': {'type:uuid': None},
|
'validate': {'type:uuid': None},
|
||||||
'is_visible': True,
|
'is_visible': True,
|
||||||
|
'is_filter': 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},
|
'default': '', 'is_visible': True, 'is_filter': 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},
|
||||||
'admin_state_up': {'allow_post': True, 'allow_put': True,
|
'admin_state_up': {'allow_post': True, 'allow_put': True,
|
||||||
'default': True,
|
'default': True,
|
||||||
'convert_to': converters.convert_to_boolean,
|
'convert_to': converters.convert_to_boolean,
|
||||||
|
'is_filter': 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_visible': True, 'is_filter': 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_visible': True},
|
'is_visible': True},
|
||||||
constants.SHARED: {
|
constants.SHARED: {
|
||||||
'allow_post': True,
|
'allow_post': True,
|
||||||
@ -61,6 +64,7 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||||||
'default': False,
|
'default': False,
|
||||||
'convert_to': converters.convert_to_boolean,
|
'convert_to': converters.convert_to_boolean,
|
||||||
'is_visible': True,
|
'is_visible': True,
|
||||||
|
'is_filter': True,
|
||||||
'required_by_policy': True,
|
'required_by_policy': True,
|
||||||
'enforce_policy': True
|
'enforce_policy': True
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,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_visible': True, 'is_filter': True},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,17 +65,20 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||||||
'validate': {'type:string': NETWORK_TYPE_MAX_LEN},
|
'validate': {'type:string': NETWORK_TYPE_MAX_LEN},
|
||||||
'default': constants.ATTR_NOT_SPECIFIED,
|
'default': constants.ATTR_NOT_SPECIFIED,
|
||||||
'enforce_policy': True,
|
'enforce_policy': True,
|
||||||
|
'is_filter': True,
|
||||||
'is_visible': True},
|
'is_visible': True},
|
||||||
PHYSICAL_NETWORK: {'allow_post': True, 'allow_put': True,
|
PHYSICAL_NETWORK: {'allow_post': True, 'allow_put': True,
|
||||||
'validate': {'type:string':
|
'validate': {'type:string':
|
||||||
PHYSICAL_NETWORK_MAX_LEN},
|
PHYSICAL_NETWORK_MAX_LEN},
|
||||||
'default': constants.ATTR_NOT_SPECIFIED,
|
'default': constants.ATTR_NOT_SPECIFIED,
|
||||||
'enforce_policy': True,
|
'enforce_policy': True,
|
||||||
|
'is_filter': True,
|
||||||
'is_visible': True},
|
'is_visible': True},
|
||||||
SEGMENTATION_ID: {'allow_post': True, 'allow_put': True,
|
SEGMENTATION_ID: {'allow_post': True, 'allow_put': True,
|
||||||
'convert_to': converters.convert_to_int,
|
'convert_to': converters.convert_to_int,
|
||||||
'enforce_policy': True,
|
'enforce_policy': True,
|
||||||
'default': constants.ATTR_NOT_SPECIFIED,
|
'default': constants.ATTR_NOT_SPECIFIED,
|
||||||
|
'is_filter': True,
|
||||||
'is_visible': True},
|
'is_visible': True},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,8 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||||||
'allow_put': False,
|
'allow_put': False,
|
||||||
'convert_to': converters.convert_to_boolean,
|
'convert_to': converters.convert_to_boolean,
|
||||||
'default': constants.ATTR_NOT_SPECIFIED,
|
'default': constants.ATTR_NOT_SPECIFIED,
|
||||||
'is_visible': True
|
'is_visible': True,
|
||||||
|
'is_filter': True
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,7 @@ ASSERT_FUNCTIONS = {
|
|||||||
'convert_list_to': assert_converter,
|
'convert_list_to': assert_converter,
|
||||||
'default': assert_converter,
|
'default': assert_converter,
|
||||||
'enforce_policy': assert_bool,
|
'enforce_policy': assert_bool,
|
||||||
|
'is_filter': 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,
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add a new keyword ``is_filter`` to attribute maps. This keyword indicates
|
||||||
|
that the attribute can be used for filtering result on list requests.
|
Loading…
Reference in New Issue
Block a user