Skip to content

Commit

Permalink
fix: mark pagination config kind as required
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-pinchelimouroux committed Oct 23, 2024
1 parent eed0531 commit 80325ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions toucan_connectors/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ def transform_with_jq(data: object, jq_filter: str) -> list:
)

UI_HIDDEN: dict[str, Any] = {"ui.hidden": True}
UI_REQUIRED: dict[str, Any] = {"ui.required": True}


def get_loop():
Expand Down
12 changes: 5 additions & 7 deletions toucan_connectors/http_api/pagination_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from pydantic import BaseModel, Field

from toucan_connectors.common import UI_HIDDEN, FilterSchemaDescription
from toucan_connectors.common import UI_HIDDEN, UI_REQUIRED, FilterSchemaDescription
from toucan_connectors.http_api.http_api_data_souce import HttpAPIDataSource

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -38,8 +38,6 @@ class NoopPaginationConfig(PaginationConfig):
Useful for connectors that can return all results at once.
"""

kind: Literal["NoopPaginationConfig"] = Field("NoopPaginationConfig", **UI_HIDDEN)

def apply_pagination_to_data_source(self, data_source: HttpAPIDataSource) -> HttpAPIDataSource:
return data_source

Expand All @@ -54,7 +52,7 @@ def get_error_status_whitelist(self) -> list[str] | None:


class OffsetLimitPaginationConfig(PaginationConfig):
kind: Literal["OffsetLimitPaginationConfig"] = Field("OffsetLimitPaginationConfig", **UI_HIDDEN)
kind: Literal["OffsetLimitPaginationConfig"] = Field("OffsetLimitPaginationConfig", **UI_HIDDEN, **UI_REQUIRED)
offset_name: str = "offset"
offset: int = Field(0, **UI_HIDDEN)
limit_name: str = "limit"
Expand Down Expand Up @@ -84,7 +82,7 @@ def get_pagination_info_filter(self) -> str | None:


class PageBasedPaginationConfig(PaginationConfig):
kind: Literal["PageBasedPaginationConfig"] = Field("PageBasedPaginationConfig", **UI_HIDDEN)
kind: Literal["PageBasedPaginationConfig"] = Field("PageBasedPaginationConfig", **UI_HIDDEN, **UI_REQUIRED)
page_name: str = "page"
page: int = 0
per_page_name: str | None = None
Expand Down Expand Up @@ -131,7 +129,7 @@ def get_error_status_whitelist(self) -> list[int] | None:


class CursorBasedPaginationConfig(PaginationConfig):
kind: Literal["CursorBasedPaginationConfig"] = Field("CursorBasedPaginationConfig", **UI_HIDDEN)
kind: Literal["CursorBasedPaginationConfig"] = Field("CursorBasedPaginationConfig", **UI_HIDDEN, **UI_REQUIRED)
cursor_name: str = "cursor"
cursor: str | None = Field(None, **UI_HIDDEN)
cursor_filter: str = Field(..., description=FilterSchemaDescription)
Expand Down Expand Up @@ -165,7 +163,7 @@ def get_error_status_whitelist(self) -> list[str] | None:


class HyperMediaPaginationConfig(PaginationConfig):
kind: Literal["HyperMediaPaginationConfig"] = Field("HyperMediaPaginationConfig", **UI_HIDDEN)
kind: Literal["HyperMediaPaginationConfig"] = Field("HyperMediaPaginationConfig", **UI_HIDDEN, **UI_REQUIRED)
next_link_filter: str = Field(..., description=FilterSchemaDescription)
next_link: str | None = None

Expand Down

0 comments on commit 80325ca

Please sign in to comment.