-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TDL-20793: Improve Tap-Asana Reliability (#53)
* TDL-20795: Add missing tap-tester tests (#47) * added missing tap-tester tests and assertions * resolved integration test failure * updated the code as per PEP8 standards * resolved pagination test failire * resolved test case fialure * upgraded the asana-python SDK and added missing fields * Revert "updated the code as per PEP8 standards" This reverts commit 8839e3a. * updated code as per PEP8 standards * added parameterized in config.yml file * updated all fields test case * reverted datatype update * upgraded asana SDK and singer-python version * - updated integration tests - removed pagination integration test * - removed pagination test * - fixed the review comments * TDL-20794: Upgrade SDK Version and add missing fields. (#48) * added the formats as date-format for the fields as per the documentation * schema fields addition * added few fields which are used as opt_fields * fixed all fields integration test --------- Co-authored-by: “rdeshmukh15” <[email protected]> Co-authored-by: RushiT0122 <[email protected]> --------- Co-authored-by: RushiT0122 <[email protected]> Co-authored-by: “rdeshmukh15” <[email protected]> * resolved the PR comments * added date-time format * sdk version updated to 3.1.0 --------- Co-authored-by: Harsh <[email protected]> Co-authored-by: RushiT0122 <[email protected]>
- Loading branch information
1 parent
86f794f
commit ec14e55
Showing
31 changed files
with
2,788 additions
and
1,213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,57 @@ | ||
|
||
import asana | ||
import singer | ||
|
||
LOGGER = singer.get_logger() | ||
|
||
|
||
""" Simple wrapper for Asana. """ | ||
class Asana(): | ||
|
||
def __init__(self, client_id, client_secret, redirect_uri, refresh_token, access_token=None): # pylint: disable=too-many-arguments | ||
self.client_id = client_id | ||
self.client_secret = client_secret | ||
self.redirect_uri = redirect_uri | ||
self.refresh_token = refresh_token | ||
self.access_token = access_token | ||
self._client = self._oauth_auth() or self._access_token_auth() | ||
self.refresh_access_token() | ||
|
||
def _oauth_auth(self): | ||
if self.client_id is None or self.client_secret is None or self.redirect_uri is None or self.refresh_token is None: | ||
LOGGER.debug("OAuth authentication unavailable.") | ||
return None | ||
return asana.Client.oauth(client_id=self.client_id, client_secret=self.client_secret, redirect_uri=self.redirect_uri) | ||
|
||
def _access_token_auth(self): | ||
if self.access_token is None: | ||
LOGGER.debug("OAuth authentication unavailable.") | ||
return None | ||
return asana.Client.access_token(self.access_token) | ||
|
||
def refresh_access_token(self): | ||
return self._client.session.refresh_token(self._client.session.token_url, client_id=self.client_id, client_secret=self.client_secret, refresh_token=self.refresh_token) | ||
|
||
@property | ||
def client(self): | ||
return self._client | ||
|
||
class Asana(): | ||
"""Base class for tap-asana""" | ||
|
||
def __init__( | ||
self, client_id, client_secret, redirect_uri, refresh_token, access_token=None | ||
): # pylint: disable=too-many-arguments | ||
self.client_id = client_id | ||
self.client_secret = client_secret | ||
self.redirect_uri = redirect_uri | ||
self.refresh_token = refresh_token | ||
self.access_token = access_token | ||
self._client = self._oauth_auth() or self._access_token_auth() | ||
self.refresh_access_token() | ||
|
||
def _oauth_auth(self): | ||
"""Oauth authentication for tap""" | ||
if ( | ||
self.client_id is None | ||
or self.client_secret is None | ||
or self.redirect_uri is None | ||
or self.refresh_token is None | ||
): | ||
LOGGER.debug("OAuth authentication unavailable.") | ||
return None | ||
return asana.Client.oauth( | ||
client_id=self.client_id, | ||
client_secret=self.client_secret, | ||
redirect_uri=self.redirect_uri, | ||
) | ||
|
||
def _access_token_auth(self): | ||
"""Check for access token""" | ||
if self.access_token is None: | ||
LOGGER.debug("OAuth authentication unavailable.") | ||
return None | ||
return asana.Client.access_token(self.access_token) | ||
|
||
def refresh_access_token(self): | ||
return self._client.session.refresh_token( | ||
self._client.session.token_url, | ||
client_id=self.client_id, | ||
client_secret=self.client_secret, | ||
refresh_token=self.refresh_token, | ||
) | ||
|
||
@property | ||
def client(self): | ||
return self._client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.