def get_awareness_watchlist_details_data_in_sentinel(self):
        """Get Mimecast awareness training watchlist details data and ingest to sentinel."""
        __method_name = inspect.currentframe().f_code.co_name
        try:
            request_body, checkpoint_data = self.get_request_body_and_checkpoint()
            next_page = True
            while next_page:
                if (
                    int(time.time())
                    >= self.function_start_time + consts.FUNCTION_APP_TIMEOUT_SECONDS
                ):
                    raise MimecastTimeoutException()
                watchlist_details_response = self.make_rest_call(
                    method="POST", url=self.watchlist_details_url, json=request_body
                )
                watchlist_details_data = watchlist_details_response["data"]
                if len(watchlist_details_data) > 0:
                    next_page_token = watchlist_details_response["meta"][
                        "pagination"
                    ].get("next", "")
                    next_page_token_flag = False
                    if next_page_token:
                        next_page_token_flag = True
                    checkpoint_token_updated = self.filter_unique_data_and_post(
                        watchlist_details_data,
                        self.hash_file_state_manager_obj,
                        consts.TABLE_NAME["WATCHLIST_DETAILS"],
                        checkpoint_data,
                        self.state_manager_obj,
                        next_page_token_flag,
                    )
                    if next_page_token:
                        request_body["meta"]["pagination"][
                            "pageToken"
                        ] = next_page_token
                        applogger.info(
                            self.log_format.format(
                                consts.LOGS_STARTS_WITH,
                                __method_name,
                                self.azure_function_name,
                                "Posting page checkpoint : {}.".format(next_page_token),
                            )
                        )
                        checkpoint_data = {
                            "pageToken": next_page_token,
                            "date": datetime.datetime.utcnow().isoformat(),
                        }
                        self.post_checkpoint_data(
                            self.state_manager_obj, checkpoint_data
                        )
                    else:
                        if checkpoint_token_updated:
                            del request_body["meta"]["pagination"]["pageToken"]
                            checkpoint_data = {}
                        else:
                            next_page = False
                            hash_data_to_save = self.convert_to_hash(
                                watchlist_details_data
                            )
                            applogger.info(
                                self.log_format.format(
                                    consts.LOGS_STARTS_WITH,
                                    __method_name,
                                    self.azure_function_name,
                                    "Posting hash checkpoint.",
                                )
                            )
                            self.post_checkpoint_data(
                                self.hash_file_state_manager_obj,
                                hash_data_to_save,
                                True,
                            )
                            applogger.info(
                                self.log_format.format(
                                    consts.LOGS_STARTS_WITH,
                                    __method_name,
                                    self.azure_function_name,
                                    "End of data.",
                                )
                            )
                else:
                    next_page = False
                    applogger.info(
                        self.log_format.format(
                            consts.LOGS_STARTS_WITH,
                            __method_name,
                            self.azure_function_name,
                            "No data 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 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 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 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 watchlist details data and ingest to sentinel.
Solutions/Mimecast/Data Connectors/MimecastAT/WatchlistDetails/mimecast_watchlist_details_to_sentinel.py