From b4951d46be039da23a80226737fc6df64205c315 Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Tue, 25 Jun 2024 19:40:23 +0200 Subject: [PATCH 1/4] move pagination models to extensions submodule --- .../extensions/core/pagination/pagination.py | 3 +- .../extensions/core/pagination/request.py | 34 +++++++++++++++++++ .../core/pagination/token_pagination.py | 3 +- 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 stac_fastapi/extensions/stac_fastapi/extensions/core/pagination/request.py diff --git a/stac_fastapi/extensions/stac_fastapi/extensions/core/pagination/pagination.py b/stac_fastapi/extensions/stac_fastapi/extensions/core/pagination/pagination.py index 296e9ae6a..7959b0357 100644 --- a/stac_fastapi/extensions/stac_fastapi/extensions/core/pagination/pagination.py +++ b/stac_fastapi/extensions/stac_fastapi/extensions/core/pagination/pagination.py @@ -5,9 +5,10 @@ import attr from fastapi import FastAPI -from stac_fastapi.api.models import GETPagination, POSTPagination from stac_fastapi.types.extension import ApiExtension +from .request import GETPagination, POSTPagination + @attr.s class PaginationExtension(ApiExtension): diff --git a/stac_fastapi/extensions/stac_fastapi/extensions/core/pagination/request.py b/stac_fastapi/extensions/stac_fastapi/extensions/core/pagination/request.py new file mode 100644 index 000000000..9524ee324 --- /dev/null +++ b/stac_fastapi/extensions/stac_fastapi/extensions/core/pagination/request.py @@ -0,0 +1,34 @@ +"""Pagination extension request models.""" + +from typing import Optional + +import attr +from pydantic import BaseModel + +from stac_fastapi.types.search import APIRequest + + +@attr.s +class GETTokenPagination(APIRequest): + """Token pagination for GET requests.""" + + token: Optional[str] = attr.ib(default=None) + + +class POSTTokenPagination(BaseModel): + """Token pagination model for POST requests.""" + + token: Optional[str] = None + + +@attr.s +class GETPagination(APIRequest): + """Page based pagination for GET requests.""" + + page: Optional[str] = attr.ib(default=None) + + +class POSTPagination(BaseModel): + """Page based pagination for POST requests.""" + + page: Optional[str] = None diff --git a/stac_fastapi/extensions/stac_fastapi/extensions/core/pagination/token_pagination.py b/stac_fastapi/extensions/stac_fastapi/extensions/core/pagination/token_pagination.py index d3fa10391..11ccfb35b 100644 --- a/stac_fastapi/extensions/stac_fastapi/extensions/core/pagination/token_pagination.py +++ b/stac_fastapi/extensions/stac_fastapi/extensions/core/pagination/token_pagination.py @@ -5,9 +5,10 @@ import attr from fastapi import FastAPI -from stac_fastapi.api.models import GETTokenPagination, POSTTokenPagination from stac_fastapi.types.extension import ApiExtension +from .request import GETTokenPagination, POSTTokenPagination + @attr.s class TokenPaginationExtension(ApiExtension): From 3003eed294d42953619d851a6eb46e50766eff87 Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Tue, 25 Jun 2024 19:44:37 +0200 Subject: [PATCH 2/4] remove models from api --- stac_fastapi/api/stac_fastapi/api/models.py | 26 --------------------- 1 file changed, 26 deletions(-) diff --git a/stac_fastapi/api/stac_fastapi/api/models.py b/stac_fastapi/api/stac_fastapi/api/models.py index 2716fe7fb..307be14a7 100644 --- a/stac_fastapi/api/stac_fastapi/api/models.py +++ b/stac_fastapi/api/stac_fastapi/api/models.py @@ -110,32 +110,6 @@ class ItemCollectionUri(CollectionUri): datetime: Optional[DateTimeType] = attr.ib(default=None, converter=str_to_interval) -class POSTTokenPagination(BaseModel): - """Token pagination model for POST requests.""" - - token: Optional[str] = None - - -@attr.s -class GETTokenPagination(APIRequest): - """Token pagination for GET requests.""" - - token: Optional[str] = attr.ib(default=None) - - -class POSTPagination(BaseModel): - """Page based pagination for POST requests.""" - - page: Optional[str] = None - - -@attr.s -class GETPagination(APIRequest): - """Page based pagination for GET requests.""" - - page: Optional[str] = attr.ib(default=None) - - # Test for ORJSON and use it rather than stdlib JSON where supported if importlib.util.find_spec("orjson") is not None: from fastapi.responses import ORJSONResponse From 812392a78e91bd373a46eccbb6df6c343f75c64f Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Tue, 25 Jun 2024 19:55:09 +0200 Subject: [PATCH 3/4] update changelog --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index ea0209926..196babe64 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,7 @@ ### Removed * Removed the Filter Extension depenency from `AggregationExtensionPostRequest` and `AggregationExtensionGetRequest` [#716](https://github.com/stac-utils/stac-fastapi/pull/716) +* move `GETPagination`, `POSTPagination`, `GETTokenPagination` and `POSTTokenPagination` to `stac_fastapi.extensions.core.pagination.request` submodule [#717](https://github.com/stac-utils/stac-fastapi/pull/717) ## [3.0.0a3] - 2024-06-13 From f6330632205d6a0f1f1177c058b1426d89d7f7dd Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Mon, 1 Jul 2024 10:51:47 +0200 Subject: [PATCH 4/4] update changelog --- CHANGES.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index dd5755777..2b74edbb1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,10 @@ ## [Unreleased] - TBD +### Changed + +* moved `GETPagination`, `POSTPagination`, `GETTokenPagination` and `POSTTokenPagination` to `stac_fastapi.extensions.core.pagination.request` submodule [#717](https://github.com/stac-utils/stac-fastapi/pull/717) + ## [3.0.0a4] - 2024-06-27 ### Fixed @@ -11,7 +15,6 @@ ### Removed * Removed the Filter Extension depenency from `AggregationExtensionPostRequest` and `AggregationExtensionGetRequest` [#716](https://github.com/stac-utils/stac-fastapi/pull/716) -* move `GETPagination`, `POSTPagination`, `GETTokenPagination` and `POSTTokenPagination` to `stac_fastapi.extensions.core.pagination.request` submodule [#717](https://github.com/stac-utils/stac-fastapi/pull/717) * Removed `add_middleware` method in `StacApi` object and let starlette handle the middleware stack creation [721](https://github.com/stac-utils/stac-fastapi/pull/721) ## [3.0.0a3] - 2024-06-13