diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 86f1c003..73804c70 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: 3e52fdac3e417f8e48fcb920b829025c - docVersion: 1.1.34 - speakeasyVersion: 1.552.0 - generationVersion: 2.610.0 - releaseVersion: 0.39.1 - configChecksum: 2b0094ee827eb2deb71ef0ff9e572192 + docChecksum: 0593f5359a35b34f3dc1b346490deff2 + docVersion: 1.1.39 + speakeasyVersion: 1.568.0 + generationVersion: 2.632.2 + releaseVersion: 0.40.0 + configChecksum: 70954879fd1a6da62295461541e8680c repoURL: https://github.com/Unstructured-IO/unstructured-python-client.git repoSubDirectory: . installationURL: https://github.com/Unstructured-IO/unstructured-python-client.git @@ -16,7 +16,7 @@ features: acceptHeaders: 3.0.0 additionalDependencies: 1.0.0 constsAndDefaults: 1.0.5 - core: 5.19.0 + core: 5.19.3 customCodeRegions: 0.1.1 defaultEnabledRetries: 0.2.0 enumUnions: 0.1.0 @@ -33,7 +33,7 @@ features: openEnums: 1.0.1 responseFormat: 1.0.1 retries: 3.0.2 - sdkHooks: 1.0.1 + sdkHooks: 1.1.0 serverIDs: 3.0.0 unions: 3.0.4 uploadStreams: 1.0.0 @@ -71,6 +71,8 @@ generatedFiles: - docs/models/operations/getconnectionchecksourcesresponse.md - docs/models/operations/getdestinationrequest.md - docs/models/operations/getdestinationresponse.md + - docs/models/operations/getencryptioncertificaterequest.md + - docs/models/operations/getencryptioncertificateresponse.md - docs/models/operations/getjobdetailsrequest.md - docs/models/operations/getjobdetailsresponse.md - docs/models/operations/getjobfailedfilesrequest.md @@ -91,8 +93,6 @@ generatedFiles: - docs/models/operations/listworkflowsresponse.md - docs/models/operations/partitionrequest.md - docs/models/operations/partitionresponse.md - - docs/models/operations/retrieverequest.md - - docs/models/operations/retrieveresponse.md - docs/models/operations/runworkflowrequest.md - docs/models/operations/runworkflowresponse.md - docs/models/operations/storesecretrequest.md @@ -140,6 +140,7 @@ generatedFiles: - docs/models/shared/elasticsearchconnectorconfig.md - docs/models/shared/elasticsearchconnectorconfiginput.md - docs/models/shared/encryptedsecret.md + - docs/models/shared/encryptioncertificateresponse.md - docs/models/shared/encryptiontype.md - docs/models/shared/failedfile.md - docs/models/shared/files.md @@ -181,7 +182,6 @@ generatedFiles: - docs/models/shared/outlooksourceconnectorconfiginput.md - docs/models/shared/outputformat.md - docs/models/shared/partitionparameters.md - - docs/models/shared/pemauthresponse.md - docs/models/shared/pineconedestinationconnectorconfig.md - docs/models/shared/pineconedestinationconnectorconfiginput.md - docs/models/shared/postgresdestinationconnectorconfig.md @@ -272,6 +272,7 @@ generatedFiles: - src/unstructured_client/models/operations/get_connection_check_destinations.py - src/unstructured_client/models/operations/get_connection_check_sources.py - src/unstructured_client/models/operations/get_destination.py + - src/unstructured_client/models/operations/get_encryption_certificate.py - src/unstructured_client/models/operations/get_job.py - src/unstructured_client/models/operations/get_job_details.py - src/unstructured_client/models/operations/get_job_failed_files.py @@ -282,7 +283,6 @@ generatedFiles: - src/unstructured_client/models/operations/list_sources.py - src/unstructured_client/models/operations/list_workflows.py - src/unstructured_client/models/operations/partition.py - - src/unstructured_client/models/operations/retrieve.py - src/unstructured_client/models/operations/run_workflow.py - src/unstructured_client/models/operations/store_secret.py - src/unstructured_client/models/operations/update_destination.py @@ -323,6 +323,7 @@ generatedFiles: - src/unstructured_client/models/shared/elasticsearchconnectorconfig.py - src/unstructured_client/models/shared/elasticsearchconnectorconfiginput.py - src/unstructured_client/models/shared/encryptedsecret.py + - src/unstructured_client/models/shared/encryptioncertificateresponse.py - src/unstructured_client/models/shared/encryptiontype.py - src/unstructured_client/models/shared/failedfile.py - src/unstructured_client/models/shared/gcsdestinationconnectorconfig.py @@ -359,7 +360,6 @@ generatedFiles: - src/unstructured_client/models/shared/outlooksourceconnectorconfig.py - src/unstructured_client/models/shared/outlooksourceconnectorconfiginput.py - src/unstructured_client/models/shared/partition_parameters.py - - src/unstructured_client/models/shared/pemauthresponse.py - src/unstructured_client/models/shared/pineconedestinationconnectorconfig.py - src/unstructured_client/models/shared/pineconedestinationconnectorconfiginput.py - src/unstructured_client/models/shared/postgresdestinationconnectorconfig.py @@ -709,5 +709,12 @@ examples: application/json: {"id": ""} "422": application/json: {"detail": []} + get_encryption_certificate: + speakeasy-default-get-encryption-certificate: + responses: + "200": + application/json: {"ca_chain": "", "encryption_certificate": ""} + "422": + application/json: {"detail": []} examplesVersion: 1.0.2 generatedTests: {} diff --git a/README.md b/README.md index 55655f56..c5327816 100644 --- a/README.md +++ b/README.md @@ -316,7 +316,7 @@ with UnstructuredClient() as uc_client:
-The same SDK client can also be used to make asynchronous requests by importing asyncio. +The same SDK client can also be used to make asychronous requests by importing asyncio. ```python # Asynchronous Example import asyncio @@ -410,30 +410,18 @@ Certain SDK methods accept file objects as part of a request body or multi-part ```python from unstructured_client import UnstructuredClient -from unstructured_client.models import shared with UnstructuredClient() as uc_client: - res = uc_client.general.partition(request={ - "partition_parameters": { - "files": { - "content": open("example.file", "rb"), - "file_name": "example.file", - }, - "split_pdf_page_range": [ - 1, - 10, - ], - "vlm_model": shared.VLMModel.GPT_4O, - "vlm_model_provider": shared.VLMModelProvider.OPENAI, - }, + res = uc_client.workflows.run_workflow(request={ + "workflow_id": "e7054f23-ce92-4bf1-a1d7-7cf9cb14d013", }) - assert res.elements is not None + assert res.job_information is not None # Handle response - print(res.elements) + print(res.job_information) ``` diff --git a/docs/models/operations/retrieverequest.md b/docs/models/operations/getencryptioncertificaterequest.md similarity index 90% rename from docs/models/operations/retrieverequest.md rename to docs/models/operations/getencryptioncertificaterequest.md index 6f1a9c98..b0a6b822 100644 --- a/docs/models/operations/retrieverequest.md +++ b/docs/models/operations/getencryptioncertificaterequest.md @@ -1,4 +1,4 @@ -# RetrieveRequest +# GetEncryptionCertificateRequest ## Fields diff --git a/docs/models/operations/getencryptioncertificateresponse.md b/docs/models/operations/getencryptioncertificateresponse.md new file mode 100644 index 00000000..251e039f --- /dev/null +++ b/docs/models/operations/getencryptioncertificateresponse.md @@ -0,0 +1,11 @@ +# GetEncryptionCertificateResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | +| `content_type` | *str* | :heavy_check_mark: | HTTP response content type for this operation | +| `encryption_certificate_response` | [Optional[shared.EncryptionCertificateResponse]](../../models/shared/encryptioncertificateresponse.md) | :heavy_minus_sign: | Successful Response | +| `status_code` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `raw_response` | [httpx.Response](https://www.python-httpx.org/api/#response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/docs/models/operations/retrieveresponse.md b/docs/models/operations/retrieveresponse.md deleted file mode 100644 index df683b89..00000000 --- a/docs/models/operations/retrieveresponse.md +++ /dev/null @@ -1,11 +0,0 @@ -# RetrieveResponse - - -## Fields - -| Field | Type | Required | Description | -| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -| `content_type` | *str* | :heavy_check_mark: | HTTP response content type for this operation | -| `pem_auth_response` | [Optional[shared.PemAuthResponse]](../../models/shared/pemauthresponse.md) | :heavy_minus_sign: | Successful Response | -| `status_code` | *int* | :heavy_check_mark: | HTTP response status code for this operation | -| `raw_response` | [httpx.Response](https://www.python-httpx.org/api/#response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/docs/models/shared/encryptioncertificateresponse.md b/docs/models/shared/encryptioncertificateresponse.md new file mode 100644 index 00000000..6a521241 --- /dev/null +++ b/docs/models/shared/encryptioncertificateresponse.md @@ -0,0 +1,13 @@ +# EncryptionCertificateResponse + +Response model for the encryption certificate. +Contains the siged user certificate and the root CA certificate +for verification. + + +## Fields + +| Field | Type | Required | Description | +| ------------------------ | ------------------------ | ------------------------ | ------------------------ | +| `ca_chain` | *str* | :heavy_check_mark: | N/A | +| `encryption_certificate` | *str* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/shared/pemauthresponse.md b/docs/models/shared/pemauthresponse.md deleted file mode 100644 index 1a3880ca..00000000 --- a/docs/models/shared/pemauthresponse.md +++ /dev/null @@ -1,12 +0,0 @@ -# PemAuthResponse - -Response model for PEM key retrieval. - - -## Fields - -| Field | Type | Required | Description | -| ----------------------- | ----------------------- | ----------------------- | ----------------------- | -| `pem_key` | *str* | :heavy_check_mark: | N/A | -| `tenant_id` | *str* | :heavy_check_mark: | N/A | -| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/sdks/general/README.md b/docs/sdks/general/README.md index 189a833f..306ba79a 100644 --- a/docs/sdks/general/README.md +++ b/docs/sdks/general/README.md @@ -22,14 +22,17 @@ with UnstructuredClient() as uc_client: res = uc_client.general.partition(request={ "partition_parameters": { + "chunking_strategy": "by_title", "files": { "content": open("example.file", "rb"), "file_name": "example.file", }, + "split_pdf_cache_tmp_data_dir": "", "split_pdf_page_range": [ 1, 10, ], + "strategy": shared.Strategy.AUTO, "vlm_model": shared.VLMModel.GPT_4O, "vlm_model_provider": shared.VLMModelProvider.OPENAI, }, diff --git a/docs/sdks/users/README.md b/docs/sdks/users/README.md index 3c761ced..fec33c24 100644 --- a/docs/sdks/users/README.md +++ b/docs/sdks/users/README.md @@ -5,12 +5,12 @@ ### Available Operations -* [retrieve](#retrieve) - Retrieve PEM Key +* [get_encryption_certificate](#get_encryption_certificate) - Retrieve the user's public key for encryption. * [store_secret](#store_secret) - Store an encrypted secret -## retrieve +## get_encryption_certificate -Given a UNSTRUCTURED_API_KEY in the post-payload, retrieve the associated PEM key +Retrieve a short lived certificate with the public key for encrypting secrets. ### Example Usage @@ -20,26 +20,26 @@ from unstructured_client import UnstructuredClient with UnstructuredClient() as uc_client: - res = uc_client.users.retrieve(request={}) + res = uc_client.users.get_encryption_certificate(request={}) - assert res.pem_auth_response is not None + assert res.encryption_certificate_response is not None # Handle response - print(res.pem_auth_response) + print(res.encryption_certificate_response) ``` ### Parameters -| Parameter | Type | Required | Description | -| ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | -| `request` | [operations.RetrieveRequest](../../models/operations/retrieverequest.md) | :heavy_check_mark: | The request object to use for the request. | -| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | -| `server_url` | *Optional[str]* | :heavy_minus_sign: | An optional server URL to use. | +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | +| `request` | [operations.GetEncryptionCertificateRequest](../../models/operations/getencryptioncertificaterequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | +| `server_url` | *Optional[str]* | :heavy_minus_sign: | An optional server URL to use. | ### Response -**[operations.RetrieveResponse](../../models/operations/retrieveresponse.md)** +**[operations.GetEncryptionCertificateResponse](../../models/operations/getencryptioncertificateresponse.md)** ### Errors diff --git a/gen.yaml b/gen.yaml index 2ce09a83..2af78a42 100644 --- a/gen.yaml +++ b/gen.yaml @@ -14,7 +14,7 @@ generation: oAuth2ClientCredentialsEnabled: false oAuth2PasswordEnabled: false python: - version: 0.39.1 + version: 0.40.0 additionalDependencies: dev: deepdiff: '>=6.0' diff --git a/poetry.lock b/poetry.lock index feb5b16d..27495061 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1176,4 +1176,4 @@ test = ["aiohttp (>=3.10.5)", "flake8 (>=5.0,<6.0)", "mypy (>=0.800)", "psutil", [metadata] lock-version = "2.1" python-versions = ">=3.9.2" -content-hash = "c1ef8dc28bf0de7ee6741ff58f346f3c9129b7f6885e3c66962c8808e7f2197c" +content-hash = "6f50317cde237c3cfc0682c2609a22a29db5f771ca4a23a0aebc8e68a2ce5efb" diff --git a/pyproject.toml b/pyproject.toml index b8d94b42..3d326882 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "unstructured-client" -version = "0.39.1" +version = "0.40.0" description = "Python Client SDK for Unstructured API" authors = [{ name = "Unstructured" },] readme = "README-PYPI.md" @@ -8,6 +8,7 @@ requires-python = ">=3.9.2" dependencies = [ "aiofiles >=24.1.0", "cryptography >=3.1", + "httpcore >=1.0.9", "httpx >=0.27.0", "nest-asyncio >=1.6.0", "pydantic >=2.11.2", @@ -52,6 +53,8 @@ pythonpath = ["src"] [tool.mypy] disable_error_code = "misc" +explicit_package_bases = true +mypy_path = "src" [[tool.mypy.overrides]] module = "typing_inspect" diff --git a/src/unstructured_client/_hooks/types.py b/src/unstructured_client/_hooks/types.py index 41284a60..a2840fe4 100644 --- a/src/unstructured_client/_hooks/types.py +++ b/src/unstructured_client/_hooks/types.py @@ -4,9 +4,11 @@ import httpx from typing import Any, Callable, List, Optional, Tuple, Union from unstructured_client.httpclient import HttpClient +from unstructured_client.sdkconfiguration import SDKConfiguration class HookContext: + config: SDKConfiguration base_url: str operation_id: str oauth2_scopes: Optional[List[str]] = None @@ -14,11 +16,13 @@ class HookContext: def __init__( self, + config: SDKConfiguration, base_url: str, operation_id: str, oauth2_scopes: Optional[List[str]], security_source: Optional[Union[Any, Callable[[], Any]]], ): + self.config = config self.base_url = base_url self.operation_id = operation_id self.oauth2_scopes = oauth2_scopes @@ -28,6 +32,7 @@ def __init__( class BeforeRequestContext(HookContext): def __init__(self, hook_ctx: HookContext): super().__init__( + hook_ctx.config, hook_ctx.base_url, hook_ctx.operation_id, hook_ctx.oauth2_scopes, @@ -38,6 +43,7 @@ def __init__(self, hook_ctx: HookContext): class AfterSuccessContext(HookContext): def __init__(self, hook_ctx: HookContext): super().__init__( + hook_ctx.config, hook_ctx.base_url, hook_ctx.operation_id, hook_ctx.oauth2_scopes, @@ -48,6 +54,7 @@ def __init__(self, hook_ctx: HookContext): class AfterErrorContext(HookContext): def __init__(self, hook_ctx: HookContext): super().__init__( + hook_ctx.config, hook_ctx.base_url, hook_ctx.operation_id, hook_ctx.oauth2_scopes, diff --git a/src/unstructured_client/_version.py b/src/unstructured_client/_version.py index 26bd4e88..b8a3d7b6 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.39.1" -__openapi_doc_version__: str = "1.1.34" -__gen_version__: str = "2.610.0" -__user_agent__: str = "speakeasy-sdk/python 0.39.1 2.610.0 1.1.34 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" try: if __package__ is not None: diff --git a/src/unstructured_client/basesdk.py b/src/unstructured_client/basesdk.py index 56998813..4ed96550 100644 --- a/src/unstructured_client/basesdk.py +++ b/src/unstructured_client/basesdk.py @@ -223,12 +223,12 @@ def do_request( client = self.sdk_configuration.client logger = self.sdk_configuration.debug_logger + hooks = self.sdk_configuration.__dict__["_hooks"] + def do(): http_res = None try: - req = self.sdk_configuration.get_hooks().before_request( - BeforeRequestContext(hook_ctx), request - ) + req = hooks.before_request(BeforeRequestContext(hook_ctx), request) logger.debug( "Request:\nMethod: %s\nURL: %s\nHeaders: %s\nBody: %s", req.method, @@ -242,9 +242,7 @@ def do(): http_res = client.send(req, stream=stream) except Exception as e: - _, e = self.sdk_configuration.get_hooks().after_error( - AfterErrorContext(hook_ctx), None, e - ) + _, e = hooks.after_error(AfterErrorContext(hook_ctx), None, e) if e is not None: logger.debug("Request Exception", exc_info=True) raise e @@ -262,7 +260,7 @@ def do(): ) if utils.match_status_codes(error_status_codes, http_res.status_code): - result, err = self.sdk_configuration.get_hooks().after_error( + result, err = hooks.after_error( AfterErrorContext(hook_ctx), http_res, None ) if err is not None: @@ -282,9 +280,7 @@ def do(): http_res = do() if not utils.match_status_codes(error_status_codes, http_res.status_code): - http_res = self.sdk_configuration.get_hooks().after_success( - AfterSuccessContext(hook_ctx), http_res - ) + http_res = hooks.after_success(AfterSuccessContext(hook_ctx), http_res) return http_res @@ -299,12 +295,12 @@ async def do_request_async( client = self.sdk_configuration.async_client logger = self.sdk_configuration.debug_logger + hooks = self.sdk_configuration.__dict__["_hooks"] + async def do(): http_res = None try: - req = self.sdk_configuration.get_hooks().before_request( - BeforeRequestContext(hook_ctx), request - ) + req = hooks.before_request(BeforeRequestContext(hook_ctx), request) logger.debug( "Request:\nMethod: %s\nURL: %s\nHeaders: %s\nBody: %s", req.method, @@ -318,9 +314,7 @@ async def do(): http_res = await client.send(req, stream=stream) except Exception as e: - _, e = self.sdk_configuration.get_hooks().after_error( - AfterErrorContext(hook_ctx), None, e - ) + _, e = hooks.after_error(AfterErrorContext(hook_ctx), None, e) if e is not None: logger.debug("Request Exception", exc_info=True) raise e @@ -338,7 +332,7 @@ async def do(): ) if utils.match_status_codes(error_status_codes, http_res.status_code): - result, err = self.sdk_configuration.get_hooks().after_error( + result, err = hooks.after_error( AfterErrorContext(hook_ctx), http_res, None ) if err is not None: @@ -360,8 +354,6 @@ async def do(): http_res = await do() if not utils.match_status_codes(error_status_codes, http_res.status_code): - http_res = self.sdk_configuration.get_hooks().after_success( - AfterSuccessContext(hook_ctx), http_res - ) + http_res = hooks.after_success(AfterSuccessContext(hook_ctx), http_res) return http_res diff --git a/src/unstructured_client/destinations.py b/src/unstructured_client/destinations.py index e8cdedf4..34c137b4 100644 --- a/src/unstructured_client/destinations.py +++ b/src/unstructured_client/destinations.py @@ -75,6 +75,7 @@ def create_connection_check_destinations( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="create_connection_check_destinations", oauth2_scopes=[], @@ -184,6 +185,7 @@ async def create_connection_check_destinations_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="create_connection_check_destinations", oauth2_scopes=[], @@ -298,6 +300,7 @@ def create_destination( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="create_destination", oauth2_scopes=[], @@ -412,6 +415,7 @@ async def create_destination_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="create_destination", oauth2_scopes=[], @@ -520,6 +524,7 @@ def delete_destination( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="delete_destination", oauth2_scopes=[], @@ -625,6 +630,7 @@ async def delete_destination_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="delete_destination", oauth2_scopes=[], @@ -733,6 +739,7 @@ def get_connection_check_destinations( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="get_connection_check_destinations", oauth2_scopes=[], @@ -842,6 +849,7 @@ async def get_connection_check_destinations_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="get_connection_check_destinations", oauth2_scopes=[], @@ -948,6 +956,7 @@ def get_destination( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="get_destination", oauth2_scopes=[], @@ -1054,6 +1063,7 @@ async def get_destination_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="get_destination", oauth2_scopes=[], @@ -1160,6 +1170,7 @@ def list_destinations( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="list_destinations", oauth2_scopes=[], @@ -1267,6 +1278,7 @@ async def list_destinations_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="list_destinations", oauth2_scopes=[], @@ -1382,6 +1394,7 @@ def update_destination( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="update_destination", oauth2_scopes=[], @@ -1495,6 +1508,7 @@ async def update_destination_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="update_destination", oauth2_scopes=[], diff --git a/src/unstructured_client/general.py b/src/unstructured_client/general.py index 73a8006e..9972ac6e 100644 --- a/src/unstructured_client/general.py +++ b/src/unstructured_client/general.py @@ -97,6 +97,7 @@ def partition( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="partition", oauth2_scopes=[], @@ -219,6 +220,7 @@ async def partition_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="partition", oauth2_scopes=[], diff --git a/src/unstructured_client/jobs.py b/src/unstructured_client/jobs.py index 6c69babf..31d30305 100644 --- a/src/unstructured_client/jobs.py +++ b/src/unstructured_client/jobs.py @@ -73,6 +73,7 @@ def cancel_job( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="cancel_job", oauth2_scopes=[], @@ -177,6 +178,7 @@ async def cancel_job_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="cancel_job", oauth2_scopes=[], @@ -283,6 +285,7 @@ def download_job_output( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="download_job_output", oauth2_scopes=[], @@ -388,6 +391,7 @@ async def download_job_output_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="download_job_output", oauth2_scopes=[], @@ -490,6 +494,7 @@ def get_job( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="get_job", oauth2_scopes=[], @@ -594,6 +599,7 @@ async def get_job_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="get_job", oauth2_scopes=[], @@ -699,6 +705,7 @@ def get_job_details( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="get_job_details", oauth2_scopes=[], @@ -804,6 +811,7 @@ async def get_job_details_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="get_job_details", oauth2_scopes=[], @@ -910,6 +918,7 @@ def get_job_failed_files( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="get_job_failed_files", oauth2_scopes=[], @@ -1016,6 +1025,7 @@ async def get_job_failed_files_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="get_job_failed_files", oauth2_scopes=[], @@ -1119,6 +1129,7 @@ def list_jobs( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="list_jobs", oauth2_scopes=[], @@ -1223,6 +1234,7 @@ async def list_jobs_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="list_jobs", oauth2_scopes=[], diff --git a/src/unstructured_client/models/operations/__init__.py b/src/unstructured_client/models/operations/__init__.py index b00712ba..b3709755 100644 --- a/src/unstructured_client/models/operations/__init__.py +++ b/src/unstructured_client/models/operations/__init__.py @@ -108,6 +108,14 @@ GetDestinationResponse, GetDestinationResponseTypedDict, ) + from .get_encryption_certificate import ( + GET_ENCRYPTION_CERTIFICATE_SERVERS, + GET_ENCRYPTION_CERTIFICATE_SERVER_PLATFORM_API, + GetEncryptionCertificateRequest, + GetEncryptionCertificateRequestTypedDict, + GetEncryptionCertificateResponse, + GetEncryptionCertificateResponseTypedDict, + ) from .get_job import ( GET_JOB_SERVERS, GET_JOB_SERVER_PLATFORM_API, @@ -189,14 +197,6 @@ PartitionResponse, PartitionResponseTypedDict, ) - from .retrieve import ( - RETRIEVE_SERVERS, - RETRIEVE_SERVER_PLATFORM_API, - RetrieveRequest, - RetrieveRequestTypedDict, - RetrieveResponse, - RetrieveResponseTypedDict, - ) from .run_workflow import ( RUN_WORKFLOW_SERVERS, RUN_WORKFLOW_SERVER_PLATFORM_API, @@ -305,6 +305,8 @@ "GET_CONNECTION_CHECK_SOURCES_SERVER_PLATFORM_API", "GET_DESTINATION_SERVERS", "GET_DESTINATION_SERVER_PLATFORM_API", + "GET_ENCRYPTION_CERTIFICATE_SERVERS", + "GET_ENCRYPTION_CERTIFICATE_SERVER_PLATFORM_API", "GET_JOB_DETAILS_SERVERS", "GET_JOB_DETAILS_SERVER_PLATFORM_API", "GET_JOB_FAILED_FILES_SERVERS", @@ -327,6 +329,10 @@ "GetDestinationRequestTypedDict", "GetDestinationResponse", "GetDestinationResponseTypedDict", + "GetEncryptionCertificateRequest", + "GetEncryptionCertificateRequestTypedDict", + "GetEncryptionCertificateResponse", + "GetEncryptionCertificateResponseTypedDict", "GetJobDetailsRequest", "GetJobDetailsRequestTypedDict", "GetJobDetailsResponse", @@ -378,14 +384,8 @@ "PartitionRequestTypedDict", "PartitionResponse", "PartitionResponseTypedDict", - "RETRIEVE_SERVERS", - "RETRIEVE_SERVER_PLATFORM_API", "RUN_WORKFLOW_SERVERS", "RUN_WORKFLOW_SERVER_PLATFORM_API", - "RetrieveRequest", - "RetrieveRequestTypedDict", - "RetrieveResponse", - "RetrieveResponseTypedDict", "RunWorkflowRequest", "RunWorkflowRequestTypedDict", "RunWorkflowResponse", @@ -495,6 +495,12 @@ "GetDestinationRequestTypedDict": ".get_destination", "GetDestinationResponse": ".get_destination", "GetDestinationResponseTypedDict": ".get_destination", + "GET_ENCRYPTION_CERTIFICATE_SERVERS": ".get_encryption_certificate", + "GET_ENCRYPTION_CERTIFICATE_SERVER_PLATFORM_API": ".get_encryption_certificate", + "GetEncryptionCertificateRequest": ".get_encryption_certificate", + "GetEncryptionCertificateRequestTypedDict": ".get_encryption_certificate", + "GetEncryptionCertificateResponse": ".get_encryption_certificate", + "GetEncryptionCertificateResponseTypedDict": ".get_encryption_certificate", "GET_JOB_SERVERS": ".get_job", "GET_JOB_SERVER_PLATFORM_API": ".get_job", "GetJobRequest": ".get_job", @@ -556,12 +562,6 @@ "PartitionRequestTypedDict": ".partition", "PartitionResponse": ".partition", "PartitionResponseTypedDict": ".partition", - "RETRIEVE_SERVERS": ".retrieve", - "RETRIEVE_SERVER_PLATFORM_API": ".retrieve", - "RetrieveRequest": ".retrieve", - "RetrieveRequestTypedDict": ".retrieve", - "RetrieveResponse": ".retrieve", - "RetrieveResponseTypedDict": ".retrieve", "RUN_WORKFLOW_SERVERS": ".run_workflow", "RUN_WORKFLOW_SERVER_PLATFORM_API": ".run_workflow", "RunWorkflowRequest": ".run_workflow", diff --git a/src/unstructured_client/models/operations/retrieve.py b/src/unstructured_client/models/operations/get_encryption_certificate.py similarity index 73% rename from src/unstructured_client/models/operations/retrieve.py rename to src/unstructured_client/models/operations/get_encryption_certificate.py index 839e2afa..5b25e300 100644 --- a/src/unstructured_client/models/operations/retrieve.py +++ b/src/unstructured_client/models/operations/get_encryption_certificate.py @@ -6,7 +6,9 @@ from pydantic import model_serializer from typing import Optional from typing_extensions import Annotated, NotRequired, TypedDict -from unstructured_client.models.shared import pemauthresponse as shared_pemauthresponse +from unstructured_client.models.shared import ( + encryptioncertificateresponse as shared_encryptioncertificateresponse, +) from unstructured_client.types import ( BaseModel, Nullable, @@ -16,19 +18,19 @@ ) from unstructured_client.utils import FieldMetadata, HeaderMetadata -RETRIEVE_SERVER_PLATFORM_API = "platform-api" +GET_ENCRYPTION_CERTIFICATE_SERVER_PLATFORM_API = "platform-api" r"""Unstructured Platform API""" -RETRIEVE_SERVERS = { - RETRIEVE_SERVER_PLATFORM_API: "https://platform.unstructuredapp.io/", +GET_ENCRYPTION_CERTIFICATE_SERVERS = { + GET_ENCRYPTION_CERTIFICATE_SERVER_PLATFORM_API: "https://platform.unstructuredapp.io/", } -class RetrieveRequestTypedDict(TypedDict): +class GetEncryptionCertificateRequestTypedDict(TypedDict): unstructured_api_key: NotRequired[Nullable[str]] -class RetrieveRequest(BaseModel): +class GetEncryptionCertificateRequest(BaseModel): unstructured_api_key: Annotated[ OptionalNullable[str], pydantic.Field(alias="unstructured-api-key"), @@ -66,18 +68,20 @@ def serialize_model(self, handler): return m -class RetrieveResponseTypedDict(TypedDict): +class GetEncryptionCertificateResponseTypedDict(TypedDict): content_type: str r"""HTTP response content type for this operation""" status_code: int r"""HTTP response status code for this operation""" raw_response: httpx.Response r"""Raw HTTP response; suitable for custom response parsing""" - pem_auth_response: NotRequired[shared_pemauthresponse.PemAuthResponseTypedDict] + encryption_certificate_response: NotRequired[ + shared_encryptioncertificateresponse.EncryptionCertificateResponseTypedDict + ] r"""Successful Response""" -class RetrieveResponse(BaseModel): +class GetEncryptionCertificateResponse(BaseModel): content_type: str r"""HTTP response content type for this operation""" @@ -87,5 +91,7 @@ class RetrieveResponse(BaseModel): raw_response: httpx.Response r"""Raw HTTP response; suitable for custom response parsing""" - pem_auth_response: Optional[shared_pemauthresponse.PemAuthResponse] = None + encryption_certificate_response: Optional[ + shared_encryptioncertificateresponse.EncryptionCertificateResponse + ] = None r"""Successful Response""" diff --git a/src/unstructured_client/models/shared/__init__.py b/src/unstructured_client/models/shared/__init__.py index 4805dd8d..246acfac 100644 --- a/src/unstructured_client/models/shared/__init__.py +++ b/src/unstructured_client/models/shared/__init__.py @@ -133,6 +133,10 @@ ElasticsearchConnectorConfigInputTypedDict, ) from .encryptedsecret import EncryptedSecret, EncryptedSecretTypedDict + from .encryptioncertificateresponse import ( + EncryptionCertificateResponse, + EncryptionCertificateResponseTypedDict, + ) from .encryptiontype import EncryptionType from .failedfile import FailedFile, FailedFileTypedDict from .gcsdestinationconnectorconfig import ( @@ -260,7 +264,6 @@ VLMModel, VLMModelProvider, ) - from .pemauthresponse import PemAuthResponse, PemAuthResponseTypedDict from .pineconedestinationconnectorconfig import ( PineconeDestinationConnectorConfig, PineconeDestinationConnectorConfigTypedDict, @@ -478,6 +481,8 @@ "ElasticsearchConnectorConfigTypedDict", "EncryptedSecret", "EncryptedSecretTypedDict", + "EncryptionCertificateResponse", + "EncryptionCertificateResponseTypedDict", "EncryptionType", "FailedFile", "FailedFileTypedDict", @@ -556,8 +561,6 @@ "OutputFormat", "PartitionParameters", "PartitionParametersTypedDict", - "PemAuthResponse", - "PemAuthResponseTypedDict", "PineconeDestinationConnectorConfig", "PineconeDestinationConnectorConfigInput", "PineconeDestinationConnectorConfigInputTypedDict", @@ -726,6 +729,8 @@ "ElasticsearchConnectorConfigInputTypedDict": ".elasticsearchconnectorconfiginput", "EncryptedSecret": ".encryptedsecret", "EncryptedSecretTypedDict": ".encryptedsecret", + "EncryptionCertificateResponse": ".encryptioncertificateresponse", + "EncryptionCertificateResponseTypedDict": ".encryptioncertificateresponse", "EncryptionType": ".encryptiontype", "FailedFile": ".failedfile", "FailedFileTypedDict": ".failedfile", @@ -805,8 +810,6 @@ "Strategy": ".partition_parameters", "VLMModel": ".partition_parameters", "VLMModelProvider": ".partition_parameters", - "PemAuthResponse": ".pemauthresponse", - "PemAuthResponseTypedDict": ".pemauthresponse", "PineconeDestinationConnectorConfig": ".pineconedestinationconnectorconfig", "PineconeDestinationConnectorConfigTypedDict": ".pineconedestinationconnectorconfig", "PineconeDestinationConnectorConfigInput": ".pineconedestinationconnectorconfiginput", diff --git a/src/unstructured_client/models/shared/body_run_workflow.py b/src/unstructured_client/models/shared/body_run_workflow.py index 66f7f51b..4eb6866d 100644 --- a/src/unstructured_client/models/shared/body_run_workflow.py +++ b/src/unstructured_client/models/shared/body_run_workflow.py @@ -46,7 +46,8 @@ class BodyRunWorkflowTypedDict(TypedDict): class BodyRunWorkflow(BaseModel): input_files: Annotated[ - OptionalNullable[List[InputFiles]], FieldMetadata(multipart=True) + OptionalNullable[List[InputFiles]], + FieldMetadata(multipart=MultipartFormMetadata(file=True)), ] = UNSET @model_serializer(mode="wrap") diff --git a/src/unstructured_client/models/shared/encryptioncertificateresponse.py b/src/unstructured_client/models/shared/encryptioncertificateresponse.py new file mode 100644 index 00000000..27d089e9 --- /dev/null +++ b/src/unstructured_client/models/shared/encryptioncertificateresponse.py @@ -0,0 +1,26 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from typing_extensions import TypedDict +from unstructured_client.types import BaseModel + + +class EncryptionCertificateResponseTypedDict(TypedDict): + r"""Response model for the encryption certificate. + Contains the siged user certificate and the root CA certificate + for verification. + """ + + ca_chain: str + encryption_certificate: str + + +class EncryptionCertificateResponse(BaseModel): + r"""Response model for the encryption certificate. + Contains the siged user certificate and the root CA certificate + for verification. + """ + + ca_chain: str + + encryption_certificate: str diff --git a/src/unstructured_client/models/shared/pemauthresponse.py b/src/unstructured_client/models/shared/pemauthresponse.py deleted file mode 100644 index d2184f96..00000000 --- a/src/unstructured_client/models/shared/pemauthresponse.py +++ /dev/null @@ -1,60 +0,0 @@ -"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" - -from __future__ import annotations -from pydantic import model_serializer -from typing_extensions import NotRequired, TypedDict -from unstructured_client.types import ( - BaseModel, - Nullable, - OptionalNullable, - UNSET, - UNSET_SENTINEL, -) - - -class PemAuthResponseTypedDict(TypedDict): - r"""Response model for PEM key retrieval.""" - - pem_key: str - tenant_id: str - user_id: NotRequired[Nullable[str]] - - -class PemAuthResponse(BaseModel): - r"""Response model for PEM key retrieval.""" - - pem_key: str - - tenant_id: str - - user_id: OptionalNullable[str] = UNSET - - @model_serializer(mode="wrap") - def serialize_model(self, handler): - optional_fields = ["user_id"] - nullable_fields = ["user_id"] - null_default_fields = [] - - serialized = handler(self) - - m = {} - - for n, f in type(self).model_fields.items(): - k = f.alias or n - val = serialized.get(k) - serialized.pop(k, None) - - optional_nullable = k in optional_fields and k in nullable_fields - is_set = ( - self.__pydantic_fields_set__.intersection({n}) - or k in null_default_fields - ) # pylint: disable=no-member - - if val is not None and val != UNSET_SENTINEL: - m[k] = val - elif val != UNSET_SENTINEL and ( - not k in optional_fields or (optional_nullable and is_set) - ): - m[k] = val - - return m diff --git a/src/unstructured_client/sdk.py b/src/unstructured_client/sdk.py index 83e4f799..f8ddc981 100644 --- a/src/unstructured_client/sdk.py +++ b/src/unstructured_client/sdk.py @@ -114,6 +114,9 @@ def __init__( hooks = SDKHooks() + # pylint: disable=protected-access + self.sdk_configuration.__dict__["_hooks"] = hooks + current_server_url, *_ = self.sdk_configuration.get_server_details() server_url, self.sdk_configuration.client = hooks.sdk_init( current_server_url, client @@ -121,9 +124,6 @@ def __init__( if current_server_url != server_url: self.sdk_configuration.server_url = server_url - # pylint: disable=protected-access - self.sdk_configuration.__dict__["_hooks"] = hooks - weakref.finalize( self, close_clients, diff --git a/src/unstructured_client/sdkconfiguration.py b/src/unstructured_client/sdkconfiguration.py index 10198812..df79bc66 100644 --- a/src/unstructured_client/sdkconfiguration.py +++ b/src/unstructured_client/sdkconfiguration.py @@ -1,6 +1,5 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" -from ._hooks import SDKHooks from ._version import ( __gen_version__, __openapi_doc_version__, @@ -42,9 +41,6 @@ class SDKConfiguration: retry_config: OptionalNullable[RetryConfig] = Field(default_factory=lambda: UNSET) timeout_ms: Optional[int] = None - def __post_init__(self): - self._hooks = SDKHooks() - def get_server_details(self) -> Tuple[str, Dict[str, str]]: if self.server_url is not None and self.server_url: return remove_suffix(self.server_url, "/"), {} @@ -55,6 +51,3 @@ def get_server_details(self) -> Tuple[str, Dict[str, str]]: raise ValueError(f'Invalid server "{self.server}"') return SERVERS[self.server], {} - - def get_hooks(self) -> SDKHooks: - return self._hooks diff --git a/src/unstructured_client/sources.py b/src/unstructured_client/sources.py index 2fca9ea1..4e6e428b 100644 --- a/src/unstructured_client/sources.py +++ b/src/unstructured_client/sources.py @@ -76,6 +76,7 @@ def create_connection_check_sources( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="create_connection_check_sources", oauth2_scopes=[], @@ -185,6 +186,7 @@ async def create_connection_check_sources_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="create_connection_check_sources", oauth2_scopes=[], @@ -298,6 +300,7 @@ def create_source( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="create_source", oauth2_scopes=[], @@ -411,6 +414,7 @@ async def create_source_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="create_source", oauth2_scopes=[], @@ -516,6 +520,7 @@ def delete_source( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="delete_source", oauth2_scopes=[], @@ -620,6 +625,7 @@ async def delete_source_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="delete_source", oauth2_scopes=[], @@ -728,6 +734,7 @@ def get_connection_check_sources( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="get_connection_check_sources", oauth2_scopes=[], @@ -837,6 +844,7 @@ async def get_connection_check_sources_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="get_connection_check_sources", oauth2_scopes=[], @@ -943,6 +951,7 @@ def get_source( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="get_source", oauth2_scopes=[], @@ -1049,6 +1058,7 @@ async def get_source_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="get_source", oauth2_scopes=[], @@ -1155,6 +1165,7 @@ def list_sources( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="list_sources", oauth2_scopes=[], @@ -1260,6 +1271,7 @@ async def list_sources_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="list_sources", oauth2_scopes=[], @@ -1373,6 +1385,7 @@ def update_source( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="update_source", oauth2_scopes=[], @@ -1486,6 +1499,7 @@ async def update_source_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="update_source", oauth2_scopes=[], diff --git a/src/unstructured_client/users.py b/src/unstructured_client/users.py index 33eaf4f2..32a8558d 100644 --- a/src/unstructured_client/users.py +++ b/src/unstructured_client/users.py @@ -173,18 +173,21 @@ def encrypt_secret( # endregion sdk-class-body - def retrieve( + def get_encryption_certificate( self, *, - request: Union[operations.RetrieveRequest, operations.RetrieveRequestTypedDict], + request: Union[ + operations.GetEncryptionCertificateRequest, + operations.GetEncryptionCertificateRequestTypedDict, + ], retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, timeout_ms: Optional[int] = None, http_headers: Optional[Mapping[str, str]] = None, - ) -> operations.RetrieveResponse: - r"""Retrieve PEM Key + ) -> operations.GetEncryptionCertificateResponse: + r"""Retrieve the user's public key for encryption. - Given a UNSTRUCTURED_API_KEY in the post-payload, retrieve the associated PEM key + Retrieve a short lived certificate with the public key for encrypting secrets. :param request: The request object to send. :param retries: Override the default retry configuration for this method @@ -200,17 +203,19 @@ def retrieve( if server_url is not None: base_url = server_url else: - base_url = operations.RETRIEVE_SERVERS[ - operations.RETRIEVE_SERVER_PLATFORM_API + base_url = operations.GET_ENCRYPTION_CERTIFICATE_SERVERS[ + operations.GET_ENCRYPTION_CERTIFICATE_SERVER_PLATFORM_API ] if not isinstance(request, BaseModel): - request = utils.unmarshal(request, operations.RetrieveRequest) - request = cast(operations.RetrieveRequest, request) + request = utils.unmarshal( + request, operations.GetEncryptionCertificateRequest + ) + request = cast(operations.GetEncryptionCertificateRequest, request) req = self._build_request( - method="POST", - path="/api/v1/users/retrieve", + method="GET", + path="/api/v1/users/secrets/encryption-certificate", base_url=base_url, url_variables=url_variables, request=request, @@ -238,8 +243,9 @@ def retrieve( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", - operation_id="retrieve", + operation_id="get_encryption_certificate", oauth2_scopes=[], security_source=self.sdk_configuration.security, ), @@ -250,9 +256,9 @@ def retrieve( response_data: Any = None if utils.match_response(http_res, "200", "application/json"): - return operations.RetrieveResponse( - pem_auth_response=utils.unmarshal_json( - http_res.text, Optional[shared.PemAuthResponse] + return operations.GetEncryptionCertificateResponse( + encryption_certificate_response=utils.unmarshal_json( + http_res.text, Optional[shared.EncryptionCertificateResponse] ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", @@ -283,18 +289,21 @@ def retrieve( http_res, ) - async def retrieve_async( + async def get_encryption_certificate_async( self, *, - request: Union[operations.RetrieveRequest, operations.RetrieveRequestTypedDict], + request: Union[ + operations.GetEncryptionCertificateRequest, + operations.GetEncryptionCertificateRequestTypedDict, + ], retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, timeout_ms: Optional[int] = None, http_headers: Optional[Mapping[str, str]] = None, - ) -> operations.RetrieveResponse: - r"""Retrieve PEM Key + ) -> operations.GetEncryptionCertificateResponse: + r"""Retrieve the user's public key for encryption. - Given a UNSTRUCTURED_API_KEY in the post-payload, retrieve the associated PEM key + Retrieve a short lived certificate with the public key for encrypting secrets. :param request: The request object to send. :param retries: Override the default retry configuration for this method @@ -310,17 +319,19 @@ async def retrieve_async( if server_url is not None: base_url = server_url else: - base_url = operations.RETRIEVE_SERVERS[ - operations.RETRIEVE_SERVER_PLATFORM_API + base_url = operations.GET_ENCRYPTION_CERTIFICATE_SERVERS[ + operations.GET_ENCRYPTION_CERTIFICATE_SERVER_PLATFORM_API ] if not isinstance(request, BaseModel): - request = utils.unmarshal(request, operations.RetrieveRequest) - request = cast(operations.RetrieveRequest, request) + request = utils.unmarshal( + request, operations.GetEncryptionCertificateRequest + ) + request = cast(operations.GetEncryptionCertificateRequest, request) req = self._build_request_async( - method="POST", - path="/api/v1/users/retrieve", + method="GET", + path="/api/v1/users/secrets/encryption-certificate", base_url=base_url, url_variables=url_variables, request=request, @@ -348,8 +359,9 @@ async def retrieve_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", - operation_id="retrieve", + operation_id="get_encryption_certificate", oauth2_scopes=[], security_source=self.sdk_configuration.security, ), @@ -360,9 +372,9 @@ async def retrieve_async( response_data: Any = None if utils.match_response(http_res, "200", "application/json"): - return operations.RetrieveResponse( - pem_auth_response=utils.unmarshal_json( - http_res.text, Optional[shared.PemAuthResponse] + return operations.GetEncryptionCertificateResponse( + encryption_certificate_response=utils.unmarshal_json( + http_res.text, Optional[shared.EncryptionCertificateResponse] ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", @@ -463,6 +475,7 @@ def store_secret( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="store_secret", oauth2_scopes=[], @@ -578,6 +591,7 @@ async def store_secret_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="store_secret", oauth2_scopes=[], diff --git a/src/unstructured_client/utils/forms.py b/src/unstructured_client/utils/forms.py index 0472aba8..e873495f 100644 --- a/src/unstructured_client/utils/forms.py +++ b/src/unstructured_client/utils/forms.py @@ -86,11 +86,39 @@ def _populate_form( return form +def _extract_file_properties(file_obj: Any) -> Tuple[str, Any, Any]: + """Extract file name, content, and content type from a file object.""" + file_fields: Dict[str, FieldInfo] = file_obj.__class__.model_fields + + file_name = "" + content = None + content_type = None + + for file_field_name in file_fields: + file_field = file_fields[file_field_name] + + file_metadata = find_field_metadata(file_field, MultipartFormMetadata) + if file_metadata is None: + continue + + if file_metadata.content: + content = getattr(file_obj, file_field_name, None) + elif file_field_name == "content_type": + content_type = getattr(file_obj, file_field_name, None) + else: + file_name = getattr(file_obj, file_field_name) + + if file_name == "" or content is None: + raise ValueError("invalid multipart/form-data file") + + return file_name, content, content_type + + def serialize_multipart_form( media_type: str, request: Any -) -> Tuple[str, Dict[str, Any], Dict[str, Any]]: +) -> Tuple[str, Dict[str, Any], List[Tuple[str, Any]]]: form: Dict[str, Any] = {} - files: Dict[str, Any] = {} + files: List[Tuple[str, Any]] = [] if not isinstance(request, BaseModel): raise TypeError("invalid request body type") @@ -112,39 +140,32 @@ def serialize_multipart_form( f_name = field.alias if field.alias else name if field_metadata.file: - file_fields: Dict[str, FieldInfo] = val.__class__.model_fields - - file_name = "" - content = None - content_type = None - - for file_field_name in file_fields: - file_field = file_fields[file_field_name] + if isinstance(val, List): + # Handle array of files + for file_obj in val: + if not _is_set(file_obj): + continue + + file_name, content, content_type = _extract_file_properties(file_obj) - file_metadata = find_field_metadata(file_field, MultipartFormMetadata) - if file_metadata is None: - continue + if content_type is not None: + files.append((f_name + "[]", (file_name, content, content_type))) + else: + files.append((f_name + "[]", (file_name, content))) + else: + # Handle single file + file_name, content, content_type = _extract_file_properties(val) - if file_metadata.content: - content = getattr(val, file_field_name, None) - elif file_field_name == "content_type": - content_type = getattr(val, file_field_name, None) + if content_type is not None: + files.append((f_name, (file_name, content, content_type))) else: - file_name = getattr(val, file_field_name) - - if file_name == "" or content is None: - raise ValueError("invalid multipart/form-data file") - - if content_type is not None: - files[f_name] = (file_name, content, content_type) - else: - files[f_name] = (file_name, content) + files.append((f_name, (file_name, content))) elif field_metadata.json: - files[f_name] = ( + files.append((f_name, ( None, marshal_json(val, request_field_types[name]), "application/json", - ) + ))) else: if isinstance(val, List): values = [] diff --git a/src/unstructured_client/workflows.py b/src/unstructured_client/workflows.py index 248dc8ec..3752c8b2 100644 --- a/src/unstructured_client/workflows.py +++ b/src/unstructured_client/workflows.py @@ -77,6 +77,7 @@ def create_workflow( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="create_workflow", oauth2_scopes=[], @@ -186,6 +187,7 @@ async def create_workflow_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="create_workflow", oauth2_scopes=[], @@ -293,6 +295,7 @@ def delete_workflow( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="delete_workflow", oauth2_scopes=[], @@ -397,6 +400,7 @@ async def delete_workflow_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="delete_workflow", oauth2_scopes=[], @@ -501,6 +505,7 @@ def get_workflow( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="get_workflow", oauth2_scopes=[], @@ -607,6 +612,7 @@ async def get_workflow_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="get_workflow", oauth2_scopes=[], @@ -713,6 +719,7 @@ def list_workflows( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="list_workflows", oauth2_scopes=[], @@ -819,6 +826,7 @@ async def list_workflows_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="list_workflows", oauth2_scopes=[], @@ -932,6 +940,7 @@ def run_workflow( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="run_workflow", oauth2_scopes=[], @@ -1045,6 +1054,7 @@ async def run_workflow_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="run_workflow", oauth2_scopes=[], @@ -1154,6 +1164,7 @@ def update_workflow( http_res = self.do_request( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="update_workflow", oauth2_scopes=[], @@ -1263,6 +1274,7 @@ async def update_workflow_async( http_res = await self.do_request_async( hook_ctx=HookContext( + config=self.sdk_configuration, base_url=base_url or "", operation_id="update_workflow", oauth2_scopes=[],