mirror of
https://github.com/MODSetter/SurfSense.git
synced 2025-09-01 18:19:08 +00:00
update seach source connector schema
This commit is contained in:
parent
9abaf4fd2a
commit
f96afe0e2a
3 changed files with 22 additions and 26 deletions
13
surfsense_backend/app/schemas/google_auth_credentials.py
Normal file
13
surfsense_backend/app/schemas/google_auth_credentials.py
Normal file
|
@ -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
|
|
@ -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)
|
|
|
@ -5,6 +5,7 @@ from typing import Any
|
||||||
from pydantic import BaseModel, ConfigDict, field_validator
|
from pydantic import BaseModel, ConfigDict, field_validator
|
||||||
|
|
||||||
from app.db import SearchSourceConnectorType
|
from app.db import SearchSourceConnectorType
|
||||||
|
from app.schemas.google_auth_credentials import GoogleAuthCredentialsBase
|
||||||
|
|
||||||
from .base import IDModel, TimestampModel
|
from .base import IDModel, TimestampModel
|
||||||
|
|
||||||
|
@ -179,6 +180,14 @@ class SearchSourceConnectorBase(BaseModel):
|
||||||
if not config.get("CLICKUP_API_TOKEN"):
|
if not config.get("CLICKUP_API_TOKEN"):
|
||||||
raise ValueError("CLICKUP_API_TOKEN cannot be empty")
|
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
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue