2024-03-07 14:06:53 +01:00
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
from pydantic import PositiveInt, computed_field, MySQLDsn
|
|
|
|
from pydantic_core import Url
|
2024-04-15 13:18:31 +02:00
|
|
|
import httpx
|
2024-03-07 14:06:53 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Configs(BaseSettings):
|
2024-04-15 13:42:46 +02:00
|
|
|
DB_HOST: str
|
|
|
|
DB_PORT: PositiveInt
|
|
|
|
DB_NAME: str
|
|
|
|
DB_LOGIN: str
|
|
|
|
DB_PASSWORD: str
|
2024-04-15 13:18:31 +02:00
|
|
|
HOST_DS: str
|
|
|
|
PORT_DS: PositiveInt
|
|
|
|
TOKEN_DS: str
|
2024-03-07 14:06:53 +01:00
|
|
|
|
|
|
|
@computed_field
|
|
|
|
def DB_URI(self) -> MySQLDsn:
|
|
|
|
return Url(
|
2024-04-15 13:42:46 +02:00
|
|
|
f"mysql+aiomysql://{self.DB_LOGIN}:{self.DB_PASSWORD}@{self.DB_HOST}:{self.DB_PORT}/{self.DB_NAME}?charset=utf8mb4"
|
2024-03-07 14:06:53 +01:00
|
|
|
)
|
|
|
|
|
2024-04-15 13:18:31 +02:00
|
|
|
@computed_field
|
|
|
|
def DS_URL(self) -> httpx.URL:
|
|
|
|
return httpx.URL(
|
|
|
|
f"http://{self.HOST_DS}:{self.PORT_DS}/force-assign-role"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2024-03-07 14:06:53 +01:00
|
|
|
model_config = SettingsConfigDict(env_file='.env', env_file_encoding='utf-8')
|
|
|
|
|
|
|
|
configs = Configs()
|