Skip to content

Commit 19bc04d

Browse files
committed
feat(operations): add the schema_changes operation option
1 parent edd41e7 commit 19bc04d

2 files changed

Lines changed: 43 additions & 3 deletions

File tree

src/typesense/operations.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
HealthCheckResponse,
2323
LogSlowRequestsTimeParams,
2424
OperationResponse,
25+
SchemaChangesResponse,
2526
SnapshotParameters,
2627
)
2728

@@ -48,8 +49,9 @@ class Operations:
4849
"""
4950

5051
resource_path: typing.Final[str] = "/operations"
51-
healht_path: typing.Final[str] = "/health"
52+
health_path: typing.Final[str] = "/health"
5253
config_path: typing.Final[str] = "/config"
54+
schema_changes: typing.Final[str] = "/schema_changes"
5355

5456
def __init__(self, api_call: ApiCall):
5557
"""
@@ -60,6 +62,23 @@ def __init__(self, api_call: ApiCall):
6062
"""
6163
self.api_call = api_call
6264

65+
@typing.overload
66+
def perform(
67+
self,
68+
operation_name: typing.Literal["schema_changes"],
69+
query_params: None = None,
70+
) -> typing.List[SchemaChangesResponse]:
71+
"""
72+
Perform a vote operation.
73+
74+
Args:
75+
operation_name (Literal["schema_changes"]): The name of the operation.
76+
query_params (None, optional): Query parameters (not used for vote operation).
77+
78+
Returns:
79+
OperationResponse: The response from the vote operation.
80+
"""
81+
6382
@typing.overload
6483
def perform(
6584
self,
@@ -150,7 +169,13 @@ def perform(
150169
def perform(
151170
self,
152171
operation_name: typing.Union[
153-
typing.Literal["snapshot, vote, db/compact, cache/clear"],
172+
typing.Literal[
173+
"snapshot",
174+
"vote",
175+
"db/compact",
176+
"cache/clear",
177+
"schema_changes",
178+
],
154179
str,
155180
],
156181
query_params: typing.Union[
@@ -189,7 +214,7 @@ def is_healthy(self) -> bool:
189214
bool: True if the server is healthy, False otherwise.
190215
"""
191216
call_resp = self.api_call.get(
192-
Operations.healht_path,
217+
Operations.health_path,
193218
as_json=True,
194219
entity_type=HealthCheckResponse,
195220
)

src/typesense/types/operations.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,21 @@ class HealthCheckResponse(typing.TypedDict):
4141
ok: bool
4242

4343

44+
class SchemaChangesResponse(typing.TypedDict):
45+
"""
46+
Response schema for schema changes.
47+
48+
Attributes:
49+
collection (str): The name of the collection.
50+
validated_docs (int): The number of validated documents.
51+
altered_docs (int): The number of altered documents
52+
"""
53+
54+
collection: str
55+
validated_docs: int
56+
altered_docs: int
57+
58+
4459
class OperationResponse(typing.TypedDict):
4560
"""
4661
Response schema for operations.

0 commit comments

Comments
 (0)