diff --git a/CHANGELOG.md b/CHANGELOG.md index c0b35ac..977c88d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ ## Upcoming * (please add here) +## 1.1.2 - 2022-07-08 +Added functionality to start initial syncs and syncs on paused connectors via the FivetranOperator + ## [1.1.1](https://github.com/fivetran/airflow-provider-fivetran/compare/v1.1.0...v1.1.1) - 2022-06-21 Fixed timestamp comparisons in `start_fivetran_sync` to be compare between pendulum.datetime.datetime instead of comparing strings diff --git a/fivetran_provider/hooks/fivetran.py b/fivetran_provider/hooks/fivetran.py index 052da0d..fa371a9 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.1" + api_user_agent = "airflow_provider_fivetran/1.1.2" api_protocol = "https" api_host = "api.fivetran.com" api_path_connectors = "v1/connectors/" @@ -230,11 +230,15 @@ def start_fivetran_sync(self, connector_id): :return: Timestamp of previously completed sync :rtype: str """ - endpoint = self.api_path_connectors + connector_id + "/force" - self._do_api_call(("POST", endpoint)) connector_details = self.get_connector(connector_id) succeeded_at = connector_details["succeeded_at"] failed_at = connector_details["failed_at"] + endpoint = self.api_path_connectors + connector_id + if self._do_api_call(("GET", endpoint))['data']['paused'] == True: + self._do_api_call(("PATCH", endpoint),json.dumps({"paused": False})) + if succeeded_at == None and failed_at == None: + succeeded_at = str(pendulum.now()) + self._do_api_call(("POST", endpoint + "/force")) last_sync = ( succeeded_at if self._parse_timestamp(succeeded_at) > self._parse_timestamp(failed_at) diff --git a/setup.cfg b/setup.cfg index c1194c8..d4b0843 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = airflow-provider-fivetran -version = 1.1.1 +version = 1.1.2 description = A Fivetran provider for Apache Airflow long_description = file: README.md long_description_content_type = text/markdown