potiuk commented on code in PR #64591:
URL: https://github.com/apache/airflow/pull/64591#discussion_r3035752462


##########
providers/zendesk/src/airflow/providers/zendesk/hooks/zendesk.py:
##########
@@ -41,56 +41,71 @@ class ZendeskHook(BaseHook):
     conn_type = "zendesk"
     hook_name = "Zendesk"
 
-    @classmethod
-    def get_ui_field_behaviour(cls) -> dict[str, Any]:
-        return {
-            "hidden_fields": ["schema", "port", "extra"],
-            "relabeling": {"host": "Zendesk domain", "login": "Zendesk email"},
-        }
-
     def __init__(self, zendesk_conn_id: str = default_conn_name) -> None:
         super().__init__()
         self.zendesk_conn_id = zendesk_conn_id
         self.base_api: BaseApi | None = None
-        zenpy_client, url = self._init_conn()
-        self.zenpy_client = zenpy_client
-        self.__url = url
-        self.get = self.zenpy_client.users._get
+        self._zenpy_client: Zenpy | None = None
+        self._url: str | None = None
 
     def _init_conn(self) -> tuple[Zenpy, str]:
         """
-        Create the Zenpy Client for our Zendesk connection.
+        Initialize the Zendesk client.
+
+        The following authentication modes are supported:
+        1. Use token: If 'use_token' is True in extras, the password field is 
treated as an API token.
+        2. Token: If 'token' is provided in extras, it's used as an API token.
+        3. OAuth: If 'oauth_token' is provided in extras, it's used as an 
OAuth token.
+        4. Password: Defaults to email/password authentication if none of the 
above are provided.
 
-        :return: zenpy.Zenpy client and the url for the API.
+        Precedence: use_token > token > oauth_token > password.
         """
         conn = self.get_connection(self.zendesk_conn_id)
-        domain = ""
-        url = ""
-        subdomain: str | None = None
-        if conn.host:
-            url = "https://"; + conn.host
-            domain = conn.host
-            if conn.host.count(".") >= 2:
-                dot_splitted_string = conn.host.rsplit(".", 2)
-                subdomain = dot_splitted_string[0]
-                domain = ".".join(dot_splitted_string[1:])
-        return Zenpy(domain=domain, subdomain=subdomain, email=conn.login, 
password=conn.password), url
+        if not conn.host:
+            raise ValueError(f"No host provided for {self.zendesk_conn_id}")
+
+        domain = conn.host.split(".")[-2] + "." + conn.host.split(".")[-1]

Review Comment:
   This will crash if host does not have two dots.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to