turbaszek commented on pull request #8652:
URL: https://github.com/apache/airflow/pull/8652#issuecomment-630815908
Hm, I think not. I think it should be:
```python
with DAG(
'send_server_ip', default_args=default_args, schedule_interval=None
) as dag:
# Using default connection as it's set to httpbin.org by default
get_ip = SimpleHttpOperator(
task_id='get_ip', endpoint='get', method='GET', xcom_push=True
)
@dag.task(add_context=True)
def email_subject_generator(context: dict, raw_json: str) -> str:
external_ip = json.loads(raw_json)['origin']
return f"Server connected from {external_ip}"
@task
def email_body_generator(raw_json: str) -> str:
return """
Seems like today your server executing Airflow is connected from the
external IP {origin}<br>
<br>
Have a nice day!
""".format(**json.loads(raw_json))
ip_info = get_ip()
subject = email_subject_generator(ip_info)
body = email_body_generator(ip_info)
send_email = EmailOperator(
task_id='send_email',
to="[email protected]",
subject=subject,
html_content=body
)
```
CC: @casassg
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]