in frauddetector/frauddetector.py [0:0]
def create_model(self):
"""Create Amazon FraudDetector model. Wraps the boto3 SDK API to allow bulk operations.
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/frauddetector.html#FraudDetector.Client.create_model
Args:
None
Returns:
:response_all: {variable_name: API-response-status, variable_name: API-response-status} dict
"""
existing_names = [m['modelId'] for m in self.models['models']]
response_all = []
if self.model_name not in existing_names:
lh.debug("create_model: {}".format(self.model_name))
# create event via Boto3 SDK fd instance
response = self.fd.create_model(
eventTypeName=self.event_type,
modelId=self.model_name,
modelType=self.model_type
)
lh.info("create_model: entity {} created".format(self.model_name))
status = {self.model_name: response['ResponseMetadata']['HTTPStatusCode']}
response_all.append(status)
else:
lh.warning("create_model: entity {} already exists, skipping".format(self.model_name))
status = {self.model_name: "skipped"}
response_all.append(status)
# update myself
self.models = self.fd.get_models()
# convert list of dicts to single dict
response_all = {k: v for d in response_all for k, v in d.items()}
return response_all