-
-
Notifications
You must be signed in to change notification settings - Fork 12
Support for cursor based pagination #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
funelie
wants to merge
16
commits into
main
Choose a base branch
from
cursor-based-pagination
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5370d68
feat: add pagination attributes and configuration
funelie f369257
feat: add pagination related exceptions
funelie 7a8c9a7
test: add pagination related exceptions to basic error tests
funelie 7e18fd4
test: tests for cursor attributes in list response and search request
funelie 3b3a3e9
feat: character validation on cursors
funelie 7122339
feat: add default pagination method and timeout to pagination config
funelie c86cf9e
fix: fix configuration requirements for pagination
funelie 8a0a707
feat: start_index and cursor are mutually exclusive in a search request
funelie 251b847
feat: enforce index pagination as default if no pagination method in …
funelie 8ee232d
refactor: remove extraneous test
funelie 8ddb7b1
test: fix doctest adding pagination to searchrequest
funelie fb7212f
chore: code styling
funelie 13d14a7
fix: cursor can be empty string
funelie f9718c2
test: complete coverage on cursor character validation
funelie ad88353
feat: complete scim exceptions with rfc 9865 exceptions
funelie 75adf75
chore: update changelog
funelie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,17 @@ | ||
| import re | ||
| from typing import Any | ||
| from typing import Generic | ||
|
|
||
| from pydantic import Field | ||
| from pydantic import ValidationInfo | ||
| from pydantic import ValidatorFunctionWrapHandler | ||
| from pydantic import field_validator | ||
| from pydantic import model_validator | ||
| from pydantic_core import PydanticCustomError | ||
| from typing_extensions import Self | ||
|
|
||
| from ..context import Context | ||
| from ..exceptions import InvalidCursorException | ||
| from ..resources.resource import AnyResource | ||
| from ..urn import URN | ||
| from .message import Message | ||
|
|
@@ -44,6 +47,22 @@ class ListResponse(Message, Generic[AnyResource], metaclass=_GenericMessageMetac | |
| items_per_page: int | None = None | ||
| """The number of resources returned in a list response page.""" | ||
|
|
||
| next_cursor: str | None = None | ||
| """A string value that can be used to retrieve the next page of list | ||
| results.""" | ||
|
|
||
| prev_cursor: str | None = None | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's https://www.rfc-editor.org/info/rfc9865/#name-response-attributes |
||
| """A string value that can be used to retrieve the previous page of list | ||
| results.""" | ||
|
|
||
| @field_validator("next_cursor", "prev_cursor") | ||
| @classmethod | ||
| def validate_cursor_chars(cls, value: str | None) -> str | None: | ||
| """According to :rfc:`RFC9865 §2 <9865#section-2>`, cursor values may only contain unreserved characters as defined in :rfc:`RFC3986 §2.3 <3986#section-2.3>`.""" | ||
| if value is not None and not re.fullmatch(r"[A-Za-z0-9\-._~]*", value): | ||
| raise InvalidCursorException().as_pydantic_error() | ||
| return value | ||
|
|
||
| resources: list[AnyResource] | None = Field(None, serialization_alias="Resources") | ||
| """A multi-valued list of complex objects containing the requested | ||
| resources.""" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sphinx RFC links are in the form of