Skip to content

chore: 🐝 Update SDK - Generate #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .speakeasy/gen.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
42 changes: 41 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 - .
- [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 - .
2 changes: 1 addition & 1 deletion gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 8 additions & 4 deletions src/unstructured_client/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions src/unstructured_client/sdkconfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]:
Expand Down
4 changes: 2 additions & 2 deletions src/unstructured_client/utils/retries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions src/unstructured_client/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down