-
Notifications
You must be signed in to change notification settings - Fork 10
[tap-frontapp] - fix libraries and dependabot issues #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
romilqlik
wants to merge
11
commits into
master
Choose a base branch
from
feature/SAC-27536-frontapp-libraries
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9f6165a
[SAC-27536] Frontapp App libary changes
gl-romil 62f087f
[SAC-27535] [tap-frontapp] - fix extraction failures (#28)
romilqlik 04153ae
Update discover.py
romilqlik 987a159
Update __init__.py
romilqlik 3fe7d0b
Update setup.py
romilqlik 23f103e
Update __init__.py
romilqlik 4340a81
Update discover.py
romilqlik f55c28f
Update __init__.py
romilqlik 9b804e3
Update __init__.py
romilqlik 937ee61
Update discover.py
romilqlik 78437a0
Update test_client.py
romilqlik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -102,3 +102,6 @@ tags | |
singer-check-tap-data | ||
state.json | ||
catalog.json | ||
output.json | ||
convert_json_csv.py | ||
notes_frontapp.txt |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"""Discovery module for the FrontApp tap.""" | ||
|
||
import sys | ||
import requests | ||
import singer | ||
from singer import metadata | ||
from singer.catalog import Catalog, CatalogEntry, Schema | ||
from .schemas import get_schemas | ||
|
||
LOGGER = singer.get_logger() | ||
|
||
|
||
def validate_credentials(token): | ||
"""Validates the FrontApp token using a simple API call.""" | ||
headers = {"Authorization": f"Bearer {token}"} | ||
try: | ||
response = requests.get("https://api2.frontapp.com/me", headers=headers, timeout=10) | ||
if response.status_code == 200: | ||
LOGGER.info("Frontapp credentials validated successfully.") | ||
else: | ||
LOGGER.critical("Invalid Frontapp credentials. Status code: %s", response.status_code) | ||
sys.exit(1) | ||
except requests.exceptions.RequestException as err: | ||
LOGGER.critical("Credential validation failed: %s", str(err)) | ||
sys.exit(1) | ||
|
||
|
||
def discover(): | ||
"""Run the discovery mode, prepare the catalog file and return the catalog.""" | ||
schemas, field_metadata = get_schemas() | ||
LOGGER.info("Schemas loaded: %s", list(schemas.keys())) | ||
|
||
catalog = Catalog([]) | ||
|
||
for stream_name, schema_dict in schemas.items(): | ||
try: | ||
schema = Schema.from_dict(schema_dict) | ||
mdata = field_metadata[stream_name] | ||
except Exception as err: | ||
LOGGER.error("Error while processing stream '%s': %s", stream_name, err) | ||
raise err | ||
|
||
key_properties = mdata.get((), {}).get("table-key-properties", []) | ||
|
||
catalog.streams.append( | ||
CatalogEntry( | ||
stream=stream_name, | ||
tap_stream_id=stream_name, | ||
key_properties=key_properties, | ||
schema=schema, | ||
metadata=metadata.to_list(mdata), | ||
) | ||
) | ||
|
||
return catalog |
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
import singer | ||
from tap_frontapp.streams import sync_selected_streams | ||
from tap_frontapp.schemas import load_and_write_schema, STATIC_SCHEMA_STREAM_IDS | ||
|
||
LOGGER = singer.get_logger() | ||
|
||
|
||
def update_currently_syncing(state, stream_name): | ||
"""Update the currently syncing stream in the Singer state.""" | ||
if not stream_name and singer.get_currently_syncing(state): | ||
del state["currently_syncing"] | ||
else: | ||
singer.set_currently_syncing(state, stream_name) | ||
singer.write_state(state) | ||
|
||
|
||
def sync(atx): | ||
"""Main sync method to process selected streams from FrontApp.""" | ||
|
||
catalog = atx.catalog | ||
state = atx.state | ||
|
||
streams_to_sync = [s.tap_stream_id for s in catalog.get_selected_streams(state)] | ||
LOGGER.info("Selected streams: %s", streams_to_sync) | ||
|
||
last_stream = singer.get_currently_syncing(state) | ||
LOGGER.info("Currently syncing: %s", last_stream) | ||
|
||
for stream_name in STATIC_SCHEMA_STREAM_IDS: | ||
load_and_write_schema(stream_name) | ||
|
||
LOGGER.info("Starting sync of selected streams.") | ||
sync_selected_streams(atx) | ||
LOGGER.info("All selected streams synced successfully.") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.