- return("A status provided together with an enforcement reason should be \"NOT_ENFORCED\"", 400)
- else:
- return("The policy id does not correspond to any existing policy instance", 404)
-
+ policy_type_id = policy_type_per_instance[policyId]
+ status_schema = policy_types[policy_type_id]["statusSchema"]
+ ps = {}
+ ps["policyId"] = policyId
+ ps["enforceStatus"] = enforceStatus
+ ps["enforceReason"] = enforceReason
+ try:
+ validate(instance=ps, schema=status_schema)
+ except:
+ return(set_error(None, "The json does not validate against the status schema.", 400, None, None, None, None, None))
+ policy_status.pop(policyId)
+ policy_status[policyId] = ps
+ return("Status updated for policy: " + policyId, 200)