Support create attribute api
Change-Id: If55c722166bbaa3f0203ce5c0c9002ceb3bde859
This commit is contained in:
parent
08f63a8426
commit
58e46e9e44
@ -136,6 +136,25 @@ class AttributesController(base.CyborgController,
|
|||||||
LOG.info('[attributes] get_one returned: %s', ret)
|
LOG.info('[attributes] get_one returned: %s', ret)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@authorize_wsgi.authorize_wsgi("cyborg:attribute", "create", False)
|
||||||
|
@expose.expose(Attribute, body=types.jsontype,
|
||||||
|
status_code=HTTPStatus.CREATED)
|
||||||
|
def post(self, req_attr):
|
||||||
|
"""Create one attribute.
|
||||||
|
:param req_attr: attribute value.
|
||||||
|
{ "deployable_id": <integer>,
|
||||||
|
"key": <string>,
|
||||||
|
"value": <string>
|
||||||
|
}
|
||||||
|
:returns: The object of created attribute
|
||||||
|
"""
|
||||||
|
LOG.info("[attributes] POST request = (%s)", req_attr)
|
||||||
|
context = pecan.request.context
|
||||||
|
attribute = objects.Attribute(context, **req_attr).create(context)
|
||||||
|
ret = Attribute.convert_with_links(attribute)
|
||||||
|
LOG.info('[attributes] post returned: %s', ret)
|
||||||
|
return ret
|
||||||
|
|
||||||
@authorize_wsgi.authorize_wsgi("cyborg:attribute", "delete")
|
@authorize_wsgi.authorize_wsgi("cyborg:attribute", "delete")
|
||||||
@expose.expose(None, wtypes.text, status_code=HTTPStatus.NO_CONTENT)
|
@expose.expose(None, wtypes.text, status_code=HTTPStatus.NO_CONTENT)
|
||||||
def delete(self, uuid):
|
def delete(self, uuid):
|
||||||
|
@ -69,6 +69,9 @@ attribute_policies = [
|
|||||||
policy.RuleDefault('cyborg:attribute:get_all',
|
policy.RuleDefault('cyborg:attribute:get_all',
|
||||||
'rule:allow',
|
'rule:allow',
|
||||||
description='Retrieve all attribute records'),
|
description='Retrieve all attribute records'),
|
||||||
|
policy.RuleDefault('cyborg:attribute:create',
|
||||||
|
'rule:allow',
|
||||||
|
description='Create an attribute record'),
|
||||||
policy.RuleDefault('cyborg:attribute:delete',
|
policy.RuleDefault('cyborg:attribute:delete',
|
||||||
'rule:allow',
|
'rule:allow',
|
||||||
description='Delete attribute records.'),
|
description='Delete attribute records.'),
|
||||||
|
@ -48,7 +48,7 @@ class Attribute(base.CyborgObject, object_base.VersionedObjectDictCompat):
|
|||||||
values = self.obj_get_changes()
|
values = self.obj_get_changes()
|
||||||
db_attr = self.dbapi.attribute_create(context,
|
db_attr = self.dbapi.attribute_create(context,
|
||||||
values)
|
values)
|
||||||
self._from_db_object(self, db_attr)
|
return self._from_db_object(self, db_attr)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get(cls, context, uuid):
|
def get(cls, context, uuid):
|
||||||
|
Loading…
Reference in New Issue
Block a user