diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 73804c70..cc6c7abb 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 8b5fa338-9106-4734-abf0-e30d67044a90 management: - docChecksum: 0593f5359a35b34f3dc1b346490deff2 - docVersion: 1.1.39 - speakeasyVersion: 1.568.0 - generationVersion: 2.632.2 - releaseVersion: 0.40.0 - configChecksum: 70954879fd1a6da62295461541e8680c + docChecksum: ae9cd2cec2edbde7b002c0a127c7aa84 + docVersion: 1.1.42 + speakeasyVersion: 1.589.0 + generationVersion: 2.664.0 + releaseVersion: 0.41.0 + configChecksum: b2d39b13446f595978a73e31a796dbe7 repoURL: https://github.com/Unstructured-IO/unstructured-python-client.git repoSubDirectory: . installationURL: https://github.com/Unstructured-IO/unstructured-python-client.git @@ -16,17 +16,16 @@ features: acceptHeaders: 3.0.0 additionalDependencies: 1.0.0 constsAndDefaults: 1.0.5 - core: 5.19.3 + core: 5.19.4 customCodeRegions: 0.1.1 defaultEnabledRetries: 0.2.0 enumUnions: 0.1.0 envVarSecurityUsage: 0.3.2 - examples: 3.0.1 + examples: 3.0.2 globalSecurity: 3.0.3 globalSecurityCallbacks: 1.0.0 globalSecurityFlattening: 1.0.0 globalServerURLs: 3.1.1 - methodServerURLs: 3.1.1 multipartFileContentType: 1.0.0 nameOverrides: 3.0.1 nullables: 1.0.1 @@ -39,7 +38,6 @@ features: uploadStreams: 1.0.0 generatedFiles: - .gitattributes - - .python-version - .vscode/settings.json - USAGE.md - docs/models/errors/detail.md @@ -252,12 +250,17 @@ generatedFiles: - src/unstructured_client/_hooks/types.py - src/unstructured_client/_version.py - src/unstructured_client/basesdk.py + - src/unstructured_client/destinations.py - src/unstructured_client/httpclient.py + - src/unstructured_client/jobs.py - src/unstructured_client/models/__init__.py - src/unstructured_client/models/errors/__init__.py - src/unstructured_client/models/errors/httpvalidationerror.py + - src/unstructured_client/models/errors/no_response_error.py + - src/unstructured_client/models/errors/responsevalidationerror.py - src/unstructured_client/models/errors/sdkerror.py - src/unstructured_client/models/errors/servererror.py + - src/unstructured_client/models/errors/unstructuredclienterror.py - src/unstructured_client/models/operations/__init__.py - src/unstructured_client/models/operations/cancel_job.py - src/unstructured_client/models/operations/create_connection_check_destinations.py @@ -404,6 +407,7 @@ generatedFiles: - src/unstructured_client/py.typed - src/unstructured_client/sdk.py - src/unstructured_client/sdkconfiguration.py + - src/unstructured_client/sources.py - src/unstructured_client/types/__init__.py - src/unstructured_client/types/basemodel.py - src/unstructured_client/users.py @@ -421,8 +425,10 @@ generatedFiles: - src/unstructured_client/utils/retries.py - src/unstructured_client/utils/security.py - src/unstructured_client/utils/serializers.py + - src/unstructured_client/utils/unmarshal_json_response.py - src/unstructured_client/utils/url.py - src/unstructured_client/utils/values.py + - src/unstructured_client/workflows.py examples: create_connection_check_destinations: speakeasy-default-create-connection-check-destinations: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 84c24252..906c378a 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,21 +1,21 @@ -speakeasyVersion: 1.552.0 +speakeasyVersion: 1.589.0 sources: my-source: sourceNamespace: my-source - sourceRevisionDigest: sha256:ac2955e4a812caa63ad339156504c9bdfae02dd241800a6c48892aaf37552c54 - sourceBlobDigest: sha256:eb516ced31caa9801a7996b8216fa7c7a46ab16dc9edd4d9eef5721cee7acd6c + sourceRevisionDigest: sha256:dc1c7c974419187404b25cb443e0d2497aa8b3ab71c95f27054eb5cd87b02ed0 + sourceBlobDigest: sha256:538ee1e259eb1db25ba57b09ba271636bad0015a794517bf6f910315e7ecaac3 tags: - latest - - speakeasy-sdk-regen-1752365566 - - 1.1.34 + - speakeasy-sdk-regen-1753403247 + - 1.1.42 targets: unstructured-python: source: my-source sourceNamespace: my-source - sourceRevisionDigest: sha256:ac2955e4a812caa63ad339156504c9bdfae02dd241800a6c48892aaf37552c54 - sourceBlobDigest: sha256:eb516ced31caa9801a7996b8216fa7c7a46ab16dc9edd4d9eef5721cee7acd6c + sourceRevisionDigest: sha256:dc1c7c974419187404b25cb443e0d2497aa8b3ab71c95f27054eb5cd87b02ed0 + sourceBlobDigest: sha256:538ee1e259eb1db25ba57b09ba271636bad0015a794517bf6f910315e7ecaac3 codeSamplesNamespace: my-source-code-samples - codeSamplesRevisionDigest: sha256:e644b82aab2fb0dc0c506d643aa22910ae14bc998f2b13ac7cc019a789dbe552 + codeSamplesRevisionDigest: sha256:1e8db4a01c54f1f99e27cc80d3f5283192aa2a6a68001f80424fbf9bdface495 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/README.md b/README.md index c5327816..8adbf15e 100644 --- a/README.md +++ b/README.md @@ -153,26 +153,18 @@ with UnstructuredClient( ## Error Handling -Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception. +[`UnstructuredClientError`](./src/unstructured_client/models/errors/unstructuredclienterror.py) is the base class for all HTTP error responses. It has the following properties: -By default, an API error will raise a errors.SDKError exception, which has the following properties: - -| Property | Type | Description | -|-----------------|------------------|-----------------------| -| `.status_code` | *int* | The HTTP status code | -| `.message` | *str* | The error message | -| `.raw_response` | *httpx.Response* | The raw HTTP response | -| `.body` | *str* | The response content | - -When custom error responses are specified for an operation, the SDK may also raise their associated exceptions. You can refer to respective *Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the `create_connection_check_destinations_async` method may raise the following exceptions: - -| Error Type | Status Code | Content Type | -| -------------------------- | ----------- | ---------------- | -| errors.HTTPValidationError | 422 | application/json | -| errors.SDKError | 4XX, 5XX | \*/\* | +| Property | Type | Description | +| ------------------ | ---------------- | --------------------------------------------------------------------------------------- | +| `err.message` | `str` | Error message | +| `err.status_code` | `int` | HTTP response status code eg `404` | +| `err.headers` | `httpx.Headers` | HTTP response headers | +| `err.body` | `str` | HTTP body. Can be empty string if no body is returned. | +| `err.raw_response` | `httpx.Response` | Raw HTTP response | +| `err.data` | | Optional. Some errors may contain structured data. [See Error Classes](#error-classes). | ### Example - ```python from unstructured_client import UnstructuredClient from unstructured_client.models import errors @@ -191,13 +183,42 @@ with UnstructuredClient() as uc_client: # Handle response print(res.dag_node_connection_check) - except errors.HTTPValidationError as e: - # handle e.data: errors.HTTPValidationErrorData - raise(e) - except errors.SDKError as e: - # handle exception - raise(e) + + except errors.UnstructuredClientError as e: + # The base class for HTTP error responses + print(e.message) + print(e.status_code) + print(e.body) + print(e.headers) + print(e.raw_response) + + # Depending on the method different errors may be thrown + if isinstance(e, errors.HTTPValidationError): + print(e.data.detail) # Optional[errors.Detail] ``` + +### Error Classes +**Primary errors:** +* [`UnstructuredClientError`](./src/unstructured_client/models/errors/unstructuredclienterror.py): The base class for HTTP error responses. + * [`HTTPValidationError`](./src/unstructured_client/models/errors/httpvalidationerror.py): Validation Error. Status code `422`. + +
Less common errors (6) + +
+ +**Network errors:** +* [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors. + * [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server. + * [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out. + + +**Inherit from [`UnstructuredClientError`](./src/unstructured_client/models/errors/unstructuredclienterror.py)**: +* [`ServerError`](./src/unstructured_client/models/errors/servererror.py): Server Error. Status code `5XX`. Applicable to 1 of 29 methods.* +* [`ResponseValidationError`](./src/unstructured_client/models/errors/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute. + +
+ +\* Check [the method documentation](#available-resources-and-operations) to see if the error is applicable. diff --git a/RELEASES.md b/RELEASES.md index 95f157fe..38a2eb87 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1069,3 +1069,14 @@ Based on: - [python v0.40.0] . ### Releases - [PyPI v0.40.0] https://pypi.org/project/unstructured-client/0.40.0 - . + + +## 2025-07-25 00:27:12 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.589.0 (2.664.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v0.41.0] . +### Releases +- [PyPI v0.41.0] https://pypi.org/project/unstructured-client/0.41.0 - . \ No newline at end of file diff --git a/codeSamples.yaml b/codeSamples.yaml index 65769ea2..34946cad 100644 --- a/codeSamples.yaml +++ b/codeSamples.yaml @@ -123,18 +123,18 @@ actions: - "lang": "python" "label": "create_connection_check_sources" "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient() as uc_client:\n\n res = uc_client.sources.create_connection_check_sources(request={\n \"source_id\": \"8d49e3f2-3e6d-4973-bc61-292af66829d7\",\n })\n\n assert res.dag_node_connection_check is not None\n\n # Handle response\n print(res.dag_node_connection_check)" - - target: $["paths"]["/api/v1/users/retrieve"]["post"] - update: - "x-codeSamples": - - "lang": "python" - "label": "retrieve" - "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient() as uc_client:\n\n res = uc_client.users.retrieve(request={})\n\n assert res.pem_auth_response is not None\n\n # Handle response\n print(res.pem_auth_response)" - target: $["paths"]["/api/v1/users/secrets"]["post"] update: "x-codeSamples": - "lang": "python" "label": "store_secret" "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient() as uc_client:\n\n res = uc_client.users.store_secret(request={\n \"encrypted_secret\": {\n \"encrypted_value\": \"\",\n },\n })\n\n assert res.secret_reference is not None\n\n # Handle response\n print(res.secret_reference)" + - target: $["paths"]["/api/v1/users/secrets/encryption-certificate"]["get"] + update: + "x-codeSamples": + - "lang": "python" + "label": "get_encryption_certificate" + "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient() as uc_client:\n\n res = uc_client.users.get_encryption_certificate(request={})\n\n assert res.encryption_certificate_response is not None\n\n # Handle response\n print(res.encryption_certificate_response)" - target: $["paths"]["/api/v1/workflows/"]["get"] update: "x-codeSamples": @@ -176,4 +176,4 @@ actions: "x-codeSamples": - "lang": "python" "label": "partition" - "source": "from unstructured_client import UnstructuredClient\nfrom unstructured_client.models import shared\n\n\nwith UnstructuredClient() as uc_client:\n\n res = uc_client.general.partition(request={\n \"partition_parameters\": {\n \"files\": {\n \"file_name\": \"example.file\",\n \"content\": open(\"example.file\", \"rb\"),\n },\n \"vlm_model_provider\": shared.VLMModelProvider.OPENAI,\n \"vlm_model\": shared.VLMModel.GPT_4O,\n \"split_pdf_page_range\": [\n 1,\n 10,\n ],\n },\n })\n\n assert res.elements is not None\n\n # Handle response\n print(res.elements)" + "source": "from unstructured_client import UnstructuredClient\nfrom unstructured_client.models import shared\n\n\nwith UnstructuredClient() as uc_client:\n\n res = uc_client.general.partition(request={\n \"partition_parameters\": {\n \"files\": {\n \"file_name\": \"example.file\",\n \"content\": open(\"example.file\", \"rb\"),\n },\n \"strategy\": shared.Strategy.AUTO,\n \"vlm_model_provider\": shared.VLMModelProvider.OPENAI,\n \"vlm_model\": shared.VLMModel.GPT_4O,\n \"chunking_strategy\": \"by_title\",\n \"split_pdf_page_range\": [\n 1,\n 10,\n ],\n \"split_pdf_cache_tmp_data_dir\": \"\",\n },\n })\n\n assert res.elements is not None\n\n # Handle response\n print(res.elements)" diff --git a/gen.yaml b/gen.yaml index f2fee0da..293f978d 100644 --- a/gen.yaml +++ b/gen.yaml @@ -13,6 +13,10 @@ generation: auth: oAuth2ClientCredentialsEnabled: false oAuth2PasswordEnabled: false + tests: + generateTests: true + generateNewTests: false + skipResponseBodyAssertions: false python: version: 0.41.0 additionalDependencies: diff --git a/pyproject.toml b/pyproject.toml index 3d326882..87b81f8c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "unstructured-client" -version = "0.40.0" +version = "0.41.0" description = "Python Client SDK for Unstructured API" authors = [{ name = "Unstructured" },] readme = "README-PYPI.md" diff --git a/src/unstructured_client/_version.py b/src/unstructured_client/_version.py index b8a3d7b6..3e673c3b 100644 --- a/src/unstructured_client/_version.py +++ b/src/unstructured_client/_version.py @@ -3,10 +3,10 @@ import importlib.metadata __title__: str = "unstructured-client" -__version__: str = "0.40.0" -__openapi_doc_version__: str = "1.1.39" -__gen_version__: str = "2.632.2" -__user_agent__: str = "speakeasy-sdk/python 0.40.0 2.632.2 1.1.39 unstructured-client" +__version__: str = "0.41.0" +__openapi_doc_version__: str = "1.1.42" +__gen_version__: str = "2.664.0" +__user_agent__: str = "speakeasy-sdk/python 0.41.0 2.664.0 1.1.42 unstructured-client" try: if __package__ is not None: