]> git.immae.eu Git - github/fretlink/tap-google-sheets.git/blobdiff - tap_google_sheets/streams.py
feat: use the official Google API python library
[github/fretlink/tap-google-sheets.git] / tap_google_sheets / streams.py
index ad5529f4ac3defef3ae215cfb7c1cf701e98137c..f7bf8ac52b3b9a54781647d1c8b520ef9cc9f44b 100644 (file)
@@ -2,9 +2,7 @@ from collections import OrderedDict
 
 # streams: API URL endpoints to be called
 # properties:
-#   <root node>: Plural stream name for the endpoint
-#   path: API endpoint relative path, when added to the base URL, creates the full path,
-#       default = stream_name
+#   <root node>: Plural stream name which will condition the endpoint called
 #   key_properties: Primary key fields for identifying an endpoint record.
 #   replication_method: INCREMENTAL or FULL_TABLE
 #   replication_keys: bookmark_field(s), typically a date-time, used for filtering the results
@@ -15,51 +13,51 @@ from collections import OrderedDict
 
 # file_metadata: Queries Google Drive API to get file information and see if file has been modified
 #    Provides audit info about who and when last changed the file.
+#    cf https://developers.google.com/drive/api/v3/reference/files/get
 FILE_METADATA = {
-    "api": "files",
-    "path": "files/{spreadsheet_id}",
     "key_properties": ["id"],
     "replication_method": "INCREMENTAL",
     "replication_keys": ["modifiedTime"],
     "params": {
+        "fileId": "{spreadsheet_id}",
         "fields": "id,name,createdTime,modifiedTime,version,teamDriveId,driveId,lastModifyingUser"
     }
 }
 
 # spreadsheet_metadata: Queries spreadsheet to get basic information on spreadhsheet and sheets
+#    cf https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/get
 SPREADSHEET_METADATA = {
-    "api": "sheets",
-    "path": "spreadsheets/{spreadsheet_id}",
     "key_properties": ["spreadsheetId"],
     "replication_method": "FULL_TABLE",
     "params": {
-        "includeGridData": "false"
+        "spreadsheetId": "{spreadsheet_id}"
     }
 }
 
 # sheet_metadata: Get Header Row and 1st data row (Rows 1 & 2) from a Sheet on Spreadsheet.
-# This endpoint includes detailed metadata about each cell in the header and first data row
-#   incl. data type, formatting, etc.
+#    This endpoint includes detailed metadata about each cell in the header and first data row
+#    incl. data type, formatting, etc.
+#    cf https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/get
 SHEET_METADATA = {
-    "api": "sheets",
-    "path": "spreadsheets/{spreadsheet_id}",
     "key_properties": ["sheetId"],
     "replication_method": "FULL_TABLE",
     "params": {
+        "spreadsheetId": "{spreadsheet_id}",
         "includeGridData": "true",
         "ranges": "'{sheet_title}'!1:2"
     }
 }
 
 # sheets_loaded: Queries a batch of Rows for each Sheet in the Spreadsheet.
-# Each query uses the `values` endpoint, to get data-only, w/out the formatting/type metadata.
+#    Each query uses the `values` endpoint, to get data-only, w/out the formatting/type metadata.
+#    cf https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/get
 SHEETS_LOADED = {
-    "api": "sheets",
-    "path": "spreadsheets/{spreadsheet_id}/values/'{sheet_title}'!{range_rows}",
     "data_key": "values",
     "key_properties": ["spreadsheetId", "sheetId", "loadDate"],
     "replication_method": "FULL_TABLE",
     "params": {
+        "spreadsheetId": "{spreadsheet_id}",
+        "range": "'{sheet_title}'!{range_rows}",
         "dateTimeRenderOption": "SERIAL_NUMBER",
         "valueRenderOption": "UNFORMATTED_VALUE",
         "majorDimension": "ROWS"