diff --git a/README.md b/README.md index 2bc2dc56..878a76e0 100755 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ s = unstructured_client.UnstructuredClient( The Python SDK makes API calls using the (requests)[https://pypi.org/project/requests/] HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a custom `requests.Session` object. -For example, you could specify a header for every request that your sdk makes as follows: +For example, you could specify a header for every request that this sdk makes as follows: ```python import unstructured_client @@ -116,6 +116,9 @@ s = unstructured_client.UnstructuredClient(client: http_client) ``` + + + ### Maturity diff --git a/RELEASES.md b/RELEASES.md index 20fdaccf..0fd986d8 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -234,4 +234,24 @@ Based on: ### Generated - [python v0.12.2] . ### Releases -- [PyPI v0.12.2] https://pypi.org/project/unstructured-client/0.12.2 - . \ No newline at end of file +- [PyPI v0.12.2] https://pypi.org/project/unstructured-client/0.12.2 - . + +## 2023-11-07 00:18:31 +### Changes +Based on: +- OpenAPI Doc 0.0.1 +- Speakeasy CLI 1.114.1 (2.181.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v0.13.0] . +### Releases +- [PyPI v0.13.0] https://pypi.org/project/unstructured-client/0.13.0 - . + +## 2023-11-09 00:18:03 +### Changes +Based on: +- OpenAPI Doc 0.0.1 +- Speakeasy CLI 1.116.0 (2.185.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v0.14.0] . +### Releases +- [PyPI v0.14.0] https://pypi.org/project/unstructured-client/0.14.0 - . \ No newline at end of file diff --git a/USAGE.md b/USAGE.md index 936f8f05..0f0f853e 100755 --- a/USAGE.md +++ b/USAGE.md @@ -13,9 +13,9 @@ req = shared.PartitionParameters( chunking_strategy='by_title', combine_under_n_chars=500, encoding='utf-8', - files=shared.PartitionParametersFiles( - content='+WmI5Q)|yy'.encode(), - files='string', + files=shared.Files( + content='0x2cC94b2FEF'.encode(), + file_name='um.shtml', ), gz_uncompressed_content_type='application/pdf', hi_res_model_name='yolox', diff --git a/docs/models/errors/httpvalidationerror.md b/docs/models/errors/httpvalidationerror.md index 9e6bbfb3..2bd575a0 100755 --- a/docs/models/errors/httpvalidationerror.md +++ b/docs/models/errors/httpvalidationerror.md @@ -3,6 +3,6 @@ ## Fields -| Field | Type | Required | Description | -| --------------------------------------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------- | -| `detail` | List[[ValidationError](../../models/errors/validationerror.md)] | :heavy_minus_sign: | N/A | \ No newline at end of file +| Field | Type | Required | Description | +| ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | +| `detail` | List[[errors.ValidationError](../../models/errors/validationerror.md)] | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/errors/loc.md b/docs/models/errors/loc.md new file mode 100755 index 00000000..cfb10450 --- /dev/null +++ b/docs/models/errors/loc.md @@ -0,0 +1,17 @@ +# Loc + + +## Supported Types + +### + +```python +loc: str = /* values here */ +``` + +### + +```python +loc: int = /* values here */ +``` + diff --git a/docs/models/errors/validationerror.md b/docs/models/errors/validationerror.md index 7b027e68..9a89662d 100755 --- a/docs/models/errors/validationerror.md +++ b/docs/models/errors/validationerror.md @@ -3,8 +3,8 @@ ## Fields -| Field | Type | Required | Description | -| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | -| `loc` | List[[Union[str, int]](../../models/errors/validationerrorloc.md)] | :heavy_check_mark: | N/A | -| `msg` | *str* | :heavy_check_mark: | N/A | -| `type` | *str* | :heavy_check_mark: | N/A | \ No newline at end of file +| Field | Type | Required | Description | +| --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | +| `loc` | List[[Union[str, int]](../../models/errors/loc.md)] | :heavy_check_mark: | N/A | +| `msg` | *str* | :heavy_check_mark: | N/A | +| `type` | *str* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/errors/validationerrorloc.md b/docs/models/errors/validationerrorloc.md deleted file mode 100755 index 537dd8dc..00000000 --- a/docs/models/errors/validationerrorloc.md +++ /dev/null @@ -1,17 +0,0 @@ -# ValidationErrorLoc - - -## Supported Types - -### - -```python -validationErrorLoc: str = /* values here */ -``` - -### - -```python -validationErrorLoc: int = /* values here */ -``` - diff --git a/docs/models/shared/partitionparametersfiles.md b/docs/models/shared/files.md similarity index 76% rename from docs/models/shared/partitionparametersfiles.md rename to docs/models/shared/files.md index b53cd038..27d480a0 100755 --- a/docs/models/shared/partitionparametersfiles.md +++ b/docs/models/shared/files.md @@ -1,4 +1,4 @@ -# PartitionParametersFiles +# Files ## Fields @@ -6,4 +6,4 @@ | Field | Type | Required | Description | | ------------------ | ------------------ | ------------------ | ------------------ | | `content` | *bytes* | :heavy_check_mark: | N/A | -| `files` | *str* | :heavy_check_mark: | N/A | \ No newline at end of file +| `file_name` | *str* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/shared/partitionparameters.md b/docs/models/shared/partitionparameters.md index 43b067d8..df6d5e1e 100755 --- a/docs/models/shared/partitionparameters.md +++ b/docs/models/shared/partitionparameters.md @@ -9,7 +9,7 @@ | `combine_under_n_chars` | *Optional[int]* | :heavy_minus_sign: | If chunking strategy is set, combine elements until a section reaches a length of n chars. Default: 500 | 500 | | `coordinates` | *Optional[bool]* | :heavy_minus_sign: | If true, return coordinates for each element. Default: false | | | `encoding` | *Optional[str]* | :heavy_minus_sign: | The encoding method used to decode the text input. Default: utf-8 | utf-8 | -| `files` | [Optional[PartitionParametersFiles]](../../models/shared/partitionparametersfiles.md) | :heavy_minus_sign: | The file to extract | | +| `files` | [Optional[shared.Files]](../../models/shared/files.md) | :heavy_minus_sign: | The file to extract | | | `gz_uncompressed_content_type` | *Optional[str]* | :heavy_minus_sign: | If file is gzipped, use this content type after unzipping | application/pdf | | `hi_res_model_name` | *Optional[str]* | :heavy_minus_sign: | The name of the inference model used when strategy is hi_res | yolox | | `include_page_breaks` | *Optional[bool]* | :heavy_minus_sign: | If True, the output will include page breaks if the filetype supports it. Default: false | | diff --git a/docs/sdks/general/README.md b/docs/sdks/general/README.md index 28716407..5f722ac7 100755 --- a/docs/sdks/general/README.md +++ b/docs/sdks/general/README.md @@ -23,9 +23,9 @@ req = shared.PartitionParameters( chunking_strategy='by_title', combine_under_n_chars=500, encoding='utf-8', - files=shared.PartitionParametersFiles( - content='+WmI5Q)|yy'.encode(), - files='string', + files=shared.Files( + content='0x2cC94b2FEF'.encode(), + file_name='um.shtml', ), gz_uncompressed_content_type='application/pdf', hi_res_model_name='yolox', @@ -65,4 +65,9 @@ if res.elements is not None: ### Response **[operations.PartitionResponse](../../models/operations/partitionresponse.md)** +### Errors +| Error Object | Status Code | Content Type | +| -------------------------- | -------------------------- | -------------------------- | +| errors.HTTPValidationError | 422 | application/json | +| errors.SDKError | 400-600 | */* | diff --git a/files.gen b/files.gen index a2bf49be..8625fd88 100755 --- a/files.gen +++ b/files.gen @@ -4,25 +4,25 @@ src/unstructured_client/sdk.py pylintrc setup.py src/unstructured_client/__init__.py -src/unstructured_client/models/__init__.py -src/unstructured_client/models/errors/sdkerror.py src/unstructured_client/utils/__init__.py src/unstructured_client/utils/retries.py src/unstructured_client/utils/utils.py +src/unstructured_client/models/errors/sdkerror.py src/unstructured_client/models/operations/partition.py -src/unstructured_client/models/operations/__init__.py src/unstructured_client/models/errors/httpvalidationerror.py src/unstructured_client/models/errors/validationerror.py -src/unstructured_client/models/errors/__init__.py src/unstructured_client/models/shared/partition_parameters.py src/unstructured_client/models/shared/security.py +src/unstructured_client/models/__init__.py +src/unstructured_client/models/errors/__init__.py +src/unstructured_client/models/operations/__init__.py src/unstructured_client/models/shared/__init__.py USAGE.md docs/models/operations/partitionresponse.md docs/models/errors/httpvalidationerror.md -docs/models/errors/validationerrorloc.md +docs/models/errors/loc.md docs/models/errors/validationerror.md -docs/models/shared/partitionparametersfiles.md +docs/models/shared/files.md docs/models/shared/partitionparameters.md docs/models/shared/security.md docs/sdks/unstructuredclient/README.md diff --git a/gen.yaml b/gen.yaml index f4e422ac..1f0ce33d 100644 --- a/gen.yaml +++ b/gen.yaml @@ -2,34 +2,39 @@ configVersion: 1.0.0 management: docChecksum: bf57420eebd40f2b1d166092f01e3927 docVersion: 0.0.1 - speakeasyVersion: 1.109.2 - generationVersion: 2.173.0 + speakeasyVersion: 1.116.0 + generationVersion: 2.185.0 generation: - comments: - disableComments: false - omitDescriptionIfSummaryPresent: false - baseServerURL: "" - repoURL: https://github.com/Unstructured-IO/unstructured-python-client.git + comments: {} sdkClassName: unstructured_client - singleTagPerOp: false - tagNamespacingDisabled: false + repoURL: https://github.com/Unstructured-IO/unstructured-python-client.git features: python: - core: 3.3.1 + core: 4.1.2 examples: 2.81.3 - globalSecurity: 2.82.0 + globalSecurity: 2.83.0 globalServerURLs: 2.82.0 nameOverrides: 2.81.1 retries: 2.82.0 serverIDs: 2.81.1 python: - version: 0.12.2 + version: 0.14.0 author: Unstructured clientServerStatusCodesAsErrors: true description: Python Client SDK for Unstructured API flattenGlobalSecurity: true + imports: + option: openapi + paths: + callbacks: models/callbacks + errors: models/errors + operations: models/operations + shared: models/shared + webhooks: models/webhooks + inputModelSuffix: input installationURL: https://github.com/Unstructured-IO/unstructured-python-client.git maxMethodParams: 0 + outputModelSuffix: output packageName: unstructured-client published: true repoSubDirectory: . diff --git a/setup.py b/setup.py index a9972e6a..57a23dc4 100755 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setuptools.setup( name="unstructured-client", - version="0.12.2", + version="0.14.0", author="Unstructured", description="Python Client SDK for Unstructured API", long_description=long_description, diff --git a/src/unstructured_client/general.py b/src/unstructured_client/general.py index dca3af67..ca13d228 100755 --- a/src/unstructured_client/general.py +++ b/src/unstructured_client/general.py @@ -12,6 +12,7 @@ def __init__(self, sdk_config: SDKConfiguration) -> None: self.sdk_configuration = sdk_config + def partition(self, request: shared.PartitionParameters, retries: Optional[utils.RetryConfig] = None) -> operations.PartitionResponse: r"""Pipeline 1""" base_url = utils.template_url(*self.sdk_configuration.get_server_details()) @@ -24,7 +25,10 @@ def partition(self, request: shared.PartitionParameters, retries: Optional[utils headers['Accept'] = 'application/json' headers['user-agent'] = self.sdk_configuration.user_agent - client = self.sdk_configuration.security_client + if callable(self.sdk_configuration.security): + client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security()) + else: + client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security) global_retry_config = self.sdk_configuration.retry_config retry_config = retries diff --git a/src/unstructured_client/models/__init__.py b/src/unstructured_client/models/__init__.py index 36628d6c..722bb998 100755 --- a/src/unstructured_client/models/__init__.py +++ b/src/unstructured_client/models/__init__.py @@ -1,3 +1,4 @@ """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" -# __init__.py + +# package diff --git a/src/unstructured_client/models/errors/__init__.py b/src/unstructured_client/models/errors/__init__.py index 60f0500b..994f4d37 100755 --- a/src/unstructured_client/models/errors/__init__.py +++ b/src/unstructured_client/models/errors/__init__.py @@ -1,6 +1,7 @@ """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" from .httpvalidationerror import * +from .sdkerror import * from .validationerror import * -from .sdkerror import SDKError -__all__ = ["HTTPValidationError","ValidationError","ValidationErrorLoc","SDKError"] + +__all__ = ["HTTPValidationError","SDKError","ValidationError"] diff --git a/src/unstructured_client/models/errors/httpvalidationerror.py b/src/unstructured_client/models/errors/httpvalidationerror.py index ab470189..e33946e7 100755 --- a/src/unstructured_client/models/errors/httpvalidationerror.py +++ b/src/unstructured_client/models/errors/httpvalidationerror.py @@ -2,7 +2,7 @@ from __future__ import annotations import dataclasses -from ..errors import validationerror as errors_validationerror +from .validationerror import ValidationError from dataclasses_json import Undefined, dataclass_json from typing import List, Optional from unstructured_client import utils @@ -12,7 +12,7 @@ @dataclasses.dataclass class HTTPValidationError(Exception): - detail: Optional[List[errors_validationerror.ValidationError]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('detail'), 'exclude': lambda f: f is None }}) + detail: Optional[List[ValidationError]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('detail'), 'exclude': lambda f: f is None }}) def __str__(self) -> str: diff --git a/src/unstructured_client/models/errors/validationerror.py b/src/unstructured_client/models/errors/validationerror.py index 39318ee6..c1b52e4d 100755 --- a/src/unstructured_client/models/errors/validationerror.py +++ b/src/unstructured_client/models/errors/validationerror.py @@ -7,11 +7,6 @@ from unstructured_client import utils -@dataclasses.dataclass -class ValidationErrorLoc: - pass - - @dataclass_json(undefined=Undefined.EXCLUDE) @dataclasses.dataclass class ValidationError: diff --git a/src/unstructured_client/models/shared/__init__.py b/src/unstructured_client/models/shared/__init__.py index 17e49ed1..b9ea8676 100755 --- a/src/unstructured_client/models/shared/__init__.py +++ b/src/unstructured_client/models/shared/__init__.py @@ -3,4 +3,4 @@ from .partition_parameters import * from .security import * -__all__ = ["PartitionParameters","PartitionParametersFiles","Security"] +__all__ = ["Files","PartitionParameters","Security"] diff --git a/src/unstructured_client/models/shared/partition_parameters.py b/src/unstructured_client/models/shared/partition_parameters.py index b036a53c..8e84af06 100755 --- a/src/unstructured_client/models/shared/partition_parameters.py +++ b/src/unstructured_client/models/shared/partition_parameters.py @@ -6,9 +6,9 @@ @dataclasses.dataclass -class PartitionParametersFiles: +class Files: content: bytes = dataclasses.field(metadata={'multipart_form': { 'content': True }}) - files: str = dataclasses.field(metadata={'multipart_form': { 'field_name': 'files' }}) + file_name: str = dataclasses.field(metadata={'multipart_form': { 'field_name': 'files' }}) @@ -23,7 +23,7 @@ class PartitionParameters: r"""If true, return coordinates for each element. Default: false""" encoding: Optional[str] = dataclasses.field(default=None, metadata={'multipart_form': { 'field_name': 'encoding' }}) r"""The encoding method used to decode the text input. Default: utf-8""" - files: Optional[PartitionParametersFiles] = dataclasses.field(default=None, metadata={'multipart_form': { 'file': True }}) + files: Optional[Files] = dataclasses.field(default=None, metadata={'multipart_form': { 'file': True }}) r"""The file to extract""" gz_uncompressed_content_type: Optional[str] = dataclasses.field(default=None, metadata={'multipart_form': { 'field_name': 'gz_uncompressed_content_type' }}) r"""If file is gzipped, use this content type after unzipping""" diff --git a/src/unstructured_client/sdk.py b/src/unstructured_client/sdk.py index 3a4e8821..52eda1bc 100755 --- a/src/unstructured_client/sdk.py +++ b/src/unstructured_client/sdk.py @@ -3,7 +3,7 @@ import requests as requests_http from .general import General from .sdkconfiguration import SDKConfiguration -from typing import Dict +from typing import Callable, Dict, Union from unstructured_client import utils from unstructured_client.models import shared @@ -14,7 +14,7 @@ class UnstructuredClient: sdk_configuration: SDKConfiguration def __init__(self, - api_key_auth: str, + api_key_auth: Union[str,Callable[[], str]], server: str = None, server_url: str = None, url_params: Dict[str, str] = None, @@ -24,7 +24,7 @@ def __init__(self, """Instantiates the SDK configuring it with the provided parameters. :param api_key_auth: The api_key_auth required for authentication - :type api_key_auth: str + :type api_key_auth: Union[str,Callable[[], str]] :param server: The server by name to use for all operations :type server: str :param server_url: The server URL to use for all operations @@ -39,15 +39,13 @@ def __init__(self, if client is None: client = requests_http.Session() - - security_client = utils.configure_security_client(client, shared.Security(api_key_auth = api_key_auth)) - + security = shared.Security(api_key_auth = api_key_auth) if server_url is not None: if url_params is not None: server_url = utils.template_url(server_url, url_params) - self.sdk_configuration = SDKConfiguration(client, security_client, server_url, server, retry_config=retry_config) + self.sdk_configuration = SDKConfiguration(client, security, server_url, server, retry_config=retry_config) self._init_sdks() diff --git a/src/unstructured_client/sdkconfiguration.py b/src/unstructured_client/sdkconfiguration.py index 984ba9f2..bfa4f592 100755 --- a/src/unstructured_client/sdkconfiguration.py +++ b/src/unstructured_client/sdkconfiguration.py @@ -2,9 +2,10 @@ import requests from dataclasses import dataclass -from typing import Dict, Tuple +from typing import Dict, Tuple, Callable, Union from .utils.retries import RetryConfig from .utils import utils +from unstructured_client.models import shared SERVER_PROD = 'prod' @@ -21,14 +22,14 @@ @dataclass class SDKConfiguration: client: requests.Session - security_client: requests.Session + security: Union[shared.Security,Callable[[], shared.Security]] = None server_url: str = '' server: str = '' language: str = 'python' openapi_doc_version: str = '0.0.1' - sdk_version: str = '0.12.2' - gen_version: str = '2.173.0' - user_agent: str = 'speakeasy-sdk/python 0.12.2 2.173.0 0.0.1 unstructured-client' + sdk_version: str = '0.14.0' + gen_version: str = '2.185.0' + user_agent: str = 'speakeasy-sdk/python 0.14.0 2.185.0 0.0.1 unstructured-client' retry_config: RetryConfig = None def get_server_details(self) -> Tuple[str, Dict[str, str]]: