support get attribute list filter by deployable_id and key
Now attribute get list api doesnot support filter by deployable_id and key, which is not reasonable. Closes-Bug: 2001586 Change-Id: I3c770f7bc83ff33d6351500ab681cea965c8bd08
This commit is contained in:
parent
8934856fc7
commit
08f63a8426
@ -109,15 +109,19 @@ class AttributesController(base.CyborgController,
|
||||
"""REST controller for Attributes."""
|
||||
|
||||
@authorize_wsgi.authorize_wsgi("cyborg:attribute", "get_all", False)
|
||||
@expose.expose(AttributeCollection, wtypes.text)
|
||||
def get_all(self):
|
||||
@expose.expose(AttributeCollection, wtypes.IntegerType(), wtypes.text)
|
||||
def get_all(self, deployable_id=None, key=None):
|
||||
"""Retrieve a list of attributes."""
|
||||
|
||||
LOG.info('[attributes] get_all.')
|
||||
LOG.info('[attributes] get_all by deployable_id:(%s) and key:(%s).',
|
||||
deployable_id, key)
|
||||
search_opts = {}
|
||||
if deployable_id:
|
||||
search_opts['deployable_id'] = deployable_id
|
||||
if key:
|
||||
search_opts['key'] = key
|
||||
context = pecan.request.context
|
||||
api_obj_attributes = objects.Attribute.get_by_filter(context, {})
|
||||
|
||||
ret = AttributeCollection.convert_with_links(api_obj_attributes)
|
||||
attributes = objects.Attribute.get_by_filter(context, search_opts)
|
||||
ret = AttributeCollection.convert_with_links(attributes)
|
||||
LOG.info('[Attributes] get_all returned: %s', ret)
|
||||
return ret
|
||||
|
||||
@ -132,21 +136,6 @@ class AttributesController(base.CyborgController,
|
||||
LOG.info('[attributes] get_one returned: %s', ret)
|
||||
return ret
|
||||
|
||||
@authorize_wsgi.authorize_wsgi("cyborg:attribute",
|
||||
"get_attribute_by_deployable_id", False)
|
||||
@expose.expose('json', wtypes.IntegerType())
|
||||
def get_attribute_by_deployable_id(self, deployable_id):
|
||||
"""Retrieve a single attribute by deployable_id."""
|
||||
LOG.info('[attributes] get_attribute_by_deployable_id: %s.',
|
||||
deployable_id)
|
||||
context = pecan.request.context
|
||||
api_obj_attributes = objects.Attribute.get_by_deployable_id(
|
||||
context, deployable_id)
|
||||
ret = AttributeCollection.convert_with_links(api_obj_attributes)
|
||||
LOG.info('[attributes] get_attribute_by_deployable_id returned:'
|
||||
' %s', ret)
|
||||
return ret
|
||||
|
||||
@authorize_wsgi.authorize_wsgi("cyborg:attribute", "delete")
|
||||
@expose.expose(None, wtypes.text, status_code=HTTPStatus.NO_CONTENT)
|
||||
def delete(self, uuid):
|
||||
|
@ -69,9 +69,6 @@ attribute_policies = [
|
||||
policy.RuleDefault('cyborg:attribute:get_all',
|
||||
'rule:allow',
|
||||
description='Retrieve all attribute records'),
|
||||
policy.RuleDefault('cyborg:attribute:get_attribute_by_deployable_id',
|
||||
'rule:allow',
|
||||
description='Get attributes by deployable_id.'),
|
||||
policy.RuleDefault('cyborg:attribute:delete',
|
||||
'rule:allow',
|
||||
description='Delete attribute records.'),
|
||||
|
Loading…
Reference in New Issue
Block a user