-
Notifications
You must be signed in to change notification settings - Fork 5
/
config.py
89 lines (71 loc) · 2.86 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
86
87
88
89
"""Configuration options for the Lambda backed API implementing `stac-fastapi`."""
from typing import Dict, Optional
from pydantic import AnyHttpUrl, BaseSettings, Field, root_validator
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",
)
userpool_id: Optional[str] = Field(
description="The Cognito Userpool used for authentication"
)
cognito_domain: Optional[AnyHttpUrl] = Field(
description="The base url of the Cognito domain for authorization and token urls"
)
client_id: Optional[str] = Field(description="The Cognito APP client ID")
client_secret: Optional[str] = Field(
"", description="The Cognito APP client secret"
)
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.",
)
@root_validator
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"):
missing_fields = [
field
for field in ["userpool_id", "cognito_domain", "client_id"]
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_"
veda_stac_settings = vedaSTACSettings()