From f96afe0e2a2ea236817fecdbfb1322cb5586d573 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Sat, 2 Aug 2025 01:36:36 +0200 Subject: [PATCH] update seach source connector schema --- .../app/schemas/google_auth_credentials.py | 13 ++++++++++ .../app/schemas/google_calendar_accounts.py | 26 ------------------- .../app/schemas/search_source_connector.py | 9 +++++++ 3 files changed, 22 insertions(+), 26 deletions(-) create mode 100644 surfsense_backend/app/schemas/google_auth_credentials.py delete mode 100644 surfsense_backend/app/schemas/google_calendar_accounts.py diff --git a/surfsense_backend/app/schemas/google_auth_credentials.py b/surfsense_backend/app/schemas/google_auth_credentials.py new file mode 100644 index 0000000..2d5a048 --- /dev/null +++ b/surfsense_backend/app/schemas/google_auth_credentials.py @@ -0,0 +1,13 @@ +from datetime import datetime + +from pydantic import BaseModel + + +class GoogleAuthCredentialsBase(BaseModel): + token: str + refresh_token: str + token_uri: str + client_id: str + expiry: datetime + scopes: list[str] + client_secret: str diff --git a/surfsense_backend/app/schemas/google_calendar_accounts.py b/surfsense_backend/app/schemas/google_calendar_accounts.py deleted file mode 100644 index 32e8355..0000000 --- a/surfsense_backend/app/schemas/google_calendar_accounts.py +++ /dev/null @@ -1,26 +0,0 @@ -from uuid import UUID - -from pydantic import BaseModel, ConfigDict - - -class GoogleCalendarAccountBase(BaseModel): - user_id: UUID - access_token: str - refresh_token: str - - -class GoogleCalendarAccountCreate(GoogleCalendarAccountBase): - pass - - -class GoogleCalendarAccountUpdate(BaseModel): - access_token: str - refresh_token: str - - -class GoogleCalendarAccountRead(BaseModel): - user_id: UUID - access_token: str - refresh_token: str - - model_config = ConfigDict(from_attributes=True) diff --git a/surfsense_backend/app/schemas/search_source_connector.py b/surfsense_backend/app/schemas/search_source_connector.py index 28d5425..4c36893 100644 --- a/surfsense_backend/app/schemas/search_source_connector.py +++ b/surfsense_backend/app/schemas/search_source_connector.py @@ -5,6 +5,7 @@ from typing import Any from pydantic import BaseModel, ConfigDict, field_validator from app.db import SearchSourceConnectorType +from app.schemas.google_auth_credentials import GoogleAuthCredentialsBase from .base import IDModel, TimestampModel @@ -179,6 +180,14 @@ class SearchSourceConnectorBase(BaseModel): if not config.get("CLICKUP_API_TOKEN"): raise ValueError("CLICKUP_API_TOKEN cannot be empty") + elif connector_type == SearchSourceConnectorType.GOOGLE_CALENDAR_CONNECTOR: + # Required fields + required_keys = list(GoogleAuthCredentialsBase.model_fields.keys()) + + for key in required_keys: + if key not in config or config[key] in (None, ""): + raise ValueError(f"{key} is required and cannot be empty") + return config