Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Commit

Permalink
enable initial syncs
Browse files Browse the repository at this point in the history
  • Loading branch information
PubChimps committed Jul 8, 2022
1 parent 925c586 commit be5ab77
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 7 additions & 3 deletions fivetran_provider/hooks/fivetran.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit be5ab77

Please sign in to comment.