peregrine/scripts/integrations/google_sheets.py
pyr0ball 5f39770b68 feat: 13 integration implementations + config examples
Add all 13 integration modules (Notion, Google Drive, Google Sheets,
Airtable, Dropbox, OneDrive, MEGA, Nextcloud, Google Calendar, Apple
Calendar/CalDAV, Slack, Discord, Home Assistant) with fields(), connect(),
and test() implementations. Add config/integrations/*.yaml.example files
and gitignore rules for live config files. Add 5 new registry/schema
tests bringing total to 193 passing.
2026-02-25 08:18:45 -08:00

34 lines
1.3 KiB
Python

from __future__ import annotations
import os
from scripts.integrations.base import IntegrationBase
class GoogleSheetsIntegration(IntegrationBase):
name = "google_sheets"
label = "Google Sheets"
tier = "paid"
def __init__(self):
self._config: dict = {}
def fields(self) -> list[dict]:
return [
{"key": "spreadsheet_id", "label": "Spreadsheet ID", "type": "text",
"placeholder": "From the URL: /d/<ID>/edit", "required": True,
"help": ""},
{"key": "sheet_name", "label": "Sheet name", "type": "text",
"placeholder": "Jobs", "required": True,
"help": "Name of the tab to write to"},
{"key": "credentials_json", "label": "Service Account JSON path", "type": "text",
"placeholder": "~/credentials/google-sheets-sa.json", "required": True,
"help": "Download from Google Cloud Console → Service Accounts → Keys"},
]
def connect(self, config: dict) -> bool:
self._config = config
return bool(config.get("spreadsheet_id") and config.get("credentials_json"))
def test(self) -> bool:
# TODO: use gspread to open_by_key()
creds = os.path.expanduser(self._config.get("credentials_json", ""))
return os.path.exists(creds)