From 2580f2b8181e6078d46d8787cffe5b2daed830ed Mon Sep 17 00:00:00 2001 From: PubChimps Date: Fri, 13 Jan 2023 13:45:19 -0800 Subject: [PATCH] increment version, update CHANGELOG --- CHANGELOG.md | 3 +++ fivetran_provider/hooks/fivetran.py | 21 +++++++++++++++++++-- setup.cfg | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00cf165..9d1b8a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ ## Upcoming * (please add here) +## 1.1.4 +Added API call to hook to return connector schemas + ## [1.1.3](https://github.com/fivetran/airflow-provider-fivetran/releases/tag/v1.1.3) - 2022-12-12 Added ability to test a Fivetran Connection type diff --git a/fivetran_provider/hooks/fivetran.py b/fivetran_provider/hooks/fivetran.py index 41b2285..7ca52ff 100644 --- a/fivetran_provider/hooks/fivetran.py +++ b/fivetran_provider/hooks/fivetran.py @@ -31,7 +31,7 @@ class FivetranHook(BaseHook): default_conn_name = "fivetran_default" conn_type = "fivetran" hook_name = "Fivetran" - api_user_agent = "airflow_provider_fivetran/1.1.3" + api_user_agent = "airflow_provider_fivetran/1.1.4" api_protocol = "https" api_host = "api.fivetran.com" api_path_connectors = "v1/connectors/" @@ -54,6 +54,23 @@ def get_ui_field_behaviour() -> Dict: }, } + @staticmethod + def _get_airflow_version() -> str: + """ + Fetch and return the current Airflow version + from aws provider + https://github.com/apache/airflow/blob/main/airflow/providers/amazon/aws/hooks/base_aws.py#L486 + """ + try: + # This can be a circular import under specific configurations. + # Importing locally to either avoid or catch it if it does happen. + from airflow import __version__ as airflow_version + + return "-airflow_version/" + airflow_version + except Exception: + # Under no condition should an error here ever cause an issue for the user. + return "" + def __init__( self, fivetran_conn_id: str = "fivetran", @@ -89,7 +106,7 @@ def _do_api_call(self, endpoint_info, json=None): auth = (self.fivetran_conn.login, self.fivetran_conn.password) url = f"{self.api_protocol}://{self.api_host}/{endpoint}" - headers = {"User-Agent": self.api_user_agent} + headers = {"User-Agent": self.api_user_agent + self._get_airflow_version()} if method == "GET": request_func = requests.get diff --git a/setup.cfg b/setup.cfg index abb91af..4c98b19 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = airflow-provider-fivetran -version = 1.1.3 +version = 1.1.4 description = A Fivetran provider for Apache Airflow long_description = file: README.md long_description_content_type = text/markdown