Skip to content

Commit 490cfbe

Browse files
Excavator: Upgrade API Version (#201)
1 parent 2e53444 commit 490cfbe

File tree

111 files changed

+22231
-156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+22231
-156
lines changed

README.md

Lines changed: 77 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
[![PyPI Version](https://img.shields.io/pypi/v/foundry-platform-sdk)](https://pypi.org/project/foundry-platform-sdk/)
55
[![License](https://img.shields.io/badge/License-Apache%202.0-lightgrey.svg)](https://opensource.org/licenses/Apache-2.0)
66

7-
> [!WARNING]
8-
> This SDK is incubating and subject to change.
9-
107
The Foundry Platform SDK is a Python SDK built on top of the Foundry API.
118
Review [Foundry API documentation](https://www.palantir.com/docs/foundry/api/) for more details.
129

@@ -308,23 +305,95 @@ To iterate over all items, you can simply create a `ResourceIterator` instance a
308305
for item in client.datasets.Dataset.Branch.list(dataset_rid):
309306
print(item)
310307

308+
# Or, you can collect all the items in a list
309+
results = list(client.datasets.Dataset.Branch.list(dataset_rid))
310+
311311
```
312312

313313
This will automatically fetch and iterate through all the pages of data from the specified API endpoint. For more granular control, you can manually fetch each page using the `next_page_token`.
314314

315315
```python
316-
page = client.datasets.Dataset.Branch.list(dataset_rid, page_size=page_size)
317-
318-
while page.next_page_token:
316+
next_page_token: Optional[str] = None
317+
while True:
318+
page = client.datasets.Dataset.Branch.list(
319+
dataset_rid, page_size=page_size, page_token=next_page_token
320+
)
319321
for branch in page.data:
320322
print(branch)
321323

322-
page = client.datasets.Dataset.Branch.list(
323-
dataset_rid, page_size=page_size, page_token=page.next_page_token
324+
if page.next_page_token is None:
325+
break
326+
327+
next_page_token = page.next_page_token
328+
329+
```
330+
331+
### Asynchronous Pagination (Beta)
332+
333+
> [!WARNING]
334+
> The asynchronous client is in beta and may change in future releases.
335+
336+
When using the `AsyncFoundryClient` client, pagination works similar to the synchronous client
337+
but you need to use `async for` to iterate over the results. Here's an example:
338+
339+
340+
```python
341+
async for item in client.datasets.Dataset.Branch.list(dataset_rid):
342+
print(item)
343+
344+
# Or, you can collect all the items in a list
345+
results = [item async for item in client.datasets.Dataset.Branch.list(dataset_rid)]
346+
347+
```
348+
349+
For more control over asynchronous pagination, you can manually handle the pagination
350+
tokens and use the `with_raw_response` utility to fetch each page.
351+
352+
353+
```python
354+
next_page_token: Optional[str] = None
355+
while True:
356+
response = await client.client.datasets.Dataset.Branch.with_raw_response.list(
357+
dataset_rid, page_token=next_page_token
324358
)
325359

360+
page = response.decode()
361+
for item in page.data:
362+
print(item)
363+
364+
if page.next_page_token is None:
365+
break
366+
367+
next_page_token = page.next_page_token
368+
369+
```
370+
371+
<a id="async-client"></a>
372+
### Asynchronous Client (Beta)
373+
374+
> [!WARNING]
375+
> The asynchronous client is in beta and may change in future releases.
376+
377+
This SDK supports creating an asynchronous client, just import and instantiate the
378+
`AsyncFoundryClient` instead of the `FoundryClient`.
379+
380+
```python
381+
from foundry import AsyncFoundryClient
382+
import foundry
383+
import asyncio
384+
from pprint import pprint
385+
386+
async def main():
387+
client = AsyncFoundryClient(...)
388+
response = await client.datasets.Dataset.Branch.create(dataset_rid, name=name, transaction_rid=transaction_rid)
389+
pprint(response)
390+
391+
if __name__ == "__main__":
392+
asyncio.run(main())
326393
```
327394

395+
When using asynchronous clients, you'll just need to use the `await` keyword when calling APIs. Otherwise, the behaviour
396+
between the `FoundryClient` and `AsyncFoundryClient` is nearly identical.
328397

329398
<a id="binary-streaming"></a>
330399
## Streaming
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
type: feature
2+
feature:
3+
description: You can now call the Foundry APIs asynchronously using the new `AsyncFoundryClient`
4+
client, now available in beta!
5+
links:
6+
- https://github.com/palantir/foundry-platform-python/pull/201

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.1174.0",
27+
"minVersion": "1.1175.0",
2828
"maxVersion": "1.x.x",
2929
"optional": false
3030
}

foundry_sdk/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515

1616
from foundry_sdk._core import ApiResponse
17+
from foundry_sdk._core import AsyncApiResponse
1718
from foundry_sdk._core import Auth
1819
from foundry_sdk._core import ConfidentialClientAuth
1920
from foundry_sdk._core import Config

foundry_sdk/_core/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@
1515

1616
from foundry_sdk._core.api_client import ApiClient
1717
from foundry_sdk._core.api_client import ApiResponse
18+
from foundry_sdk._core.api_client import AsyncApiClient
19+
from foundry_sdk._core.api_client import AsyncApiResponse
1820
from foundry_sdk._core.api_client import RequestInfo
1921
from foundry_sdk._core.api_client import SdkInternal
2022
from foundry_sdk._core.api_client import StreamedApiResponse
2123
from foundry_sdk._core.api_client import StreamingContextManager
24+
from foundry_sdk._core.api_client import async_with_raw_response
25+
from foundry_sdk._core.api_client import async_with_streaming_response
2226
from foundry_sdk._core.api_client import with_raw_response
2327
from foundry_sdk._core.api_client import with_streaming_response
2428
from foundry_sdk._core.auth_utils import Auth
@@ -27,6 +31,7 @@
2731
from foundry_sdk._core.confidential_client_auth import ConfidentialClientAuth
2832
from foundry_sdk._core.config import Config
2933
from foundry_sdk._core.public_client_auth import PublicClientAuth
34+
from foundry_sdk._core.resource_iterator import AsyncResourceIterator
3035
from foundry_sdk._core.resource_iterator import ResourceIterator
3136
from foundry_sdk._core.user_token_auth_client import UserTokenAuth
3237
from foundry_sdk._core.utils import RID

0 commit comments

Comments
 (0)