apache-airflow-providers-telegram 4.4.0rc1__tar.gz → 4.4.0rc2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: apache-airflow-providers-telegram
3
- Version: 4.4.0rc1
3
+ Version: 4.4.0rc2
4
4
  Summary: Provider package apache-airflow-providers-telegram for Apache Airflow
5
5
  Keywords: airflow-provider,telegram,airflow,integration
6
6
  Author-email: Apache Software Foundation <dev@airflow.apache.org>
@@ -74,7 +74,7 @@ Project-URL: YouTube, https://www.youtube.com/channel/UCSXwxpWZQ7XZ1WL3wqevChA/
74
74
 
75
75
  Package ``apache-airflow-providers-telegram``
76
76
 
77
- Release: ``4.4.0.rc1``
77
+ Release: ``4.4.0.rc2``
78
78
 
79
79
 
80
80
  `Telegram <https://telegram.org/>`__
@@ -42,7 +42,7 @@
42
42
 
43
43
  Package ``apache-airflow-providers-telegram``
44
44
 
45
- Release: ``4.4.0.rc1``
45
+ Release: ``4.4.0.rc2``
46
46
 
47
47
 
48
48
  `Telegram <https://telegram.org/>`__
@@ -28,9 +28,10 @@ def get_provider_info():
28
28
  "name": "Telegram",
29
29
  "description": "`Telegram <https://telegram.org/>`__\n",
30
30
  "state": "ready",
31
- "source-date-epoch": 1705912297,
31
+ "source-date-epoch": 1709556330,
32
32
  "versions": [
33
33
  "4.4.0",
34
+ "4.3.1",
34
35
  "4.3.0",
35
36
  "4.2.0",
36
37
  "4.1.1",
@@ -64,6 +65,12 @@ def get_provider_info():
64
65
  "python-modules": ["airflow.providers.telegram.operators.telegram"],
65
66
  }
66
67
  ],
68
+ "connection-types": [
69
+ {
70
+ "hook-class-name": "airflow.providers.telegram.hooks.telegram.TelegramHook",
71
+ "connection-type": "telegram",
72
+ }
73
+ ],
67
74
  "hooks": [
68
75
  {"integration-name": "Telegram", "python-modules": ["airflow.providers.telegram.hooks.telegram"]}
69
76
  ],
@@ -19,6 +19,7 @@
19
19
  from __future__ import annotations
20
20
 
21
21
  import asyncio
22
+ from typing import Any
22
23
 
23
24
  import telegram
24
25
  import tenacity
@@ -38,14 +39,15 @@ class TelegramHook(BaseHook):
38
39
  chat_id can also be provided in the connection using 'host' field in connection.
39
40
  Following is the details of a telegram_connection:
40
41
  name: 'telegram-connection-name'
41
- conn_type: 'http'
42
- password: 'TELEGRAM_TOKEN'
42
+ conn_type: 'telegram'
43
+ password: 'TELEGRAM_TOKEN' (optional)
43
44
  host: 'chat_id' (optional)
44
45
  Examples:
45
46
  .. code-block:: python
46
47
 
47
48
  # Create hook
48
49
  telegram_hook = TelegramHook(telegram_conn_id="telegram_default")
50
+ telegram_hook = TelegramHook() # will use telegram_default
49
51
  # or telegram_hook = TelegramHook(telegram_conn_id='telegram_default', chat_id='-1xxx')
50
52
  # or telegram_hook = TelegramHook(token='xxx:xxx', chat_id='-1xxx')
51
53
 
@@ -58,21 +60,33 @@ class TelegramHook(BaseHook):
58
60
  :param chat_id: optional chat_id of the telegram chat/channel/group
59
61
  """
60
62
 
63
+ conn_name_attr = "telegram_conn_id"
64
+ default_conn_name = "telegram_default"
65
+ conn_type = "telegram"
66
+ hook_name = "Telegram"
67
+
61
68
  def __init__(
62
69
  self,
63
- telegram_conn_id: str | None = None,
70
+ telegram_conn_id: str | None = default_conn_name,
64
71
  token: str | None = None,
65
72
  chat_id: str | None = None,
66
- **kwargs,
67
73
  ) -> None:
68
- super().__init__(**kwargs)
74
+ super().__init__()
69
75
  self.token = self.__get_token(token, telegram_conn_id)
70
76
  self.chat_id = self.__get_chat_id(chat_id, telegram_conn_id)
71
77
  self.connection = self.get_conn()
72
78
 
79
+ @classmethod
80
+ def get_ui_field_behaviour(cls) -> dict[str, Any]:
81
+ """Return custom field behaviour."""
82
+ return {
83
+ "hidden_fields": ["schema", "extra", "login", "port", "extra"],
84
+ "relabeling": {},
85
+ }
86
+
73
87
  def get_conn(self) -> telegram.Bot:
74
88
  """
75
- Returns the telegram bot client.
89
+ Return the telegram bot client.
76
90
 
77
91
  :return: telegram bot client
78
92
  """
@@ -80,7 +94,7 @@ class TelegramHook(BaseHook):
80
94
 
81
95
  def __get_token(self, token: str | None, telegram_conn_id: str | None) -> str:
82
96
  """
83
- Returns the telegram API token.
97
+ Return the telegram API token.
84
98
 
85
99
  :param token: telegram API token
86
100
  :param telegram_conn_id: telegram connection name
@@ -101,7 +115,7 @@ class TelegramHook(BaseHook):
101
115
 
102
116
  def __get_chat_id(self, chat_id: str | None, telegram_conn_id: str | None) -> str | None:
103
117
  """
104
- Returns the telegram chat ID for a chat/channel/group.
118
+ Return the telegram chat ID for a chat/channel/group.
105
119
 
106
120
  :param chat_id: optional chat ID
107
121
  :param telegram_conn_id: telegram connection name
@@ -123,7 +137,7 @@ class TelegramHook(BaseHook):
123
137
  )
124
138
  def send_message(self, api_params: dict) -> None:
125
139
  """
126
- Sends the message to a telegram channel or chat.
140
+ Send the message to a telegram channel or chat.
127
141
 
128
142
  :param api_params: params for telegram_instance.send_message. It can also be used to override chat_id
129
143
  """
@@ -72,7 +72,7 @@ class TelegramOperator(BaseOperator):
72
72
  super().__init__(**kwargs)
73
73
 
74
74
  def execute(self, context: Context) -> None:
75
- """Calls the TelegramHook to post the provided Telegram message."""
75
+ """Call the TelegramHook to post the provided Telegram message."""
76
76
  if self.text:
77
77
  self.telegram_kwargs["text"] = self.text
78
78
 
@@ -28,7 +28,7 @@ build-backend = "flit_core.buildapi"
28
28
 
29
29
  [project]
30
30
  name = "apache-airflow-providers-telegram"
31
- version = "4.4.0.rc1"
31
+ version = "4.4.0.rc2"
32
32
  description = "Provider package apache-airflow-providers-telegram for Apache Airflow"
33
33
  readme = "README.rst"
34
34
  authors = [