eodag 2.12.1__py3-none-any.whl → 3.0.0b2__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 (78) hide show
  1. eodag/api/core.py +440 -321
  2. eodag/api/product/__init__.py +5 -1
  3. eodag/api/product/_assets.py +57 -2
  4. eodag/api/product/_product.py +89 -68
  5. eodag/api/product/metadata_mapping.py +181 -66
  6. eodag/api/search_result.py +48 -1
  7. eodag/cli.py +20 -6
  8. eodag/config.py +95 -6
  9. eodag/plugins/apis/base.py +8 -165
  10. eodag/plugins/apis/ecmwf.py +36 -24
  11. eodag/plugins/apis/usgs.py +40 -24
  12. eodag/plugins/authentication/aws_auth.py +2 -2
  13. eodag/plugins/authentication/header.py +31 -6
  14. eodag/plugins/authentication/keycloak.py +13 -84
  15. eodag/plugins/authentication/oauth.py +3 -3
  16. eodag/plugins/authentication/openid_connect.py +256 -46
  17. eodag/plugins/authentication/qsauth.py +3 -0
  18. eodag/plugins/authentication/sas_auth.py +8 -1
  19. eodag/plugins/authentication/token.py +92 -46
  20. eodag/plugins/authentication/token_exchange.py +120 -0
  21. eodag/plugins/download/aws.py +86 -91
  22. eodag/plugins/download/base.py +72 -40
  23. eodag/plugins/download/http.py +607 -264
  24. eodag/plugins/download/s3rest.py +28 -15
  25. eodag/plugins/manager.py +74 -57
  26. eodag/plugins/search/__init__.py +36 -0
  27. eodag/plugins/search/base.py +225 -18
  28. eodag/plugins/search/build_search_result.py +389 -32
  29. eodag/plugins/search/cop_marine.py +378 -0
  30. eodag/plugins/search/creodias_s3.py +15 -14
  31. eodag/plugins/search/csw.py +5 -7
  32. eodag/plugins/search/data_request_search.py +44 -20
  33. eodag/plugins/search/qssearch.py +508 -203
  34. eodag/plugins/search/static_stac_search.py +99 -36
  35. eodag/resources/constraints/climate-dt.json +13 -0
  36. eodag/resources/constraints/extremes-dt.json +8 -0
  37. eodag/resources/ext_product_types.json +1 -1
  38. eodag/resources/product_types.yml +1897 -34
  39. eodag/resources/providers.yml +3539 -3277
  40. eodag/resources/stac.yml +48 -54
  41. eodag/resources/stac_api.yml +71 -25
  42. eodag/resources/stac_provider.yml +5 -0
  43. eodag/resources/user_conf_template.yml +51 -3
  44. eodag/rest/__init__.py +6 -0
  45. eodag/rest/cache.py +70 -0
  46. eodag/rest/config.py +68 -0
  47. eodag/rest/constants.py +27 -0
  48. eodag/rest/core.py +757 -0
  49. eodag/rest/server.py +397 -258
  50. eodag/rest/stac.py +438 -307
  51. eodag/rest/types/collections_search.py +44 -0
  52. eodag/rest/types/eodag_search.py +232 -43
  53. eodag/rest/types/{stac_queryables.py → queryables.py} +81 -43
  54. eodag/rest/types/stac_search.py +277 -0
  55. eodag/rest/utils/__init__.py +216 -0
  56. eodag/rest/utils/cql_evaluate.py +119 -0
  57. eodag/rest/utils/rfc3339.py +65 -0
  58. eodag/types/__init__.py +99 -9
  59. eodag/types/bbox.py +15 -14
  60. eodag/types/download_args.py +31 -0
  61. eodag/types/search_args.py +58 -7
  62. eodag/types/whoosh.py +81 -0
  63. eodag/utils/__init__.py +72 -9
  64. eodag/utils/constraints.py +37 -37
  65. eodag/utils/exceptions.py +23 -17
  66. eodag/utils/repr.py +113 -0
  67. eodag/utils/requests.py +138 -0
  68. eodag/utils/rest.py +104 -0
  69. eodag/utils/stac_reader.py +100 -16
  70. {eodag-2.12.1.dist-info → eodag-3.0.0b2.dist-info}/METADATA +65 -44
  71. eodag-3.0.0b2.dist-info/RECORD +110 -0
  72. {eodag-2.12.1.dist-info → eodag-3.0.0b2.dist-info}/WHEEL +1 -1
  73. {eodag-2.12.1.dist-info → eodag-3.0.0b2.dist-info}/entry_points.txt +6 -5
  74. eodag/plugins/apis/cds.py +0 -540
  75. eodag/rest/utils.py +0 -1133
  76. eodag-2.12.1.dist-info/RECORD +0 -94
  77. {eodag-2.12.1.dist-info → eodag-3.0.0b2.dist-info}/LICENSE +0 -0
  78. {eodag-2.12.1.dist-info → eodag-3.0.0b2.dist-info}/top_level.txt +0 -0
eodag/resources/stac.yml CHANGED
@@ -17,63 +17,88 @@
17
17
  # limitations under the License.
18
18
 
19
19
  stac_version: 1.0.0
20
- stac_api_version: 1.0.0-rc.3
20
+ stac_api_version: 1.0.0
21
21
 
22
22
  # Capabilities ----------------------------------------------------------------
23
23
 
24
24
  # https://stacspec.org/STAC-api.html#operation/getLandingPage
25
25
  landing_page:
26
- title: "EODAG"
27
26
  type: "Catalog"
28
- description: "STAC API provided by EODAG"
29
27
  links:
30
28
  - rel: self
31
29
  type: "application/json"
32
30
  href: "{catalog[root]}/"
33
31
  - rel: service-desc
34
32
  type: "application/vnd.oai.openapi+json;version=3.0"
33
+ title: "OpenAPI service description"
35
34
  href: "{catalog[root]}/api"
36
35
  - rel: service-doc
37
36
  type: "text/html"
37
+ title: "OpenAPI service documentation"
38
38
  href: "{catalog[root]}/api.html"
39
39
  - rel: conformance
40
40
  type: "application/json"
41
+ title: "STAC/WFS3 conformance classes implemented by this server"
41
42
  href: "{catalog[root]}/conformance"
42
43
  - rel: data
43
44
  type: "application/json"
44
45
  href: "{catalog[root]}/collections"
45
46
  - rel: search
47
+ type: "application/geo+json"
48
+ title: "STAC search"
46
49
  href: "{catalog[root]}/search"
47
50
  method: GET
51
+ - rel: search
52
+ type: "application/geo+json"
53
+ title: "STAC search"
54
+ href: "{catalog[root]}/search"
55
+ method: POST
48
56
  stac_version: "{stac_version}"
49
- id: eodag-stac-api
50
57
  conformsTo: "{conformance[conformsTo]}"
51
58
 
52
59
  # required by OGC API - Features
53
60
  # http://docs.opengeospatial.org/is/17-069r3/17-069r3.html#_declaration_of_conformance_classes
54
61
  conformance:
55
62
  conformsTo:
56
- - https://api.stacspec.org/v1.0.0-rc.3/core
57
- - https://api.stacspec.org/v1.0.0-rc.3/item-search
58
- - https://api.stacspec.org/v1.0.0-rc.3/ogcapi-features
59
- - https://api.stacspec.org/v1.0.0-rc.3/collections
63
+ - https://api.stacspec.org/v1.0.0/core
64
+ - https://api.stacspec.org/v1.0.0/item-search
65
+ - https://api.stacspec.org/v1.0.0/item-search#query
66
+ - https://api.stacspec.org/v1.0.0/item-search#filter
67
+ - https://api.stacspec.org/v1.0.0/item-search#sort
68
+ - https://api.stacspec.org/v1.0.0/ogcapi-features
69
+ - https://api.stacspec.org/v1.0.0/ogcapi-features#query
70
+ - https://api.stacspec.org/v1.0.0/ogcapi-features#sort
71
+ - https://api.stacspec.org/v1.0.0/collections
72
+ - https://api.stacspec.org/v1.0.0/collection-search
73
+ - https://api.stacspec.org/v1.0.0/collection-search#free-text
74
+ - https://api.stacspec.org/v1.0.0/collection-search#advanced-free-text
75
+ - http://www.opengis.net/spec/ogcapi-common-2/1.0/conf/simple-query
60
76
  - http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/core
61
77
  - http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/oas30
62
78
  - http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/geojson
79
+ - http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/filter
80
+ - http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/features-filter
81
+ - http://www.opengis.net/spec/cql2/1.0/conf/cql2-text
82
+ - http://www.opengis.net/spec/cql2/1.0/conf/cql2-json
83
+ - http://www.opengis.net/spec/cql2/1.0/conf/basic-cql2
84
+ - http://www.opengis.net/spec/cql2/1.0/conf/basic-spatial-operators
85
+ - http://www.opengis.net/spec/cql2/1.0/conf/temporal-operators
86
+ - http://www.opengis.net/spec/cql2/1.0/conf/advanced-comparison-operators
63
87
 
64
88
  # https://stacspec.org/STAC-api.html#operation/getCollections
65
89
  collections:
90
+ collections:
91
+ - "{collection}"
66
92
  links:
67
- - rel: self
68
- title: collections
69
- href: "{collections[url]}"
70
93
  - rel: root
94
+ type: "application/json"
71
95
  href: "{collections[root]}/"
72
96
  - rel: parent
97
+ type: "application/json"
73
98
  href: "{collections[root]}/"
74
- collections:
75
- - "{collection}"
76
- stac_version: "{stac_version}"
99
+ - rel: self
100
+ type: "application/json"
101
+ href: "{collections[url]}"
77
102
 
78
103
  # https://stacspec.org/STAC-api.html#operation/describeCollection
79
104
  collection:
@@ -121,14 +146,6 @@ collection:
121
146
  - '$.product_type.instrument'
122
147
  processing:level: '$.product_type.processingLevel'
123
148
 
124
- provider:
125
- name: '$.provider.name'
126
- description: '$.provider.description'
127
- # one or more of "producer" "licensor" "processor" "host"
128
- roles: '$.provider.roles'
129
- url: '$.provider.url'
130
- priority: '$.provider.priority'
131
-
132
149
  # Data ------------------------------------------------------------------------
133
150
 
134
151
  # https://stacspec.org/STAC-api.html#operation/getFeatures
@@ -147,26 +164,18 @@ items:
147
164
  - rel: parent
148
165
  title: "{catalog[id]}"
149
166
  href: "{catalog[url]}"
150
- # implement next/prev page links
151
- # https://github.com/radiantearth/stac-spec/blob/master/api-spec/api-spec.md#paging-extension
152
- - rel: next
153
- href: '$.search_results.next'
154
- title: Next page
155
- type: application/geo+json
156
- method: '$.search_results.method'
157
- body: '$.search_results.body'
158
167
  # time and date when the response was generated
159
- timeStamp: '$.search_results.timeStamp'
168
+ timeStamp: '$.timeStamp'
160
169
  # count request result
161
- numberMatched: '$.search_results.numberMatched'
170
+ numberMatched: '$.numberMatched'
162
171
  # len(features)
163
- numberReturned: '$.search_results.numberReturned'
172
+ numberReturned: '$.numberReturned'
164
173
 
165
174
  # https://stacspec.org/STAC-api.html#operation/getFeature
166
175
  item:
167
176
  stac_version: "{stac_version}"
168
177
  stac_extensions:
169
- id: '$.product.properties.title'
178
+ id: '$.product.properties.id'
170
179
  bbox:
171
180
  - '{item[geometry].bounds[0]}'
172
181
  - '{item[geometry].bounds[1]}'
@@ -204,6 +213,7 @@ item:
204
213
  version: '$.product.properties.productVersion'
205
214
  view:sun_elevation: '$.product.properties.illuminationElevationAngle'
206
215
  view:sun_azimuth: '$.product.properties.illuminationAzimuthAngle'
216
+ order:status: '{$.product.properties.storageStatus#get_group_name((?P<succeeded>ONLINE)|(?P<shipping>STAGING)|(?P<orderable>OFFLINE))}'
207
217
  links:
208
218
  - rel: self
209
219
  title: "{item[id]}"
@@ -216,20 +226,7 @@ item:
216
226
  - rel: collection
217
227
  title: "{item[collection]}"
218
228
  href: "{catalog[url]}"
219
- assets:
220
- downloadLink:
221
- title: 'Download link'
222
- href: "{catalog[url]}/items/{item[id]}/download"
223
- # https://github.com/radiantearth/stac-spec/blob/master/item-spec/item-spec.md#media-types
224
- type: 'application/zip'
225
- _dc_qs: '$.product.properties._dc_qs'
226
- thumbnail:
227
- title: 'Thumbnail'
228
- href: '$.product.properties.quicklook'
229
- type: 'image/jpeg'
230
- role: thumbnail
231
- # https://github.com/radiantearth/stac-spec/blob/master/item-spec/item-spec.md#media-types
232
- origin_assets: '$.product.assets'
229
+
233
230
  # product properties not needed in items
234
231
  metadata_ignore:
235
232
  - title
@@ -242,10 +239,12 @@ metadata_ignore:
242
239
  # extensions mapping {prefix: schema_url,}
243
240
  stac_extensions:
244
241
  eo: 'https://stac-extensions.github.io/eo/v1.0.0/schema.json'
242
+ order: 'https://stac-extensions.github.io/order/v1.1.0/schema.json'
245
243
  published: 'https://stac-extensions.github.io/timestamps/v1.0.0/schema.json'
246
244
  processing: 'https://stac-extensions.github.io/processing/v1.0.0/schema.json'
247
245
  sar: 'https://stac-extensions.github.io/sar/v1.0.0/schema.json'
248
246
  sat: 'https://stac-extensions.github.io/sat/v1.0.0/schema.json'
247
+ storage: 'https://stac-extensions.github.io/storage/v1.0.0/schema.json'
249
248
  sci: 'https://stac-extensions.github.io/scientific/v1.0.0/schema.json'
250
249
  version: 'https://stac-extensions.github.io/version/v1.0.0/schema.json'
251
250
  view: 'https://stac-extensions.github.io/view/v1.0.0/schema.json'
@@ -297,12 +296,7 @@ catalogs:
297
296
  - - "{collection[extent][temporal][interval][0][0]}"
298
297
  - "{collection[extent][temporal][interval][0][1]}"
299
298
  crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84
300
- keywords:
301
- - "{collection[keywords][0]}"
302
- - "{collection[keywords][1]}"
303
- - "{collection[keywords][2]}"
304
- - "{collection[keywords][3]}"
305
- - "{collection[keywords][4]}"
299
+ keywords: "{collection[keywords]}"
306
300
  license: "{collection[license]}"
307
301
  properties: "{collection[properties]}"
308
302
  providers: "{collection[providers]}"
@@ -107,6 +107,7 @@ paths:
107
107
  description: |-
108
108
  Fetch features in the given catalog provided with `catalogPath`.
109
109
  parameters:
110
+ - $ref: '#/components/parameters/provider'
110
111
  - $ref: '#/components/parameters/catalogPath'
111
112
  - $ref: '#/components/parameters/bbox'
112
113
  - $ref: '#/components/parameters/datetime'
@@ -130,6 +131,7 @@ paths:
130
131
  Fetch the feature with id `featureId` in the given catalog provided
131
132
  with `cataloPath`.
132
133
  parameters:
134
+ - $ref: '#/components/parameters/provider'
133
135
  - $ref: '#/components/parameters/catalogPath'
134
136
  - $ref: '#/components/parameters/featureId'
135
137
  responses:
@@ -148,6 +150,7 @@ paths:
148
150
  Download the feature with id `featureId` in the given catalog provided
149
151
  with `catalogPath`.
150
152
  parameters:
153
+ - $ref: '#/components/parameters/provider'
151
154
  - $ref: '#/components/parameters/catalogPath'
152
155
  - $ref: '#/components/parameters/featureId'
153
156
  responses:
@@ -169,9 +172,14 @@ paths:
169
172
  summary: The feature collections in the dataset.
170
173
  description: A body of Feature Collections that belong or are used together with additional links. Request may not return the full set of metadata per Feature Collection.
171
174
  operationId: getCollections
175
+ parameters:
176
+ - $ref: '#/components/parameters/provider'
177
+ - $ref: '#/components/parameters/q'
172
178
  responses:
173
179
  '200':
174
180
  $ref: '#/components/responses/Collections'
181
+ '202':
182
+ $ref: '#/components/responses/Accepted'
175
183
  '500':
176
184
  $ref: '#/components/responses/ServerError'
177
185
  /collections/{collectionId}:
@@ -225,6 +233,7 @@ paths:
225
233
  tags:
226
234
  - Data
227
235
  parameters:
236
+ - $ref: '#/components/parameters/provider'
228
237
  - $ref: '#/components/parameters/collectionId'
229
238
  - $ref: '#/components/parameters/bbox'
230
239
  - $ref: '#/components/parameters/datetime'
@@ -254,6 +263,7 @@ paths:
254
263
  tags:
255
264
  - Data
256
265
  parameters:
266
+ - $ref: '#/components/parameters/provider'
257
267
  - $ref: '#/components/parameters/collectionId'
258
268
  - $ref: '#/components/parameters/featureId'
259
269
  summary: fetch a single feature
@@ -275,6 +285,7 @@ paths:
275
285
  tags:
276
286
  - Data
277
287
  parameters:
288
+ - $ref: '#/components/parameters/provider'
278
289
  - $ref: '#/components/parameters/collectionId'
279
290
  - $ref: '#/components/parameters/featureId'
280
291
  summary: download a single feature assets archive
@@ -300,24 +311,19 @@ paths:
300
311
  description: |-
301
312
  Retrieve Items matching filters. Intended as a shorthand API for simple
302
313
  queries.
303
-
304
- This method is optional, but you MUST implement `POST /search` if you
305
- want to implement this method.
306
-
307
- If this endpoint is implemented on a server, it is required to add a
308
- link referring to this endpoint with `rel` set to `search` to the
309
- `links` array in `GET /`. As `GET` is the default method, the `method`
310
- may not be set explicitly in the link.
311
314
  operationId: getSearchSTAC
312
315
  tags:
313
316
  - STAC
314
317
  parameters:
315
- - $ref: '#/components/parameters/bbox'
316
- - $ref: '#/components/parameters/datetime'
317
- - $ref: '#/components/parameters/limit'
318
- - $ref: '#/components/parameters/intersects'
319
- - $ref: '#/components/parameters/ids'
320
- - $ref: '#/components/parameters/collectionsArray'
318
+ - $ref: '#/components/parameters/bbox'
319
+ - $ref: '#/components/parameters/datetime'
320
+ - $ref: '#/components/parameters/limit'
321
+ - $ref: '#/components/parameters/intersects'
322
+ - $ref: '#/components/parameters/ids'
323
+ - $ref: '#/components/parameters/collectionsArray'
324
+ - $ref: '#/components/parameters/provider'
325
+ - $ref: '#/components/parameters/filter'
326
+ - $ref: '#/components/parameters/sortby'
321
327
  responses:
322
328
  '200':
323
329
  description: A feature collection.
@@ -342,22 +348,22 @@ paths:
342
348
  description: |-
343
349
  Retrieve items matching filters. Intended as the standard, full-featured
344
350
  query API.
345
-
346
- This method is mandatory to implement if `GET /search` is implemented.
347
- If this endpoint is implemented on a server, it is required to add a
348
- link referring to this endpoint with `rel` set to `search` and `method`
349
- set to `POST` to the `links` array in `GET /`.
350
351
  tags:
351
352
  - STAC
352
353
  operationId: postSearchSTAC
353
354
  requestBody:
354
355
  description: |
355
- The `POST /search` JSON body specification is detailed in the [STAC specification](https://api.stacspec.org/v1.0.0/item-search/)
356
+ The `POST /search` JSON body specification is detailed in the
357
+ [STAC specification](https://api.stacspec.org/v1.0.0/item-search/).
358
+ Both [Query](https://github.com/stac-api-extensions/query) and
359
+ [Filter](https://github.com/stac-api-extensions/filter) extensions are supported.
356
360
  required: true
357
361
  content:
358
362
  application/json:
359
363
  schema:
360
- $ref: '#/components/schemas/searchBody'
364
+ allOf:
365
+ - $ref: '#/components/schemas/searchBody'
366
+ - $ref: 'https://api.stacspec.org/v1.0.0-beta.3/item-search/openapi.yaml#/components/schemas/components-schemas-searchBody'
361
367
  responses:
362
368
  '200':
363
369
  description: A feature collection.
@@ -621,6 +627,30 @@ components:
621
627
  required: false
622
628
  schema:
623
629
  type: string
630
+ filter:
631
+ name: filter
632
+ x-stac-api-fragment: filter
633
+ in: query
634
+ description: |-
635
+ A CQL filter expression for filtering items.
636
+ required: false
637
+ schema:
638
+ oneOf:
639
+ - $ref: 'https://api.stacspec.org/v1.0.0-beta.3/item-search/openapi.yaml#/components/schemas/booleanValueExpression'
640
+ - $ref: '#/components/schemas/filter-cql-text'
641
+ sortby:
642
+ name: sortby
643
+ x-stac-api-fragment: sort
644
+ in: query
645
+ description: |-
646
+ An array of property names, prefixed by either "+" for ascending or
647
+ "-" for descending. If no prefix is provided, "+" is assumed.
648
+ required: false
649
+ schema:
650
+ type: string
651
+ example: '+start_datetime'
652
+ style: form
653
+ explode: false
624
654
  schemas:
625
655
  queryProp:
626
656
  description: Apply query operations to a specific property
@@ -1125,6 +1155,10 @@ components:
1125
1155
  type: array
1126
1156
  items:
1127
1157
  $ref: '#/components/schemas/link'
1158
+ filter-cql-text:
1159
+ description: |
1160
+ A CQL filter expression in the 'cql-text' encoding.
1161
+ type: string
1128
1162
  geometryGeoJSON:
1129
1163
  oneOf:
1130
1164
  - $ref: '#/components/schemas/pointGeoJSON'
@@ -1454,6 +1488,7 @@ components:
1454
1488
  description: The search criteria
1455
1489
  type: object
1456
1490
  allOf:
1491
+ - $ref: '#/components/schemas/providerFilter'
1457
1492
  - $ref: '#/components/schemas/collectionsFilter'
1458
1493
  - $ref: '#/components/schemas/bboxFilter'
1459
1494
  - $ref: '#/components/schemas/datetimeFilter'
@@ -1470,10 +1505,12 @@ components:
1470
1505
  - 34
1471
1506
  collections:
1472
1507
  - S2_MSI_L1C
1473
- platform:
1474
- eq: S2A
1475
- eo:cloud_cover:
1476
- lte: 80
1508
+ query:
1509
+ platform:
1510
+ eq: S2A
1511
+ eo:cloud_cover:
1512
+ lte: 80
1513
+ provider: peps
1477
1514
  limit: 10
1478
1515
  limit:
1479
1516
  type: integer
@@ -1578,6 +1615,9 @@ components:
1578
1615
  properties:
1579
1616
  collections:
1580
1617
  $ref: '#/components/schemas/collectionsArray'
1618
+ providerFilter:
1619
+ type: string
1620
+ description: Only interrogate the specifiec provider
1581
1621
  queryFilter:
1582
1622
  description: An object representing a query filter.
1583
1623
  type: object
@@ -1876,6 +1916,12 @@ components:
1876
1916
  text/html:
1877
1917
  schema:
1878
1918
  type: string
1919
+ Accepted:
1920
+ description: The request has been accepted, but the data is not yet ready. Please wait a few minutes before trying again.
1921
+ content:
1922
+ application/json:
1923
+ schema:
1924
+ $ref: '#/components/schemas/exception'
1879
1925
  Collections:
1880
1926
  description: >-
1881
1927
  The feature collections shared by this API.
@@ -24,6 +24,11 @@ search:
24
24
  next_page_url_key_path: '$.links[?(@.rel="next")].href'
25
25
  next_page_query_obj_key_path: '$.links[?(@.rel="next")].body'
26
26
  next_page_merge_key_path: '$.links[?(@.rel="next")].merge'
27
+ sort:
28
+ sort_by_tpl: '{{"sortby": [ {{"field": "{sort_param}", "direction": "{sort_order}" }} ] }}'
29
+ sort_order_mapping:
30
+ ascending: asc
31
+ descending: desc
27
32
  discover_metadata:
28
33
  auto_discovery: true
29
34
  metadata_pattern: '^[a-zA-Z0-9_:-]+$'
@@ -133,15 +133,21 @@ ecmwf:
133
133
  password:
134
134
  cop_ads:
135
135
  priority: # Lower value means lower priority (Default: 0)
136
- api:
136
+ search: # Search parameters configuration
137
+ download:
138
+ extract:
137
139
  outputs_prefix:
140
+ auth:
138
141
  credentials:
139
142
  username:
140
143
  password:
141
144
  cop_cds:
142
145
  priority: # Lower value means lower priority (Default: 0)
143
- api:
146
+ search: # Search parameters configuration
147
+ download:
148
+ extract:
144
149
  outputs_prefix:
150
+ auth:
145
151
  credentials:
146
152
  username:
147
153
  password:
@@ -191,6 +197,15 @@ hydroweb_next:
191
197
  download:
192
198
  outputs_prefix:
193
199
  wekeo:
200
+ priority: # Lower value means lower priority (Default: 0)
201
+ search: # Search parameters configuration
202
+ download:
203
+ outputs_prefix:
204
+ auth:
205
+ credentials:
206
+ username:
207
+ password:
208
+ wekeo_cmems:
194
209
  priority: # Lower value means lower priority (Default: 0)
195
210
  search:
196
211
  download:
@@ -199,7 +214,6 @@ wekeo:
199
214
  credentials:
200
215
  username:
201
216
  password:
202
-
203
217
  creodias_s3:
204
218
  priority: # Lower value means lower priority (Default: 0)
205
219
  search: # Search parameters configuration
@@ -209,3 +223,37 @@ creodias_s3:
209
223
  credentials:
210
224
  aws_access_key_id:
211
225
  aws_secret_access_key:
226
+ dedt_lumi:
227
+ priority: # Lower value means lower priority (Default: 0)
228
+ search:
229
+ download:
230
+ outputs_prefix:
231
+ auth:
232
+ credentials:
233
+ username:
234
+ password:
235
+ dedl:
236
+ priority: # Lower value means lower priority (Default: 0)
237
+ search: # Search parameters configuration
238
+ download:
239
+ outputs_prefix:
240
+ auth:
241
+ credentials:
242
+ username:
243
+ password:
244
+ eumetsat_ds:
245
+ priority: # Lower value means lower priority (Default: 0)
246
+ search: # Search parameters configuration
247
+ outputs_prefix:
248
+ auth:
249
+ credentials:
250
+ username:
251
+ password:
252
+ download:
253
+ outputs_prefix:
254
+ cop_marine:
255
+ priority: # Lower value means lower priority (Default: 0)
256
+ search: # Search parameters configuration
257
+ download:
258
+ extract:
259
+ outputs_prefix:
eodag/rest/__init__.py CHANGED
@@ -16,3 +16,9 @@
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
18
  """EODAG REST API"""
19
+ try:
20
+ from fastapi import __version__ # noqa: F401
21
+ except ImportError:
22
+ raise ImportError(
23
+ f"{__name__} not available, please install eodag[server] or eodag[all]"
24
+ )
eodag/rest/cache.py ADDED
@@ -0,0 +1,70 @@
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
+ from typing import Any, Callable, Coroutine, Dict, TypeVar, cast
20
+
21
+ import orjson
22
+ from cachetools import LRUCache
23
+ from fastapi import FastAPI, Request
24
+
25
+ from eodag.rest.config import Settings
26
+ from eodag.utils import urlsplit
27
+
28
+ logger = logging.getLogger("eodag.rest.utils")
29
+
30
+ T = TypeVar("T")
31
+
32
+
33
+ def init_cache(app: FastAPI) -> None:
34
+ """Connect to local cache"""
35
+ settings = Settings.from_environment()
36
+
37
+ app.state.cache = LRUCache(maxsize=settings.cache_maxsize)
38
+
39
+
40
+ async def cached(
41
+ fn: Callable[[], Coroutine[Any, Any, T]], cache_key: str, request: Request
42
+ ) -> T:
43
+ """Either get the result from local cache or run the function and cache the result."""
44
+ settings = Settings.from_environment()
45
+
46
+ host = urlsplit(cast(str, request.state.url_root)).netloc
47
+
48
+ host_cache_key = f"{cache_key}:{host}"
49
+
50
+ try:
51
+ c: Dict[str, Any] = request.app.state.cache
52
+
53
+ if cached := c.get(host_cache_key):
54
+ logger.debug("Cache result hit")
55
+ return orjson.loads(cached) # type: ignore
56
+ except Exception as e:
57
+ logger.error(f"Error in cache: {e}")
58
+ if settings.debug:
59
+ raise
60
+
61
+ result = await fn()
62
+
63
+ try:
64
+ c[host_cache_key] = orjson.dumps(result) # type: ignore
65
+ except Exception as e:
66
+ logger.error(f"Error in cache: {e}")
67
+ if settings.debug:
68
+ raise
69
+
70
+ return result
eodag/rest/config.py ADDED
@@ -0,0 +1,68 @@
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
+ from __future__ import annotations
19
+
20
+ from functools import lru_cache
21
+ from typing import List, Union
22
+
23
+ from pydantic import Field
24
+ from pydantic.functional_validators import BeforeValidator
25
+ from pydantic_settings import BaseSettings, SettingsConfigDict
26
+ from typing_extensions import Doc
27
+
28
+ from eodag.rest.constants import DEFAULT_MAXSIZE, DEFAULT_TTL
29
+ from eodag.utils import Annotated
30
+
31
+
32
+ def str2liststr(raw: Union[str, List[str]]) -> List[str]:
33
+ """Convert str to list[str]"""
34
+ if isinstance(raw, list):
35
+ return raw
36
+ return raw.split(",")
37
+
38
+
39
+ class Settings(BaseSettings):
40
+ """EODAG Server config"""
41
+
42
+ # local cache config
43
+ cache_ttl: int = Field(default=DEFAULT_TTL)
44
+ cache_maxsize: int = Field(default=DEFAULT_MAXSIZE)
45
+
46
+ debug: bool = False
47
+
48
+ stac_api_title: str = "eodag-stac-api"
49
+ stac_api_description: str = "STAC API provided by EODAG"
50
+ stac_api_landing_id: str = "eodag-stac-api"
51
+
52
+ origin_url_blacklist: Annotated[
53
+ Union[str, List[str]],
54
+ BeforeValidator(str2liststr),
55
+ Doc(
56
+ "Hide from clients items assets' alternative URLs starting with URLs from the list"
57
+ ),
58
+ ] = Field(default=[])
59
+
60
+ model_config = SettingsConfigDict(
61
+ env_prefix="EODAG_", extra="ignore", env_nested_delimiter="__"
62
+ )
63
+
64
+ @classmethod
65
+ @lru_cache(maxsize=1)
66
+ def from_environment(cls) -> Settings:
67
+ """Get settings"""
68
+ return Settings()