Add parameters verification when Audit is being created

We have to check Audit Type and Audit State to make sure
these parameters are in valid status.

Also, we provide default states for the next attributes:

- 'audit_template' is required and should be either UUID or text field
- 'state' is readonly so it raises an error if submitted in POST
  and is set by default to PENDING
- 'deadline' is optional and should be a datetime
- 'type' is a required text field

Change-Id: I2a7e0deec0ee2040e86400b500bb0efd8eade564
Closes-Bug: #1532843
Closes-Bug: #1533210
This commit is contained in:
Alexander Chadin
2016-04-06 17:42:06 +03:00
parent 0f14b7635d
commit e52dc4f8aa
9 changed files with 67 additions and 40 deletions

View File

@@ -138,6 +138,8 @@ class InfraOptimClientJSON(base.BaseInfraOptimClient):
"""
audit = {'audit_template_uuid': audit_template_uuid}
audit.update(kwargs)
if not audit['state']:
del audit['state']
return self._create_request('audits', audit)