Skip to content

Commit

Permalink
Merge pull request #1 from davicorreiajr/feature/select-streams
Browse files Browse the repository at this point in the history
Add select_streams option (to be added in the config file) to generate catalog file with some stream(s) pre-selected
  • Loading branch information
davicorreiajr authored Mar 30, 2020
2 parents 4d4082c + c957d83 commit 57cec09
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions tap_google_sheets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
'user_agent'
]

def do_discover(client, spreadsheet_id):
def do_discover(client, spreadsheet_id, select_streams):

LOGGER.info('Starting discover')
catalog = discover(client, spreadsheet_id)
catalog = discover(client, spreadsheet_id, select_streams)
json.dump(catalog.to_dict(), sys.stdout, indent=2)
LOGGER.info('Finished discover')

Expand All @@ -44,9 +44,10 @@ def main():

config = parsed_args.config
spreadsheet_id = config.get('spreadsheet_id')
select_streams = config.get('select_streams')

if parsed_args.discover:
do_discover(client, spreadsheet_id)
do_discover(client, spreadsheet_id, select_streams)
elif parsed_args.catalog:
sync(client=client,
config=config,
Expand Down
4 changes: 3 additions & 1 deletion tap_google_sheets/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
from tap_google_sheets.schema import get_schemas, STREAMS


def discover(client, spreadsheet_id):
def discover(client, spreadsheet_id, select_streams):
schemas, field_metadata = get_schemas(client, spreadsheet_id)
catalog = Catalog([])

for stream_name, schema_dict in schemas.items():
if select_streams and stream_name in select_streams:
schema_dict['selected'] = True
schema = Schema.from_dict(schema_dict)
mdata = field_metadata[stream_name]
key_properties = None
Expand Down

0 comments on commit 57cec09

Please sign in to comment.