Initial commit — PlantGuideScraper project
This commit is contained in:
36
backend/app/schemas/api_key.py
Normal file
36
backend/app/schemas/api_key.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class ApiKeyBase(BaseModel):
|
||||
source: str
|
||||
api_key: Optional[str] = None # Optional for no-auth sources, used as Client ID for OAuth
|
||||
api_secret: Optional[str] = None # Also used as Client Secret for OAuth sources
|
||||
access_token: Optional[str] = None # For OAuth sources like Wikimedia
|
||||
rate_limit_per_sec: float = 1.0
|
||||
enabled: bool = True
|
||||
|
||||
|
||||
class ApiKeyCreate(ApiKeyBase):
|
||||
pass
|
||||
|
||||
|
||||
class ApiKeyUpdate(BaseModel):
|
||||
api_key: Optional[str] = None
|
||||
api_secret: Optional[str] = None
|
||||
access_token: Optional[str] = None
|
||||
rate_limit_per_sec: Optional[float] = None
|
||||
enabled: Optional[bool] = None
|
||||
|
||||
|
||||
class ApiKeyResponse(BaseModel):
|
||||
id: int
|
||||
source: str
|
||||
api_key_masked: str # Show only last 4 chars
|
||||
has_secret: bool
|
||||
has_access_token: bool
|
||||
rate_limit_per_sec: float
|
||||
enabled: bool
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
Reference in New Issue
Block a user