Skip to content

Commit 448a2a9

Browse files
Excavator: Upgrade API Version
1 parent 7a0493a commit 448a2a9

File tree

111 files changed

+31020
-410
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

+31020
-410
lines changed

README.md

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -202,27 +202,61 @@ the [Pydantic error documentation](https://docs.pydantic.dev/latest/errors/error
202202
experience. See [Static Type Analysis](#static-types) below for more information.
203203

204204
### HTTP exceptions
205-
When an HTTP error status is returned, a `PalantirRPCException` is thrown.
205+
When an HTTP error status is returned, a `PalantirRPCException` is thrown. There are several
206+
subclasses that be caught for more specific conditions, all of which inherit from
207+
`PalantirRPCException`.
208+
209+
210+
| Status Code | Error Class |
211+
| ----------- | -------------------------- |
212+
| 400 | `BadRequestError` |
213+
| 401 | `UnauthorizedError` |
214+
| 403 | `PermissionDeniedError` |
215+
| 404 | `NotFoundError` |
216+
| 422 | `UnprocessableEntityError` |
217+
| 429 | `RateLimitError` |
218+
| >=500,<600 | `InternalServerError` |
219+
| Other | `PalantirRPCException` |
206220

207221
```python
208222
from foundry import PalantirRPCException
223+
from foundry import NotFoundError
224+
from foundry import RateLimitError
209225

210226

211227
try:
212228
api_response = foundry_client.datasets.Transaction.abort(dataset_rid, transaction_rid)
213229
...
230+
except NotFoundError as e:
231+
print("Dataset or Transaction not found", e)
232+
except RateLimitError as e:
233+
print("We are aborting too many Transactions", e)
214234
except PalantirRPCException as e:
215-
print("Another HTTP exception occurred: " + str(e))
235+
print("Another HTTP exception occurred", e)
216236
```
217237

218-
This exception will have the following properties. See the [Foundry API docs](https://www.palantir.com/docs/foundry/api/general/overview/errors) for details about the Foundry error information.
238+
All HTTP exceptions will have the following properties. See the [Foundry API docs](https://www.palantir.com/docs/foundry/api/general/overview/errors) for details about the Foundry error information.
219239

220240
| Property | Type | Description |
221241
| ----------------- | -----------------------| ------------------------------------------------------------------------------------------------------------------------------ |
222242
| name | str | The Palantir error name. See the [Foundry API docs](https://www.palantir.com/docs/foundry/api/general/overview/errors). |
223243
| error_instance_id | str | The Palantir error instance ID. See the [Foundry API docs](https://www.palantir.com/docs/foundry/api/general/overview/errors). |
224244
| parameters | Dict[str, Any] | The Palantir error parameters. See the [Foundry API docs](https://www.palantir.com/docs/foundry/api/general/overview/errors). |
225245

246+
### Other exceptions
247+
There are a handful of other exception classes that could be thrown when instantiating or using a client.
248+
249+
| ErrorClass | Thrown Directly | Description |
250+
| ------------------------ | --------------- | --------------------------------------------------------------------------------------------------------------------------------- |
251+
| NotAuthenticated | Yes | You used either `ConfidentialClientAuth` or `PublicClientAuth` to make an API call without going through the OAuth process first. |
252+
| ConnectionError | Yes | An issue occurred when connecting to the server. This also catches both `ProxyError` and `SSLError`. |
253+
| ProxyError | Yes | An issue occurred when connecting to or authenticating with a proxy server. |
254+
| SSLError | Yes | An SSL error occurred when connecting to the server. |
255+
| TimeoutError | No | The request timed out. This catches both `ConnectTimeout` and `ReadTimeout`. |
256+
| ConnectTimeout | Yes | The request timed out when attempting to connect to the server. |
257+
| ReadTimeout | Yes | The server did not send any data in the allotted amount of time. |
258+
| StreamConsumedError | Yes | The content of the given stream has already been consumed. |
259+
| SDKInternalError | Yes | An unexpected issue occurred and should be reported. |
226260

227261
<a id="pagination"></a>
228262
## Pagination
@@ -251,26 +285,20 @@ while page.next_page_token:
251285

252286
<a id="binary-streaming"></a>
253287
## Streaming
254-
This SDK supports optionally streaming binary data using a flag in the method definition.
288+
This SDK supports streaming binary data using a separate streaming client accessible under
289+
`with_streaming_response` on each Resource. To ensure the stream is closed, you need to use a context
290+
manager when making a request with this client.
255291

256292
```python
257293
# Non-streaming response
258-
with open("profile_picture.png", "rb") as f:
294+
with open("profile_picture.png", "wb") as f:
259295
f.write(foundry_client.admin.User.profile_picture(user_id))
260296

261297
# Streaming response
262-
with open("profile_picture.png", "rb") as f:
263-
for chunk in foundry_client.admin.User.profile_picture(user_id, stream=True):
264-
f.write(chunk)
265-
```
266-
267-
This flag is available on all endpoints which return binary data. Additionally, you can set a desired `chunk_size` to read into memory before
268-
the next chunk is given to you. By default, this value is set to None and chunks will be returned to you as they are received from the host.
269-
270-
```python
271-
with open("profile_picture.png", "rb") as f:
272-
for chunk in foundry_client.admin.User.profile_picture(user_id, stream=True, chunk_size=1024):
273-
f.write(chunk)
298+
with open("profile_picture.png", "wb") as f:
299+
with foundry_client.admin.User.with_streaming_response.profile_picture(user_id) as response:
300+
for chunk in response.iter_bytes():
301+
f.write(chunk)
274302
```
275303

276304
<a id="static-types"></a>
@@ -1401,6 +1429,7 @@ Namespace | Resource | Operation | HTTP request |
14011429
- [SearchJsonQueryV2Dict](docs/v2/models/SearchJsonQueryV2Dict.md)
14021430
- [SearchObjectsResponseV2](docs/v2/models/SearchObjectsResponseV2.md)
14031431
- [SearchObjectsResponseV2Dict](docs/v2/models/SearchObjectsResponseV2Dict.md)
1432+
- [SearchOrderByType](docs/v2/models/SearchOrderByType.md)
14041433
- [SearchOrderByV2Dict](docs/v2/models/SearchOrderByV2Dict.md)
14051434
- [SearchOrderingV2Dict](docs/v2/models/SearchOrderingV2Dict.md)
14061435
- [SelectedPropertyApiName](docs/v2/models/SelectedPropertyApiName.md)
@@ -1811,6 +1840,7 @@ Namespace | Resource | Operation | HTTP request |
18111840
- [SearchObjectsResponse](docs/v1/models/SearchObjectsResponse.md)
18121841
- [SearchObjectsResponseDict](docs/v1/models/SearchObjectsResponseDict.md)
18131842
- [SearchOrderByDict](docs/v1/models/SearchOrderByDict.md)
1843+
- [SearchOrderByType](docs/v1/models/SearchOrderByType.md)
18141844
- [SearchOrderingDict](docs/v1/models/SearchOrderingDict.md)
18151845
- [SelectedPropertyApiName](docs/v1/models/SelectedPropertyApiName.md)
18161846
- [SharedPropertyTypeApiName](docs/v1/models/SharedPropertyTypeApiName.md)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# SearchOrderByType
2+
3+
SearchOrderByType
4+
5+
| **Value** |
6+
| --------- |
7+
| `"fields"` |
8+
| `"relevance"` |
9+
10+
11+
[[Back to Model list]](../../../../README.md#models-v1-link) [[Back to API list]](../../../../README.md#apis-v1-link) [[Back to README]](../../../../README.md)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# SearchOrderByType
2+
3+
SearchOrderByType
4+
5+
| **Value** |
6+
| --------- |
7+
| `"fields"` |
8+
| `"relevance"` |
9+
10+
11+
[[Back to Model list]](../../../../README.md#models-v2-link) [[Back to API list]](../../../../README.md#apis-v2-link) [[Back to README]](../../../../README.md)

docs/v2/ontologies/models/SearchOrderByV2Dict.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# SearchOrderByV2Dict
22

3-
Specifies the ordering of search results by a field and an ordering direction.
3+
Specifies the ordering of search results by a field and an ordering direction or by relevance if scores are required in a nearestNeighbors query. By default `orderType` is set to `fields`.
44

55
## Properties
66
| Name | Type | Required | Description |
77
| ------------ | ------------- | ------------- | ------------- |
8+
**orderType** | NotRequired[SearchOrderByType] | No | |
89
**fields** | List[SearchOrderingV2Dict] | Yes | |
910

1011

foundry/__init__.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,32 @@
1313
# limitations under the License.
1414

1515

16+
from foundry._core import ApiResponse
1617
from foundry._core import ConfidentialClientAuth
1718
from foundry._core import Config
19+
from foundry._core import ResourceIterator
20+
from foundry._core import StreamedApiResponse
21+
from foundry._core import StreamingContextManager
1822
from foundry._core import UserTokenAuth
23+
from foundry._errors import BadRequestError
24+
from foundry._errors import ConnectionError
25+
from foundry._errors import ConnectTimeout
1926
from foundry._errors import EnvironmentNotConfigured
27+
from foundry._errors import InternalServerError
2028
from foundry._errors import NotAuthenticated
29+
from foundry._errors import NotFoundError
30+
from foundry._errors import PalantirException
2131
from foundry._errors import PalantirRPCException
32+
from foundry._errors import PermissionDeniedError
33+
from foundry._errors import ProxyError
34+
from foundry._errors import RateLimitError
35+
from foundry._errors import ReadTimeout
36+
from foundry._errors import SDKInternalError
37+
from foundry._errors import SSLError
38+
from foundry._errors import StreamConsumedError
39+
from foundry._errors import TimeoutError
40+
from foundry._errors import UnauthorizedError
41+
from foundry._errors import UnprocessableEntityError
2242

2343
# The OpenAPI document version from the spec information
2444
# See https://swagger.io/specification/#info-object
@@ -36,7 +56,20 @@
3656
"ConfidentialClientAuth",
3757
"UserTokenAuth",
3858
"Config",
39-
"NotAuthenticated",
59+
"PalantirException",
4060
"EnvironmentNotConfigured",
61+
"NotAuthenticated",
62+
"ConnectionError",
63+
"ProxyError",
64+
"SSLError",
4165
"PalantirRPCException",
66+
"BadRequestError",
67+
"UnauthorizedError",
68+
"PermissionDeniedError",
69+
"NotFoundError",
70+
"UnprocessableEntityError",
71+
"RateLimitError",
72+
"InternalServerError",
73+
"SDKInternalError",
74+
"StreamConsumedError",
4275
]

foundry/_core/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414

1515

1616
from foundry._core.api_client import ApiClient
17+
from foundry._core.api_client import ApiResponse
1718
from foundry._core.api_client import RequestInfo
19+
from foundry._core.api_client import StreamedApiResponse
20+
from foundry._core.api_client import StreamingContextManager
1821
from foundry._core.auth_utils import Auth
1922
from foundry._core.binary_stream import BinaryStream
2023
from foundry._core.confidential_client_auth import ConfidentialClientAuth

0 commit comments

Comments
 (0)