def get_awareness_user_data_in_sentinel(self):
        """Get Mimecast Awareness Training phishing campaigns user data and ingest to sentinel."""
        __method_name = inspect.currentframe().f_code.co_name
        try:
            campaigns_response = self.make_rest_call(
                method="POST", url=self.get_campaign_url
            )
            campaigns_data = campaigns_response["data"]
            if len(campaigns_data) > 0:
                applogger.info(
                    self.log_format.format(
                        consts.LOGS_STARTS_WITH,
                        __method_name,
                        self.azure_function_name,
                        "Awareness Training Phishing User Data : Found {} Phishing Campaigns ids".format(
                            len(campaigns_data)
                        ),
                    )
                )
                for campaign in campaigns_data:
                    if (
                        int(time.time())
                        >= self.function_start_time
                        + consts.FUNCTION_APP_TIMEOUT_SECONDS
                    ):
                        raise MimecastTimeoutException()
                    self.fetch_user_data_for_campaigns(campaign["id"])
            else:
                applogger.info(
                    self.log_format.format(
                        consts.LOGS_STARTS_WITH,
                        __method_name,
                        self.azure_function_name,
                        "No Phishing Campaigns found.",
                    )
                )
        except KeyError as key_error:
            applogger.error(
                self.log_format.format(
                    consts.LOGS_STARTS_WITH,
                    __method_name,
                    self.azure_function_name,
                    consts.KEY_ERROR_MSG.format(key_error),
                )
            )
            raise MimecastException()
        except MimecastTimeoutException:
            applogger.info(
                self.log_format.format(
                    consts.LOGS_STARTS_WITH,
                    __method_name,
                    self.azure_function_name,
                    "function app 9:30 mins executed hence breaking.",
                )
            )
            return
        except RetryError as error:
            applogger.error(
                self.log_format.format(
                    consts.LOGS_STARTS_WITH,
                    __method_name,
                    self.azure_function_name,
                    consts.MAX_RETRY_ERROR_MSG.format(
                        error, error.last_attempt.exception()
                    ),
                )
            )
            raise MimecastException()
        except MimecastException:
            raise MimecastException()
        except Exception as err:
            applogger.error(
                self.log_format.format(
                    consts.LOGS_STARTS_WITH,
                    __method_name,
                    self.azure_function_name,
                    consts.UNEXPECTED_ERROR_MSG.format(err),
                )
            )
            raise MimecastException()
Get Mimecast Awareness Training phishing campaigns user data and ingest to sentinel.
Solutions/Mimecast/Data Connectors/MimecastAT/UserData/mimecast_user_data_to_sentinel.py