{"body":"def _produce_message_via_rest(self, topic, message):\n        import requests, json\n        KAFKA_REST_URL = \"<URL>\"\n        KAFKA_X_AUTH_TOKEN = \"<TOKEN>\"\n        LOG.info(\" Inside produce_message_via_rest\")\n        LOG.info(\" Kafka REST url is \", KAFKA_REST_URL)\n        \n        proxies = {\n            'http': 'http://x.x.x.x:3128',\n            'https': 'http://x.x.x.x:3128',\n        }\n        # Metric payload to be sent to Kafka\n        message_payload = {\n            \"value\": {\n                \"type\": \"text\",\n                \"data\": json.dumps(message.decode('utf-8')),\n            }\n        }\n        # Sent message via POST call to Kafka REST API\n        response = requests.post(\n            KAFKA_REST_URL,\n            headers={\n                \"Content-Type\": \"application/json\",\n                \"Accept\": \"application/json\",\n                \"X-Auth-Token\": KAFKA_X_AUTH_TOKEN,\n            },\n            data=json.dumps(message_payload),\n            proxies=proxies,\n        )\n        \n        LOG.info(response.__dict__)\n        # Check the response status code\n        if response.status_code == 200:\n            LOG.info(' | Message published successfully')\n        else:\n            LOG.info(' | Failed to publish message. Status code:', response.status_code)\n\n","name":"","extension":"txt","url":"https://www.irccloud.com/pastebin/dMijsA9v","modified":1684171625,"id":"dMijsA9v","size":1280,"lines":37,"own_paste":false,"theme":"","date":1684171625}