-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathconfig.py
85 lines (67 loc) · 2.7 KB
/
config.py
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""Configuration options for the Lambda backed API implementing `stac-fastapi`."""
from typing import Dict, Optional
from pydantic import AnyHttpUrl, Field, model_validator
from pydantic_settings import BaseSettings
class vedaSTACSettings(BaseSettings):
"""Application settings"""
env: Dict = {}
timeout: int = 30 # seconds
memory: int = 8000 # Mb
# Secret database credentials
stac_pgstac_secret_arn: Optional[str] = Field(
None,
description="Name or ARN of the AWS Secret containing database connection parameters",
)
stac_root_path: str = Field(
"",
description="Optional path prefix to add to all api endpoints",
)
raster_root_path: str = Field(
"",
description="Optional path prefix to add to all raster endpoints",
)
custom_host: str = Field(
None,
description="Complete url of custom host including subdomain. When provided, override host in api integration",
)
project_name: Optional[str] = Field(
"VEDA (Visualization, Exploration, and Data Analysis)",
description="Name of the STAC Catalog",
)
project_description: Optional[str] = Field(
"VEDA (Visualization, Exploration, and Data Analysis) is NASA's open-source Earth Science platform in the cloud.",
description="Description of the STAC Catalog",
)
keycloak_client_id: Optional[str] = Field(None, description="Auth client ID")
openid_configuration_url: Optional[AnyHttpUrl] = Field(
None, description="OpenID config url"
)
stac_enable_transactions: bool = Field(
False, description="Whether to enable transactions endpoints"
)
disable_default_apigw_endpoint: Optional[bool] = Field(
False,
description="Boolean to disable default API gateway endpoints for stac, raster, and ingest APIs. Defaults to false.",
)
@model_validator(mode="before")
def check_transaction_fields(cls, values):
"""
Validates the existence of auth env vars in case stac_enable_transactions is True
"""
if values.get("stac_enable_transactions") == "True":
missing_fields = [
field
for field in ["keycloak_client_id", "openid_configuration_url"]
if not values.get(field)
]
if missing_fields:
raise ValueError(
f"When 'stac_enable_transactions' is True, the following fields must be provided: {', '.join(missing_fields)}"
)
return values
class Config:
"""model config"""
env_file = ".env"
env_prefix = "VEDA_"
extra = "ignore"
veda_stac_settings = vedaSTACSettings()