eodag 3.10.1__py3-none-any.whl → 4.0.0a2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- eodag/__init__.py +6 -1
- eodag/api/collection.py +353 -0
- eodag/api/core.py +606 -641
- eodag/api/product/__init__.py +3 -3
- eodag/api/product/_product.py +74 -56
- eodag/api/product/drivers/__init__.py +4 -46
- eodag/api/product/drivers/base.py +0 -28
- eodag/api/product/metadata_mapping.py +178 -216
- eodag/api/search_result.py +156 -15
- eodag/cli.py +83 -403
- eodag/config.py +81 -51
- eodag/plugins/apis/base.py +2 -2
- eodag/plugins/apis/ecmwf.py +36 -25
- eodag/plugins/apis/usgs.py +55 -40
- eodag/plugins/authentication/base.py +1 -3
- eodag/plugins/crunch/filter_date.py +3 -3
- eodag/plugins/crunch/filter_latest_intersect.py +2 -2
- eodag/plugins/crunch/filter_latest_tpl_name.py +1 -1
- eodag/plugins/download/aws.py +46 -42
- eodag/plugins/download/base.py +13 -14
- eodag/plugins/download/http.py +65 -65
- eodag/plugins/manager.py +28 -29
- eodag/plugins/search/__init__.py +6 -4
- eodag/plugins/search/base.py +131 -80
- eodag/plugins/search/build_search_result.py +245 -173
- eodag/plugins/search/cop_marine.py +87 -56
- eodag/plugins/search/csw.py +47 -37
- eodag/plugins/search/qssearch.py +653 -429
- eodag/plugins/search/stac_list_assets.py +1 -1
- eodag/plugins/search/static_stac_search.py +43 -44
- eodag/resources/{product_types.yml → collections.yml} +2594 -2453
- eodag/resources/ext_collections.json +1 -1
- eodag/resources/ext_product_types.json +1 -1
- eodag/resources/providers.yml +2706 -2733
- eodag/resources/stac_provider.yml +50 -92
- eodag/resources/user_conf_template.yml +9 -0
- eodag/types/__init__.py +2 -0
- eodag/types/queryables.py +70 -91
- eodag/types/search_args.py +1 -1
- eodag/utils/__init__.py +97 -21
- eodag/utils/dates.py +0 -12
- eodag/utils/exceptions.py +6 -6
- eodag/utils/free_text_search.py +3 -3
- eodag/utils/repr.py +2 -0
- {eodag-3.10.1.dist-info → eodag-4.0.0a2.dist-info}/METADATA +13 -99
- eodag-4.0.0a2.dist-info/RECORD +93 -0
- {eodag-3.10.1.dist-info → eodag-4.0.0a2.dist-info}/entry_points.txt +0 -4
- eodag/plugins/authentication/oauth.py +0 -60
- eodag/plugins/download/creodias_s3.py +0 -71
- eodag/plugins/download/s3rest.py +0 -351
- eodag/plugins/search/data_request_search.py +0 -565
- eodag/resources/stac.yml +0 -294
- eodag/resources/stac_api.yml +0 -2105
- eodag/rest/__init__.py +0 -24
- eodag/rest/cache.py +0 -70
- eodag/rest/config.py +0 -67
- eodag/rest/constants.py +0 -26
- eodag/rest/core.py +0 -764
- eodag/rest/errors.py +0 -210
- eodag/rest/server.py +0 -604
- eodag/rest/server.wsgi +0 -6
- eodag/rest/stac.py +0 -1032
- eodag/rest/templates/README +0 -1
- eodag/rest/types/__init__.py +0 -18
- eodag/rest/types/collections_search.py +0 -44
- eodag/rest/types/eodag_search.py +0 -386
- eodag/rest/types/queryables.py +0 -174
- eodag/rest/types/stac_search.py +0 -272
- eodag/rest/utils/__init__.py +0 -207
- eodag/rest/utils/cql_evaluate.py +0 -119
- eodag/rest/utils/rfc3339.py +0 -64
- eodag-3.10.1.dist-info/RECORD +0 -116
- {eodag-3.10.1.dist-info → eodag-4.0.0a2.dist-info}/WHEEL +0 -0
- {eodag-3.10.1.dist-info → eodag-4.0.0a2.dist-info}/licenses/LICENSE +0 -0
- {eodag-3.10.1.dist-info → eodag-4.0.0a2.dist-info}/top_level.txt +0 -0
eodag/rest/errors.py
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
# Copyright 2024, CS GROUP - France, https://www.csgroup.eu/
|
|
3
|
-
#
|
|
4
|
-
# This file is part of EODAG project
|
|
5
|
-
# https://www.github.com/CS-SI/EODAG
|
|
6
|
-
#
|
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
# you may not use this file except in compliance with the License.
|
|
9
|
-
# You may obtain a copy of the License at
|
|
10
|
-
#
|
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
#
|
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
# See the License for the specific language governing permissions and
|
|
17
|
-
# limitations under the License.
|
|
18
|
-
import logging
|
|
19
|
-
import re
|
|
20
|
-
import warnings
|
|
21
|
-
from typing import Union
|
|
22
|
-
|
|
23
|
-
from fastapi import FastAPI, Request
|
|
24
|
-
from fastapi.responses import ORJSONResponse
|
|
25
|
-
from starlette import status
|
|
26
|
-
from starlette.exceptions import HTTPException as StarletteHTTPException
|
|
27
|
-
|
|
28
|
-
from eodag.rest.types.eodag_search import EODAGSearch
|
|
29
|
-
from eodag.utils.exceptions import (
|
|
30
|
-
AuthenticationError,
|
|
31
|
-
DownloadError,
|
|
32
|
-
EodagError,
|
|
33
|
-
MisconfiguredError,
|
|
34
|
-
NoMatchingProductType,
|
|
35
|
-
NotAvailableError,
|
|
36
|
-
PluginImplementationError,
|
|
37
|
-
RequestError,
|
|
38
|
-
TimeOutError,
|
|
39
|
-
UnsupportedProductType,
|
|
40
|
-
UnsupportedProvider,
|
|
41
|
-
ValidationError,
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
EODAG_DEFAULT_STATUS_CODES = {
|
|
45
|
-
AuthenticationError: status.HTTP_500_INTERNAL_SERVER_ERROR,
|
|
46
|
-
DownloadError: status.HTTP_500_INTERNAL_SERVER_ERROR,
|
|
47
|
-
MisconfiguredError: status.HTTP_500_INTERNAL_SERVER_ERROR,
|
|
48
|
-
PluginImplementationError: status.HTTP_500_INTERNAL_SERVER_ERROR,
|
|
49
|
-
NotAvailableError: status.HTTP_404_NOT_FOUND,
|
|
50
|
-
NoMatchingProductType: status.HTTP_404_NOT_FOUND,
|
|
51
|
-
TimeOutError: status.HTTP_504_GATEWAY_TIMEOUT,
|
|
52
|
-
UnsupportedProductType: status.HTTP_404_NOT_FOUND,
|
|
53
|
-
UnsupportedProvider: status.HTTP_404_NOT_FOUND,
|
|
54
|
-
ValidationError: status.HTTP_400_BAD_REQUEST,
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
warnings.warn(
|
|
58
|
-
"The module `eodag.rest.errors` is deprecated since v3.9.0 and will be removed in a future version. "
|
|
59
|
-
"The STAC server has moved to https://github.com/CS-SI/stac-fastapi-eodag",
|
|
60
|
-
category=DeprecationWarning,
|
|
61
|
-
stacklevel=2,
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
logger = logging.getLogger("eodag.rest.server")
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
class ResponseSearchError(Exception):
|
|
69
|
-
"""Represent a EODAG search error response"""
|
|
70
|
-
|
|
71
|
-
def __init__(self, errors: list[tuple[str, Exception]]) -> None:
|
|
72
|
-
self._errors = errors
|
|
73
|
-
|
|
74
|
-
@property
|
|
75
|
-
def errors(self) -> list[dict[str, Union[str, int]]]:
|
|
76
|
-
"""return errors as a list of dict"""
|
|
77
|
-
error_list: list[dict[str, Union[str, int]]] = []
|
|
78
|
-
for name, exception in self._errors:
|
|
79
|
-
|
|
80
|
-
error_dict: dict[str, Union[str, int]] = {
|
|
81
|
-
"provider": name,
|
|
82
|
-
"error": exception.__class__.__name__,
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if exception.args:
|
|
86
|
-
error_dict["message"] = exception.args[0]
|
|
87
|
-
|
|
88
|
-
if len(exception.args) > 1:
|
|
89
|
-
error_dict["detail"] = " ".join([str(i) for i in exception.args[1:]])
|
|
90
|
-
|
|
91
|
-
error_dict["status_code"] = EODAG_DEFAULT_STATUS_CODES.get(
|
|
92
|
-
type(exception), getattr(exception, "status_code", 500)
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
if type(exception) in (
|
|
96
|
-
MisconfiguredError,
|
|
97
|
-
AuthenticationError,
|
|
98
|
-
PluginImplementationError,
|
|
99
|
-
):
|
|
100
|
-
logger.error("%s: %s", type(exception).__name__, str(exception))
|
|
101
|
-
error_dict[
|
|
102
|
-
"message"
|
|
103
|
-
] = "Internal server error: please contact the administrator"
|
|
104
|
-
error_dict.pop("detail", None)
|
|
105
|
-
|
|
106
|
-
if type(exception) is ValidationError:
|
|
107
|
-
for error_param in exception.parameters:
|
|
108
|
-
error_param_pattern = rf"\b{error_param}\b"
|
|
109
|
-
if re.search(error_param_pattern, exception.message):
|
|
110
|
-
stac_param = EODAGSearch.to_stac(error_param)
|
|
111
|
-
exception.message = re.sub(
|
|
112
|
-
error_param_pattern,
|
|
113
|
-
stac_param,
|
|
114
|
-
exception.message,
|
|
115
|
-
)
|
|
116
|
-
error_dict["message"] = exception.message
|
|
117
|
-
|
|
118
|
-
error_list.append(error_dict)
|
|
119
|
-
|
|
120
|
-
return error_list
|
|
121
|
-
|
|
122
|
-
@property
|
|
123
|
-
def status_code(self) -> int:
|
|
124
|
-
"""get global errors status code"""
|
|
125
|
-
if len(self._errors) == 1 and type(self.errors[0]["status_code"]) is int:
|
|
126
|
-
return self.errors[0]["status_code"]
|
|
127
|
-
|
|
128
|
-
return 400
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
async def response_search_error_handler(
|
|
132
|
-
request: Request, exc: Exception
|
|
133
|
-
) -> ORJSONResponse:
|
|
134
|
-
"""Handle ResponseSearchError exceptions"""
|
|
135
|
-
if not isinstance(exc, ResponseSearchError):
|
|
136
|
-
return starlette_exception_handler(request, exc)
|
|
137
|
-
|
|
138
|
-
return ORJSONResponse(
|
|
139
|
-
status_code=exc.status_code,
|
|
140
|
-
content={"errors": exc.errors},
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
async def eodag_errors_handler(request: Request, exc: Exception) -> ORJSONResponse:
|
|
145
|
-
"""Handler for EODAG errors"""
|
|
146
|
-
if not isinstance(exc, EodagError):
|
|
147
|
-
return starlette_exception_handler(request, exc)
|
|
148
|
-
|
|
149
|
-
exception_status_code = getattr(exc, "status_code", None)
|
|
150
|
-
default_status_code = exception_status_code or 500
|
|
151
|
-
code = EODAG_DEFAULT_STATUS_CODES.get(type(exc), default_status_code)
|
|
152
|
-
|
|
153
|
-
detail = f"{type(exc).__name__}: {str(exc)}"
|
|
154
|
-
|
|
155
|
-
if type(exc) in (
|
|
156
|
-
MisconfiguredError,
|
|
157
|
-
AuthenticationError,
|
|
158
|
-
TimeOutError,
|
|
159
|
-
PluginImplementationError,
|
|
160
|
-
):
|
|
161
|
-
logger.error("%s: %s", type(exc).__name__, str(exc))
|
|
162
|
-
|
|
163
|
-
if type(exc) in (
|
|
164
|
-
MisconfiguredError,
|
|
165
|
-
AuthenticationError,
|
|
166
|
-
PluginImplementationError,
|
|
167
|
-
):
|
|
168
|
-
detail = "Internal server error: please contact the administrator"
|
|
169
|
-
|
|
170
|
-
if type(exc) is ValidationError:
|
|
171
|
-
for error_param in exc.parameters:
|
|
172
|
-
stac_param = EODAGSearch.to_stac(error_param)
|
|
173
|
-
exc.message = exc.message.replace(error_param, stac_param)
|
|
174
|
-
detail = exc.message
|
|
175
|
-
|
|
176
|
-
return ORJSONResponse(
|
|
177
|
-
status_code=code,
|
|
178
|
-
content={"description": detail},
|
|
179
|
-
)
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
def starlette_exception_handler(request: Request, error: Exception) -> ORJSONResponse:
|
|
183
|
-
"""Default errors handle"""
|
|
184
|
-
description = (
|
|
185
|
-
getattr(error, "description", None)
|
|
186
|
-
or getattr(error, "detail", None)
|
|
187
|
-
or str(error)
|
|
188
|
-
)
|
|
189
|
-
return ORJSONResponse(
|
|
190
|
-
status_code=getattr(error, "status_code", 500),
|
|
191
|
-
content={"description": description},
|
|
192
|
-
)
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
def add_exception_handlers(app: FastAPI) -> None:
|
|
196
|
-
"""Add exception handlers to the FastAPI application.
|
|
197
|
-
|
|
198
|
-
Args:
|
|
199
|
-
app: the FastAPI application.
|
|
200
|
-
|
|
201
|
-
Returns:
|
|
202
|
-
None
|
|
203
|
-
"""
|
|
204
|
-
app.add_exception_handler(StarletteHTTPException, starlette_exception_handler)
|
|
205
|
-
|
|
206
|
-
app.add_exception_handler(RequestError, eodag_errors_handler)
|
|
207
|
-
for exc in EODAG_DEFAULT_STATUS_CODES:
|
|
208
|
-
app.add_exception_handler(exc, eodag_errors_handler)
|
|
209
|
-
|
|
210
|
-
app.add_exception_handler(ResponseSearchError, response_search_error_handler)
|