-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.py
More file actions
91 lines (73 loc) · 2.94 KB
/
config.py
File metadata and controls
91 lines (73 loc) · 2.94 KB
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
90
91
# -*- coding: utf-8 -*-
# Copyright 2024, CS GROUP - France, https://www.cs-soprasteria.com
#
# This file is part of stac-fastapi-eodag project
# https://www.github.com/CS-SI/stac-fastapi-eodag
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""EODAG STAC API configuration"""
from __future__ import annotations
from functools import lru_cache
from typing import Annotated, Literal, Union
from pydantic import Field
from pydantic.functional_validators import BeforeValidator
from stac_fastapi.types.config import ApiSettings
from stac_fastapi.eodag.utils import str2liststr
class Settings(ApiSettings):
"""EODAG Server config"""
debug: bool = False
database_type: Annotated[Literal["sqlite", "postgresql"], Field] = Field(
default="sqlite",
description="Type of database to use for STAC API backend",
validate_default=False,
)
keep_origin_url: bool = Field(
default=False,
description=("Keep origin as alternate URL when data-download extension is enabled."),
)
origin_url_blacklist: Annotated[Union[str, list[str]], BeforeValidator(str2liststr)] = Field(
default=[],
description=("Hide from clients items assets' origin URLs starting with URLs from the list."),
)
auto_order_whitelist: Annotated[Union[str, list[str]], BeforeValidator(str2liststr)] = Field(
default=[
"wekeo_main",
],
description=("List of providers for which the order should be done at the same time as the download."),
)
fetch_providers: bool = Field(default=False, description="Fetch additional collections from all providers.")
count: bool = Field(
default=False,
description=("Whether to run a query with a count request or not"),
)
download_base_url: str = Field(
default="",
description="base url to be used for download link",
pattern=r"(http|https):\/\/[\w:.-]+\/",
validate_default=False,
)
validate_request: bool = Field(
default=True,
description="Validate search and product order requests",
alias="validate",
)
provider_online_status_threshold: float = Field(
default=0.8,
description="Threshold for considering a provider as online based"
"on the statuses of the all collections provided",
alias="provider_online_status_threshold",
)
@lru_cache(maxsize=1)
def get_settings() -> Settings:
"""Get settings"""
return Settings()