Source code for scim2_models.messages.search_request

from enum import Enum
from typing import Any

from pydantic import field_validator

from ..path import URN
from ..path import Path
from .message import Message
from .response_parameters import ResponseParameters


[docs] class SearchRequest(Message, ResponseParameters): """SearchRequest object defined at :rfc:`RFC7644 §3.4.3 <7644#section-3.4.3>`.""" __schema__ = URN("urn:ietf:params:scim:api:messages:2.0:SearchRequest") filter: str | None = None """The filter string used to request a subset of resources.""" sort_by: Path[Any] | None = None """A string indicating the attribute whose value SHALL be used to order the returned responses."""
[docs] class SortOrder(str, Enum): ascending = "ascending" descending = "descending"
sort_order: SortOrder | None = None """A string indicating the order in which the "sortBy" parameter is applied.""" start_index: int | None = None """An integer indicating the 1-based index of the first query result."""
[docs] @field_validator("start_index") @classmethod def start_index_floor(cls, value: int | None) -> int | None: """According to :rfc:`RFC7644 §3.4.2 <7644#section-3.4.2.4>`, start_index values less than 1 are interpreted as 1. A value less than 1 SHALL be interpreted as 1. """ return None if value is None else max(1, value)
count: int | None = None """An integer indicating the desired maximum number of query results per page."""
[docs] @field_validator("count") @classmethod def count_floor(cls, value: int | None) -> int | None: """According to :rfc:`RFC7644 §3.4.2 <7644#section-3.4.2.4>`, count values less than 0 are interpreted as 0. A negative value SHALL be interpreted as 0. """ return None if value is None else max(0, value)
@property def start_index_0(self) -> int | None: """The 0 indexed start index.""" return self.start_index - 1 if self.start_index is not None else None @property def stop_index_0(self) -> int | None: """The 0 indexed stop index.""" return ( self.start_index_0 + self.count if self.start_index_0 is not None and self.count is not None else None )