stac-fastapi-core 4.2.0__py3-none-any.whl → 5.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.
@@ -0,0 +1,570 @@
1
+ Metadata-Version: 2.1
2
+ Name: stac-fastapi-core
3
+ Version: 5.0.0a1
4
+ Summary: Core library for the Elasticsearch and Opensearch stac-fastapi backends.
5
+ Home-page: https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch
6
+ License: MIT
7
+ Classifier: Intended Audience :: Developers
8
+ Classifier: Intended Audience :: Information Technology
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Requires-Python: >=3.9
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: fastapi~=0.109.0
19
+ Requires-Dist: attrs>=23.2.0
20
+ Requires-Dist: pydantic<3.0.0,>=2.4.1
21
+ Requires-Dist: stac-pydantic~=3.1.0
22
+ Requires-Dist: stac-fastapi.api==5.2.0
23
+ Requires-Dist: stac-fastapi.extensions==5.2.0
24
+ Requires-Dist: stac-fastapi.types==5.2.0
25
+ Requires-Dist: orjson~=3.9.0
26
+ Requires-Dist: overrides~=7.4.0
27
+ Requires-Dist: geojson-pydantic~=1.0.0
28
+ Requires-Dist: pygeofilter~=0.3.1
29
+ Requires-Dist: jsonschema~=4.0.0
30
+ Requires-Dist: slowapi~=0.1.9
31
+
32
+ # stac-fastapi-elasticsearch-opensearch
33
+
34
+ <!-- markdownlint-disable MD033 MD041 -->
35
+
36
+
37
+ <p align="left">
38
+ <img src="https://raw.githubusercontent.com/stac-utils/stac-fastapi-elasticsearch-opensearch/refs/heads/main/assets/sfeos.png" width=1000>
39
+ </p>
40
+
41
+ **Jump to:** [Project Introduction](#project-introduction---what-is-sfeos) | [Quick Start](#quick-start) | [Table of Contents](#table-of-contents)
42
+
43
+ [![Downloads](https://static.pepy.tech/badge/stac-fastapi-core?color=blue)](https://pepy.tech/project/stac-fastapi-core)
44
+ [![GitHub contributors](https://img.shields.io/github/contributors/stac-utils/stac-fastapi-elasticsearch-opensearch?color=blue)](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/graphs/contributors)
45
+ [![GitHub stars](https://img.shields.io/github/stars/stac-utils/stac-fastapi-elasticsearch-opensearch.svg?color=blue)](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/stargazers)
46
+ [![GitHub forks](https://img.shields.io/github/forks/stac-utils/stac-fastapi-elasticsearch-opensearch.svg?color=blue)](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/network/members)
47
+ [![PyPI version](https://img.shields.io/pypi/v/stac-fastapi-elasticsearch.svg?color=blue)](https://pypi.org/project/stac-fastapi-elasticsearch/)
48
+ [![STAC](https://img.shields.io/badge/STAC-1.1.0-blue.svg)](https://github.com/radiantearth/stac-spec/tree/v1.1.0)
49
+ [![stac-fastapi](https://img.shields.io/badge/stac--fastapi-5.2.0-blue.svg)](https://github.com/stac-utils/stac-fastapi)
50
+
51
+ ## Sponsors & Supporters
52
+
53
+ The following organizations have contributed time and/or funding to support the development of this project:
54
+
55
+ <p align="left">
56
+ <a href="https://healy-hyperspatial.github.io/"><img src="https://raw.githubusercontent.com/stac-utils/stac-fastapi-elasticsearch-opensearch/refs/heads/main/assets/hh-logo-blue.png" alt="Healy Hyperspatial" height="100" hspace="20"></a>
57
+ <a href="https://atomicmaps.io/"><img src="https://raw.githubusercontent.com/stac-utils/stac-fastapi-elasticsearch-opensearch/refs/heads/main/assets/am-logo-black.png" alt="Atomic Maps" height="100" hspace="20"></a>
58
+ <a href="https://remotesensing.vito.be/"><img src="https://raw.githubusercontent.com/stac-utils/stac-fastapi-elasticsearch-opensearch/refs/heads/main/assets/VITO.png" alt="VITO Remote Sensing" height="100" hspace="20"></a>
59
+ </p>
60
+
61
+ ## Project Introduction - What is SFEOS?
62
+
63
+ SFEOS (stac-fastapi-elasticsearch-opensearch) is a high-performance, scalable API implementation for serving SpatioTemporal Asset Catalog (STAC) data - an enhanced GeoJSON format designed specifically for geospatial assets like satellite imagery, aerial photography, and other Earth observation data. This project enables organizations to:
64
+
65
+ - **Efficiently catalog and search geospatial data** such as satellite imagery, aerial photography, DEMs, and other geospatial assets using Elasticsearch or OpenSearch as the database backend
66
+ - **Implement standardized STAC APIs** that support complex spatial, temporal, and property-based queries across large collections of geospatial data
67
+ - **Scale to millions of geospatial assets** with fast search performance through optimized spatial indexing and query capabilities
68
+ - **Support OGC-compliant filtering** including spatial operations (intersects, contains, etc.) and temporal queries
69
+ - **Perform geospatial aggregations** to analyze data distribution across space and time
70
+
71
+ This implementation builds on the STAC-FastAPI framework, providing a production-ready solution specifically optimized for Elasticsearch and OpenSearch databases. It's ideal for organizations managing large geospatial data catalogs who need efficient discovery and access capabilities through standardized APIs.
72
+
73
+
74
+
75
+ ## Common Deployment Patterns
76
+
77
+ stac-fastapi-elasticsearch-opensearch can be deployed in several ways depending on your needs:
78
+
79
+ - **Containerized Application**: Run as a Docker container with connections to Elasticsearch/OpenSearch databases
80
+ - **Serverless Function**: Deploy as AWS Lambda or similar serverless function with API Gateway
81
+ - **Traditional Server**: Run on virtual machines or bare metal servers in your infrastructure
82
+ - **Kubernetes**: Deploy as part of a larger microservices architecture with container orchestration
83
+
84
+ The implementation is flexible and can scale from small local deployments to large production environments serving millions of geospatial assets.
85
+
86
+ ## Technologies
87
+
88
+ This project is built on the following technologies: STAC, stac-fastapi, FastAPI, Elasticsearch, Python, OpenSearch
89
+
90
+ <p align="left">
91
+ <a href="https://stacspec.org/"><img src="https://raw.githubusercontent.com/stac-utils/stac-fastapi-elasticsearch-opensearch/refs/heads/main/assets/STAC-01.png" alt="STAC" height="100" hspace="10"></a>
92
+ <a href="https://www.python.org/"><img src="https://raw.githubusercontent.com/stac-utils/stac-fastapi-elasticsearch-opensearch/refs/heads/main/assets/python.png" alt="Python" height="80" hspace="10"></a>
93
+ <a href="https://fastapi.tiangolo.com/"><img src="https://raw.githubusercontent.com/stac-utils/stac-fastapi-elasticsearch-opensearch/refs/heads/main/assets/fastapi.svg" alt="FastAPI" height="80" hspace="10"></a>
94
+ <a href="https://www.elastic.co/"><img src="https://raw.githubusercontent.com/stac-utils/stac-fastapi-elasticsearch-opensearch/refs/heads/main/assets/elasticsearch.png" alt="Elasticsearch" height="80" hspace="10"></a>
95
+ <a href="https://opensearch.org/"><img src="https://raw.githubusercontent.com/stac-utils/stac-fastapi-elasticsearch-opensearch/refs/heads/main/assets/opensearch.svg" alt="OpenSearch" height="80" hspace="10"></a>
96
+ </p>
97
+
98
+ ## Table of Contents
99
+
100
+ - [Documentation & Resources](#documentation--resources)
101
+ - [Package Structure](#package-structure)
102
+ - [Examples](#examples)
103
+ - [Performance](#performance)
104
+ - [Quick Start](#quick-start)
105
+ - [Installation](#installation)
106
+ - [Running Locally](#running-locally)
107
+ - [Configuration reference](#configuration-reference)
108
+ - [Interacting with the API](#interacting-with-the-api)
109
+ - [Configure the API](#configure-the-api)
110
+ - [Collection pagination](#collection-pagination)
111
+ - [Ingesting Sample Data CLI Tool](#ingesting-sample-data-cli-tool)
112
+ - [Elasticsearch Mappings](#elasticsearch-mappings)
113
+ - [Managing Elasticsearch Indices](#managing-elasticsearch-indices)
114
+ - [Snapshots](#snapshots)
115
+ - [Reindexing](#reindexing)
116
+ - [Auth](#auth)
117
+ - [Aggregation](#aggregation)
118
+ - [Rate Limiting](#rate-limiting)
119
+
120
+ ## Documentation & Resources
121
+
122
+ - **Online Documentation**: [https://stac-utils.github.io/stac-fastapi-elasticsearch-opensearch](https://stac-utils.github.io/stac-fastapi-elasticsearch-opensearch/)
123
+ - **Source Code**: [https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch)
124
+ - **API Examples**: [Postman Documentation](https://documenter.getpostman.com/view/12888943/2s8ZDSdRHA) - Examples of how to use the API endpoints
125
+ - **Community**:
126
+ - [Gitter Chat](https://app.gitter.im/#/room/#stac-fastapi-elasticsearch_community:gitter.im) - For real-time discussions
127
+ - [GitHub Discussions](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/discussions) - For longer-form questions and answers
128
+
129
+ ## Package Structure
130
+
131
+ This project is organized into several packages, each with a specific purpose:
132
+
133
+ - **stac_fastapi_core**: Core functionality that's database-agnostic, including API models, extensions, and shared utilities. This package provides the foundation for building STAC API implementations with any database backend. See [stac-fastapi-mongo](https://github.com/Healy-Hyperspatial/stac-fastapi-mongo) for a working example.
134
+
135
+ - **sfeos_helpers**: Shared helper functions and utilities used by both the Elasticsearch and OpenSearch backends. This package includes:
136
+ - `database`: Specialized modules for index, document, and database utility operations
137
+ - `aggregation`: Elasticsearch/OpenSearch-specific aggregation functionality
138
+ - Shared logic and utilities that improve code reuse between backends
139
+
140
+ - **stac_fastapi_elasticsearch**: Complete implementation of the STAC API using Elasticsearch as the backend database. This package depends on both `stac_fastapi_core` and `sfeos_helpers`.
141
+ -
142
+ - **stac_fastapi_opensearch**: Complete implementation of the STAC API using OpenSearch as the backend database. This package depends on both `stac_fastapi_core` and `sfeos_helpers`.
143
+
144
+ ## Examples
145
+
146
+ The `/examples` directory contains several useful examples and reference implementations:
147
+
148
+ - **pip_docker**: Examples of running stac-fastapi-elasticsearch from PyPI in Docker without needing any code from the repository
149
+ - **auth**: Authentication examples including:
150
+ - Basic authentication
151
+ - OAuth2 with Keycloak
152
+ - Route dependencies configuration
153
+ - **rate_limit**: Example of implementing rate limiting for API requests
154
+ - **postman_collections**: Postman collection files you can import for testing API endpoints
155
+
156
+ These examples provide practical reference implementations for various deployment scenarios and features.
157
+
158
+ ## Performance
159
+
160
+ ### Direct Response Mode
161
+
162
+ - The `enable_direct_response` option is provided by the stac-fastapi core library (introduced in stac-fastapi 5.2.0) and is available in this project starting from v4.0.0.
163
+ - **Control via environment variable**: Set `ENABLE_DIRECT_RESPONSE=true` to enable this feature.
164
+ - **How it works**: When enabled, endpoints return Starlette Response objects directly, bypassing FastAPI's default serialization for improved performance.
165
+ - **Important limitation**: All FastAPI dependencies (including authentication, custom status codes, and validation) are disabled for all routes when this mode is enabled.
166
+ - **Best use case**: This mode is best suited for public or read-only APIs where authentication and custom logic are not required.
167
+ - **Default setting**: `false` for safety.
168
+ - **More information**: See [issue #347](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/issues/347) for background and implementation details.
169
+
170
+ ## Quick Start
171
+
172
+ This section helps you get up and running with stac-fastapi-elasticsearch-opensearch quickly.
173
+
174
+ ### Installation
175
+
176
+ - **For versions 4.0.0a1 and newer** (PEP 625 compliant naming):
177
+ ```bash
178
+ pip install stac-fastapi-elasticsearch # Elasticsearch backend
179
+ pip install stac-fastapi-opensearch # Opensearch backend
180
+ pip install stac-fastapi-core # Core library
181
+ ```
182
+
183
+ - **For versions 4.0.0a0 and older**:
184
+ ```bash
185
+ pip install stac-fastapi.elasticsearch # Elasticsearch backend
186
+ pip install stac-fastapi.opensearch # Opensearch backend
187
+ pip install stac-fastapi.core # Core library
188
+ ```
189
+
190
+ > **Important Note:** Starting with version 4.0.0a1, package names have changed from using periods (e.g., `stac-fastapi.core`) to using hyphens (e.g., `stac-fastapi-core`) to comply with PEP 625. The internal package structure uses underscores, but users should install with hyphens as shown above. Please update your requirements files accordingly.
191
+
192
+ ### Running Locally
193
+
194
+ There are two main ways to run the API locally:
195
+
196
+ #### Using Pre-built Docker Images
197
+
198
+ - We provide ready-to-use Docker images through GitHub Container Registry:
199
+ - [ElasticSearch backend](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pkgs/container/stac-fastapi-es)
200
+ - [OpenSearch backend](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pkgs/container/stac-fastapi-os)
201
+
202
+ - **Pull and run the images**:
203
+ ```shell
204
+ # For Elasticsearch backend
205
+ docker pull ghcr.io/stac-utils/stac-fastapi-es:latest
206
+
207
+ # For OpenSearch backend
208
+ docker pull ghcr.io/stac-utils/stac-fastapi-os:latest
209
+ ```
210
+
211
+ #### Using Docker Compose
212
+
213
+ - **Prerequisites**: Ensure [Docker Compose](https://docs.docker.com/compose/install/) or [Podman Compose](https://podman-desktop.io/docs/compose) is installed on your machine.
214
+
215
+ - **Start the API**:
216
+ ```shell
217
+ docker compose up elasticsearch app-elasticsearch
218
+ ```
219
+
220
+ - **Configuration**: By default, Docker Compose uses Elasticsearch 8.x and OpenSearch 2.11.1. To use different versions, create a `.env` file:
221
+ ```shell
222
+ ELASTICSEARCH_VERSION=8.11.0
223
+ OPENSEARCH_VERSION=2.11.1
224
+ ENABLE_DIRECT_RESPONSE=false
225
+ ```
226
+
227
+ - **Compatibility**: The most recent Elasticsearch 7.x versions should also work. See the [opensearch-py docs](https://github.com/opensearch-project/opensearch-py/blob/main/COMPATIBILITY.md) for compatibility information.
228
+
229
+
230
+
231
+ ## Configuration Reference
232
+
233
+ You can customize additional settings in your `.env` file:
234
+
235
+ | Variable | Description | Default | Required |
236
+ |------------------------------|--------------------------------------------------------------------------------------|--------------------------|---------------------------------------------------------------------------------------------|
237
+ | `ES_HOST` | Hostname for external Elasticsearch/OpenSearch. | `localhost` | Optional |
238
+ | `ES_PORT` | Port for Elasticsearch/OpenSearch. | `9200` (ES) / `9202` (OS)| Optional |
239
+ | `ES_USE_SSL` | Use SSL for connecting to Elasticsearch/OpenSearch. | `false` | Optional |
240
+ | `ES_VERIFY_CERTS` | Verify SSL certificates when connecting. | `false` | Optional |
241
+ | `STAC_FASTAPI_TITLE` | Title of the API in the documentation. | `stac-fastapi-<backend>` | Optional |
242
+ | `STAC_FASTAPI_DESCRIPTION` | Description of the API in the documentation. | N/A | Optional |
243
+ | `STAC_FASTAPI_VERSION` | API version. | `2.1` | Optional |
244
+ | `STAC_FASTAPI_LANDING_PAGE_ID` | Landing page ID | `stac-fastapi` | Optional |
245
+ | `APP_HOST` | Server bind address. | `0.0.0.0` | Optional |
246
+ | `APP_PORT` | Server port. | `8080` | Optional |
247
+ | `ENVIRONMENT` | Runtime environment. | `local` | Optional |
248
+ | `WEB_CONCURRENCY` | Number of worker processes. | `10` | Optional |
249
+ | `RELOAD` | Enable auto-reload for development. | `true` | Optional |
250
+ | `STAC_FASTAPI_RATE_LIMIT` | API rate limit per client. | `200/minute` | Optional |
251
+ | `BACKEND` | Tests-related variable | `elasticsearch` or `opensearch` based on the backend | Optional |
252
+ | `ELASTICSEARCH_VERSION` | Version of Elasticsearch to use. | `8.11.0` | Optional | |
253
+ | `OPENSEARCH_VERSION` | OpenSearch version | `2.11.1` | Optional
254
+ | `ENABLE_DIRECT_RESPONSE` | Enable direct response for maximum performance (disables all FastAPI dependencies, including authentication, custom status codes, and validation) | `false` | Optional
255
+ | `RAISE_ON_BULK_ERROR` | Controls whether bulk insert operations raise exceptions on errors. If set to `true`, the operation will stop and raise an exception when an error occurs. If set to `false`, errors will be logged, and the operation will continue. **Note:** STAC Item and ItemCollection validation errors will always raise, regardless of this flag. | `false` Optional |
256
+ | `DATABASE_REFRESH` | Controls whether database operations refresh the index immediately after changes. If set to `true`, changes will be immediately searchable. If set to `false`, changes may not be immediately visible but can improve performance for bulk operations. If set to `wait_for`, changes will wait for the next refresh cycle to become visible. | `false` | Optional |
257
+ | `ENABLE_TRANSACTIONS_EXTENSIONS` | Enables or disables the Transactions and Bulk Transactions API extensions. If set to `false`, the POST `/collections` route and related transaction endpoints (including bulk transaction operations) will be unavailable in the API. This is useful for deployments where mutating the catalog via the API should be prevented. | `true` | Optional |
258
+
259
+ > [!NOTE]
260
+ > The variables `ES_HOST`, `ES_PORT`, `ES_USE_SSL`, and `ES_VERIFY_CERTS` apply to both Elasticsearch and OpenSearch backends, so there is no need to rename the key names to `OS_` even if you're using OpenSearch.
261
+
262
+ ## Interacting with the API
263
+
264
+ - **Creating a Collection**:
265
+ ```shell
266
+ curl -X "POST" "http://localhost:8080/collections" \
267
+ -H 'Content-Type: application/json; charset=utf-8' \
268
+ -d $'{
269
+ "id": "my_collection"
270
+ }'
271
+ ```
272
+
273
+ - **Adding an Item to a Collection**:
274
+ ```shell
275
+ curl -X "POST" "http://localhost:8080/collections/my_collection/items" \
276
+ -H 'Content-Type: application/json; charset=utf-8' \
277
+ -d @item.json
278
+ ```
279
+
280
+ - **Searching for Items**:
281
+ ```shell
282
+ curl -X "GET" "http://localhost:8080/search" \
283
+ -H 'Content-Type: application/json; charset=utf-8' \
284
+ -d $'{
285
+ "collections": ["my_collection"],
286
+ "limit": 10
287
+ }'
288
+ ```
289
+
290
+ - **Filtering by Bbox**:
291
+ ```shell
292
+ curl -X "GET" "http://localhost:8080/search" \
293
+ -H 'Content-Type: application/json; charset=utf-8' \
294
+ -d $'{
295
+ "collections": ["my_collection"],
296
+ "bbox": [-180, -90, 180, 90]
297
+ }'
298
+ ```
299
+
300
+ - **Filtering by Datetime**:
301
+ ```shell
302
+ curl -X "GET" "http://localhost:8080/search" \
303
+ -H 'Content-Type: application/json; charset=utf-8' \
304
+ -d $'{
305
+ "collections": ["my_collection"],
306
+ "datetime": "2020-01-01T00:00:00Z/2020-12-31T23:59:59Z"
307
+ }'
308
+ ```
309
+
310
+ ## Configure the API
311
+
312
+ - **API Title and Description**: By default set to `stac-fastapi-<backend>`. Customize these by setting:
313
+ - `STAC_FASTAPI_TITLE`: Changes the API title in the documentation
314
+ - `STAC_FASTAPI_DESCRIPTION`: Changes the API description in the documentation
315
+
316
+ - **Database Indices**: By default, the API reads from and writes to:
317
+ - `collections` index for collections
318
+ - `items_<collection name>` indices for items
319
+ - Customize with `STAC_COLLECTIONS_INDEX` and `STAC_ITEMS_INDEX_PREFIX` environment variables
320
+
321
+ - **Root Path Configuration**: The application root path is the base URL by default.
322
+ - For AWS Lambda with Gateway API: Set `STAC_FASTAPI_ROOT_PATH` to match the Gateway API stage name (e.g., `/v1`)
323
+
324
+
325
+ ## Collection Pagination
326
+
327
+ - **Overview**: The collections route supports pagination through optional query parameters.
328
+ - **Parameters**:
329
+ - `limit`: Controls the number of collections returned per page
330
+ - `token`: Used to retrieve subsequent pages of results
331
+ - **Response Structure**: The `links` field in the response contains a `next` link with the token for the next page of results.
332
+ - **Example Usage**:
333
+ ```shell
334
+ curl -X "GET" "http://localhost:8080/collections?limit=1&token=example_token"
335
+ ```
336
+
337
+ ## Ingesting Sample Data CLI Tool
338
+
339
+ - **Overview**: The `data_loader.py` script provides a convenient way to load STAC items into the database.
340
+
341
+ - **Usage**:
342
+ ```shell
343
+ python3 data_loader.py --base-url http://localhost:8080
344
+ ```
345
+
346
+ - **Options**:
347
+ ```
348
+ --base-url TEXT Base URL of the STAC API [required]
349
+ --collection-id TEXT ID of the collection to which items are added
350
+ --use-bulk Use bulk insert method for items
351
+ --data-dir PATH Directory containing collection.json and feature
352
+ collection file
353
+ --help Show this message and exit.
354
+ ```
355
+
356
+ - **Example Workflows**:
357
+ - **Loading Sample Data**:
358
+ ```shell
359
+ python3 data_loader.py --base-url http://localhost:8080
360
+ ```
361
+ - **Loading Data to a Specific Collection**:
362
+ ```shell
363
+ python3 data_loader.py --base-url http://localhost:8080 --collection-id my-collection
364
+ ```
365
+ - **Using Bulk Insert for Performance**:
366
+ ```shell
367
+ python3 data_loader.py --base-url http://localhost:8080 --use-bulk
368
+ ```
369
+
370
+ ## Elasticsearch Mappings
371
+
372
+ - **Overview**: Mappings apply to search index, not source data. They define how documents and their fields are stored and indexed.
373
+ - **Implementation**:
374
+ - Mappings are stored in index templates that are created on application startup
375
+ - These templates are automatically applied when creating new Collection and Item indices
376
+ - The `sfeos_helpers` package contains shared mapping definitions used by both Elasticsearch and OpenSearch backends
377
+ - **Customization**: Custom mappings can be defined by extending the base mapping templates.
378
+
379
+ ## Managing Elasticsearch Indices
380
+
381
+ ### Snapshots
382
+
383
+ - **Overview**: Snapshots provide a way to backup and restore your indices.
384
+
385
+ - **Creating a Snapshot Repository**:
386
+ ```shell
387
+ curl -X "PUT" "http://localhost:9200/_snapshot/my_fs_backup" \
388
+ -H 'Content-Type: application/json; charset=utf-8' \
389
+ -d $'{
390
+ "type": "fs",
391
+ "settings": {
392
+ "location": "/usr/share/elasticsearch/snapshots/my_fs_backup"
393
+ }
394
+ }'
395
+ ```
396
+ - This creates a snapshot repository that stores files in the elasticsearch/snapshots directory in this git repo clone
397
+ - The elasticsearch.yml and compose files create a mapping from that directory to /usr/share/elasticsearch/snapshots within the Elasticsearch container and grant permissions for using it
398
+
399
+ - **Creating a Snapshot**:
400
+ ```shell
401
+ curl -X "PUT" "http://localhost:9200/_snapshot/my_fs_backup/my_snapshot_2?wait_for_completion=true" \
402
+ -H 'Content-Type: application/json; charset=utf-8' \
403
+ -d $'{
404
+ "metadata": {
405
+ "taken_because": "dump of all items",
406
+ "taken_by": "pvarner"
407
+ },
408
+ "include_global_state": false,
409
+ "ignore_unavailable": false,
410
+ "indices": "items_my-collection"
411
+ }'
412
+ ```
413
+ - This creates a snapshot named my_snapshot_2 and waits for the action to be completed before returning
414
+ - This can also be done asynchronously by omitting the wait_for_completion parameter, and queried for status later
415
+ - The indices parameter determines which indices are snapshotted, and can include wildcards
416
+
417
+ - **Viewing Snapshots**:
418
+ ```shell
419
+ # View a specific snapshot
420
+ curl http://localhost:9200/_snapshot/my_fs_backup/my_snapshot_2
421
+
422
+ # View all snapshots
423
+ curl http://localhost:9200/_snapshot/my_fs_backup/_all
424
+ ```
425
+ - These commands allow you to check the status and details of your snapshots
426
+
427
+ - **Restoring a Snapshot**:
428
+ ```shell
429
+ curl -X "POST" "http://localhost:9200/_snapshot/my_fs_backup/my_snapshot_2/_restore?wait_for_completion=true" \
430
+ -H 'Content-Type: application/json; charset=utf-8' \
431
+ -d $'{
432
+ "include_aliases": false,
433
+ "include_global_state": false,
434
+ "ignore_unavailable": true,
435
+ "rename_replacement": "items_$1-copy",
436
+ "indices": "items_*",
437
+ "rename_pattern": "items_(.+)"
438
+ }'
439
+ ```
440
+ - This specific command will restore any indices that match items_* and rename them so that the new index name will be suffixed with -copy
441
+ - The rename_pattern and rename_replacement parameters allow you to restore indices under new names
442
+
443
+ - **Updating Collection References**:
444
+ ```shell
445
+ curl -X "POST" "http://localhost:9200/items_my-collection-copy/_update_by_query" \
446
+ -H 'Content-Type: application/json; charset=utf-8' \
447
+ -d $'{
448
+ "query": {
449
+ "match_all": {}
450
+ },
451
+ "script": {
452
+ "lang": "painless",
453
+ "params": {
454
+ "collection": "my-collection-copy"
455
+ },
456
+ "source": "ctx._source.collection = params.collection"
457
+ }
458
+ }'
459
+ ```
460
+ - After restoring, the item documents have been restored in the new index (e.g., my-collection-copy), but the value of the collection field in those documents is still the original value of my-collection
461
+ - This command updates these values to match the new collection name using Elasticsearch's Update By Query feature
462
+
463
+ - **Creating a New Collection**:
464
+ ```shell
465
+ curl -X "POST" "http://localhost:8080/collections" \
466
+ -H 'Content-Type: application/json' \
467
+ -d $'{
468
+ "id": "my-collection-copy"
469
+ }'
470
+ ```
471
+ - The final step is to create a new collection through the API with the new name for each of the restored indices
472
+ - This gives you a copy of the collection that has a resource URI (/collections/my-collection-copy) and can be correctly queried by collection name
473
+
474
+ ### Reindexing
475
+
476
+ - **Overview**: Reindexing allows you to copy documents from one index to another, optionally transforming them in the process.
477
+
478
+ - **Use Cases**:
479
+ - Apply changes to documents
480
+ - Correct dynamically generated mappings
481
+ - Transform data (e.g., lowercase identifiers)
482
+ - The index templates will make sure that manually created indices will also have the correct mappings and settings
483
+
484
+ - **Example: Reindexing with Transformation**:
485
+ ```shell
486
+ curl -X "POST" "http://localhost:9200/_reindex" \
487
+ -H 'Content-Type: application/json' \
488
+ -d $'{
489
+ "source": {
490
+ "index": "items_my-collection-lower_my-collection-hex-000001"
491
+ },
492
+ "dest": {
493
+ "index": "items_my-collection-lower_my-collection-hex-000002"
494
+ },
495
+ "script": {
496
+ "source": "ctx._source.id = ctx._source.id.toLowerCase()",
497
+ "lang": "painless"
498
+ }
499
+ }'
500
+ ```
501
+ - In this example, we make a copy of an existing Item index but change the Item identifier to be lowercase
502
+ - The script parameter allows you to transform documents during the reindexing process
503
+
504
+ - **Updating Aliases**:
505
+ ```shell
506
+ curl -X "POST" "http://localhost:9200/_aliases" \
507
+ -H 'Content-Type: application/json' \
508
+ -d $'{
509
+ "actions": [
510
+ {
511
+ "remove": {
512
+ "index": "*",
513
+ "alias": "items_my-collection"
514
+ }
515
+ },
516
+ {
517
+ "add": {
518
+ "index": "items_my-collection-lower_my-collection-hex-000002",
519
+ "alias": "items_my-collection"
520
+ }
521
+ }
522
+ ]
523
+ }'
524
+ ```
525
+ - If you are happy with the data in the newly created index, you can move the alias items_my-collection to the new index
526
+ - This makes the modified Items with lowercase identifiers visible to users accessing my-collection in the STAC API
527
+ - Using aliases allows you to switch between different index versions without changing the API endpoint
528
+
529
+ ## Auth
530
+
531
+ - **Overview**: Authentication is an optional feature that can be enabled through Route Dependencies.
532
+ - **Implementation Options**:
533
+ - Basic authentication
534
+ - OAuth2 with Keycloak
535
+ - Custom route dependencies
536
+ - **Configuration**: Authentication can be configured using the `STAC_FASTAPI_ROUTE_DEPENDENCIES` environment variable.
537
+ - **Examples and Documentation**: Detailed examples and implementation guides can be found in the [examples/auth](examples/auth) directory.
538
+
539
+ ## Aggregation
540
+
541
+ - **Supported Aggregations**:
542
+ - Spatial aggregations of points and geometries
543
+ - Frequency distribution aggregation of any property including dates
544
+ - Temporal distribution of datetime values
545
+
546
+ - **Endpoint Locations**:
547
+ - Root Catalog level: `/aggregations`
548
+ - Collection level: `/<collection_id>/aggregations`
549
+
550
+ - **Implementation Details**: The `sfeos_helpers.aggregation` package provides specialized functionality for both Elasticsearch and OpenSearch backends.
551
+
552
+ - **Documentation**: Detailed information about supported aggregations can be found in [the aggregation docs](./docs/src/aggregation.md).
553
+
554
+
555
+ ## Rate Limiting
556
+
557
+ - **Overview**: Rate limiting is an optional security feature that controls API request frequency on a remote address basis.
558
+
559
+ - **Configuration**: Enabled by setting the `STAC_FASTAPI_RATE_LIMIT` environment variable:
560
+ ```
561
+ STAC_FASTAPI_RATE_LIMIT=500/minute
562
+ ```
563
+
564
+ - **Functionality**:
565
+ - Limits each client to a specified number of requests per time period (e.g., 500 requests per minute)
566
+ - Helps prevent API abuse and maintains system stability
567
+ - Ensures fair resource allocation among all clients
568
+
569
+ - **Examples**: Implementation examples are available in the [examples/rate_limit](examples/rate_limit) directory.
570
+
@@ -2,24 +2,23 @@ stac_fastapi/core/__init__.py,sha256=8izV3IWRGdXmDOK1hIPQAanbWs9EI04PJCGgqG1ZGIs
2
2
  stac_fastapi/core/base_database_logic.py,sha256=GfxPMtg2gHAZM44haIgi_9J-IG1et_FYA5xRBosJpJA,1608
3
3
  stac_fastapi/core/base_settings.py,sha256=R3_Sx7n5XpGMs3zAwFJD7y008WvGU_uI2xkaabm82Kg,239
4
4
  stac_fastapi/core/basic_auth.py,sha256=RhFv3RVSHF6OaqnaaU2DO4ncJ_S5nB1q8UNpnVJJsrk,2155
5
- stac_fastapi/core/core.py,sha256=SoJy0VLpHNBQixR-JrKg45YC3WyHCa7pLqxGFyMv7rU,41286
6
- stac_fastapi/core/database_logic.py,sha256=KXBNL47QcqYsmtRrHjKaH3r_A4Wl4DUpumSDiuj4uVU,7051
7
- stac_fastapi/core/datetime_utils.py,sha256=ICUHPgvbH-xumIKdKVtcXogaCNEsxoaVqhWlVoCx-Ug,1481
5
+ stac_fastapi/core/core.py,sha256=oFDJw7EOLGtkRX-msm4W6DaDQz_P4CgZo1TFHOGy4kI,32064
6
+ stac_fastapi/core/datetime_utils.py,sha256=oueonjfuKdsB8IF_Ow-brK_X1bXs8_GLuVZOZr_L4ws,2527
8
7
  stac_fastapi/core/rate_limit.py,sha256=Gu8dAaJReGsj1L91U6m2tflU6RahpXDRs2-AYSKoybA,1318
9
8
  stac_fastapi/core/route_dependencies.py,sha256=zefYlfQTMW292vdqmtquW4UswtBHwH5Pm-8UynyZbJQ,5522
10
9
  stac_fastapi/core/serializers.py,sha256=pJjpwA6BOHjCXBCmwVTH7MOmTjY9NXF1-i_E0yB60Zg,6228
11
10
  stac_fastapi/core/session.py,sha256=Qr080UU_7qKtIv0qZAuOV7oNUQUzT5Yn00h-m_aoCvY,473
12
- stac_fastapi/core/utilities.py,sha256=bMtM2oxTky94hFbwf_n7BcL1TY2EKq4pOx616TrZbjQ,8407
13
- stac_fastapi/core/version.py,sha256=XAYr-IO1hoDdSshTkYzWFp3wj4AdjSQwUik30pTEaAo,45
11
+ stac_fastapi/core/utilities.py,sha256=n8bK6EB3ZPl16uKtXhAVhlDiPkm9iRjRKJDzFn3ddP4,7295
12
+ stac_fastapi/core/version.py,sha256=MQ4i7PSJnhrL3abG-m_vOwI3ksvRoHcs0eiBtxywE3E,47
14
13
  stac_fastapi/core/extensions/__init__.py,sha256=2MCo0UoInkgItIM8id-rbeygzn_qUOvTGfr8jFXZjHQ,167
15
- stac_fastapi/core/extensions/aggregation.py,sha256=nH9vKlPawo9wCaYVmMMh0_iHQbQbF7GwVuwWVZoC_P4,23068
14
+ stac_fastapi/core/extensions/aggregation.py,sha256=v1hUHqlYuMqfQ554g3cTp16pUyRYucQxPERbHPAFtf8,1878
16
15
  stac_fastapi/core/extensions/fields.py,sha256=NCT5XHvfaf297eDPNaIFsIzvJnbbUTpScqF0otdx0NA,1066
17
- stac_fastapi/core/extensions/filter.py,sha256=ytF0zzDX_FZAv2Rz7bd4C0dFnMcdg3EXjALOmOKpCmY,6745
16
+ stac_fastapi/core/extensions/filter.py,sha256=QYsu8hUyqZDKycpMkKOAAW7Vd7KVl2Q-1k3mX-aWQI0,3246
18
17
  stac_fastapi/core/extensions/query.py,sha256=Xmo8pfZEZKPudZEjjozv3R0wLOP0ayjC9E67sBOXqWY,1803
19
18
  stac_fastapi/core/models/__init__.py,sha256=g-D1DiGfmC9Bg27DW9JzkN6fAvscv75wyhyiZ6NzvIk,48
20
19
  stac_fastapi/core/models/links.py,sha256=3jk4t2wA3RGTq9_BbzFsMKvMbgDBajQy4vKZFSHt7E8,6666
21
20
  stac_fastapi/core/models/search.py,sha256=7SgAUyzHGXBXSqB4G6cwq9FMwoAS00momb7jvBkjyow,27
22
- stac_fastapi_core-4.2.0.dist-info/METADATA,sha256=IgYty3ErvzuKDsaWAujVjJBtxYMq1UM_iTgxDARs9aY,21549
23
- stac_fastapi_core-4.2.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
24
- stac_fastapi_core-4.2.0.dist-info/top_level.txt,sha256=vqn-D9-HsRPTTxy0Vk_KkDmTiMES4owwBQ3ydSZYb2s,13
25
- stac_fastapi_core-4.2.0.dist-info/RECORD,,
21
+ stac_fastapi_core-5.0.0a1.dist-info/METADATA,sha256=PHt2MIEtHfqLkPApcbEaTkJ0zFd01or4gVfx5mjJUKU,31595
22
+ stac_fastapi_core-5.0.0a1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
23
+ stac_fastapi_core-5.0.0a1.dist-info/top_level.txt,sha256=vqn-D9-HsRPTTxy0Vk_KkDmTiMES4owwBQ3ydSZYb2s,13
24
+ stac_fastapi_core-5.0.0a1.dist-info/RECORD,,