in aws-frauddetector-entitytype/src/aws_frauddetector_entitytype/helpers/validation_helpers.py [0:0]
def check_variable_entries_are_valid(arguments_to_check: dict):
variable_entries_to_check = arguments_to_check.get("variableEntries", [])
required_attributes = {"dataSource", "dataType", "defaultValue", "name"}
all_attributes = {
"dataSource",
"dataType",
"defaultValue",
"description",
"name",
"variableType",
}
for variable_entry in variable_entries_to_check:
variable_attributes = set(variable_entry.keys())
if not required_attributes.issubset(variable_attributes):
missing_attributes = required_attributes.difference(variable_attributes)
missing_attributes_message = (
f"Variable Entries did not have the following required attributes: {missing_attributes}"
)
LOG.warning(missing_attributes_message)
raise exceptions.InvalidRequest(missing_attributes_message)
if not variable_attributes.issubset(all_attributes):
unrecognized_attributes = variable_attributes.difference(all_attributes)
unrecognized_attributes_message = (
f"Error: variable entries has unrecognized attributes: {unrecognized_attributes}"
)
LOG.warning(unrecognized_attributes_message)
raise exceptions.InvalidRequest(unrecognized_attributes_message)
return True