feat: introduce pydantic-settings for config definition and validation (#5202)
Co-authored-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
12
api/configs/extra/__init__.py
Normal file
12
api/configs/extra/__init__.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
from configs.extra.notion_configs import NotionConfigs
|
||||
from configs.extra.sentry_configs import SentryConfigs
|
||||
|
||||
|
||||
class ExtraServiceConfigs(
|
||||
# place the configs in alphabet order
|
||||
NotionConfigs,
|
||||
SentryConfigs,
|
||||
):
|
||||
pass
|
||||
33
api/configs/extra/notion_configs.py
Normal file
33
api/configs/extra/notion_configs.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class NotionConfigs(BaseModel):
|
||||
"""
|
||||
Notion integration configs
|
||||
"""
|
||||
NOTION_CLIENT_ID: Optional[str] = Field(
|
||||
description='Notion client ID',
|
||||
default=None,
|
||||
)
|
||||
|
||||
NOTION_CLIENT_SECRET: Optional[str] = Field(
|
||||
description='Notion client secret key',
|
||||
default=None,
|
||||
)
|
||||
|
||||
NOTION_INTEGRATION_TYPE: Optional[str] = Field(
|
||||
description='Notion integration type, default to None, available values: internal.',
|
||||
default=None,
|
||||
)
|
||||
|
||||
NOTION_INTERNAL_SECRET: Optional[str] = Field(
|
||||
description='Notion internal secret key',
|
||||
default=None,
|
||||
)
|
||||
|
||||
NOTION_INTEGRATION_TOKEN: Optional[str] = Field(
|
||||
description='Notion integration token',
|
||||
default=None,
|
||||
)
|
||||
23
api/configs/extra/sentry_configs.py
Normal file
23
api/configs/extra/sentry_configs.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, Field, PositiveFloat
|
||||
|
||||
|
||||
class SentryConfigs(BaseModel):
|
||||
"""
|
||||
Sentry configs
|
||||
"""
|
||||
SENTRY_DSN: Optional[str] = Field(
|
||||
description='Sentry DSN',
|
||||
default=None,
|
||||
)
|
||||
|
||||
SENTRY_TRACES_SAMPLE_RATE: PositiveFloat = Field(
|
||||
description='Sentry trace sample rate',
|
||||
default=1.0,
|
||||
)
|
||||
|
||||
SENTRY_PROFILES_SAMPLE_RATE: PositiveFloat = Field(
|
||||
description='Sentry profiles sample rate',
|
||||
default=1.0,
|
||||
)
|
||||
Reference in New Issue
Block a user