File size: 1,825 Bytes
1b7e88c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import logging
import os
import time
from typing import Any, Optional

from omagent_core.engine.configuration.settings.authentication_settings import \
    AuthenticationSettings
from pydantic import Field
from pydantic_settings import BaseSettings

AAAS_TEMPLATE_CONFIG = {
    "name": "AaasConfig",
    "base_url": {
        "value": "http://localhost:30002",
        "description": "The aaas task server API endpoint",
        "env_var": "AAAS_TASK_SERVER_URL",
    },
    "token": {
        "value": None,
        "description": "The authorization token",
        "env_var": "AAAS_TOKEN",
    },
    "enable": {
        "value": True,
        "description": "Whether to enable the aaas task server",
        "env_var": "AAAS_ENABLE",
    },
    "domain_token": {
        "value": None,
        "description": "The domain token",
        "env_var": "DOMAIN_TOKEN",
    },
    "is_prod": {
        "value": False,
        "description": "Whether it is a production environment",
        "env_var": "IS_PROD",
    }
}


class AaasConfig(BaseSettings):
    class Config:
        """Configuration for this pydantic object."""

        extra = "allow"

    base_url: str = Field(
        default="http://localhost:30002", description="The aaas task server API endpoint"
    )
    token: Optional[str] = Field(
        default=None,
        description="The authorization token",
    )
    enable: bool = Field(
        default=True,
        description="Whether to enable the aaas task server",
    )
    domain_token: Optional[str] = Field(
        default=None,
        description="The domain token",
    )
    is_prod: bool = Field(
        default=False,
        description="Whether it is a production environment",
    )

    def model_post_init(self, __context: Any) -> None:
        self.host = self.base_url + "/api"