def create_entity_type()

in frauddetector/frauddetector.py [0:0]


    def create_entity_type(self):
        """Create Amazon FraudDetector entity. Wraps the boto3 SDK API to allow bulk operations.
        https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/frauddetector.html#FraudDetector.Client.put_entity_type

        Args:
            None
            
        Returns:
            :response_all:      {variable_name: API-response-status, variable_name: API-response-status} dict
        """

        existing_names = [e['name'] for e in self.entities['entityTypes']]
        response_all = []

        if self.entity_type not in existing_names:

            lh.debug("create_entity_type: {}".format(self.entity_type))
            # create event via Boto3 SDK fd instance
            response = self.fd.put_entity_type(
                name = self.entity_type
            )
            lh.info("create_entity_type: entity {} created".format(self.entity_type))
            status = {self.entity_type: response['ResponseMetadata']['HTTPStatusCode']}
            response_all.append(status)
        else:
            lh.warning("create_entity_type: entity {} already exists, skipping".format(self.entity_type))
            status = {self.event_type: "skipped"}
            response_all.append(status)

        # update myself
        self.entities = self.fd.get_entity_types()

        # 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