-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsettings.py
More file actions
43 lines (31 loc) · 1007 Bytes
/
settings.py
File metadata and controls
43 lines (31 loc) · 1007 Bytes
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
from typing import Literal
import yaml
# Compatability shim to support users with v1 and v2 installed
try:
from pydantic.v1 import BaseSettings, AnyUrl
except ImportError:
from pydantic import BaseSettings, AnyUrl
from .dot_proxygen import settings_file
def _yaml_settings_file_source(_):
with settings_file().open() as yaml_file:
settings = yaml.safe_load(yaml_file)
return settings or {}
class Settings(BaseSettings):
endpoint_url: AnyUrl = "https://proxygen.prod.api.platform.nhs.uk"
spec_output_format: Literal["json", "yaml"] = "yaml"
api: str = None
class Config:
env_prefix: Literal["PROXYGEN_CREDENTIALS_"]
@classmethod
def customise_sources(
cls,
init_settings,
env_settings,
file_secret_settings,
):
return (
init_settings,
env_settings,
_yaml_settings_file_source,
)
SETTINGS = Settings()