def parser_threat_intel_feed_success_response(response, file_type, compress, mimecast_endpoint):
        """Parsing Threat Intel Feed responses depending on compress and file format parameters."""

        if response.headers.get("Content-Type") == "application/octet-stream":
            response = response.content
            if compress:
                try:
                    parsed_events = ThreatIntelFeedResponseHelper.parse_compressed_data(response, file_type)
                except Exception as exception:
                    exception.extra_message = "Parsing of Threat Intel Feed compressed data failed."
                    raise ParsingError("Parsing of Threat Intel Feed compressed data failed.")
            else:
                try:
                    parsed_events = ThreatIntelFeedResponseHelper.parse_uncompressed_data(response, file_type)
                except Exception as exception:
                    exception.extra_message = "Parsing of Threat Intel Feed uncompressed data failed."
                    raise ParsingError("Parsing of Threat Intel Feed uncompressed data failed.")
            return parsed_events
        else:
            try:
                response_text = json.loads(response.text)
            except json.JSONDecodeError:
                logging.error(mimecast_endpoint + ": Invalid content provided. Probably no more logs left.")
                return []
            else:
                if response_text["fail"]:
                    no_threat_intel_feed = ["No results found for threat intel feed.", "Unable to compress feeds."]
                    if any(x in response_text["fail"][0]["errors"][0]["message"] for x in no_threat_intel_feed):
                        return []
                    else:
                        logging.error(mimecast_endpoint + ": " + response_text["fail"][0]["errors"][0]["message"])
                        raise InvalidDataError(f'Unknown error: {response_text["fail"][0]["errors"][0]["message"]}')
Parsing Threat Intel Feed responses depending on compress and file format parameters.
Solutions/MimecastTIRegional/Data Connectors/Helpers/threat_intel_feed_response_helper.py