inttegro.search
Typed models shared by customer, order, product, payout, and financial-account search.
1"""Typed models shared by customer, order, product, payout, and financial-account search.""" 2 3from .models import ( 4 Facet, 5 FacetBucket, 6 FacetResult, 7 Filter, 8 Freshness, 9 FreshnessState, 10 Operator, 11 Page, 12 Request, 13 ResourceFreshness, 14 ResourceReference, 15 ResourceTotal, 16 ResourceType, 17 Result, 18 Sort, 19 SortDirection, 20 SortField, 21 SortResult, 22 Total, 23 TotalRelation, 24) 25 26__all__ = [ 27 "Facet", "FacetBucket", "FacetResult", "Filter", "Freshness", 28 "FreshnessState", "Operator", "Page", "Request", "ResourceFreshness", 29 "ResourceReference", "ResourceTotal", "ResourceType", "Result", "Sort", 30 "SortDirection", "SortField", "SortResult", "Total", "TotalRelation", 31]
66@dataclass(frozen=True, slots=True, kw_only=True) 67class Facet(ApiRequest): 68 """A route-local field to group and count.""" 69 field: str 70 limit: int | UnsetType = dataclass_field(default=UNSET)
A route-local field to group and count.
131@dataclass(frozen=True, slots=True, init=False, repr=False, eq=False) 132class FacetBucket(ApiModel): 133 """One value and count in a requested facet.""" 134 135 value: str = dataclass_field(init=False) 136 count: int = dataclass_field(init=False)
One value and count in a requested facet.
139@dataclass(frozen=True, slots=True, init=False, repr=False, eq=False) 140class FacetResult(ApiModel): 141 """The buckets returned for one requested field.""" 142 143 field: str = dataclass_field(init=False) 144 buckets: list[FacetBucket] = dataclass_field(init=False)
The buckets returned for one requested field.
58@dataclass(frozen=True, slots=True, kw_only=True) 59class Filter(ApiRequest): 60 """A route-local field constraint.""" 61 field: str 62 operator: Operator 63 values: list[str]
A route-local field constraint.
157@dataclass(frozen=True, slots=True, init=False, repr=False, eq=False) 158class Freshness(ApiModel): 159 """Overall and resource-specific search index freshness.""" 160 161 state: FreshnessState = dataclass_field(init=False) 162 observed_at: datetime | None = dataclass_field(init=False) 163 resources: list[ResourceFreshness] | None = dataclass_field(init=False)
Overall and resource-specific search index freshness.
49class FreshnessState(WireEnum): 50 """Freshness of the search projection relative to canonical resources.""" 51 CURRENT = "current" 52 DELAYED = "delayed" 53 PARTIAL = "partial" 54 UNKNOWN = "unknown" 55 UNAVAILABLE = "unavailable"
Freshness of the search projection relative to canonical resources.
15class Operator(WireEnum): 16 """Comparison supported by a resource search filter.""" 17 EQ = "eq" 18 IN = "in"
Comparison supported by a resource search filter.
166@dataclass(frozen=True, slots=True, init=False, repr=False, eq=False) 167class Page(ApiModel): 168 """Search projections and continuation metadata.""" 169 170 resource_types: list[ResourceType] = dataclass_field(init=False) 171 sort: SortResult = dataclass_field(init=False) 172 page_size: int = dataclass_field(init=False) 173 result_count: int = dataclass_field(init=False) 174 has_more: bool = dataclass_field(init=False) 175 total: Total = dataclass_field(init=False) 176 resource_totals: list[ResourceTotal] = dataclass_field(init=False) 177 results: list[Result] = dataclass_field(init=False) 178 facets: list[FacetResult] = dataclass_field(init=False) 179 next_cursor: str | None = dataclass_field(init=False) 180 freshness: Freshness = dataclass_field(init=False)
Search projections and continuation metadata.
80@dataclass(frozen=True, slots=True, kw_only=True) 81class Request(ApiRequest): 82 """A typed resource-local search request.""" 83 84 text: str | UnsetType = dataclass_field(default=UNSET) 85 filters: list[Filter] | UnsetType = dataclass_field(default=UNSET) 86 facets: list[Facet] | UnsetType = dataclass_field(default=UNSET) 87 sort: Sort | UnsetType = dataclass_field(default=UNSET) 88 page_size: int | UnsetType = dataclass_field(default=UNSET) 89 cursor: str | UnsetType = dataclass_field(default=UNSET)
A typed resource-local search request.
147@dataclass(frozen=True, slots=True, init=False, repr=False, eq=False) 148class ResourceFreshness(ApiModel): 149 """Freshness information for the searched resource type.""" 150 151 resource_type: ResourceType = dataclass_field(init=False) 152 state: FreshnessState = dataclass_field(init=False) 153 observed_at: datetime | None = dataclass_field(init=False) 154 last_indexed_at: datetime | None = dataclass_field(init=False)
Freshness information for the searched resource type.
109@dataclass(frozen=True, slots=True, init=False, repr=False, eq=False) 110class ResourceReference(ApiModel): 111 """The canonical type and identifier for a search result.""" 112 113 type: ResourceType = dataclass_field(init=False) 114 id: str = dataclass_field(init=False)
The canonical type and identifier for a search result.
100@dataclass(frozen=True, slots=True, init=False, repr=False, eq=False) 101class ResourceTotal(ApiModel): 102 """A per-resource result count.""" 103 104 resource_type: ResourceType = dataclass_field(init=False) 105 value: int = dataclass_field(init=False) 106 relation: TotalRelation = dataclass_field(init=False)
A per-resource result count.
34class ResourceType(WireEnum): 35 """Resource type represented by a search projection.""" 36 CUSTOMER = "customer" 37 FINANCIAL_ACCOUNT = "financial_account" 38 ORDER = "order" 39 PAYOUT = "payout" 40 PRODUCT = "product"
Resource type represented by a search projection.
117@dataclass(frozen=True, slots=True, init=False, repr=False, eq=False) 118class Result(ApiModel): 119 """A discovery projection for a canonical resource.""" 120 121 resource: ResourceReference = dataclass_field(init=False) 122 title: str = dataclass_field(init=False) 123 summary: str | None = dataclass_field(init=False) 124 status: str | None = dataclass_field(init=False) 125 customer_name: str | None = dataclass_field(init=False) 126 amount: Amount | None = dataclass_field(init=False) 127 url: str | None = dataclass_field(init=False) 128 updated_at: datetime = dataclass_field(init=False)
A discovery projection for a canonical resource.
73@dataclass(frozen=True, slots=True, kw_only=True) 74class Sort(ApiRequest): 75 """Typed search ordering.""" 76 field: SortField 77 direction: SortDirection
Typed search ordering.
28class SortDirection(WireEnum): 29 """Direction applied to the selected search ordering.""" 30 ASC = "asc" 31 DESC = "desc"
Direction applied to the selected search ordering.
21class SortField(WireEnum): 22 """Supported ordering field for resource search.""" 23 RELEVANCE = "relevance" 24 UPDATED_AT = "updated_at" 25 PUBLISHED_AT = "published_at"
Supported ordering field for resource search.
183@dataclass(frozen=True, slots=True, init=False, repr=False, eq=False) 184class SortResult(ApiModel): 185 """Ordering echoed by a search response.""" 186 187 field: SortField = dataclass_field(init=False) 188 direction: SortDirection = dataclass_field(init=False)
Ordering echoed by a search response.
92@dataclass(frozen=True, slots=True, init=False, repr=False, eq=False) 93class Total(ApiModel): 94 """The result count and whether it is exact.""" 95 96 value: int = dataclass_field(init=False) 97 relation: TotalRelation = dataclass_field(init=False)
The result count and whether it is exact.
43class TotalRelation(WireEnum): 44 """Whether a returned total is exact or a lower bound.""" 45 EXACT = "exact" 46 LOWER_BOUND = "lower_bound"
Whether a returned total is exact or a lower bound.