def handle_response(response, body, log_type):
    """Handle the response from Azure Sentinel."""
    try:
        __method_name = inspect.currentframe().f_code.co_name
        if response.status >= 200 and response.status <= 299:
            applogger.debug(
                "{}(method={}) : Status_code: {} Accepted: Data Posted Successfully to azure sentinel.".format(
                    consts.LOGS_STARTS_WITH,
                    __method_name,
                    response.status,
                )
            )
            return response.status
        elif response.status == 400:
            applogger.error(
                "{}(method={}) : {} : Response code: {} from posting data to log analytics. Response: {}".format(
                    consts.LOGS_STARTS_WITH,
                    __method_name,
                    consts.CLOUD_INTEGRATED_FUNCTION_NAME,
                    response.status,
                    response.text,
                )
            )
            curent_corrupt_data_obj = StateManager(
                consts.CONN_STRING,
                "{}-Ingest-To-Sentinel-Corrupt_{}".format(consts.CLOUD_INTEGRATED_FUNCTION_NAME, str(int(time.time()))),
                consts.FILE_SHARE_NAME,
            )
            curent_corrupt_data_obj.post(body)
            raise MimecastException()
        elif response.status == 403:
            applogger.error(
                "{}(method={}) : {} : Response code :{} Error occurred for build signature: Response: {}."
                "Issue with WorkspaceKey ,Kindly verify your WorkspaceKey".format(
                    consts.LOGS_STARTS_WITH,
                    __method_name,
                    consts.CLOUD_INTEGRATED_FUNCTION_NAME,
                    response.status,
                    response.text,
                )
            )
            raise MimecastException()
        elif response.status == 429:
            applogger.error(
                "{}(method={}) : {} : Error occurred: Response code : {} Too many request: Response: {} . "
                "sleeping for {} seconds and retrying..".format(
                    consts.LOGS_STARTS_WITH,
                    __method_name,
                    consts.CLOUD_INTEGRATED_FUNCTION_NAME,
                    response.status,
                    response.text,
                    consts.INGESTION_ERROR_SLEEP_TIME,
                )
            )
            time.sleep(consts.INGESTION_ERROR_SLEEP_TIME)
            return False
        elif response.status == 500:
            applogger.error(
                "{}(method={}) : {} : Error occurred:  Response code : {} Internal Server Error: Response: {} . "
                "sleeping for {} seconds and retrying..".format(
                    consts.LOGS_STARTS_WITH,
                    __method_name,
                    consts.CLOUD_INTEGRATED_FUNCTION_NAME,
                    response.status,
                    response.text,
                    consts.INGESTION_ERROR_SLEEP_TIME,
                )
            )
            time.sleep(consts.INGESTION_ERROR_SLEEP_TIME)
            return False
        elif response.status == 503:
            applogger.error(
                "{}(method={}) : {} : Error occurred: Response code : {} Service Unavailable: Response: {} . "
                "sleeping for {} seconds and retrying..".format(
                    consts.LOGS_STARTS_WITH,
                    __method_name,
                    consts.CLOUD_INTEGRATED_FUNCTION_NAME,
                    response.status,
                    response.text,
                    consts.INGESTION_ERROR_SLEEP_TIME,
                )
            )
            time.sleep(consts.INGESTION_ERROR_SLEEP_TIME)
            return False
        applogger.error(
            "{}(method={}) : {} : Response code: {} from posting data to log analytics. Response: {}".format(
                consts.LOGS_STARTS_WITH,
                __method_name,
                consts.CLOUD_INTEGRATED_FUNCTION_NAME,
                response.status,
                response.text,
            )
        )
        raise MimecastException()
    except MimecastException:
        raise MimecastException()
    except Exception as error:
        applogger.error(
            "{}(method={}) : {} : Unknown Error: {}.".format(
                consts.LOGS_STARTS_WITH,
                __method_name,
                consts.CLOUD_INTEGRATED_FUNCTION_NAME,
                error,
            )
        )
        raise MimecastException()
Handle the response from Azure Sentinel.
Solutions/Mimecast/Data Connectors/MimecastCloudIntegrated/SharedCode/sentinel.py