Skip to content

Commit 0ba66ca

Browse files
Excavator: Upgrade API Version
1 parent 856df4d commit 0ba66ca

File tree

10 files changed

+460
-6
lines changed

10 files changed

+460
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,7 @@ Namespace | Name | Import |
15691569
**Functions** | [RangesConstraint](docs/v2/Functions/models/RangesConstraint.md) | `from foundry_sdk.v2.functions.models import RangesConstraint` |
15701570
**Functions** | [RegexConstraint](docs/v2/Functions/models/RegexConstraint.md) | `from foundry_sdk.v2.functions.models import RegexConstraint` |
15711571
**Functions** | [RidConstraint](docs/v2/Functions/models/RidConstraint.md) | `from foundry_sdk.v2.functions.models import RidConstraint` |
1572+
**Functions** | [StreamingExecuteQueryRequest](docs/v2/Functions/models/StreamingExecuteQueryRequest.md) | `from foundry_sdk.v2.functions.models import StreamingExecuteQueryRequest` |
15721573
**Functions** | [StructConstraint](docs/v2/Functions/models/StructConstraint.md) | `from foundry_sdk.v2.functions.models import StructConstraint` |
15731574
**Functions** | [StructFieldApiName](docs/v2/Functions/models/StructFieldApiName.md) | `from foundry_sdk.v2.functions.models import StructFieldApiName` |
15741575
**Functions** | [StructFieldName](docs/v2/Functions/models/StructFieldName.md) | `from foundry_sdk.v2.functions.models import StructFieldName` |
@@ -2805,6 +2806,7 @@ Namespace | Name | Import |
28052806
**Functions** | QueryRuntimeError | `from foundry_sdk.v2.functions.errors import QueryRuntimeError` |
28062807
**Functions** | QueryTimeExceededLimit | `from foundry_sdk.v2.functions.errors import QueryTimeExceededLimit` |
28072808
**Functions** | QueryVersionNotFound | `from foundry_sdk.v2.functions.errors import QueryVersionNotFound` |
2809+
**Functions** | StreamingExecuteQueryPermissionDenied | `from foundry_sdk.v2.functions.errors import StreamingExecuteQueryPermissionDenied` |
28082810
**Functions** | UnknownParameter | `from foundry_sdk.v2.functions.errors import UnknownParameter` |
28092811
**Functions** | ValueTypeNotFound | `from foundry_sdk.v2.functions.errors import ValueTypeNotFound` |
28102812
**Functions** | VersionIdNotFound | `from foundry_sdk.v2.functions.errors import VersionIdNotFound` |

docs-snippets-npm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"sls": {
2525
"dependencies": {
2626
"com.palantir.foundry.api:api-gateway": {
27-
"minVersion": "1.1350.0",
27+
"minVersion": "1.1362.0",
2828
"maxVersion": "1.x.x",
2929
"optional": false
3030
}

docs-snippets-npm/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,11 @@ export const PYTHON_PLATFORM_SNIPPETS: SdkSnippets<typeof PLATFORM_API_DOCS_SPEC
10381038
"template": "from foundry_sdk import FoundryClient\nimport foundry_sdk\nfrom pprint import pprint\n\nclient = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname=\"example.palantirfoundry.com\")\n\n# FunctionRid\nrid = None\n# Optional[PreviewMode] | Enables the use of preview functionality.\npreview = None\n# Optional[FunctionVersion]\nversion = None\n\n\ntry:\n api_response = client.functions.Query.get_by_rid(rid=rid, preview=preview, version=version)\n print(\"The get_by_rid response:\\n\")\n pprint(api_response)\nexcept foundry_sdk.PalantirRPCException as e:\n print(\"HTTP error when calling Query.get_by_rid: %s\\n\" % e)"
10391039
}
10401040
],
1041+
"v2.streamingExecuteQuery": [
1042+
{
1043+
"template": "from foundry_sdk import FoundryClient\nimport foundry_sdk\nfrom pprint import pprint\n\nclient = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname=\"example.palantirfoundry.com\")\n\n# QueryApiName\nquery_api_name = None\n# Dict[ParameterId, Optional[DataValue]]\nparameters = None\n# Optional[Attribution]\nattribution = None\n# Optional[OntologyIdentifier] | Optional ontology identifier (RID or API name). When provided, executes an ontology-scoped function. When omitted, executes a global function.\nontology = \"example-ontology\"\n# Optional[PreviewMode] | Enables the use of preview functionality.\npreview = None\n# Optional[TraceParent]\ntrace_parent = None\n# Optional[TraceState]\ntrace_state = None\n# Optional[FunctionVersion]\nversion = None\n\n\ntry:\n api_response = client.functions.Query.streaming_execute(\n query_api_name,\n parameters=parameters,\n attribution=attribution,\n ontology=ontology,\n preview=preview,\n trace_parent=trace_parent,\n trace_state=trace_state,\n version=version,\n )\n print(\"The streaming_execute response:\\n\")\n pprint(api_response)\nexcept foundry_sdk.PalantirRPCException as e:\n print(\"HTTP error when calling Query.streaming_execute: %s\\n\" % e)"
1044+
}
1045+
],
10411046
"v2.getValueType": [
10421047
{
10431048
"template": "from foundry_sdk import FoundryClient\nimport foundry_sdk\nfrom pprint import pprint\n\nclient = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname=\"example.palantirfoundry.com\")\n\n# ValueTypeRid\nvalue_type_rid = None\n# Optional[PreviewMode] | Enables the use of preview functionality.\npreview = None\n\n\ntry:\n api_response = client.functions.ValueType.get(value_type_rid, preview=preview)\n print(\"The get response:\\n\")\n pprint(api_response)\nexcept foundry_sdk.PalantirRPCException as e:\n print(\"HTTP error when calling ValueType.get: %s\\n\" % e)"

docs/v2/Functions/Query.md

Lines changed: 107 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ Method | HTTP request | Release Stage |
55
[**execute**](#execute) | **POST** /v2/functions/queries/{queryApiName}/execute | Private Beta |
66
[**get**](#get) | **GET** /v2/functions/queries/{queryApiName} | Private Beta |
77
[**get_by_rid**](#get_by_rid) | **POST** /v2/functions/queries/getByRid | Private Beta |
8+
[**streaming_execute**](#streaming_execute) | **POST** /v2/functions/queries/{queryApiName}/streamingExecute | Private Beta |
89

910
# **execute**
1011
Executes a Query using the given parameters. By default, this executes the latest version of the query.
1112

12-
Optional parameters do not need to be supplied.
13+
This endpoint is maintained for backward compatibility only.
14+
15+
For all new implementations, use the `streamingExecute` endpoint, which supports all function types
16+
and provides enhanced functionality.
1317

1418

1519
### Parameters
@@ -190,3 +194,105 @@ See [README](../../../README.md#authorization)
190194

191195
[[Back to top]](#) [[Back to API list]](../../../README.md#apis-v2-link) [[Back to Model list]](../../../README.md#models-v2-link) [[Back to README]](../../../README.md)
192196

197+
# **streaming_execute**
198+
Executes a Query using the given parameters, returning results as an NDJSON stream. By default, this executes the latest version of the query.
199+
200+
This endpoint supports all Query functions. The endpoint name 'streamingExecute' refers to the NDJSON
201+
streaming response format. Both streaming and non-streaming functions can use this endpoint.
202+
Non-streaming functions return a single-line NDJSON response, while streaming functions return multi-line NDJSON responses.
203+
This is the recommended endpoint for all query execution.
204+
205+
The response is returned as a binary stream in NDJSON (Newline Delimited JSON) format, where each line
206+
is a StreamingExecuteQueryResponse containing either a data batch or an error.
207+
208+
For a function returning a list of 5 records with a batch size of 3, the response stream would contain
209+
two lines. The first line contains the first 3 items, and the second line contains the remaining 2 items:
210+
211+
```
212+
{"type":"data","value":[{"productId":"SKU-001","price":29.99},{"productId":"SKU-002","price":49.99},{"productId":"SKU-003","price":19.99}]}
213+
{"type":"data","value":[{"productId":"SKU-004","price":39.99},{"productId":"SKU-005","price":59.99}]}
214+
```
215+
216+
Each line is a separate JSON object followed by a newline character. Clients should parse the stream
217+
line-by-line to process results as they arrive. If an error occurs during execution, the stream will
218+
contain an error line:
219+
220+
```
221+
{"type":"error","errorCode":"INVALID_ARGUMENT","errorName":"QueryRuntimeError","errorInstanceId":"3f8a9c7b-2e4d-4a1f-9b8c-7d6e5f4a3b2c","errorDescription":"Division by zero","parameters":{}}
222+
```
223+
224+
225+
### Parameters
226+
227+
Name | Type | Description | Notes |
228+
------------- | ------------- | ------------- | ------------- |
229+
**query_api_name** | QueryApiName | | |
230+
**parameters** | Dict[ParameterId, Optional[DataValue]] | | |
231+
**attribution** | Optional[Attribution] | | [optional] |
232+
**ontology** | Optional[OntologyIdentifier] | Optional ontology identifier (RID or API name). When provided, executes an ontology-scoped function. When omitted, executes a global function. | [optional] |
233+
**preview** | Optional[PreviewMode] | Enables the use of preview functionality. | [optional] |
234+
**trace_parent** | Optional[TraceParent] | | [optional] |
235+
**trace_state** | Optional[TraceState] | | [optional] |
236+
**version** | Optional[FunctionVersion] | | [optional] |
237+
238+
### Return type
239+
**bytes**
240+
241+
### Example
242+
243+
```python
244+
from foundry_sdk import FoundryClient
245+
import foundry_sdk
246+
from pprint import pprint
247+
248+
client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com")
249+
250+
# QueryApiName
251+
query_api_name = None
252+
# Dict[ParameterId, Optional[DataValue]]
253+
parameters = None
254+
# Optional[Attribution]
255+
attribution = None
256+
# Optional[OntologyIdentifier] | Optional ontology identifier (RID or API name). When provided, executes an ontology-scoped function. When omitted, executes a global function.
257+
ontology = "example-ontology"
258+
# Optional[PreviewMode] | Enables the use of preview functionality.
259+
preview = None
260+
# Optional[TraceParent]
261+
trace_parent = None
262+
# Optional[TraceState]
263+
trace_state = None
264+
# Optional[FunctionVersion]
265+
version = None
266+
267+
268+
try:
269+
api_response = client.functions.Query.streaming_execute(
270+
query_api_name,
271+
parameters=parameters,
272+
attribution=attribution,
273+
ontology=ontology,
274+
preview=preview,
275+
trace_parent=trace_parent,
276+
trace_state=trace_state,
277+
version=version,
278+
)
279+
print("The streaming_execute response:\n")
280+
pprint(api_response)
281+
except foundry_sdk.PalantirRPCException as e:
282+
print("HTTP error when calling Query.streaming_execute: %s\n" % e)
283+
284+
```
285+
286+
287+
288+
### Authorization
289+
290+
See [README](../../../README.md#authorization)
291+
292+
### HTTP response details
293+
| Status Code | Type | Description | Content Type |
294+
|-------------|-------------|-------------|------------------|
295+
**200** | bytes | | application/octet-stream |
296+
297+
[[Back to top]](#) [[Back to API list]](../../../README.md#apis-v2-link) [[Back to Model list]](../../../README.md#models-v2-link) [[Back to README]](../../../README.md)
298+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# StreamingExecuteQueryRequest
2+
3+
StreamingExecuteQueryRequest
4+
5+
## Properties
6+
| Name | Type | Required | Description |
7+
| ------------ | ------------- | ------------- | ------------- |
8+
**ontology** | Optional[OntologyIdentifier] | No | Optional ontology identifier (RID or API name). When provided, executes an ontology-scoped function. When omitted, executes a global function. |
9+
**parameters** | Dict[ParameterId, Optional[DataValue]] | Yes | |
10+
**version** | Optional[FunctionVersion] | No | |
11+
12+
13+
[[Back to Model list]](../../../../README.md#models-v2-link) [[Back to API list]](../../../../README.md#apis-v2-link) [[Back to README]](../../../../README.md)

foundry_sdk/_versions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
# using the autorelease bot
1818
__version__ = "0.0.0"
1919

20-
__openapi_document_version__ = "1.1350.0"
20+
__openapi_document_version__ = "1.1362.0"

foundry_sdk/v2/cli.py

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5307,7 +5307,10 @@ def functions_query_op_execute(
53075307
"""
53085308
Executes a Query using the given parameters. By default, this executes the latest version of the query.
53095309
5310-
Optional parameters do not need to be supplied.
5310+
This endpoint is maintained for backward compatibility only.
5311+
5312+
For all new implementations, use the `streamingExecute` endpoint, which supports all function types
5313+
and provides enhanced functionality.
53115314
53125315
"""
53135316
result = client.functions.Query.execute(
@@ -5372,6 +5375,77 @@ def functions_query_op_get_by_rid(
53725375
click.echo(repr(result))
53735376

53745377

5378+
@functions_query.command("streaming_execute")
5379+
@click.argument("query_api_name", type=str, required=True)
5380+
@click.option("--parameters", type=str, required=True, help="""""")
5381+
@click.option("--attribution", type=str, required=False, help="""""")
5382+
@click.option(
5383+
"--ontology",
5384+
type=str,
5385+
required=False,
5386+
help="""Optional ontology identifier (RID or API name). When provided, executes an ontology-scoped
5387+
function. When omitted, executes a global function.
5388+
""",
5389+
)
5390+
@click.option(
5391+
"--preview", type=bool, required=False, help="""Enables the use of preview functionality."""
5392+
)
5393+
@click.option("--trace_parent", type=str, required=False, help="""""")
5394+
@click.option("--trace_state", type=str, required=False, help="""""")
5395+
@click.option("--version", type=str, required=False, help="""""")
5396+
@click.pass_obj
5397+
def functions_query_op_streaming_execute(
5398+
client: FoundryClient,
5399+
query_api_name: str,
5400+
parameters: str,
5401+
attribution: typing.Optional[str],
5402+
ontology: typing.Optional[str],
5403+
preview: typing.Optional[bool],
5404+
trace_parent: typing.Optional[str],
5405+
trace_state: typing.Optional[str],
5406+
version: typing.Optional[str],
5407+
):
5408+
"""
5409+
Executes a Query using the given parameters, returning results as an NDJSON stream. By default, this executes the latest version of the query.
5410+
5411+
This endpoint supports all Query functions. The endpoint name 'streamingExecute' refers to the NDJSON
5412+
streaming response format. Both streaming and non-streaming functions can use this endpoint.
5413+
Non-streaming functions return a single-line NDJSON response, while streaming functions return multi-line NDJSON responses.
5414+
This is the recommended endpoint for all query execution.
5415+
5416+
The response is returned as a binary stream in NDJSON (Newline Delimited JSON) format, where each line
5417+
is a StreamingExecuteQueryResponse containing either a data batch or an error.
5418+
5419+
For a function returning a list of 5 records with a batch size of 3, the response stream would contain
5420+
two lines. The first line contains the first 3 items, and the second line contains the remaining 2 items:
5421+
5422+
```
5423+
{"type":"data","value":[{"productId":"SKU-001","price":29.99},{"productId":"SKU-002","price":49.99},{"productId":"SKU-003","price":19.99}]}
5424+
{"type":"data","value":[{"productId":"SKU-004","price":39.99},{"productId":"SKU-005","price":59.99}]}
5425+
```
5426+
5427+
Each line is a separate JSON object followed by a newline character. Clients should parse the stream
5428+
line-by-line to process results as they arrive. If an error occurs during execution, the stream will
5429+
contain an error line:
5430+
5431+
```
5432+
{"type":"error","errorCode":"INVALID_ARGUMENT","errorName":"QueryRuntimeError","errorInstanceId":"3f8a9c7b-2e4d-4a1f-9b8c-7d6e5f4a3b2c","errorDescription":"Division by zero","parameters":{}}
5433+
```
5434+
5435+
"""
5436+
result = client.functions.Query.streaming_execute(
5437+
query_api_name=query_api_name,
5438+
parameters=json.loads(parameters),
5439+
attribution=attribution,
5440+
ontology=ontology,
5441+
preview=preview,
5442+
trace_parent=trace_parent,
5443+
trace_state=trace_state,
5444+
version=version,
5445+
)
5446+
click.echo(result)
5447+
5448+
53755449
@cli.group("geo")
53765450
def geo():
53775451
pass

foundry_sdk/v2/functions/errors.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,21 @@ class QueryVersionNotFound(errors.NotFoundError):
211211
error_instance_id: str
212212

213213

214+
class StreamingExecuteQueryPermissionDeniedParameters(typing_extensions.TypedDict):
215+
"""Could not streamingExecute the Query."""
216+
217+
__pydantic_config__ = {"extra": "allow"} # type: ignore
218+
219+
queryApiName: functions_models.QueryApiName
220+
221+
222+
@dataclass
223+
class StreamingExecuteQueryPermissionDenied(errors.PermissionDeniedError):
224+
name: typing.Literal["StreamingExecuteQueryPermissionDenied"]
225+
parameters: StreamingExecuteQueryPermissionDeniedParameters
226+
error_instance_id: str
227+
228+
214229
class UnknownParameterParameters(typing_extensions.TypedDict):
215230
"""
216231
The provided parameters were not found. Please look at the `knownParameters` field
@@ -273,6 +288,7 @@ class VersionIdNotFound(errors.NotFoundError):
273288
"QueryRuntimeError",
274289
"QueryTimeExceededLimit",
275290
"QueryVersionNotFound",
291+
"StreamingExecuteQueryPermissionDenied",
276292
"UnknownParameter",
277293
"ValueTypeNotFound",
278294
"VersionIdNotFound",

foundry_sdk/v2/functions/models.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
from foundry_sdk import _core as core
2424
from foundry_sdk.v2.core import models as core_models
25+
from foundry_sdk.v2.ontologies import models as ontologies_models
2526

2627

2728
class ArrayConstraint(core.ModelBase):
@@ -285,6 +286,19 @@ class RidConstraint(core.ModelBase):
285286
type: typing.Literal["rid"] = "rid"
286287

287288

289+
class StreamingExecuteQueryRequest(core.ModelBase):
290+
"""StreamingExecuteQueryRequest"""
291+
292+
ontology: typing.Optional[ontologies_models.OntologyIdentifier] = None
293+
"""
294+
Optional ontology identifier (RID or API name). When provided, executes an ontology-scoped
295+
function. When omitted, executes a global function.
296+
"""
297+
298+
parameters: typing.Dict[ParameterId, typing.Optional[DataValue]]
299+
version: typing.Optional[FunctionVersion] = None
300+
301+
288302
class StructConstraint(core.ModelBase):
289303
"""StructConstraint"""
290304

@@ -593,6 +607,7 @@ class VersionId(core.ModelBase):
593607
"RangesConstraint",
594608
"RegexConstraint",
595609
"RidConstraint",
610+
"StreamingExecuteQueryRequest",
596611
"StructConstraint",
597612
"StructFieldApiName",
598613
"StructFieldName",

0 commit comments

Comments
 (0)