if policyId != i and \
data == policy_instances[i] and \
policyTypeId == policy_type_per_instance[i]:
- return(set_error(None, "The policy already exists with a different id.", 404, "No action has been taken. The id of the existing policy instance is: " + i + ".", None, None, None, None))
+ return(set_error(None, "The policy already exists with a different id.", 400, "No action has been taken. The id of the existing policy instance is: " + i + ".", None, None, None, None))
if policyId in list(policy_instances.keys()):
if data["scope"] != policy_instances[policyId]["scope"]:
- return(set_error(None, "The policy already exists with a different scope.", 404, "The policy put involves a modification of the existing scope, which is not allowed.", None, None, "scope", None))
+ return(set_error(None, "The policy already exists with a different scope.", 400, "The policy put involves a modification of the existing scope, which is not allowed.", None, None, "scope", None))
if 'code' in request.args:
return(send_error_code(request.args))
+ if policyId in policy_instances.keys():
+ code = 201
+ else:
+ code = 200
+
policy_instances[policyId] = data
policy_status[policyId] = set_status("UNDEFINED")
if 'policyTypeId' in request.args:
else:
policy_type_per_instance[policyId] = "UNDEFINED"
- if policyId in policy_instances.keys():
- code = 201
- else:
- code = 200
-
response = make_response(policy_instances[policyId], code)
if code == 201:
response.headers['Location'] = "http://localhost:8085/A1-P/v1/policies/" + policyId