This is an automated email from the ASF dual-hosted git repository.

vincbeck pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new c4967b00c4 Make Amazon Chime connection lazy loaded and consistent 
with docs (#34000)
c4967b00c4 is described below

commit c4967b00c447ac7ac8f73ab2d01810765a856616
Author: Andrey Anshin <[email protected]>
AuthorDate: Fri Sep 1 18:34:08 2023 +0400

    Make Amazon Chime connection lazy loaded and consistent with docs (#34000)
---
 airflow/providers/amazon/aws/hooks/chime.py    | 19 ++++++++++++-------
 tests/providers/amazon/aws/hooks/test_chime.py |  3 ++-
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/airflow/providers/amazon/aws/hooks/chime.py 
b/airflow/providers/amazon/aws/hooks/chime.py
index e7e37ea7b9..f12defdeb8 100644
--- a/airflow/providers/amazon/aws/hooks/chime.py
+++ b/airflow/providers/amazon/aws/hooks/chime.py
@@ -21,6 +21,7 @@ from __future__ import annotations
 
 import json
 import re
+from functools import cached_property
 from typing import Any
 
 from airflow.exceptions import AirflowException
@@ -28,19 +29,19 @@ from airflow.providers.http.hooks.http import HttpHook
 
 
 class ChimeWebhookHook(HttpHook):
-    """Interact with Chime Web Hooks to create notifications.
+    """Interact with Amazon Chime Webhooks to create notifications.
 
     .. warning:: This hook is only designed to work with web hooks and not 
chat bots.
 
-    :param chime_conn_id: Chime connection ID with Endpoint as 
"https://hooks.chime.aws"; and
-                         the webhook token in the form of 
```{webhook.id}?token{webhook.token}```
-
+    :param chime_conn_id: :ref:`Amazon Chime Connection ID 
<howto/connection:chime>`
+        with Endpoint as `https://hooks.chime.aws` and the webhook token
+        in the form of ``{webhook.id}?token{webhook.token}``
     """
 
     conn_name_attr = "chime_conn_id"
     default_conn_name = "chime_default"
     conn_type = "chime"
-    hook_name = "Chime Web Hook"
+    hook_name = "Amazon Chime Webhook"
 
     def __init__(
         self,
@@ -49,7 +50,11 @@ class ChimeWebhookHook(HttpHook):
         **kwargs: Any,
     ) -> None:
         super().__init__(*args, **kwargs)
-        self.webhook_endpoint = self._get_webhook_endpoint(chime_conn_id)
+        self._chime_conn_id = chime_conn_id
+
+    @cached_property
+    def webhook_endpoint(self):
+        return self._get_webhook_endpoint(self._chime_conn_id)
 
     def _get_webhook_endpoint(self, conn_id: str) -> str:
         """
@@ -104,7 +109,7 @@ class ChimeWebhookHook(HttpHook):
             "hidden_fields": ["login", "port", "extra"],
             "relabeling": {
                 "host": "Chime Webhook Endpoint",
-                "password": "Webhook Token",
+                "password": "Chime Webhook token",
             },
             "placeholders": {
                 "schema": "https",
diff --git a/tests/providers/amazon/aws/hooks/test_chime.py 
b/tests/providers/amazon/aws/hooks/test_chime.py
index d5130964f4..2c6b33d563 100644
--- a/tests/providers/amazon/aws/hooks/test_chime.py
+++ b/tests/providers/amazon/aws/hooks/test_chime.py
@@ -66,8 +66,9 @@ class TestChimeWebhookHook:
 
         # When/Then
         expected_message = r"Expected Chime webhook token in the form"
+        hook = ChimeWebhookHook(chime_conn_id="chime-bad-url")
         with pytest.raises(AirflowException, match=expected_message):
-            ChimeWebhookHook(chime_conn_id="chime-bad-url")
+            assert not hook.webhook_endpoint
 
     def test_get_webhook_endpoint_conn_id(self):
         # Given

Reply via email to