diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 25e4d1a4..2f867673 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -4,21 +4,21 @@ management: docChecksum: 559aacf6828c62bd379326645382b3ba docVersion: 0.0.1 speakeasyVersion: internal - generationVersion: 2.230.1 - releaseVersion: 0.15.2 - configChecksum: c7f5587d10f16ad71c809e8627e64175 + generationVersion: 2.237.2 + releaseVersion: 0.15.5 + configChecksum: 5138d0e0d09d018eeec74356c4b3fef5 repoURL: https://github.com/Unstructured-IO/unstructured-python-client.git repoSubDirectory: . installationURL: https://github.com/Unstructured-IO/unstructured-python-client.git published: true features: python: - core: 4.4.1 + core: 4.4.2 examples: 2.81.3 - globalSecurity: 2.83.1 + globalSecurity: 2.83.2 globalServerURLs: 2.82.1 nameOverrides: 2.81.1 - retries: 2.82.0 + retries: 2.82.1 serverIDs: 2.81.1 unions: 2.82.5 generatedFiles: diff --git a/RELEASES.md b/RELEASES.md index b68bee7c..1d847c4c 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -344,4 +344,44 @@ Based on: ### Generated - [python v0.15.2] . ### Releases -- [PyPI v0.15.2] https://pypi.org/project/unstructured-client/0.15.2 - . \ No newline at end of file +- [PyPI v0.15.2] https://pypi.org/project/unstructured-client/0.15.2 - . + +## 2024-01-12 00:19:36 +### Changes +Based on: +- OpenAPI Doc 0.0.1 +- Speakeasy CLI 1.136.1 (2.231.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v0.15.2] . +### Releases +- [PyPI v0.15.2] https://pypi.org/project/unstructured-client/0.15.2 - . + +## 2024-01-16 00:19:58 +### Changes +Based on: +- OpenAPI Doc 0.0.1 +- Speakeasy CLI 1.141.1 (2.233.2) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v0.15.3] . +### Releases +- [PyPI v0.15.3] https://pypi.org/project/unstructured-client/0.15.3 - . + +## 2024-01-17 00:19:51 +### Changes +Based on: +- OpenAPI Doc 0.0.1 +- Speakeasy CLI 1.142.1 (2.234.3) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v0.15.4] . +### Releases +- [PyPI v0.15.4] https://pypi.org/project/unstructured-client/0.15.4 - . + +## 2024-01-19 00:19:58 +### Changes +Based on: +- OpenAPI Doc 0.0.1 +- Speakeasy CLI 1.147.0 (2.237.2) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v0.15.5] . +### Releases +- [PyPI v0.15.5] https://pypi.org/project/unstructured-client/0.15.5 - . \ No newline at end of file diff --git a/gen.yaml b/gen.yaml index 86087780..2d441262 100644 --- a/gen.yaml +++ b/gen.yaml @@ -6,7 +6,7 @@ generation: fixes: nameResolutionDec2023: false python: - version: 0.15.2 + version: 0.15.5 author: Unstructured clientServerStatusCodesAsErrors: true description: Python Client SDK for Unstructured API diff --git a/setup.py b/setup.py index 4fca2489..1d9bf600 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setuptools.setup( name="unstructured-client", - version="0.15.2", + version="0.15.5", author="Unstructured", description="Python Client SDK for Unstructured API", long_description=long_description, diff --git a/src/unstructured_client/sdk.py b/src/unstructured_client/sdk.py index 4ebbcc63..18fb5cb1 100644 --- 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: Union[str,Callable[[], 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,7 +39,11 @@ def __init__(self, if client is None: client = requests_http.Session() - security = shared.Security(api_key_auth = api_key_auth) + if callable(api_key_auth): + def security(): + return shared.Security(api_key_auth = api_key_auth()) + else: + security = shared.Security(api_key_auth = api_key_auth) if server_url is not None: if url_params is not None: diff --git a/src/unstructured_client/sdkconfiguration.py b/src/unstructured_client/sdkconfiguration.py index bb4fd2af..b1e695f1 100644 --- a/src/unstructured_client/sdkconfiguration.py +++ b/src/unstructured_client/sdkconfiguration.py @@ -27,9 +27,9 @@ class SDKConfiguration: server: str = '' language: str = 'python' openapi_doc_version: str = '0.0.1' - sdk_version: str = '0.15.2' - gen_version: str = '2.230.1' - user_agent: str = 'speakeasy-sdk/python 0.15.2 2.230.1 0.0.1 unstructured-client' + sdk_version: str = '0.15.5' + gen_version: str = '2.237.2' + user_agent: str = 'speakeasy-sdk/python 0.15.5 2.237.2 0.0.1 unstructured-client' retry_config: RetryConfig = None def get_server_details(self) -> Tuple[str, Dict[str, str]]: diff --git a/src/unstructured_client/utils/retries.py b/src/unstructured_client/utils/retries.py index 25f49a1f..8eba0940 100644 --- a/src/unstructured_client/utils/retries.py +++ b/src/unstructured_client/utils/retries.py @@ -75,12 +75,12 @@ def do_request(): if res.status_code == parsed_code: raise TemporaryError(res) except requests.exceptions.ConnectionError as exception: - if not retries.config.config.retry_connection_errors: + if retries.config.config.retry_connection_errors: raise raise PermanentError(exception) from exception except requests.exceptions.Timeout as exception: - if not retries.config.config.retry_connection_errors: + if retries.config.config.retry_connection_errors: raise raise PermanentError(exception) from exception diff --git a/src/unstructured_client/utils/utils.py b/src/unstructured_client/utils/utils.py index 1a60d406..f7096142 100644 --- a/src/unstructured_client/utils/utils.py +++ b/src/unstructured_client/utils/utils.py @@ -110,19 +110,22 @@ def _parse_security_scheme_value(client: SecurityClient, scheme_metadata: Dict, else: raise Exception('not supported') elif scheme_type == "openIdConnect": - client.client.headers[header_name] = value + client.client.headers[header_name] = _apply_bearer(value) elif scheme_type == 'oauth2': - client.client.headers[header_name] = value + client.client.headers[header_name] = _apply_bearer(value) elif scheme_type == 'http': if sub_type == 'bearer': - client.client.headers[header_name] = value.lower().startswith( - 'bearer ') and value or f'Bearer {value}' + client.client.headers[header_name] = _apply_bearer(value) else: raise Exception('not supported') else: raise Exception('not supported') +def _apply_bearer(token: str) -> str: + return token.lower().startswith('bearer ') and token or f'Bearer {token}' + + def _parse_basic_auth_scheme(client: SecurityClient, scheme: dataclass): username = "" password = ""