josh-fell commented on code in PR #29166:
URL: https://github.com/apache/airflow/pull/29166#discussion_r1087126820
##########
airflow/providers/dbt/cloud/hooks/dbt.py:
##########
@@ -181,33 +181,46 @@ def __init__(self, dbt_cloud_conn_id: str =
default_conn_name, *args, **kwargs)
super().__init__(auth_type=TokenAuth)
self.dbt_cloud_conn_id = dbt_cloud_conn_id
+ @staticmethod
+ def _get_tenant_domain(conn: Connection) -> str:
+ if conn.schema:
+ warnings.warn(
+ "The `schema` parameter is deprecated and use within a dbt
Cloud connection will be removed "
+ "in a future version. Please use `host` instead and specify
the entire tenant domain name.",
+ category=DeprecationWarning,
+ stacklevel=2,
+ )
+ # Prior to deprecation, the connection.schema value could _only_
modify the third-level
+ # domain value while '.getdbt.com' was always used as the
remainder of the domain name.
+ tenant = f"{conn.schema}.getdbt.com"
+ else:
+ tenant = conn.host or "cloud.getdbt.com"
+
+ return tenant
+
@staticmethod
def get_request_url_params(
tenant: str, endpoint: str, include_related: list[str] | None = None
) -> tuple[str, dict[str, Any]]:
"""
Form URL from base url and endpoint url
- :param tenant: The tenant name which is need to be replaced in base
url.
+ :param tenant: The tenant domain name which is need to be replaced in
base url.
:param endpoint: Endpoint url to be requested.
:param include_related: Optional. List of related fields to pull with
the run.
Valid values are "trigger", "job", "repository", and "environment".
"""
data: dict[str, Any] = {}
- base_url = f"https://{tenant}.getdbt.com/api/v2/accounts/"
if include_related:
data = {"include_related": include_related}
- if base_url and not base_url.endswith("/") and endpoint and not
endpoint.startswith("/"):
- url = base_url + "/" + endpoint
- else:
- url = (base_url or "") + (endpoint or "")
Review Comment:
Refactoring the branching here since this line would never be executed
anyway.
--
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]