Skip to content

Commit

Permalink
move pagination models to extensions submodule (#717)
Browse files Browse the repository at this point in the history
* move pagination models to extensions submodule

* remove models from api

* update changelog

* update changelog

---------

Co-authored-by: Jonathan Healy <[email protected]>
  • Loading branch information
vincentsarago and jonhealy1 authored Jul 1, 2024
1 parent 1916d44 commit 270e03d
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 28 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 0 additions & 26 deletions stac_fastapi/api/stac_fastapi/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 270e03d

Please sign in to comment.