apache-airflow-providers-telegram 4.4.0rc1__py3-none-any.whl → 4.5.0__py3-none-any.whl
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.
- airflow/providers/telegram/__init__.py +3 -3
- airflow/providers/telegram/get_provider_info.py +10 -2
- airflow/providers/telegram/hooks/telegram.py +24 -9
- airflow/providers/telegram/operators/telegram.py +2 -1
- {apache_airflow_providers_telegram-4.4.0rc1.dist-info → apache_airflow_providers_telegram-4.5.0.dist-info}/METADATA +10 -9
- apache_airflow_providers_telegram-4.5.0.dist-info/RECORD +11 -0
- apache_airflow_providers_telegram-4.4.0rc1.dist-info/RECORD +0 -11
- {apache_airflow_providers_telegram-4.4.0rc1.dist-info → apache_airflow_providers_telegram-4.5.0.dist-info}/WHEEL +0 -0
- {apache_airflow_providers_telegram-4.4.0rc1.dist-info → apache_airflow_providers_telegram-4.5.0.dist-info}/entry_points.txt +0 -0
@@ -27,7 +27,7 @@ import packaging.version
|
|
27
27
|
|
28
28
|
__all__ = ["__version__"]
|
29
29
|
|
30
|
-
__version__ = "4.
|
30
|
+
__version__ = "4.5.0"
|
31
31
|
|
32
32
|
try:
|
33
33
|
from airflow import __version__ as airflow_version
|
@@ -35,8 +35,8 @@ except ImportError:
|
|
35
35
|
from airflow.version import version as airflow_version
|
36
36
|
|
37
37
|
if packaging.version.parse(packaging.version.parse(airflow_version).base_version) < packaging.version.parse(
|
38
|
-
"2.
|
38
|
+
"2.7.0"
|
39
39
|
):
|
40
40
|
raise RuntimeError(
|
41
|
-
f"The package `apache-airflow-providers-telegram:{__version__}` needs Apache Airflow 2.
|
41
|
+
f"The package `apache-airflow-providers-telegram:{__version__}` needs Apache Airflow 2.7.0+"
|
42
42
|
)
|
@@ -28,9 +28,11 @@ def get_provider_info():
|
|
28
28
|
"name": "Telegram",
|
29
29
|
"description": "`Telegram <https://telegram.org/>`__\n",
|
30
30
|
"state": "ready",
|
31
|
-
"source-date-epoch":
|
31
|
+
"source-date-epoch": 1714477687,
|
32
32
|
"versions": [
|
33
|
+
"4.5.0",
|
33
34
|
"4.4.0",
|
35
|
+
"4.3.1",
|
34
36
|
"4.3.0",
|
35
37
|
"4.2.0",
|
36
38
|
"4.1.1",
|
@@ -48,7 +50,7 @@ def get_provider_info():
|
|
48
50
|
"1.0.1",
|
49
51
|
"1.0.0",
|
50
52
|
],
|
51
|
-
"dependencies": ["apache-airflow>=2.
|
53
|
+
"dependencies": ["apache-airflow>=2.7.0", "python-telegram-bot>=20.2"],
|
52
54
|
"integrations": [
|
53
55
|
{
|
54
56
|
"integration-name": "Telegram",
|
@@ -64,6 +66,12 @@ def get_provider_info():
|
|
64
66
|
"python-modules": ["airflow.providers.telegram.operators.telegram"],
|
65
67
|
}
|
66
68
|
],
|
69
|
+
"connection-types": [
|
70
|
+
{
|
71
|
+
"hook-class-name": "airflow.providers.telegram.hooks.telegram.TelegramHook",
|
72
|
+
"connection-type": "telegram",
|
73
|
+
}
|
74
|
+
],
|
67
75
|
"hooks": [
|
68
76
|
{"integration-name": "Telegram", "python-modules": ["airflow.providers.telegram.hooks.telegram"]}
|
69
77
|
],
|
@@ -16,9 +16,11 @@
|
|
16
16
|
# specific language governing permissions and limitations
|
17
17
|
# under the License.
|
18
18
|
"""Hook for Telegram."""
|
19
|
+
|
19
20
|
from __future__ import annotations
|
20
21
|
|
21
22
|
import asyncio
|
23
|
+
from typing import Any
|
22
24
|
|
23
25
|
import telegram
|
24
26
|
import tenacity
|
@@ -38,14 +40,15 @@ class TelegramHook(BaseHook):
|
|
38
40
|
chat_id can also be provided in the connection using 'host' field in connection.
|
39
41
|
Following is the details of a telegram_connection:
|
40
42
|
name: 'telegram-connection-name'
|
41
|
-
conn_type: '
|
42
|
-
password: 'TELEGRAM_TOKEN'
|
43
|
+
conn_type: 'telegram'
|
44
|
+
password: 'TELEGRAM_TOKEN' (optional)
|
43
45
|
host: 'chat_id' (optional)
|
44
46
|
Examples:
|
45
47
|
.. code-block:: python
|
46
48
|
|
47
49
|
# Create hook
|
48
50
|
telegram_hook = TelegramHook(telegram_conn_id="telegram_default")
|
51
|
+
telegram_hook = TelegramHook() # will use telegram_default
|
49
52
|
# or telegram_hook = TelegramHook(telegram_conn_id='telegram_default', chat_id='-1xxx')
|
50
53
|
# or telegram_hook = TelegramHook(token='xxx:xxx', chat_id='-1xxx')
|
51
54
|
|
@@ -58,21 +61,33 @@ class TelegramHook(BaseHook):
|
|
58
61
|
:param chat_id: optional chat_id of the telegram chat/channel/group
|
59
62
|
"""
|
60
63
|
|
64
|
+
conn_name_attr = "telegram_conn_id"
|
65
|
+
default_conn_name = "telegram_default"
|
66
|
+
conn_type = "telegram"
|
67
|
+
hook_name = "Telegram"
|
68
|
+
|
61
69
|
def __init__(
|
62
70
|
self,
|
63
|
-
telegram_conn_id: str | None =
|
71
|
+
telegram_conn_id: str | None = default_conn_name,
|
64
72
|
token: str | None = None,
|
65
73
|
chat_id: str | None = None,
|
66
|
-
**kwargs,
|
67
74
|
) -> None:
|
68
|
-
super().__init__(
|
75
|
+
super().__init__()
|
69
76
|
self.token = self.__get_token(token, telegram_conn_id)
|
70
77
|
self.chat_id = self.__get_chat_id(chat_id, telegram_conn_id)
|
71
78
|
self.connection = self.get_conn()
|
72
79
|
|
80
|
+
@classmethod
|
81
|
+
def get_ui_field_behaviour(cls) -> dict[str, Any]:
|
82
|
+
"""Return custom field behaviour."""
|
83
|
+
return {
|
84
|
+
"hidden_fields": ["schema", "extra", "login", "port", "extra"],
|
85
|
+
"relabeling": {},
|
86
|
+
}
|
87
|
+
|
73
88
|
def get_conn(self) -> telegram.Bot:
|
74
89
|
"""
|
75
|
-
|
90
|
+
Return the telegram bot client.
|
76
91
|
|
77
92
|
:return: telegram bot client
|
78
93
|
"""
|
@@ -80,7 +95,7 @@ class TelegramHook(BaseHook):
|
|
80
95
|
|
81
96
|
def __get_token(self, token: str | None, telegram_conn_id: str | None) -> str:
|
82
97
|
"""
|
83
|
-
|
98
|
+
Return the telegram API token.
|
84
99
|
|
85
100
|
:param token: telegram API token
|
86
101
|
:param telegram_conn_id: telegram connection name
|
@@ -101,7 +116,7 @@ class TelegramHook(BaseHook):
|
|
101
116
|
|
102
117
|
def __get_chat_id(self, chat_id: str | None, telegram_conn_id: str | None) -> str | None:
|
103
118
|
"""
|
104
|
-
|
119
|
+
Return the telegram chat ID for a chat/channel/group.
|
105
120
|
|
106
121
|
:param chat_id: optional chat ID
|
107
122
|
:param telegram_conn_id: telegram connection name
|
@@ -123,7 +138,7 @@ class TelegramHook(BaseHook):
|
|
123
138
|
)
|
124
139
|
def send_message(self, api_params: dict) -> None:
|
125
140
|
"""
|
126
|
-
|
141
|
+
Send the message to a telegram channel or chat.
|
127
142
|
|
128
143
|
:param api_params: params for telegram_instance.send_message. It can also be used to override chat_id
|
129
144
|
"""
|
@@ -16,6 +16,7 @@
|
|
16
16
|
# specific language governing permissions and limitations
|
17
17
|
# under the License.
|
18
18
|
"""Operator for Telegram."""
|
19
|
+
|
19
20
|
from __future__ import annotations
|
20
21
|
|
21
22
|
from typing import TYPE_CHECKING, Sequence
|
@@ -72,7 +73,7 @@ class TelegramOperator(BaseOperator):
|
|
72
73
|
super().__init__(**kwargs)
|
73
74
|
|
74
75
|
def execute(self, context: Context) -> None:
|
75
|
-
"""
|
76
|
+
"""Call the TelegramHook to post the provided Telegram message."""
|
76
77
|
if self.text:
|
77
78
|
self.telegram_kwargs["text"] = self.text
|
78
79
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: apache-airflow-providers-telegram
|
3
|
-
Version: 4.
|
3
|
+
Version: 4.5.0
|
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>
|
@@ -19,12 +19,13 @@ Classifier: Programming Language :: Python :: 3.8
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.9
|
20
20
|
Classifier: Programming Language :: Python :: 3.10
|
21
21
|
Classifier: Programming Language :: Python :: 3.11
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
22
23
|
Classifier: Topic :: System :: Monitoring
|
23
|
-
Requires-Dist: apache-airflow>=2.
|
24
|
+
Requires-Dist: apache-airflow>=2.7.0
|
24
25
|
Requires-Dist: python-telegram-bot>=20.2
|
25
26
|
Project-URL: Bug Tracker, https://github.com/apache/airflow/issues
|
26
|
-
Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.
|
27
|
-
Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.
|
27
|
+
Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.5.0/changelog.html
|
28
|
+
Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.5.0
|
28
29
|
Project-URL: Slack Chat, https://s.apache.org/airflow-slack
|
29
30
|
Project-URL: Source Code, https://github.com/apache/airflow
|
30
31
|
Project-URL: Twitter, https://twitter.com/ApacheAirflow
|
@@ -74,7 +75,7 @@ Project-URL: YouTube, https://www.youtube.com/channel/UCSXwxpWZQ7XZ1WL3wqevChA/
|
|
74
75
|
|
75
76
|
Package ``apache-airflow-providers-telegram``
|
76
77
|
|
77
|
-
Release: ``4.
|
78
|
+
Release: ``4.5.0``
|
78
79
|
|
79
80
|
|
80
81
|
`Telegram <https://telegram.org/>`__
|
@@ -87,7 +88,7 @@ This is a provider package for ``telegram`` provider. All classes for this provi
|
|
87
88
|
are in ``airflow.providers.telegram`` python package.
|
88
89
|
|
89
90
|
You can find package information and changelog for the provider
|
90
|
-
in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.
|
91
|
+
in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.5.0/>`_.
|
91
92
|
|
92
93
|
Installation
|
93
94
|
------------
|
@@ -96,7 +97,7 @@ You can install this package on top of an existing Airflow 2 installation (see `
|
|
96
97
|
for the minimum Airflow version supported) via
|
97
98
|
``pip install apache-airflow-providers-telegram``
|
98
99
|
|
99
|
-
The package supports the following python versions: 3.8,3.9,3.10,3.11
|
100
|
+
The package supports the following python versions: 3.8,3.9,3.10,3.11,3.12
|
100
101
|
|
101
102
|
Requirements
|
102
103
|
------------
|
@@ -104,9 +105,9 @@ Requirements
|
|
104
105
|
======================= ==================
|
105
106
|
PIP package Version required
|
106
107
|
======================= ==================
|
107
|
-
``apache-airflow`` ``>=2.
|
108
|
+
``apache-airflow`` ``>=2.7.0``
|
108
109
|
``python-telegram-bot`` ``>=20.2``
|
109
110
|
======================= ==================
|
110
111
|
|
111
112
|
The changelog for the provider package can be found in the
|
112
|
-
`changelog <https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.
|
113
|
+
`changelog <https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.5.0/changelog.html>`_.
|
@@ -0,0 +1,11 @@
|
|
1
|
+
airflow/providers/telegram/LICENSE,sha256=ywUBpKZc7Jb96rVt5I3IDbg7dIJAbUSHkuoDcF3jbH4,13569
|
2
|
+
airflow/providers/telegram/__init__.py,sha256=I45ziG0xXBXSo8_ZooawNKEtB4uvtQV5zOWYLxD_fTU,1583
|
3
|
+
airflow/providers/telegram/get_provider_info.py,sha256=s9jFeejdFby0QeQlpenBLE5Agaj4mgqYmZ6dPfErcp8,2743
|
4
|
+
airflow/providers/telegram/hooks/__init__.py,sha256=mlJxuZLkd5x-iq2SBwD3mvRQpt3YR7wjz_nceyF1IaI,787
|
5
|
+
airflow/providers/telegram/hooks/telegram.py,sha256=QqX3H65L8DOZSIqmNO_Q5SqDOr6SEtPpep61MXBPlf8,5746
|
6
|
+
airflow/providers/telegram/operators/__init__.py,sha256=mlJxuZLkd5x-iq2SBwD3mvRQpt3YR7wjz_nceyF1IaI,787
|
7
|
+
airflow/providers/telegram/operators/telegram.py,sha256=fvKOeHwuf0o26wWVP2sER9ByCHD6dkNZCPzjIqp1D8k,3014
|
8
|
+
apache_airflow_providers_telegram-4.5.0.dist-info/entry_points.txt,sha256=QbI_ZGIDTfpx3npCqi0CebJFs_NCjoG8Tn9dGkQDBkE,104
|
9
|
+
apache_airflow_providers_telegram-4.5.0.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
|
10
|
+
apache_airflow_providers_telegram-4.5.0.dist-info/METADATA,sha256=SF8gOKT0mQMnBB6_C1HmCusyD75aCS6oHR2og_d-1lQ,4794
|
11
|
+
apache_airflow_providers_telegram-4.5.0.dist-info/RECORD,,
|
@@ -1,11 +0,0 @@
|
|
1
|
-
airflow/providers/telegram/LICENSE,sha256=ywUBpKZc7Jb96rVt5I3IDbg7dIJAbUSHkuoDcF3jbH4,13569
|
2
|
-
airflow/providers/telegram/__init__.py,sha256=v4C6PfxJHpIQkO994BW843j_cjKsxdW7FLQpZouubZM,1583
|
3
|
-
airflow/providers/telegram/get_provider_info.py,sha256=sY5ZU751vJY7U6C6Nb8FjOB60dXYrH1XwUERaqHvKx8,2492
|
4
|
-
airflow/providers/telegram/hooks/__init__.py,sha256=mlJxuZLkd5x-iq2SBwD3mvRQpt3YR7wjz_nceyF1IaI,787
|
5
|
-
airflow/providers/telegram/hooks/telegram.py,sha256=_0H7rc7oFTWIs0xxNuIRwnoTh-hi9_Mct8szuI9LZGE,5267
|
6
|
-
airflow/providers/telegram/operators/__init__.py,sha256=mlJxuZLkd5x-iq2SBwD3mvRQpt3YR7wjz_nceyF1IaI,787
|
7
|
-
airflow/providers/telegram/operators/telegram.py,sha256=2a3Co15yZEYqMbwECpMlkkjtXxwdlUsrnkPvTEP6as0,3014
|
8
|
-
apache_airflow_providers_telegram-4.4.0rc1.dist-info/entry_points.txt,sha256=QbI_ZGIDTfpx3npCqi0CebJFs_NCjoG8Tn9dGkQDBkE,104
|
9
|
-
apache_airflow_providers_telegram-4.4.0rc1.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
|
10
|
-
apache_airflow_providers_telegram-4.4.0rc1.dist-info/METADATA,sha256=kupO_tsJoo-ceWSJGL1t9Bqw92XAnggP7wQSO-Usz-I,4750
|
11
|
-
apache_airflow_providers_telegram-4.4.0rc1.dist-info/RECORD,,
|
File without changes
|