-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathsample_dag.py
62 lines (51 loc) · 1.98 KB
/
sample_dag.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import pendulum
from airflow.decorators import dag, task
from ms_teams_powerautomate_webhook_operator import MSTeamsPowerAutomateWebhookOperator
@dag(
schedule=None,
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
catchup=False,
tags=["example"],
)
def sample_dag():
@task()
def get_formatted_date(**kwargs):
iso8601date = kwargs["execution_date"].strftime("%Y-%m-%dT%H:%M:%SZ")
# Teams date/time formatting: https://learn.microsoft.com/en-us/adaptive-cards/authoring-cards/text-features#datetime-example
formatted_date = (
f"{{{{DATE({iso8601date}, SHORT)}}}} at {{{{TIME({iso8601date})}}}}"
)
print(formatted_date)
return formatted_date
formatted_date = get_formatted_date()
op1 = MSTeamsPowerAutomateWebhookOperator(
task_id="send_to_teams",
http_conn_id="msteams_webhook_url",
heading_title="Airflow local",
header_bar_style="good",
heading_subtitle=formatted_date,
card_width_full=False,
body_message="""Dag **lorem_ipsum** has completed successfully in **localhost**""",
body_facts_dict={"Lorems": "184", "Dolor": "Sat", "Time taken": "2h 30m"},
button_text="View logs",
)
formatted_date >> op1
# op1 = MSTeamsPowerAutomateWebhookOperator(
# task_id="send_to_teams",
# http_conn_id="msteams_webhook_url",
# card_width_full=True,
# header_bar_show=True,
# header_bar_style="good",
# heading_title="Message from Airflow Local",
# heading_title_size="medium",
# heading_subtitle=formatted_date,
# heading_subtitle_subtle=True,
# heading_show_logo=True,
# body_message="**lorem_ipsum** has completed successfully in **localhost**",
# body_message_color_type="positive",
# button_text="View logs",
# button_url="http://localhost:8080",
# button_style="default",
# button_show=True,
# )
sample_dag()