eodag 3.10.0__py3-none-any.whl → 4.0.0a1__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.
Files changed (68) hide show
  1. eodag/api/core.py +378 -419
  2. eodag/api/product/__init__.py +3 -3
  3. eodag/api/product/_product.py +68 -40
  4. eodag/api/product/drivers/__init__.py +3 -5
  5. eodag/api/product/drivers/base.py +1 -18
  6. eodag/api/product/metadata_mapping.py +151 -215
  7. eodag/api/search_result.py +13 -7
  8. eodag/cli.py +72 -395
  9. eodag/config.py +46 -50
  10. eodag/plugins/apis/base.py +2 -2
  11. eodag/plugins/apis/ecmwf.py +20 -21
  12. eodag/plugins/apis/usgs.py +37 -33
  13. eodag/plugins/authentication/base.py +1 -3
  14. eodag/plugins/crunch/filter_date.py +3 -3
  15. eodag/plugins/crunch/filter_latest_intersect.py +2 -2
  16. eodag/plugins/crunch/filter_latest_tpl_name.py +1 -1
  17. eodag/plugins/download/aws.py +45 -41
  18. eodag/plugins/download/base.py +13 -14
  19. eodag/plugins/download/http.py +65 -65
  20. eodag/plugins/manager.py +28 -29
  21. eodag/plugins/search/__init__.py +3 -4
  22. eodag/plugins/search/base.py +128 -77
  23. eodag/plugins/search/build_search_result.py +105 -107
  24. eodag/plugins/search/cop_marine.py +44 -47
  25. eodag/plugins/search/csw.py +33 -33
  26. eodag/plugins/search/qssearch.py +335 -354
  27. eodag/plugins/search/stac_list_assets.py +1 -1
  28. eodag/plugins/search/static_stac_search.py +31 -31
  29. eodag/resources/{product_types.yml → collections.yml} +2353 -2429
  30. eodag/resources/ext_collections.json +1 -1
  31. eodag/resources/providers.yml +2427 -2719
  32. eodag/resources/stac_provider.yml +46 -90
  33. eodag/types/queryables.py +55 -91
  34. eodag/types/search_args.py +1 -1
  35. eodag/utils/__init__.py +94 -21
  36. eodag/utils/exceptions.py +6 -6
  37. eodag/utils/free_text_search.py +3 -3
  38. {eodag-3.10.0.dist-info → eodag-4.0.0a1.dist-info}/METADATA +10 -87
  39. eodag-4.0.0a1.dist-info/RECORD +92 -0
  40. {eodag-3.10.0.dist-info → eodag-4.0.0a1.dist-info}/entry_points.txt +0 -4
  41. eodag/plugins/authentication/oauth.py +0 -60
  42. eodag/plugins/download/creodias_s3.py +0 -71
  43. eodag/plugins/download/s3rest.py +0 -351
  44. eodag/plugins/search/data_request_search.py +0 -565
  45. eodag/resources/stac.yml +0 -294
  46. eodag/resources/stac_api.yml +0 -2105
  47. eodag/rest/__init__.py +0 -24
  48. eodag/rest/cache.py +0 -70
  49. eodag/rest/config.py +0 -67
  50. eodag/rest/constants.py +0 -26
  51. eodag/rest/core.py +0 -764
  52. eodag/rest/errors.py +0 -210
  53. eodag/rest/server.py +0 -604
  54. eodag/rest/server.wsgi +0 -6
  55. eodag/rest/stac.py +0 -1032
  56. eodag/rest/templates/README +0 -1
  57. eodag/rest/types/__init__.py +0 -18
  58. eodag/rest/types/collections_search.py +0 -44
  59. eodag/rest/types/eodag_search.py +0 -386
  60. eodag/rest/types/queryables.py +0 -174
  61. eodag/rest/types/stac_search.py +0 -272
  62. eodag/rest/utils/__init__.py +0 -207
  63. eodag/rest/utils/cql_evaluate.py +0 -119
  64. eodag/rest/utils/rfc3339.py +0 -64
  65. eodag-3.10.0.dist-info/RECORD +0 -116
  66. {eodag-3.10.0.dist-info → eodag-4.0.0a1.dist-info}/WHEEL +0 -0
  67. {eodag-3.10.0.dist-info → eodag-4.0.0a1.dist-info}/licenses/LICENSE +0 -0
  68. {eodag-3.10.0.dist-info → eodag-4.0.0a1.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)