update audit API description

Change-Id: I1d3eb9364fb5597788a282d275c71f5a314a0923
This commit is contained in:
licanwei
2018-01-02 22:08:20 -08:00
parent 97799521f9
commit 9411f85cd2
2 changed files with 11 additions and 11 deletions

View File

@@ -166,10 +166,10 @@ class AuditPatchType(types.JsonPatchType):
class Audit(base.APIBase): class Audit(base.APIBase):
"""API representation of a audit. """API representation of an audit.
This class enforces type checking and value constraints, and converts This class enforces type checking and value constraints, and converts
between the internal object model and the API representation of a audit. between the internal object model and the API representation of an audit.
""" """
_goal_uuid = None _goal_uuid = None
_goal_name = None _goal_name = None
@@ -264,19 +264,19 @@ class Audit(base.APIBase):
goal_uuid = wsme.wsproperty( goal_uuid = wsme.wsproperty(
wtypes.text, _get_goal_uuid, _set_goal_uuid, mandatory=True) wtypes.text, _get_goal_uuid, _set_goal_uuid, mandatory=True)
"""Goal UUID the audit template refers to""" """Goal UUID the audit refers to"""
goal_name = wsme.wsproperty( goal_name = wsme.wsproperty(
wtypes.text, _get_goal_name, _set_goal_name, mandatory=False) wtypes.text, _get_goal_name, _set_goal_name, mandatory=False)
"""The name of the goal this audit template refers to""" """The name of the goal this audit refers to"""
strategy_uuid = wsme.wsproperty( strategy_uuid = wsme.wsproperty(
wtypes.text, _get_strategy_uuid, _set_strategy_uuid, mandatory=False) wtypes.text, _get_strategy_uuid, _set_strategy_uuid, mandatory=False)
"""Strategy UUID the audit template refers to""" """Strategy UUID the audit refers to"""
strategy_name = wsme.wsproperty( strategy_name = wsme.wsproperty(
wtypes.text, _get_strategy_name, _set_strategy_name, mandatory=False) wtypes.text, _get_strategy_name, _set_strategy_name, mandatory=False)
"""The name of the strategy this audit template refers to""" """The name of the strategy this audit refers to"""
parameters = {wtypes.text: types.jsontype} parameters = {wtypes.text: types.jsontype}
"""The strategy parameters for this audit""" """The strategy parameters for this audit"""
@@ -526,7 +526,7 @@ class AuditsController(rest.RestController):
def post(self, audit_p): def post(self, audit_p):
"""Create a new audit. """Create a new audit.
:param audit_p: a audit within the request body. :param audit_p: an audit within the request body.
""" """
context = pecan.request.context context = pecan.request.context
policy.enforce(context, 'audit:create', policy.enforce(context, 'audit:create',
@@ -556,7 +556,7 @@ class AuditsController(rest.RestController):
if no_schema and audit.parameters: if no_schema and audit.parameters:
raise exception.Invalid(_('Specify parameters but no predefined ' raise exception.Invalid(_('Specify parameters but no predefined '
'strategy for audit template, or no ' 'strategy for audit, or no '
'parameter spec in predefined strategy')) 'parameter spec in predefined strategy'))
audit_dict = audit.as_dict() audit_dict = audit.as_dict()
@@ -579,7 +579,7 @@ class AuditsController(rest.RestController):
def patch(self, audit, patch): def patch(self, audit, patch):
"""Update an existing audit. """Update an existing audit.
:param audit: UUID or name of a audit. :param audit: UUID or name of an audit.
:param patch: a json PATCH document to apply to this audit. :param patch: a json PATCH document to apply to this audit.
""" """
if self.from_audits: if self.from_audits:

View File

@@ -721,7 +721,7 @@ class TestPost(api_base.FunctionalTest):
self.assertEqual('application/json', response.content_type) self.assertEqual('application/json', response.content_type)
self.assertEqual(400, response.status_int) self.assertEqual(400, response.status_int)
expected_error_msg = ('Specify parameters but no predefined ' expected_error_msg = ('Specify parameters but no predefined '
'strategy for audit template, or no ' 'strategy for audit, or no '
'parameter spec in predefined strategy') 'parameter spec in predefined strategy')
self.assertTrue(response.json['error_message']) self.assertTrue(response.json['error_message'])
self.assertIn(expected_error_msg, response.json['error_message']) self.assertIn(expected_error_msg, response.json['error_message'])
@@ -743,7 +743,7 @@ class TestPost(api_base.FunctionalTest):
self.assertEqual('application/json', response.content_type) self.assertEqual('application/json', response.content_type)
self.assertEqual(400, response.status_int) self.assertEqual(400, response.status_int)
expected_error_msg = ('Specify parameters but no predefined ' expected_error_msg = ('Specify parameters but no predefined '
'strategy for audit template, or no ' 'strategy for audit, or no '
'parameter spec in predefined strategy') 'parameter spec in predefined strategy')
self.assertTrue(response.json['error_message']) self.assertTrue(response.json['error_message'])
self.assertIn(expected_error_msg, response.json['error_message']) self.assertIn(expected_error_msg, response.json['error_message'])