aboutsummaryrefslogtreecommitdiffhomepage
path: root/tap_google_sheets/discover.py
diff options
context:
space:
mode:
authorJeff Huth <jeff.huth@bytecode.io>2019-11-13 17:03:56 -0800
committerJeff Huth <jeff.huth@bytecode.io>2019-11-13 17:03:56 -0800
commit89643ba6fa98db82efd3246805ef801a8bfb5c81 (patch)
tree739027b4e827def2db81631c9d6ed58ec2b97809 /tap_google_sheets/discover.py
parent5f8005471d3affaaf23489df93a58ca64c3da3ca (diff)
downloadtap-google-sheets-89643ba6fa98db82efd3246805ef801a8bfb5c81.tar.gz
tap-google-sheets-89643ba6fa98db82efd3246805ef801a8bfb5c81.tar.zst
tap-google-sheets-89643ba6fa98db82efd3246805ef801a8bfb5c81.zip
Initial commit
Discovery mode works. Still working on normal sync.
Diffstat (limited to 'tap_google_sheets/discover.py')
-rw-r--r--tap_google_sheets/discover.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tap_google_sheets/discover.py b/tap_google_sheets/discover.py
new file mode 100644
index 0000000..6477a5f
--- /dev/null
+++ b/tap_google_sheets/discover.py
@@ -0,0 +1,26 @@
1from singer.catalog import Catalog, CatalogEntry, Schema
2from tap_google_sheets.schema import get_schemas, STREAMS
3
4
5def discover(client, spreadsheet_id):
6 schemas, field_metadata = get_schemas(client, spreadsheet_id)
7 catalog = Catalog([])
8
9 for stream_name, schema_dict in schemas.items():
10 schema = Schema.from_dict(schema_dict)
11 mdata = field_metadata[stream_name]
12 key_properties = None
13 for md in mdata:
14 table_key_properties = md.get('metadata', {}).get('table-key-properties')
15 if table_key_properties:
16 key_properties = table_key_properties
17
18 catalog.streams.append(CatalogEntry(
19 stream=stream_name,
20 tap_stream_id=stream_name,
21 key_properties=STREAMS.get(stream_name, {}).get('key_properties', key_properties),
22 schema=schema,
23 metadata=mdata
24 ))
25
26 return catalog