Skip to content

Commit 075e766

Browse files
feat: [TPUF-1097] tpuf: return failed IDs for conditional writes
1 parent d34a3d9 commit 075e766

File tree

6 files changed

+49
-6
lines changed

6 files changed

+49
-6
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 11
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/turbopuffer-benesch%2Fturbopuffer-fa6433a17c7e89ab3329d6f31204ec4996d187b199096b76c09665c73003515c.yml
3-
openapi_spec_hash: 507a79825cddda3b68915b007d262851
4-
config_hash: 96def6365ccbb9b4d87d665602519568
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/turbopuffer-benesch%2Fturbopuffer-d496b79de3c2f3c601206f699e7d13fa74f0afed31f73fa94d08bb195b79f6c2.yml
3+
openapi_spec_hash: 8d838304a3f379497edb054f8f427153
4+
config_hash: e0aa4ce6d5a9a6e326ad47865d970b74

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ It is generated with [Stainless](https://www.stainless.com/).
1313

1414
Use the Turbopuffer MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.
1515

16-
[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40turbopuffer%2Fturbopuffer-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkB0dXJib3B1ZmZlci90dXJib3B1ZmZlci1tY3AiXX0)
17-
[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40turbopuffer%2Fturbopuffer-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40turbopuffer%2Fturbopuffer-mcp%22%5D%7D)
16+
[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40turbopuffer%2Fturbopuffer-mcp&config=eyJuYW1lIjoiQHR1cmJvcHVmZmVyL3R1cmJvcHVmZmVyLW1jcCIsInRyYW5zcG9ydCI6InNzZSIsInVybCI6Imh0dHBzOi8vdHVyYm9wdWZmZXIuc3RsbWNwLmNvbS9zc2UifQ)
17+
[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40turbopuffer%2Fturbopuffer-mcp%22%2C%22type%22%3A%22sse%22%2C%22url%22%3A%22https%3A%2F%2Fturbopuffer.stlmcp.com%2Fsse%22%7D)
1818

1919
> Note: You may need to set environment variables in your MCP client.
2020

src/turbopuffer/resources/namespaces.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ def write(
556556
patch_columns: ColumnsParam | Omit = omit,
557557
patch_condition: Filter | Omit = omit,
558558
patch_rows: Iterable[RowParam] | Omit = omit,
559+
return_affected_ids: bool | Omit = omit,
559560
schema: Dict[str, AttributeSchemaParam] | Omit = omit,
560561
upsert_columns: ColumnsParam | Omit = omit,
561562
upsert_condition: Filter | Omit = omit,
@@ -596,6 +597,10 @@ def write(
596597
patch_condition: A condition evaluated against the current value of each document targeted by a
597598
patch write. Only documents that pass the condition are patched.
598599
600+
return_affected_ids: If true, return the IDs of affected rows (deleted, patched, upserted) in the
601+
response. For filtered and conditional writes, only IDs for writes that
602+
succeeded will be included.
603+
599604
schema: The schema of the attributes attached to the documents.
600605
601606
upsert_columns: A list of documents in columnar format. Each key is a column name, mapped to an
@@ -633,6 +638,7 @@ def write(
633638
"patch_columns": patch_columns,
634639
"patch_condition": patch_condition,
635640
"patch_rows": patch_rows,
641+
"return_affected_ids": return_affected_ids,
636642
"schema": schema,
637643
"upsert_columns": upsert_columns,
638644
"upsert_condition": upsert_condition,
@@ -1152,6 +1158,7 @@ async def write(
11521158
patch_columns: ColumnsParam | Omit = omit,
11531159
patch_condition: object | Omit = omit,
11541160
patch_rows: Iterable[RowParam] | Omit = omit,
1161+
return_affected_ids: bool | Omit = omit,
11551162
schema: Dict[str, AttributeSchemaParam] | Omit = omit,
11561163
upsert_columns: ColumnsParam | Omit = omit,
11571164
upsert_condition: object | Omit = omit,
@@ -1192,6 +1199,10 @@ async def write(
11921199
patch_condition: A condition evaluated against the current value of each document targeted by a
11931200
patch write. Only documents that pass the condition are patched.
11941201
1202+
return_affected_ids: If true, return the IDs of affected rows (deleted, patched, upserted) in the
1203+
response. For filtered and conditional writes, only IDs for writes that
1204+
succeeded will be included.
1205+
11951206
schema: The schema of the attributes attached to the documents.
11961207
11971208
upsert_columns: A list of documents in columnar format. Each key is a column name, mapped to an
@@ -1229,6 +1240,7 @@ async def write(
12291240
"patch_columns": patch_columns,
12301241
"patch_condition": patch_condition,
12311242
"patch_rows": patch_rows,
1243+
"return_affected_ids": return_affected_ids,
12321244
"schema": schema,
12331245
"upsert_columns": upsert_columns,
12341246
"upsert_condition": upsert_condition,

src/turbopuffer/types/namespace_write_params.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ class NamespaceWriteParams(TypedDict, total=False):
7272

7373
patch_rows: Iterable[RowParam]
7474

75+
return_affected_ids: bool
76+
"""
77+
If true, return the IDs of affected rows (deleted, patched, upserted) in the
78+
response. For filtered and conditional writes, only IDs for writes that
79+
succeeded will be included.
80+
"""
81+
7582
schema: Dict[str, AttributeSchemaParam]
7683
"""The schema of the attributes attached to the documents."""
7784

src/turbopuffer/types/namespace_write_response.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import Optional
3+
from typing import List, Optional
44
from typing_extensions import Literal
55

6+
from .id import ID
67
from .._models import BaseModel
78
from .write_billing import WriteBilling
89

@@ -24,6 +25,20 @@ class NamespaceWriteResponse(BaseModel):
2425
status: Literal["OK"]
2526
"""The status of the request."""
2627

28+
deleted_ids: Optional[List[ID]] = None
29+
"""The IDs of documents that were deleted.
30+
31+
Only included when `return_affected_ids` is true and at least one document was
32+
deleted.
33+
"""
34+
35+
patched_ids: Optional[List[ID]] = None
36+
"""The IDs of documents that were patched.
37+
38+
Only included when `return_affected_ids` is true and at least one document was
39+
patched.
40+
"""
41+
2742
rows_deleted: Optional[int] = None
2843
"""The number of rows deleted by the write request."""
2944

@@ -35,3 +50,10 @@ class NamespaceWriteResponse(BaseModel):
3550

3651
rows_upserted: Optional[int] = None
3752
"""The number of rows upserted by the write request."""
53+
54+
upserted_ids: Optional[List[ID]] = None
55+
"""The IDs of documents that were upserted.
56+
57+
Only included when `return_affected_ids` is true and at least one document was
58+
upserted.
59+
"""

tests/api_resources/test_namespaces.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ def test_method_write_with_all_params(self, client: Turbopuffer) -> None:
442442
"vector": [0],
443443
}
444444
],
445+
return_affected_ids=True,
445446
schema={"foo": "string"},
446447
upsert_columns={
447448
"id": ["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
@@ -911,6 +912,7 @@ async def test_method_write_with_all_params(self, async_client: AsyncTurbopuffer
911912
"vector": [0],
912913
}
913914
],
915+
return_affected_ids=True,
914916
schema={"foo": "string"},
915917
upsert_columns={
916918
"id": ["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],

0 commit comments

Comments
 (0)