stac-fastapi.api 5.2.0__tar.gz → 6.0.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_api-5.2.0 → stac_fastapi_api-6.0.0}/PKG-INFO +2 -2
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/setup.py +1 -1
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/stac_fastapi/api/app.py +8 -3
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/stac_fastapi/api/errors.py +1 -1
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/stac_fastapi/api/models.py +10 -3
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/stac_fastapi/api/openapi.py +2 -2
- stac_fastapi_api-6.0.0/stac_fastapi/api/py.typed +0 -0
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/stac_fastapi/api/routes.py +14 -18
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/stac_fastapi/api/version.py +1 -1
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/stac_fastapi.api.egg-info/PKG-INFO +2 -2
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/stac_fastapi.api.egg-info/SOURCES.txt +1 -0
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/stac_fastapi.api.egg-info/requires.txt +1 -1
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/tests/test_api.py +9 -5
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/tests/test_models.py +4 -1
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/README.md +0 -0
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/setup.cfg +0 -0
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/stac_fastapi/api/__init__.py +0 -0
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/stac_fastapi/api/config.py +0 -0
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/stac_fastapi/api/middleware.py +0 -0
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/stac_fastapi.api.egg-info/dependency_links.txt +0 -0
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/stac_fastapi.api.egg-info/not-zip-safe +0 -0
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/stac_fastapi.api.egg-info/top_level.txt +0 -0
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/tests/test_app.py +0 -0
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/tests/test_app_prefix.py +0 -0
- {stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/tests/test_middleware.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: stac-fastapi.api
|
|
3
|
-
Version:
|
|
3
|
+
Version: 6.0.0
|
|
4
4
|
Summary: An implementation of STAC API based on the FastAPI framework.
|
|
5
5
|
Home-page: https://github.com/stac-utils/stac-fastapi
|
|
6
6
|
Author: Arturo Engineering
|
|
@@ -19,7 +19,7 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
19
19
|
Requires-Python: >=3.9
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
Requires-Dist: brotli_asgi
|
|
22
|
-
Requires-Dist: stac-fastapi.types~=
|
|
22
|
+
Requires-Dist: stac-fastapi.types~=6.0
|
|
23
23
|
Provides-Extra: dev
|
|
24
24
|
Requires-Dist: httpx; extra == "dev"
|
|
25
25
|
Requires-Dist: pytest; extra == "dev"
|
|
@@ -12,7 +12,7 @@ from stac_pydantic.api.collections import Collections
|
|
|
12
12
|
from stac_pydantic.shared import MimeTypes
|
|
13
13
|
from stac_pydantic.version import STAC_VERSION
|
|
14
14
|
from starlette.middleware import Middleware
|
|
15
|
-
from starlette.responses import
|
|
15
|
+
from starlette.responses import Response
|
|
16
16
|
|
|
17
17
|
from stac_fastapi.api.errors import DEFAULT_STATUS_CODES, add_exception_handlers
|
|
18
18
|
from stac_fastapi.api.middleware import CORSMiddleware, ProxyHeaderMiddleware
|
|
@@ -21,8 +21,10 @@ from stac_fastapi.api.models import (
|
|
|
21
21
|
CollectionUri,
|
|
22
22
|
EmptyRequest,
|
|
23
23
|
GeoJSONResponse,
|
|
24
|
+
HealthCheck,
|
|
24
25
|
ItemCollectionUri,
|
|
25
26
|
ItemUri,
|
|
27
|
+
JSONResponse,
|
|
26
28
|
)
|
|
27
29
|
from stac_fastapi.api.openapi import update_openapi
|
|
28
30
|
from stac_fastapi.api.routes import (
|
|
@@ -108,7 +110,7 @@ class StacApi:
|
|
|
108
110
|
),
|
|
109
111
|
takes_self=True,
|
|
110
112
|
),
|
|
111
|
-
converter=update_openapi,
|
|
113
|
+
converter=update_openapi, # type: ignore
|
|
112
114
|
)
|
|
113
115
|
router: APIRouter = attr.ib(default=attr.Factory(APIRouter))
|
|
114
116
|
search_get_request_model: Type[BaseSearchGetRequest] = attr.ib(
|
|
@@ -396,12 +398,15 @@ class StacApi:
|
|
|
396
398
|
mgmt_router.add_api_route(
|
|
397
399
|
name="Health",
|
|
398
400
|
path="/_mgmt/health",
|
|
399
|
-
response_model=
|
|
401
|
+
response_model=(
|
|
402
|
+
HealthCheck if self.settings.enable_response_models else None
|
|
403
|
+
),
|
|
400
404
|
responses={
|
|
401
405
|
200: {
|
|
402
406
|
"content": {
|
|
403
407
|
MimeTypes.json.value: {},
|
|
404
408
|
},
|
|
409
|
+
"model": HealthCheck,
|
|
405
410
|
},
|
|
406
411
|
},
|
|
407
412
|
response_class=self.response_class,
|
|
@@ -8,8 +8,8 @@ from fastapi.encoders import jsonable_encoder
|
|
|
8
8
|
from fastapi.exceptions import RequestValidationError, ResponseValidationError
|
|
9
9
|
from starlette import status
|
|
10
10
|
from starlette.requests import Request
|
|
11
|
-
from starlette.responses import JSONResponse
|
|
12
11
|
|
|
12
|
+
from stac_fastapi.api.models import JSONResponse
|
|
13
13
|
from stac_fastapi.types.errors import (
|
|
14
14
|
ConflictError,
|
|
15
15
|
DatabaseError,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Api request/response models."""
|
|
2
2
|
|
|
3
|
-
from typing import List, Optional, Type, Union
|
|
3
|
+
from typing import List, Literal, Optional, Type, Union
|
|
4
4
|
|
|
5
5
|
import attr
|
|
6
6
|
from fastapi import Path, Query
|
|
@@ -56,7 +56,8 @@ def create_request_model(
|
|
|
56
56
|
for model in models:
|
|
57
57
|
for k, field_info in model.model_fields.items():
|
|
58
58
|
fields[k] = (field_info.annotation, field_info)
|
|
59
|
-
|
|
59
|
+
|
|
60
|
+
return create_model(model_name, **fields, __base__=base_model) # type: ignore
|
|
60
61
|
|
|
61
62
|
raise TypeError("Mixed Request Model types. Check extension request types.")
|
|
62
63
|
|
|
@@ -121,7 +122,7 @@ class ItemCollectionUri(APIRequest, DatetimeMixin):
|
|
|
121
122
|
description="Limits the number of results that are included in each page of the response (capped to 10_000)." # noqa: E501
|
|
122
123
|
),
|
|
123
124
|
] = attr.ib(default=10)
|
|
124
|
-
bbox: Optional[BBox] = attr.ib(default=None, converter=_bbox_converter)
|
|
125
|
+
bbox: Optional[BBox] = attr.ib(default=None, converter=_bbox_converter) # type: ignore
|
|
125
126
|
datetime: DateTimeQueryType = attr.ib(default=None, validator=_validate_datetime)
|
|
126
127
|
|
|
127
128
|
|
|
@@ -135,3 +136,9 @@ class JSONSchemaResponse(JSONResponse):
|
|
|
135
136
|
"""JSON with custom, vendor content-type."""
|
|
136
137
|
|
|
137
138
|
media_type = "application/schema+json"
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
class HealthCheck(BaseModel, extra="allow"):
|
|
142
|
+
"""health check response model."""
|
|
143
|
+
|
|
144
|
+
status: Literal["UP", "DOWN"]
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from fastapi import FastAPI
|
|
4
4
|
from starlette.requests import Request
|
|
5
|
-
from starlette.responses import
|
|
5
|
+
from starlette.responses import Response
|
|
6
6
|
from starlette.routing import Route, request_response
|
|
7
7
|
|
|
8
8
|
|
|
@@ -22,7 +22,7 @@ def update_openapi(app: FastAPI) -> FastAPI:
|
|
|
22
22
|
# Create a patched endpoint function that modifies the content type of the response
|
|
23
23
|
async def patched_openapi_endpoint(req: Request) -> Response:
|
|
24
24
|
# Get the response from the old endpoint function
|
|
25
|
-
response
|
|
25
|
+
response = await old_endpoint(req)
|
|
26
26
|
# Update the content type header in place
|
|
27
27
|
response.headers["content-type"] = "application/vnd.oai.openapi+json;version=3.0"
|
|
28
28
|
# Return the updated response
|
|
File without changes
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import copy
|
|
4
4
|
import functools
|
|
5
5
|
import inspect
|
|
6
|
-
from typing import Any, Callable, Dict, List, Optional, Type, TypedDict, Union
|
|
6
|
+
from typing import Any, Awaitable, Callable, Dict, List, Optional, Type, TypedDict, Union
|
|
7
7
|
|
|
8
8
|
from fastapi import Depends, FastAPI, params
|
|
9
9
|
from fastapi.datastructures import DefaultPlaceholder
|
|
@@ -39,7 +39,7 @@ def sync_to_async(func):
|
|
|
39
39
|
def create_async_endpoint(
|
|
40
40
|
func: Callable,
|
|
41
41
|
request_model: Union[Type[APIRequest], Type[BaseModel], Dict],
|
|
42
|
-
):
|
|
42
|
+
) -> Callable[[Any, Any], Awaitable[Any]]:
|
|
43
43
|
"""Wrap a function in a coroutine which may be used to create a FastAPI endpoint.
|
|
44
44
|
|
|
45
45
|
Synchronous functions are executed asynchronously using a background thread.
|
|
@@ -48,32 +48,28 @@ def create_async_endpoint(
|
|
|
48
48
|
if not inspect.iscoroutinefunction(func):
|
|
49
49
|
func = sync_to_async(func)
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
_endpoint: Callable[[Any, Any], Awaitable[Any]]
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
if isinstance(request_model, dict):
|
|
54
|
+
|
|
55
|
+
async def _endpoint(request: Request, request_data: Dict[str, Any]):
|
|
56
|
+
"""Endpoint."""
|
|
57
|
+
return _wrap_response(await func(request_data, request=request))
|
|
58
|
+
|
|
59
|
+
elif issubclass(request_model, APIRequest):
|
|
60
|
+
|
|
61
|
+
async def _endpoint(request: Request, request_data=Depends(request_model)):
|
|
57
62
|
"""Endpoint."""
|
|
58
63
|
return _wrap_response(await func(request=request, **request_data.kwargs()))
|
|
59
64
|
|
|
60
65
|
elif issubclass(request_model, BaseModel):
|
|
61
66
|
|
|
62
|
-
async def _endpoint(
|
|
63
|
-
request: Request,
|
|
64
|
-
request_data: request_model, # type:ignore
|
|
65
|
-
):
|
|
67
|
+
async def _endpoint(request: Request, request_data: request_model): # type: ignore
|
|
66
68
|
"""Endpoint."""
|
|
67
69
|
return _wrap_response(await func(request_data, request=request))
|
|
68
70
|
|
|
69
71
|
else:
|
|
70
|
-
|
|
71
|
-
async def _endpoint(
|
|
72
|
-
request: Request,
|
|
73
|
-
request_data: Dict[str, Any], # type:ignore
|
|
74
|
-
):
|
|
75
|
-
"""Endpoint."""
|
|
76
|
-
return _wrap_response(await func(request_data, request=request))
|
|
72
|
+
raise ValueError(f"Unsupported type for request model {type(request_model)}")
|
|
77
73
|
|
|
78
74
|
return _endpoint
|
|
79
75
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: stac-fastapi.api
|
|
3
|
-
Version:
|
|
3
|
+
Version: 6.0.0
|
|
4
4
|
Summary: An implementation of STAC API based on the FastAPI framework.
|
|
5
5
|
Home-page: https://github.com/stac-utils/stac-fastapi
|
|
6
6
|
Author: Arturo Engineering
|
|
@@ -19,7 +19,7 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
19
19
|
Requires-Python: >=3.9
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
Requires-Dist: brotli_asgi
|
|
22
|
-
Requires-Dist: stac-fastapi.types~=
|
|
22
|
+
Requires-Dist: stac-fastapi.types~=6.0
|
|
23
23
|
Provides-Extra: dev
|
|
24
24
|
Requires-Dist: httpx; extra == "dev"
|
|
25
25
|
Requires-Dist: pytest; extra == "dev"
|
|
@@ -3,10 +3,8 @@ from starlette.testclient import TestClient
|
|
|
3
3
|
|
|
4
4
|
from stac_fastapi.api.app import StacApi
|
|
5
5
|
from stac_fastapi.api.models import ItemCollectionUri, create_request_model
|
|
6
|
-
from stac_fastapi.extensions.core import
|
|
7
|
-
|
|
8
|
-
TransactionExtension,
|
|
9
|
-
)
|
|
6
|
+
from stac_fastapi.extensions.core import TokenPaginationExtension, TransactionExtension
|
|
7
|
+
from stac_fastapi.extensions.core.transaction import BaseTransactionsClient
|
|
10
8
|
from stac_fastapi.types import config, core
|
|
11
9
|
|
|
12
10
|
|
|
@@ -421,7 +419,7 @@ class DummyCoreClient(core.BaseCoreClient):
|
|
|
421
419
|
...
|
|
422
420
|
|
|
423
421
|
|
|
424
|
-
class DummyTransactionsClient(
|
|
422
|
+
class DummyTransactionsClient(BaseTransactionsClient):
|
|
425
423
|
"""Defines a pattern for implementing the STAC transaction extension."""
|
|
426
424
|
|
|
427
425
|
def create_item(self, *args, **kwargs):
|
|
@@ -430,6 +428,9 @@ class DummyTransactionsClient(core.BaseTransactionsClient):
|
|
|
430
428
|
def update_item(self, *args, **kwargs):
|
|
431
429
|
return "dummy response"
|
|
432
430
|
|
|
431
|
+
def patch_item(self, *args, **kwargs):
|
|
432
|
+
return "dummy response"
|
|
433
|
+
|
|
433
434
|
def delete_item(self, *args, **kwargs):
|
|
434
435
|
return "dummy response"
|
|
435
436
|
|
|
@@ -439,6 +440,9 @@ class DummyTransactionsClient(core.BaseTransactionsClient):
|
|
|
439
440
|
def update_collection(self, *args, **kwargs):
|
|
440
441
|
return "dummy response"
|
|
441
442
|
|
|
443
|
+
def patch_collection(self, *args, **kwargs):
|
|
444
|
+
return "dummy response"
|
|
445
|
+
|
|
442
446
|
def delete_collection(self, *args, **kwargs):
|
|
443
447
|
return "dummy response"
|
|
444
448
|
|
|
@@ -43,7 +43,10 @@ def test_create_get_request_model():
|
|
|
43
43
|
model = request_model(bbox="0,0,0,1,1,1")
|
|
44
44
|
assert model.bbox == (0.0, 0.0, 0.0, 1.0, 1.0, 1.0)
|
|
45
45
|
|
|
46
|
-
with pytest.raises(
|
|
46
|
+
with pytest.raises(HTTPException):
|
|
47
|
+
request_model(bbox="a,b")
|
|
48
|
+
|
|
49
|
+
with pytest.raises(HTTPException):
|
|
47
50
|
request_model(bbox="0,0,0,1,1")
|
|
48
51
|
|
|
49
52
|
model = request_model(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stac_fastapi_api-5.2.0 → stac_fastapi_api-6.0.0}/stac_fastapi.api.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|