diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index e193b5e4..8457ba25 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -3,10 +3,10 @@ id: 8b5fa338-9106-4734-abf0-e30d67044a90 management: docChecksum: 21f469b38bb72725739ee9d9d0fc8780 docVersion: 1.0.51 - speakeasyVersion: 1.405.6 - generationVersion: 2.428.1 - releaseVersion: 0.26.0-beta.4 - configChecksum: 0b79ec3eb6db29cf265da8359efa5611 + speakeasyVersion: 1.410.0 + generationVersion: 2.434.1 + releaseVersion: 0.26.0 + configChecksum: 0916704b547a0697b2ccf93c0d4becac repoURL: https://github.com/Unstructured-IO/unstructured-python-client.git repoSubDirectory: . installationURL: https://github.com/Unstructured-IO/unstructured-python-client.git @@ -14,8 +14,8 @@ management: features: python: additionalDependencies: 1.0.0 - constsAndDefaults: 1.0.3 - core: 5.5.7 + constsAndDefaults: 1.0.4 + core: 5.5.8 defaultEnabledRetries: 0.2.0 enumUnions: 0.1.0 envVarSecurityUsage: 0.3.1 @@ -36,6 +36,7 @@ features: uploadStreams: 1.0.0 generatedFiles: - .gitattributes + - .python-version - .vscode/settings.json - CONTRIBUTING.md - USAGE.md diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 20b8cc73..04018a2f 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,8 +1,8 @@ -speakeasyVersion: 1.405.6 +speakeasyVersion: 1.410.0 sources: my-source: sourceNamespace: my-source - sourceRevisionDigest: sha256:e3464d52f2e61a998b54643c076678c5fd4239186074f29643d5703366dedd85 + sourceRevisionDigest: sha256:4587b07d95e133a5fe806b02e4b82bb9e268499adeaa299139edf722073f5bb1 sourceBlobDigest: sha256:27e4879df402e924f9f65d336ea6d2fc8b16a00b87b4a802866238f7e9f639d3 tags: - latest @@ -11,7 +11,7 @@ targets: unstructured-python: source: my-source sourceNamespace: my-source - sourceRevisionDigest: sha256:e3464d52f2e61a998b54643c076678c5fd4239186074f29643d5703366dedd85 + sourceRevisionDigest: sha256:4587b07d95e133a5fe806b02e4b82bb9e268499adeaa299139edf722073f5bb1 sourceBlobDigest: sha256:27e4879df402e924f9f65d336ea6d2fc8b16a00b87b4a802866238f7e9f639d3 workflow: workflowVersion: 1.0.0 diff --git a/README.md b/README.md index f798f76e..4296f1e0 100755 --- a/README.md +++ b/README.md @@ -137,13 +137,24 @@ if res.elements is not None: ## Error Handling -Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an error. If Error objects are specified in your OpenAPI Spec, the SDK will raise the appropriate Error type. +Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception. -| Error Object | Status Code | Content Type | +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 `partition_async` method may raise the following exceptions: + +| Error Type | Status Code | Content Type | | -------------------------- | -------------------------- | -------------------------- | | errors.HTTPValidationError | 422 | application/json | | errors.ServerError | 5XX | application/json | -| errors.SDKError | 4xx-5xx | */* | +| errors.SDKError | 4XX | \*/\* | ### Example diff --git a/RELEASES.md b/RELEASES.md index 4de9c6e3..803be956 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -684,4 +684,14 @@ Based on: ### Generated - [python v0.26.0-beta.4] . ### Releases -- [PyPI v0.26.0-beta.4] https://pypi.org/project/unstructured-client/0.26.0-beta.4 - . \ No newline at end of file +- [PyPI v0.26.0-beta.4] https://pypi.org/project/unstructured-client/0.26.0-beta.4 - . + +## 2024-10-07 00:09:40 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.410.0 (2.434.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v0.26.0] . +### Releases +- [PyPI v0.26.0] https://pypi.org/project/unstructured-client/0.26.0 - . \ No newline at end of file diff --git a/gen.yaml b/gen.yaml index 3a369a6e..45b10d16 100644 --- a/gen.yaml +++ b/gen.yaml @@ -33,6 +33,7 @@ python: responseRequiredSep2024: false flattenGlobalSecurity: true flattenRequests: false + flatteningOrder: parameters-first imports: option: openapi paths: diff --git a/pyproject.toml b/pyproject.toml index d0c94840..3f728816 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "unstructured-client" -version = "0.26.0-beta.4" +version = "0.26.0" description = "Python Client SDK for Unstructured API" authors = ["Unstructured",] readme = "README-PYPI.md" diff --git a/src/unstructured_client/models/operations/partition.py b/src/unstructured_client/models/operations/partition.py index ce6ab779..d57cfcd1 100644 --- a/src/unstructured_client/models/operations/partition.py +++ b/src/unstructured_client/models/operations/partition.py @@ -4,8 +4,8 @@ import httpx import pydantic from pydantic import model_serializer -from typing import Any, Dict, List, Optional, TypedDict -from typing_extensions import Annotated, NotRequired +from typing import Any, Dict, List, Optional +from typing_extensions import Annotated, NotRequired, TypedDict from unstructured_client.models.shared import ( partition_parameters as shared_partition_parameters, ) diff --git a/src/unstructured_client/models/shared/partition_parameters.py b/src/unstructured_client/models/shared/partition_parameters.py index df2865b8..8670f5fd 100644 --- a/src/unstructured_client/models/shared/partition_parameters.py +++ b/src/unstructured_client/models/shared/partition_parameters.py @@ -6,8 +6,8 @@ import pydantic from pydantic import model_serializer from pydantic.functional_validators import PlainValidator -from typing import IO, List, Optional, TypedDict, Union -from typing_extensions import Annotated, NotRequired +from typing import IO, List, Optional, Union +from typing_extensions import Annotated, NotRequired, TypedDict from unstructured_client import utils from unstructured_client.types import ( BaseModel, diff --git a/src/unstructured_client/models/shared/security.py b/src/unstructured_client/models/shared/security.py index 5b452b2d..be191705 100644 --- a/src/unstructured_client/models/shared/security.py +++ b/src/unstructured_client/models/shared/security.py @@ -1,8 +1,8 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from typing import Optional, TypedDict -from typing_extensions import Annotated, NotRequired +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict from unstructured_client.types import BaseModel from unstructured_client.utils import FieldMetadata, SecurityMetadata diff --git a/src/unstructured_client/models/shared/validationerror.py b/src/unstructured_client/models/shared/validationerror.py index f9bf74dc..d221b582 100644 --- a/src/unstructured_client/models/shared/validationerror.py +++ b/src/unstructured_client/models/shared/validationerror.py @@ -1,7 +1,8 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from typing import List, TypedDict, Union +from typing import List, Union +from typing_extensions import TypedDict from unstructured_client.types import BaseModel diff --git a/src/unstructured_client/sdkconfiguration.py b/src/unstructured_client/sdkconfiguration.py index 0c24c405..d8111013 100644 --- a/src/unstructured_client/sdkconfiguration.py +++ b/src/unstructured_client/sdkconfiguration.py @@ -34,11 +34,9 @@ class SDKConfiguration: server: Optional[str] = "" language: str = "python" openapi_doc_version: str = "1.0.51" - sdk_version: str = "0.26.0-beta.4" - gen_version: str = "2.428.1" - user_agent: str = ( - "speakeasy-sdk/python 0.26.0-beta.4 2.428.1 1.0.51 unstructured-client" - ) + sdk_version: str = "0.26.0" + gen_version: str = "2.434.1" + user_agent: str = "speakeasy-sdk/python 0.26.0 2.434.1 1.0.51 unstructured-client" retry_config: OptionalNullable[RetryConfig] = Field(default_factory=lambda: UNSET) timeout_ms: Optional[int] = None diff --git a/src/unstructured_client/utils/__init__.py b/src/unstructured_client/utils/__init__.py index 6c26aeb9..d248ebc9 100644 --- a/src/unstructured_client/utils/__init__.py +++ b/src/unstructured_client/utils/__init__.py @@ -27,6 +27,7 @@ serialize_float, serialize_int, stream_to_text, + validate_const, validate_decimal, validate_float, validate_int, @@ -83,6 +84,7 @@ "unmarshal", "unmarshal_json", "validate_decimal", + "validate_const", "validate_float", "validate_int", "validate_open_enum", diff --git a/src/unstructured_client/utils/serializers.py b/src/unstructured_client/utils/serializers.py index 85d57f43..605133c7 100644 --- a/src/unstructured_client/utils/serializers.py +++ b/src/unstructured_client/utils/serializers.py @@ -116,6 +116,19 @@ def validate(e): return validate +def validate_const(v): + def validate(c): + if is_optional_type(type(c)) and c is None: + return None + + if v != c: + raise ValueError(f"Expected {v}") + + return c + + return validate + + def unmarshal_json(raw, typ: Any) -> Any: return unmarshal(from_json(raw), typ)