stac-fastapi.extensions 6.3.2__tar.gz → 6.4.0__tar.gz
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.
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/PKG-INFO +3 -3
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/pyproject.toml +2 -2
- stac_fastapi_extensions-6.4.0/stac_fastapi/extensions/sort/__init__.py +20 -0
- stac_fastapi_extensions-6.4.0/stac_fastapi/extensions/sort/client.py +107 -0
- stac_fastapi_extensions-6.4.0/stac_fastapi/extensions/sort/sort.py +289 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/version.py +1 -1
- stac_fastapi_extensions-6.3.2/stac_fastapi/extensions/sort/__init__.py +0 -5
- stac_fastapi_extensions-6.3.2/stac_fastapi/extensions/sort/sort.py +0 -55
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/.gitignore +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/README.md +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/__init__.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/aggregation/__init__.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/aggregation/aggregation.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/aggregation/client.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/aggregation/request.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/aggregation/types.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/bulk_transactions/__init__.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/bulk_transactions/bulk_transactions.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/collection_search/__init__.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/collection_search/client.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/collection_search/collection_search.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/collection_search/request.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/core/__init__.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/fields/__init__.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/fields/fields.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/fields/request.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/filter/__init__.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/filter/client.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/filter/filter.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/filter/request.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/free_text/__init__.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/free_text/free_text.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/free_text/request.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/pagination/__init__.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/pagination/offset_pagination.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/pagination/pagination.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/pagination/request.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/pagination/token_pagination.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/py.typed +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/query/__init__.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/query/query.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/query/request.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/sort/request.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/third_party/__init__.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/transaction/__init__.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/transaction/client.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/transaction/request.py +0 -0
- {stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/transaction/transaction.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: stac-fastapi-extensions
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.4.0
|
|
4
4
|
Summary: Extensions for stac-fastapi apis.
|
|
5
5
|
Project-URL: Homepage, https://github.com/stac-utils/stac-fastapi
|
|
6
6
|
Author-email: ArturoAI <engineering@arturo.ai>
|
|
@@ -16,5 +16,5 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.13
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.14
|
|
18
18
|
Requires-Python: >=3.11
|
|
19
|
-
Requires-Dist: stac-fastapi-api~=6.
|
|
20
|
-
Requires-Dist: stac-fastapi-types~=6.
|
|
19
|
+
Requires-Dist: stac-fastapi-api~=6.4
|
|
20
|
+
Requires-Dist: stac-fastapi-types~=6.4
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Sort extension module."""
|
|
2
|
+
|
|
3
|
+
from .client import AsyncBaseSortablesClient, BaseSortablesClient
|
|
4
|
+
from .sort import (
|
|
5
|
+
CollectionSearchSortExtension,
|
|
6
|
+
ItemCollectionSortExtension,
|
|
7
|
+
SearchSortExtension,
|
|
8
|
+
SortConformanceClasses,
|
|
9
|
+
SortExtension,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"SortExtension",
|
|
14
|
+
"SearchSortExtension",
|
|
15
|
+
"ItemCollectionSortExtension",
|
|
16
|
+
"CollectionSearchSortExtension",
|
|
17
|
+
"SortConformanceClasses",
|
|
18
|
+
"AsyncBaseSortablesClient",
|
|
19
|
+
"BaseSortablesClient",
|
|
20
|
+
]
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"""Sort extension clients."""
|
|
2
|
+
|
|
3
|
+
import abc
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
import attr
|
|
7
|
+
from starlette.requests import Request
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@attr.s
|
|
11
|
+
class AsyncBaseSortablesClient(abc.ABC):
|
|
12
|
+
"""Defines a pattern for implementing the STAC sort extension sortables endpoints."""
|
|
13
|
+
|
|
14
|
+
async def get_sortables(
|
|
15
|
+
self, request: Request | None = None, **kwargs: Any
|
|
16
|
+
) -> dict[str, Any]:
|
|
17
|
+
"""Get the sortables available for item search.
|
|
18
|
+
|
|
19
|
+
This base implementation returns a blank sortables schema.
|
|
20
|
+
"""
|
|
21
|
+
return {
|
|
22
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
23
|
+
"$id": "https://example.org/sortables",
|
|
24
|
+
"type": "object",
|
|
25
|
+
"title": "Sortables",
|
|
26
|
+
"properties": {},
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async def get_collection_sortables(
|
|
30
|
+
self, collection_id: str, request: Request | None = None, **kwargs: Any
|
|
31
|
+
) -> dict[str, Any]:
|
|
32
|
+
"""Get the sortables available for a specific collection.
|
|
33
|
+
|
|
34
|
+
This base implementation returns a blank sortables schema.
|
|
35
|
+
"""
|
|
36
|
+
return {
|
|
37
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
38
|
+
"$id": f"https://example.org/collections/{collection_id}/sortables",
|
|
39
|
+
"type": "object",
|
|
40
|
+
"title": "Sortables",
|
|
41
|
+
"properties": {},
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async def get_collections_sortables(
|
|
45
|
+
self, request: Request | None = None, **kwargs: Any
|
|
46
|
+
) -> dict[str, Any]:
|
|
47
|
+
"""Get the sortables available for collection search.
|
|
48
|
+
|
|
49
|
+
This base implementation returns a blank sortables schema.
|
|
50
|
+
"""
|
|
51
|
+
return {
|
|
52
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
53
|
+
"$id": "https://example.org/collections-sortables",
|
|
54
|
+
"type": "object",
|
|
55
|
+
"title": "Sortables",
|
|
56
|
+
"properties": {},
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@attr.s
|
|
61
|
+
class BaseSortablesClient(abc.ABC):
|
|
62
|
+
"""Defines a pattern for implementing the STAC sort extension sortables endpoints."""
|
|
63
|
+
|
|
64
|
+
def get_sortables(
|
|
65
|
+
self, request: Request | None = None, **kwargs: Any
|
|
66
|
+
) -> dict[str, Any]:
|
|
67
|
+
"""Get the sortables available for item search.
|
|
68
|
+
|
|
69
|
+
This base implementation returns a blank sortables schema.
|
|
70
|
+
"""
|
|
71
|
+
return {
|
|
72
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
73
|
+
"$id": "https://example.org/sortables",
|
|
74
|
+
"type": "object",
|
|
75
|
+
"title": "Sortables",
|
|
76
|
+
"properties": {},
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
def get_collection_sortables(
|
|
80
|
+
self, collection_id: str, request: Request | None = None, **kwargs: Any
|
|
81
|
+
) -> dict[str, Any]:
|
|
82
|
+
"""Get the sortables available for a specific collection.
|
|
83
|
+
|
|
84
|
+
This base implementation returns a blank sortables schema.
|
|
85
|
+
"""
|
|
86
|
+
return {
|
|
87
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
88
|
+
"$id": f"https://example.org/collections/{collection_id}/sortables",
|
|
89
|
+
"type": "object",
|
|
90
|
+
"title": "Sortables",
|
|
91
|
+
"properties": {},
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
def get_collections_sortables(
|
|
95
|
+
self, request: Request | None = None, **kwargs: Any
|
|
96
|
+
) -> dict[str, Any]:
|
|
97
|
+
"""Get the sortables available for collection search.
|
|
98
|
+
|
|
99
|
+
This base implementation returns a blank sortables schema.
|
|
100
|
+
"""
|
|
101
|
+
return {
|
|
102
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
103
|
+
"$id": "https://example.org/collections-sortables",
|
|
104
|
+
"type": "object",
|
|
105
|
+
"title": "Sortables",
|
|
106
|
+
"properties": {},
|
|
107
|
+
}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
"""Sort extension."""
|
|
2
|
+
|
|
3
|
+
from enum import StrEnum
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
import attr
|
|
7
|
+
from fastapi import APIRouter, FastAPI
|
|
8
|
+
from pydantic import BaseModel, Field
|
|
9
|
+
|
|
10
|
+
from stac_fastapi.api.models import (
|
|
11
|
+
CollectionUri,
|
|
12
|
+
EmptyRequest,
|
|
13
|
+
JSONSchemaResponse,
|
|
14
|
+
)
|
|
15
|
+
from stac_fastapi.api.routes import create_async_endpoint
|
|
16
|
+
from stac_fastapi.types.extension import ApiExtension
|
|
17
|
+
from stac_fastapi.types.search import APIRequest
|
|
18
|
+
|
|
19
|
+
from .client import AsyncBaseSortablesClient, BaseSortablesClient
|
|
20
|
+
from .request import SortExtensionGetRequest, SortExtensionPostRequest
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class SortablesSchema(BaseModel):
|
|
24
|
+
"""Pydantic model for the Sortables JSON Schema response."""
|
|
25
|
+
|
|
26
|
+
schema_url: str = Field(
|
|
27
|
+
default="https://json-schema.org/draft/2020-12/schema", alias="$schema"
|
|
28
|
+
)
|
|
29
|
+
id_url: str = Field(alias="$id")
|
|
30
|
+
type: str = "object"
|
|
31
|
+
title: str | None = "Sortables"
|
|
32
|
+
properties: dict[str, Any] = Field(default_factory=dict)
|
|
33
|
+
additionalProperties: bool = True
|
|
34
|
+
|
|
35
|
+
model_config = {
|
|
36
|
+
"populate_by_name": True,
|
|
37
|
+
"json_schema_extra": {
|
|
38
|
+
"example": {
|
|
39
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
40
|
+
"$id": "https://example.com/sortables",
|
|
41
|
+
"title": "Sortables",
|
|
42
|
+
"type": "object",
|
|
43
|
+
"properties": {
|
|
44
|
+
"id": {"type": "string"},
|
|
45
|
+
"datetime": {"type": "string", "format": "date-time"},
|
|
46
|
+
},
|
|
47
|
+
"additionalProperties": True,
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class SortConformanceClasses(StrEnum):
|
|
54
|
+
"""Conformance classes for the Sort v1.1.0 extension.
|
|
55
|
+
|
|
56
|
+
See https://github.com/stac-api-extensions/sort
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
ITEM_SEARCH_SORT = "https://api.stacspec.org/v1.1.0/item-search#sort"
|
|
60
|
+
ITEM_SEARCH_SORTABLES = "https://api.stacspec.org/v1.1.0/item-search#sortables"
|
|
61
|
+
|
|
62
|
+
FEATURES_SORT = "https://api.stacspec.org/v1.1.0/ogcapi-features#sort"
|
|
63
|
+
FEATURES_SORTABLES = (
|
|
64
|
+
"http://www.opengis.net/spec/ogcapi-features-5/1.0/conf/sortables"
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
COLLECTION_SEARCH_SORT = "https://api.stacspec.org/v1.1.0/collection-search#sort"
|
|
68
|
+
COLLECTION_SEARCH_SORTABLES = (
|
|
69
|
+
"https://api.stacspec.org/v1.1.0/collection-search#sortables"
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
SORTABLES_CONFORMANCE_URIS: frozenset[str] = frozenset(
|
|
74
|
+
{
|
|
75
|
+
SortConformanceClasses.ITEM_SEARCH_SORTABLES.value,
|
|
76
|
+
SortConformanceClasses.FEATURES_SORTABLES.value,
|
|
77
|
+
SortConformanceClasses.COLLECTION_SEARCH_SORTABLES.value,
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@attr.s
|
|
83
|
+
class SortExtension(ApiExtension):
|
|
84
|
+
"""Sort Extension.
|
|
85
|
+
|
|
86
|
+
The Sort extension adds the `sortby` parameter to search endpoints and provides
|
|
87
|
+
sortables endpoints for discovering available sort fields.
|
|
88
|
+
https://github.com/stac-api-extensions/sort
|
|
89
|
+
"""
|
|
90
|
+
|
|
91
|
+
GET: type[APIRequest] = SortExtensionGetRequest
|
|
92
|
+
POST: type[BaseModel] = SortExtensionPostRequest
|
|
93
|
+
client: AsyncBaseSortablesClient | BaseSortablesClient | None = attr.ib(default=None)
|
|
94
|
+
router: APIRouter = attr.ib(
|
|
95
|
+
factory=lambda: APIRouter(default_response_class=JSONSchemaResponse)
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
conformance_classes: list[str] = attr.ib(
|
|
99
|
+
factory=lambda: [
|
|
100
|
+
SortConformanceClasses.ITEM_SEARCH_SORT,
|
|
101
|
+
SortConformanceClasses.ITEM_SEARCH_SORTABLES,
|
|
102
|
+
SortConformanceClasses.FEATURES_SORT,
|
|
103
|
+
SortConformanceClasses.FEATURES_SORTABLES,
|
|
104
|
+
SortConformanceClasses.COLLECTION_SEARCH_SORT,
|
|
105
|
+
SortConformanceClasses.COLLECTION_SEARCH_SORTABLES,
|
|
106
|
+
]
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
def __attrs_post_init__(self):
|
|
110
|
+
"""Remove sortables conformance classes when no client is provided.
|
|
111
|
+
|
|
112
|
+
Without a client the sortables endpoints cannot be served, so the
|
|
113
|
+
associated conformance URIs are removed from the advertised list.
|
|
114
|
+
"""
|
|
115
|
+
if self.client is None:
|
|
116
|
+
self.conformance_classes = [
|
|
117
|
+
c for c in self.conformance_classes if c not in SORTABLES_CONFORMANCE_URIS
|
|
118
|
+
]
|
|
119
|
+
|
|
120
|
+
def register(self, app: FastAPI) -> None:
|
|
121
|
+
"""Register the extension with a FastAPI application.
|
|
122
|
+
|
|
123
|
+
Args:
|
|
124
|
+
app: target FastAPI application.
|
|
125
|
+
|
|
126
|
+
Returns:
|
|
127
|
+
None
|
|
128
|
+
"""
|
|
129
|
+
if self.client is None:
|
|
130
|
+
return
|
|
131
|
+
|
|
132
|
+
self.router.prefix = app.state.router_prefix
|
|
133
|
+
|
|
134
|
+
self.router.add_api_route(
|
|
135
|
+
name="Sortables",
|
|
136
|
+
path="/sortables",
|
|
137
|
+
methods=["GET"],
|
|
138
|
+
response_model=SortablesSchema,
|
|
139
|
+
response_model_exclude_none=True,
|
|
140
|
+
endpoint=create_async_endpoint(self.client.get_sortables, EmptyRequest),
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
self.router.add_api_route(
|
|
144
|
+
name="Collection Sortables",
|
|
145
|
+
path="/collections/{collection_id}/sortables",
|
|
146
|
+
methods=["GET"],
|
|
147
|
+
response_model=SortablesSchema,
|
|
148
|
+
response_model_exclude_none=True,
|
|
149
|
+
endpoint=create_async_endpoint(
|
|
150
|
+
self.client.get_collection_sortables, CollectionUri
|
|
151
|
+
),
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
self.router.add_api_route(
|
|
155
|
+
name="Collections Catalog Sortables",
|
|
156
|
+
path="/collections-sortables",
|
|
157
|
+
methods=["GET"],
|
|
158
|
+
response_model=SortablesSchema,
|
|
159
|
+
response_model_exclude_none=True,
|
|
160
|
+
endpoint=create_async_endpoint(
|
|
161
|
+
self.client.get_collections_sortables, EmptyRequest
|
|
162
|
+
),
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
app.include_router(self.router, tags=["Sort Extension"])
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
@attr.s
|
|
169
|
+
class SearchSortExtension(SortExtension):
|
|
170
|
+
"""Item Search Sort Extension.
|
|
171
|
+
|
|
172
|
+
Provides sort capabilities for the `/search` endpoint.
|
|
173
|
+
"""
|
|
174
|
+
|
|
175
|
+
conformance_classes: list[str] = attr.ib(
|
|
176
|
+
factory=lambda: [
|
|
177
|
+
SortConformanceClasses.ITEM_SEARCH_SORT,
|
|
178
|
+
SortConformanceClasses.ITEM_SEARCH_SORTABLES,
|
|
179
|
+
]
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
def register(self, app: FastAPI) -> None:
|
|
183
|
+
"""Register the extension with a FastAPI application.
|
|
184
|
+
|
|
185
|
+
Args:
|
|
186
|
+
app: target FastAPI application.
|
|
187
|
+
|
|
188
|
+
Returns:
|
|
189
|
+
None
|
|
190
|
+
"""
|
|
191
|
+
if self.client is None:
|
|
192
|
+
return
|
|
193
|
+
|
|
194
|
+
self.router.prefix = app.state.router_prefix
|
|
195
|
+
|
|
196
|
+
self.router.add_api_route(
|
|
197
|
+
name="Sortables",
|
|
198
|
+
path="/sortables",
|
|
199
|
+
methods=["GET"],
|
|
200
|
+
response_model=SortablesSchema,
|
|
201
|
+
response_model_exclude_none=True,
|
|
202
|
+
endpoint=create_async_endpoint(self.client.get_sortables, EmptyRequest),
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
app.include_router(self.router, tags=["Sort Extension"])
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
@attr.s
|
|
209
|
+
class ItemCollectionSortExtension(SortExtension):
|
|
210
|
+
"""Item Collection Sort Extension.
|
|
211
|
+
|
|
212
|
+
Provides sort capabilities for the `/collections/{id}/items` endpoint.
|
|
213
|
+
"""
|
|
214
|
+
|
|
215
|
+
conformance_classes: list[str] = attr.ib(
|
|
216
|
+
factory=lambda: [
|
|
217
|
+
SortConformanceClasses.FEATURES_SORT,
|
|
218
|
+
SortConformanceClasses.FEATURES_SORTABLES,
|
|
219
|
+
]
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
def register(self, app: FastAPI) -> None:
|
|
223
|
+
"""Register the extension with a FastAPI application.
|
|
224
|
+
|
|
225
|
+
Args:
|
|
226
|
+
app: target FastAPI application.
|
|
227
|
+
|
|
228
|
+
Returns:
|
|
229
|
+
None
|
|
230
|
+
"""
|
|
231
|
+
if self.client is None:
|
|
232
|
+
return
|
|
233
|
+
|
|
234
|
+
self.router.prefix = app.state.router_prefix
|
|
235
|
+
|
|
236
|
+
self.router.add_api_route(
|
|
237
|
+
name="Collection Sortables",
|
|
238
|
+
path="/collections/{collection_id}/sortables",
|
|
239
|
+
methods=["GET"],
|
|
240
|
+
response_model=SortablesSchema,
|
|
241
|
+
response_model_exclude_none=True,
|
|
242
|
+
endpoint=create_async_endpoint(
|
|
243
|
+
self.client.get_collection_sortables, CollectionUri
|
|
244
|
+
),
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
app.include_router(self.router, tags=["Sort Extension"])
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
@attr.s
|
|
251
|
+
class CollectionSearchSortExtension(SortExtension):
|
|
252
|
+
"""Collection Search Sort Extension.
|
|
253
|
+
|
|
254
|
+
Provides sort capabilities for the `/collections` endpoint.
|
|
255
|
+
"""
|
|
256
|
+
|
|
257
|
+
conformance_classes: list[str] = attr.ib(
|
|
258
|
+
factory=lambda: [
|
|
259
|
+
SortConformanceClasses.COLLECTION_SEARCH_SORT,
|
|
260
|
+
SortConformanceClasses.COLLECTION_SEARCH_SORTABLES,
|
|
261
|
+
]
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
def register(self, app: FastAPI) -> None:
|
|
265
|
+
"""Register the extension with a FastAPI application.
|
|
266
|
+
|
|
267
|
+
Args:
|
|
268
|
+
app: target FastAPI application.
|
|
269
|
+
|
|
270
|
+
Returns:
|
|
271
|
+
None
|
|
272
|
+
"""
|
|
273
|
+
if self.client is None:
|
|
274
|
+
return
|
|
275
|
+
|
|
276
|
+
self.router.prefix = app.state.router_prefix
|
|
277
|
+
|
|
278
|
+
self.router.add_api_route(
|
|
279
|
+
name="Collections Catalog Sortables",
|
|
280
|
+
path="/collections-sortables",
|
|
281
|
+
methods=["GET"],
|
|
282
|
+
response_model=SortablesSchema,
|
|
283
|
+
response_model_exclude_none=True,
|
|
284
|
+
endpoint=create_async_endpoint(
|
|
285
|
+
self.client.get_collections_sortables, EmptyRequest
|
|
286
|
+
),
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
app.include_router(self.router, tags=["Sort Extension"])
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"""Sort extension."""
|
|
2
|
-
|
|
3
|
-
from enum import StrEnum
|
|
4
|
-
|
|
5
|
-
import attr
|
|
6
|
-
from fastapi import FastAPI
|
|
7
|
-
from pydantic import BaseModel
|
|
8
|
-
|
|
9
|
-
from stac_fastapi.types.extension import ApiExtension
|
|
10
|
-
from stac_fastapi.types.search import APIRequest
|
|
11
|
-
|
|
12
|
-
from .request import SortExtensionGetRequest, SortExtensionPostRequest
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class SortConformanceClasses(StrEnum):
|
|
16
|
-
"""Conformance classes for the Sort extension.
|
|
17
|
-
|
|
18
|
-
See https://github.com/stac-api-extensions/sort
|
|
19
|
-
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
SEARCH = "https://api.stacspec.org/v1.0.0/item-search#sort"
|
|
23
|
-
ITEMS = "https://api.stacspec.org/v1.0.0/ogcapi-features#sort"
|
|
24
|
-
COLLECTIONS = "https://api.stacspec.org/v1.0.0-rc.1/collection-search#sort"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
@attr.s
|
|
28
|
-
class SortExtension(ApiExtension):
|
|
29
|
-
"""Sort Extension.
|
|
30
|
-
|
|
31
|
-
The Sort extension adds the `sortby` parameter to the `/search` endpoint, allowing the
|
|
32
|
-
caller to specify the sort order of the returned items.
|
|
33
|
-
https://github.com/stac-api-extensions/sort
|
|
34
|
-
"""
|
|
35
|
-
|
|
36
|
-
GET: type[APIRequest] = SortExtensionGetRequest
|
|
37
|
-
POST: type[BaseModel] = SortExtensionPostRequest
|
|
38
|
-
|
|
39
|
-
conformance_classes: list[str] = attr.ib(
|
|
40
|
-
factory=lambda: [
|
|
41
|
-
SortConformanceClasses.SEARCH,
|
|
42
|
-
]
|
|
43
|
-
)
|
|
44
|
-
schema_href: str | None = attr.ib(default=None)
|
|
45
|
-
|
|
46
|
-
def register(self, app: FastAPI) -> None:
|
|
47
|
-
"""Register the extension with a FastAPI application.
|
|
48
|
-
|
|
49
|
-
Args:
|
|
50
|
-
app: target FastAPI application.
|
|
51
|
-
|
|
52
|
-
Returns:
|
|
53
|
-
None
|
|
54
|
-
"""
|
|
55
|
-
pass
|
|
File without changes
|
|
File without changes
|
{stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stac_fastapi_extensions-6.3.2 → stac_fastapi_extensions-6.4.0}/stac_fastapi/extensions/py.typed
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|