diff --git a/.genignore b/.genignore index 164078a0..8e5fcfd4 100644 --- a/.genignore +++ b/.genignore @@ -8,6 +8,10 @@ _test_unstructured_client # ignore Makefile Makefile +# No active endpoints in here, but we don't want to delete it +# Hold onto the custom regions until these endpoints come back +src/unstructured_client/users.py + # Ignore general.py so we can patch in our partitioning url # If we ever have a new endpoint under /general, we need to: # - Comment out this ignore line diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index cc6c7abb..5c393771 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: ae9cd2cec2edbde7b002c0a127c7aa84 - docVersion: 1.1.42 - speakeasyVersion: 1.589.0 - generationVersion: 2.664.0 - releaseVersion: 0.41.0 - configChecksum: b2d39b13446f595978a73e31a796dbe7 + docChecksum: 1e625384a184f21d27f5afa31f705ada + docVersion: 1.1.45 + speakeasyVersion: 1.595.0 + generationVersion: 2.670.1 + releaseVersion: 0.42.0 + configChecksum: cd0ffde4496a99df26b7766acfe9c43d 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.4 + core: 5.19.5 customCodeRegions: 0.1.1 defaultEnabledRetries: 0.2.0 enumUnions: 0.1.0 @@ -69,8 +69,6 @@ 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 @@ -93,8 +91,6 @@ generatedFiles: - docs/models/operations/partitionresponse.md - docs/models/operations/runworkflowrequest.md - docs/models/operations/runworkflowresponse.md - - docs/models/operations/storesecretrequest.md - - docs/models/operations/storesecretresponse.md - docs/models/operations/updatedestinationrequest.md - docs/models/operations/updatedestinationresponse.md - docs/models/operations/updatesourcerequest.md @@ -137,8 +133,6 @@ generatedFiles: - docs/models/shared/dropboxsourceconnectorconfiginput.md - 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 @@ -236,7 +230,6 @@ generatedFiles: - docs/sdks/jobs/README.md - docs/sdks/sources/README.md - docs/sdks/unstructuredclient/README.md - - docs/sdks/users/README.md - docs/sdks/workflows/README.md - poetry.toml - py.typed @@ -275,7 +268,6 @@ 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 @@ -287,7 +279,6 @@ generatedFiles: - src/unstructured_client/models/operations/list_workflows.py - src/unstructured_client/models/operations/partition.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 - src/unstructured_client/models/operations/update_source.py - src/unstructured_client/models/operations/update_workflow.py @@ -325,8 +316,6 @@ generatedFiles: - src/unstructured_client/models/shared/dropboxsourceconnectorconfiginput.py - 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 @@ -410,7 +399,6 @@ generatedFiles: - src/unstructured_client/sources.py - src/unstructured_client/types/__init__.py - src/unstructured_client/types/basemodel.py - - src/unstructured_client/users.py - src/unstructured_client/utils/__init__.py - src/unstructured_client/utils/annotations.py - src/unstructured_client/utils/datetimes.py diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 906c378a..d06bddc8 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,21 +1,21 @@ -speakeasyVersion: 1.589.0 +speakeasyVersion: 1.595.0 sources: my-source: sourceNamespace: my-source - sourceRevisionDigest: sha256:dc1c7c974419187404b25cb443e0d2497aa8b3ab71c95f27054eb5cd87b02ed0 - sourceBlobDigest: sha256:538ee1e259eb1db25ba57b09ba271636bad0015a794517bf6f910315e7ecaac3 + sourceRevisionDigest: sha256:fbae2a3d20d8dc0210e15a73e96e96325b1f38e080c97a1f893a843cd0a723e8 + sourceBlobDigest: sha256:71012d02fdfa3ce10a9dd1b7152af158ad50029dca56ed47c15480e76d977261 tags: - latest - - speakeasy-sdk-regen-1753403247 - - 1.1.42 + - speakeasy-sdk-regen-1754007218 + - 1.1.45 targets: unstructured-python: source: my-source sourceNamespace: my-source - sourceRevisionDigest: sha256:dc1c7c974419187404b25cb443e0d2497aa8b3ab71c95f27054eb5cd87b02ed0 - sourceBlobDigest: sha256:538ee1e259eb1db25ba57b09ba271636bad0015a794517bf6f910315e7ecaac3 + sourceRevisionDigest: sha256:fbae2a3d20d8dc0210e15a73e96e96325b1f38e080c97a1f893a843cd0a723e8 + sourceBlobDigest: sha256:71012d02fdfa3ce10a9dd1b7152af158ad50029dca56ed47c15480e76d977261 codeSamplesNamespace: my-source-code-samples - codeSamplesRevisionDigest: sha256:1e8db4a01c54f1f99e27cc80d3f5283192aa2a6a68001f80424fbf9bdface495 + codeSamplesRevisionDigest: sha256:244db79d394b3d7a4e244006d91bdadeb850c019a9a7c5d80d3dc3550447019a workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c7ca1e7..6fc55a66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### Fixes * Fix some environments failing to split pdfs with `Can't patch loop of type `, remove usage of `nest-asyncio` +* Remove some operations under `client.users` that are not fully ready yet ## 0.41.0 diff --git a/README.md b/README.md index 8adbf15e..f45a924d 100644 --- a/README.md +++ b/README.md @@ -213,7 +213,7 @@ with UnstructuredClient() as uc_client: **Inherit from [`UnstructuredClientError`](./src/unstructured_client/models/errors/unstructuredclienterror.py)**: -* [`ServerError`](./src/unstructured_client/models/errors/servererror.py): Server Error. Status code `5XX`. Applicable to 1 of 29 methods.* +* [`ServerError`](./src/unstructured_client/models/errors/servererror.py): Server Error. Status code `5XX`. Applicable to 1 of 27 methods.* * [`ResponseValidationError`](./src/unstructured_client/models/errors/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute. diff --git a/RELEASES.md b/RELEASES.md index 38a2eb87..7b4c4a4f 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1079,4 +1079,14 @@ Based on: ### Generated - [python v0.41.0] . ### Releases -- [PyPI v0.41.0] https://pypi.org/project/unstructured-client/0.41.0 - . \ No newline at end of file +- [PyPI v0.41.0] https://pypi.org/project/unstructured-client/0.41.0 - . + +## 2025-08-01 00:13:22 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.595.0 (2.670.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v0.42.0] . +### Releases +- [PyPI v0.42.0] https://pypi.org/project/unstructured-client/0.42.0 - . \ No newline at end of file diff --git a/_test_unstructured_client/unit/test_encryption.py b/_test_unstructured_client/unit/test_encryption.py index 6fca3b39..c190c1c8 100644 --- a/_test_unstructured_client/unit/test_encryption.py +++ b/_test_unstructured_client/unit/test_encryption.py @@ -33,6 +33,7 @@ def rsa_key_pair(): return private_key_pem, public_key_pem +@pytest.mark.skip(reason="Encryption is not in the SDK yet") def test_encrypt_rsa(rsa_key_pair): private_key_pem, public_key_pem = rsa_key_pair @@ -55,6 +56,7 @@ def test_encrypt_rsa(rsa_key_pair): assert decrypted_text == plaintext +@pytest.mark.skip(reason="Encryption is not in the SDK yet") def test_encrypt_rsa_aes(rsa_key_pair): private_key_pem, public_key_pem = rsa_key_pair @@ -80,6 +82,7 @@ def test_encrypt_rsa_aes(rsa_key_pair): rsa_key_size_bytes = 2048 // 8 max_payload_size = rsa_key_size_bytes - 66 # OAEP SHA256 overhead +@pytest.mark.skip(reason="Encryption is not in the SDK yet") @pytest.mark.parametrize(("plaintext", "secret_type"), [ ("Short message", "rsa"), ("A" * (max_payload_size), "rsa"), # Just at the RSA limit diff --git a/codeSamples.yaml b/codeSamples.yaml index 34946cad..7ce6c598 100644 --- a/codeSamples.yaml +++ b/codeSamples.yaml @@ -123,18 +123,6 @@ actions: - "lang": "python" "label": "create_connection_check_sources" "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient() as uc_client:\n\n res = uc_client.sources.create_connection_check_sources(request={\n \"source_id\": \"8d49e3f2-3e6d-4973-bc61-292af66829d7\",\n })\n\n assert res.dag_node_connection_check is not None\n\n # Handle response\n print(res.dag_node_connection_check)" - - target: $["paths"]["/api/v1/users/secrets"]["post"] - update: - "x-codeSamples": - - "lang": "python" - "label": "store_secret" - "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient() as uc_client:\n\n res = uc_client.users.store_secret(request={\n \"encrypted_secret\": {\n \"encrypted_value\": \"\",\n },\n })\n\n assert res.secret_reference is not None\n\n # Handle response\n print(res.secret_reference)" - - target: $["paths"]["/api/v1/users/secrets/encryption-certificate"]["get"] - update: - "x-codeSamples": - - "lang": "python" - "label": "get_encryption_certificate" - "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient() as uc_client:\n\n res = uc_client.users.get_encryption_certificate(request={})\n\n assert res.encryption_certificate_response is not None\n\n # Handle response\n print(res.encryption_certificate_response)" - target: $["paths"]["/api/v1/workflows/"]["get"] update: "x-codeSamples": diff --git a/docs/models/operations/getencryptioncertificaterequest.md b/docs/models/operations/getencryptioncertificaterequest.md deleted file mode 100644 index b0a6b822..00000000 --- a/docs/models/operations/getencryptioncertificaterequest.md +++ /dev/null @@ -1,8 +0,0 @@ -# GetEncryptionCertificateRequest - - -## Fields - -| Field | Type | Required | Description | -| ----------------------- | ----------------------- | ----------------------- | ----------------------- | -| `unstructured_api_key` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/operations/getencryptioncertificateresponse.md b/docs/models/operations/getencryptioncertificateresponse.md deleted file mode 100644 index 251e039f..00000000 --- a/docs/models/operations/getencryptioncertificateresponse.md +++ /dev/null @@ -1,11 +0,0 @@ -# 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/storesecretrequest.md b/docs/models/operations/storesecretrequest.md deleted file mode 100644 index 51bfcdd1..00000000 --- a/docs/models/operations/storesecretrequest.md +++ /dev/null @@ -1,9 +0,0 @@ -# StoreSecretRequest - - -## Fields - -| Field | Type | Required | Description | -| ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | -| `encrypted_secret` | [shared.EncryptedSecret](../../models/shared/encryptedsecret.md) | :heavy_check_mark: | N/A | -| `unstructured_api_key` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/operations/storesecretresponse.md b/docs/models/operations/storesecretresponse.md deleted file mode 100644 index 7c393ed4..00000000 --- a/docs/models/operations/storesecretresponse.md +++ /dev/null @@ -1,11 +0,0 @@ -# StoreSecretResponse - - -## Fields - -| Field | Type | Required | Description | -| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -| `content_type` | *str* | :heavy_check_mark: | HTTP response content type for this operation | -| `secret_reference` | [Optional[shared.SecretReference]](../../models/shared/secretreference.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/encryptedsecret.md b/docs/models/shared/encryptedsecret.md deleted file mode 100644 index 9a2d74b8..00000000 --- a/docs/models/shared/encryptedsecret.md +++ /dev/null @@ -1,11 +0,0 @@ -# EncryptedSecret - - -## Fields - -| Field | Type | Required | Description | -| ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | -| `aes_iv` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | -| `encrypted_aes_key` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | -| `encrypted_value` | *str* | :heavy_check_mark: | N/A | -| `type` | [Optional[shared.EncryptionType]](../../models/shared/encryptiontype.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/shared/encryptioncertificateresponse.md b/docs/models/shared/encryptioncertificateresponse.md deleted file mode 100644 index 6a521241..00000000 --- a/docs/models/shared/encryptioncertificateresponse.md +++ /dev/null @@ -1,13 +0,0 @@ -# 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/sdks/destinations/README.md b/docs/sdks/destinations/README.md index 1c8ec7b9..5b25549f 100644 --- a/docs/sdks/destinations/README.md +++ b/docs/sdks/destinations/README.md @@ -19,6 +19,7 @@ Initiate a connection check for the destination connector ### Example Usage + ```python from unstructured_client import UnstructuredClient @@ -60,6 +61,7 @@ Create a new destination connector using the provided configuration and name. ### Example Usage + ```python from unstructured_client import UnstructuredClient from unstructured_client.models import shared @@ -110,6 +112,7 @@ Delete a specific destination connector by its ID. ### Example Usage + ```python from unstructured_client import UnstructuredClient @@ -151,6 +154,7 @@ Retrieves the most recent connection check for the specified destination connect ### Example Usage + ```python from unstructured_client import UnstructuredClient @@ -192,6 +196,7 @@ Retrieve detailed information for a specific destination connector by its ID. ### Example Usage + ```python from unstructured_client import UnstructuredClient @@ -233,6 +238,7 @@ Retrieve a list of available destination connectors. ### Example Usage + ```python from unstructured_client import UnstructuredClient @@ -272,6 +278,7 @@ Update the configuration of an existing destination connector. ### Example Usage + ```python from unstructured_client import UnstructuredClient diff --git a/docs/sdks/general/README.md b/docs/sdks/general/README.md index 8c6311f9..1eee2b9e 100644 --- a/docs/sdks/general/README.md +++ b/docs/sdks/general/README.md @@ -13,6 +13,7 @@ Description ### Example Usage + ```python from unstructured_client import UnstructuredClient from unstructured_client.models import shared diff --git a/docs/sdks/jobs/README.md b/docs/sdks/jobs/README.md index c0805217..feddfe3b 100644 --- a/docs/sdks/jobs/README.md +++ b/docs/sdks/jobs/README.md @@ -18,6 +18,7 @@ Cancel the specified job. ### Example Usage + ```python from unstructured_client import UnstructuredClient @@ -59,6 +60,7 @@ Download the output of a job from a workflow where the input file was provided a ### Example Usage + ```python from unstructured_client import UnstructuredClient @@ -102,6 +104,7 @@ Retrieve detailed information for a specific job by its ID. ### Example Usage + ```python from unstructured_client import UnstructuredClient @@ -143,6 +146,7 @@ Retrieve processing details for a specific job by its ID. ### Example Usage + ```python from unstructured_client import UnstructuredClient @@ -184,6 +188,7 @@ Retrieve failed files for a specific job by its ID. ### Example Usage + ```python from unstructured_client import UnstructuredClient @@ -225,6 +230,7 @@ Retrieve a list of jobs with optional filtering by workflow ID or job status. ### Example Usage + ```python from unstructured_client import UnstructuredClient diff --git a/docs/sdks/sources/README.md b/docs/sdks/sources/README.md index 53d0815e..dc0c748d 100644 --- a/docs/sdks/sources/README.md +++ b/docs/sdks/sources/README.md @@ -19,6 +19,7 @@ Initiates a connection check for the specified source connector. ### Example Usage + ```python from unstructured_client import UnstructuredClient @@ -60,6 +61,7 @@ Create a new source connector using the provided configuration and name. ### Example Usage + ```python from unstructured_client import UnstructuredClient from unstructured_client.models import shared @@ -113,6 +115,7 @@ Delete a specific source connector identified by its ID. ### Example Usage + ```python from unstructured_client import UnstructuredClient @@ -154,6 +157,7 @@ Retrieves the most recent connection check for the specified source connector. ### Example Usage + ```python from unstructured_client import UnstructuredClient @@ -195,6 +199,7 @@ Retrieve detailed information for a specific source connector by its ID. ### Example Usage + ```python from unstructured_client import UnstructuredClient @@ -236,6 +241,7 @@ Retrieve a list of available source connectors. ### Example Usage + ```python from unstructured_client import UnstructuredClient @@ -275,6 +281,7 @@ Update the configuration of an existing source connector. ### Example Usage + ```python from unstructured_client import UnstructuredClient diff --git a/docs/sdks/users/README.md b/docs/sdks/users/README.md deleted file mode 100644 index 1a45dc4b..00000000 --- a/docs/sdks/users/README.md +++ /dev/null @@ -1,91 +0,0 @@ -# Users -(*users*) - -## Overview - -### Available Operations - -* [get_encryption_certificate](#get_encryption_certificate) - Retrieve the user's public key for encryption. -* [store_secret](#store_secret) - Store an encrypted secret - -## get_encryption_certificate - -Retrieve a short lived certificate with the public key for encrypting secrets. - -### Example Usage - -```python -from unstructured_client import UnstructuredClient - - -with UnstructuredClient() as uc_client: - - res = uc_client.users.get_encryption_certificate(request={}) - - assert res.encryption_certificate_response is not None - - # Handle response - print(res.encryption_certificate_response) - -``` - -### Parameters - -| 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. | - -### Response - -**[operations.GetEncryptionCertificateResponse](../../models/operations/getencryptioncertificateresponse.md)** - -### Errors - -| Error Type | Status Code | Content Type | -| -------------------------- | -------------------------- | -------------------------- | -| errors.HTTPValidationError | 422 | application/json | -| errors.SDKError | 4XX, 5XX | \*/\* | - -## store_secret - -After encrypting a secret locally, store it and get back a reference id. - -### Example Usage - -```python -from unstructured_client import UnstructuredClient - - -with UnstructuredClient() as uc_client: - - res = uc_client.users.store_secret(request={ - "encrypted_secret": { - "encrypted_value": "", - }, - }) - - assert res.secret_reference is not None - - # Handle response - print(res.secret_reference) - -``` - -### Parameters - -| Parameter | Type | Required | Description | -| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | -| `request` | [operations.StoreSecretRequest](../../models/operations/storesecretrequest.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. | - -### Response - -**[operations.StoreSecretResponse](../../models/operations/storesecretresponse.md)** - -### Errors - -| Error Type | Status Code | Content Type | -| -------------------------- | -------------------------- | -------------------------- | -| errors.HTTPValidationError | 422 | application/json | -| errors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/workflows/README.md b/docs/sdks/workflows/README.md index 9ecb0808..a522bc31 100644 --- a/docs/sdks/workflows/README.md +++ b/docs/sdks/workflows/README.md @@ -18,6 +18,7 @@ Create a new workflow, either custom or auto, and configure its settings. ### Example Usage + ```python from unstructured_client import UnstructuredClient from unstructured_client.models import shared @@ -63,6 +64,7 @@ Delete a workflow by its ID. ### Example Usage + ```python from unstructured_client import UnstructuredClient @@ -104,6 +106,7 @@ Retrieve detailed information for a specific workflow by its ID. ### Example Usage + ```python from unstructured_client import UnstructuredClient @@ -145,6 +148,7 @@ Retrieve a list of workflows, optionally filtered by source, destination, state, ### Example Usage + ```python from unstructured_client import UnstructuredClient @@ -184,6 +188,7 @@ Run a workflow by triggering a new job if none is currently active. ### Example Usage + ```python from unstructured_client import UnstructuredClient @@ -225,6 +230,7 @@ Update an existing workflow's name, connectors, schedule, or workflow type. ### Example Usage + ```python from unstructured_client import UnstructuredClient diff --git a/poetry.lock b/poetry.lock index b0c03228..638d9bf5 100644 --- a/poetry.lock +++ b/poetry.lock @@ -611,18 +611,6 @@ files = [ {file = "mypy_extensions-1.1.0.tar.gz", hash = "sha256:52e68efc3284861e772bbcd66823fde5ae21fd2fdb51c62a211403730b916558"}, ] -[[package]] -name = "nest-asyncio" -version = "1.6.0" -description = "Patch asyncio to allow nested event loops" -optional = false -python-versions = ">=3.5" -groups = ["main"] -files = [ - {file = "nest_asyncio-1.6.0-py3-none-any.whl", hash = "sha256:87af6efd6b5e897c81050477ef65c62e2b2f35d51703cae01aff2905b1852e1c"}, - {file = "nest_asyncio-1.6.0.tar.gz", hash = "sha256:6f172d5449aca15afd6c646851f4e31e02c598d553a667e38cafa997cfec55fe"}, -] - [[package]] name = "orderly-set" version = "5.5.0" @@ -1249,4 +1237,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 = "f1ed0b2c01f3e8201fb3c491269c2736725ba2bb1eea5fab13d7b8520a6ab3d9" +content-hash = "bc7eb54bd2eb68bd39aedc2f6da6b4faf217363f542fd493ee94766edf743cf3" diff --git a/pyproject.toml b/pyproject.toml index da7b9e99..9fce1905 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "unstructured-client" -version = "0.41.0" +version = "0.42.0" description = "Python Client SDK for Unstructured API" authors = [{ name = "Unstructured" },] readme = "README-PYPI.md" @@ -10,8 +10,7 @@ dependencies = [ "cryptography >=3.1", "httpcore >=1.0.9", "httpx >=0.27.0", - "pydantic >=2.10.3", - "nest-asyncio >=1.6.0", + "pydantic >=2.11.2", "pypdf >=4.0", "requests-toolbelt >=1.0.0", ] @@ -48,7 +47,6 @@ requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" [tool.pytest.ini_options] -asyncio_mode = "auto" asyncio_default_fixture_loop_scope = "function" pythonpath = ["src"] diff --git a/src/unstructured_client/_version.py b/src/unstructured_client/_version.py index 3e673c3b..79c2f364 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.41.0" -__openapi_doc_version__: str = "1.1.42" -__gen_version__: str = "2.664.0" -__user_agent__: str = "speakeasy-sdk/python 0.41.0 2.664.0 1.1.42 unstructured-client" +__version__: str = "0.42.0" +__openapi_doc_version__: str = "1.1.45" +__gen_version__: str = "2.670.1" +__user_agent__: str = "speakeasy-sdk/python 0.42.0 2.670.1 1.1.45 unstructured-client" try: if __package__ is not None: diff --git a/src/unstructured_client/models/operations/__init__.py b/src/unstructured_client/models/operations/__init__.py index 40899f82..ee9d33af 100644 --- a/src/unstructured_client/models/operations/__init__.py +++ b/src/unstructured_client/models/operations/__init__.py @@ -82,12 +82,6 @@ GetDestinationResponse, GetDestinationResponseTypedDict, ) - from .get_encryption_certificate import ( - GetEncryptionCertificateRequest, - GetEncryptionCertificateRequestTypedDict, - GetEncryptionCertificateResponse, - GetEncryptionCertificateResponseTypedDict, - ) from .get_job import ( GetJobRequest, GetJobRequestTypedDict, @@ -154,12 +148,6 @@ RunWorkflowResponse, RunWorkflowResponseTypedDict, ) - from .store_secret import ( - StoreSecretRequest, - StoreSecretRequestTypedDict, - StoreSecretResponse, - StoreSecretResponseTypedDict, - ) from .update_destination import ( UpdateDestinationRequest, UpdateDestinationRequestTypedDict, @@ -232,10 +220,6 @@ "GetDestinationRequestTypedDict", "GetDestinationResponse", "GetDestinationResponseTypedDict", - "GetEncryptionCertificateRequest", - "GetEncryptionCertificateRequestTypedDict", - "GetEncryptionCertificateResponse", - "GetEncryptionCertificateResponseTypedDict", "GetJobDetailsRequest", "GetJobDetailsRequestTypedDict", "GetJobDetailsResponse", @@ -280,10 +264,6 @@ "RunWorkflowRequestTypedDict", "RunWorkflowResponse", "RunWorkflowResponseTypedDict", - "StoreSecretRequest", - "StoreSecretRequestTypedDict", - "StoreSecretResponse", - "StoreSecretResponseTypedDict", "UpdateDestinationRequest", "UpdateDestinationRequestTypedDict", "UpdateDestinationResponse", @@ -351,10 +331,6 @@ "GetDestinationRequestTypedDict": ".get_destination", "GetDestinationResponse": ".get_destination", "GetDestinationResponseTypedDict": ".get_destination", - "GetEncryptionCertificateRequest": ".get_encryption_certificate", - "GetEncryptionCertificateRequestTypedDict": ".get_encryption_certificate", - "GetEncryptionCertificateResponse": ".get_encryption_certificate", - "GetEncryptionCertificateResponseTypedDict": ".get_encryption_certificate", "GetJobRequest": ".get_job", "GetJobRequestTypedDict": ".get_job", "GetJobResponse": ".get_job", @@ -399,10 +375,6 @@ "RunWorkflowRequestTypedDict": ".run_workflow", "RunWorkflowResponse": ".run_workflow", "RunWorkflowResponseTypedDict": ".run_workflow", - "StoreSecretRequest": ".store_secret", - "StoreSecretRequestTypedDict": ".store_secret", - "StoreSecretResponse": ".store_secret", - "StoreSecretResponseTypedDict": ".store_secret", "UpdateDestinationRequest": ".update_destination", "UpdateDestinationRequestTypedDict": ".update_destination", "UpdateDestinationResponse": ".update_destination", diff --git a/src/unstructured_client/models/operations/get_encryption_certificate.py b/src/unstructured_client/models/operations/get_encryption_certificate.py deleted file mode 100644 index 00cc0250..00000000 --- a/src/unstructured_client/models/operations/get_encryption_certificate.py +++ /dev/null @@ -1,90 +0,0 @@ -"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" - -from __future__ import annotations -import httpx -import pydantic -from pydantic import model_serializer -from typing import Optional -from typing_extensions import Annotated, NotRequired, TypedDict -from unstructured_client.models.shared import ( - encryptioncertificateresponse as shared_encryptioncertificateresponse, -) -from unstructured_client.types import ( - BaseModel, - Nullable, - OptionalNullable, - UNSET, - UNSET_SENTINEL, -) -from unstructured_client.utils import FieldMetadata, HeaderMetadata - - -class GetEncryptionCertificateRequestTypedDict(TypedDict): - unstructured_api_key: NotRequired[Nullable[str]] - - -class GetEncryptionCertificateRequest(BaseModel): - unstructured_api_key: Annotated[ - OptionalNullable[str], - pydantic.Field(alias="unstructured-api-key"), - FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), - ] = UNSET - - @model_serializer(mode="wrap") - def serialize_model(self, handler): - optional_fields = ["unstructured-api-key"] - nullable_fields = ["unstructured-api-key"] - 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 - - -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""" - encryption_certificate_response: NotRequired[ - shared_encryptioncertificateresponse.EncryptionCertificateResponseTypedDict - ] - r"""Successful Response""" - - -class GetEncryptionCertificateResponse(BaseModel): - 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""" - - encryption_certificate_response: Optional[ - shared_encryptioncertificateresponse.EncryptionCertificateResponse - ] = None - r"""Successful Response""" diff --git a/src/unstructured_client/models/operations/store_secret.py b/src/unstructured_client/models/operations/store_secret.py deleted file mode 100644 index fe5eb8ad..00000000 --- a/src/unstructured_client/models/operations/store_secret.py +++ /dev/null @@ -1,93 +0,0 @@ -"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" - -from __future__ import annotations -import httpx -import pydantic -from pydantic import model_serializer -from typing import Optional -from typing_extensions import Annotated, NotRequired, TypedDict -from unstructured_client.models.shared import ( - encryptedsecret as shared_encryptedsecret, - secretreference as shared_secretreference, -) -from unstructured_client.types import ( - BaseModel, - Nullable, - OptionalNullable, - UNSET, - UNSET_SENTINEL, -) -from unstructured_client.utils import FieldMetadata, HeaderMetadata, RequestMetadata - - -class StoreSecretRequestTypedDict(TypedDict): - encrypted_secret: shared_encryptedsecret.EncryptedSecretTypedDict - unstructured_api_key: NotRequired[Nullable[str]] - - -class StoreSecretRequest(BaseModel): - encrypted_secret: Annotated[ - shared_encryptedsecret.EncryptedSecret, - FieldMetadata(request=RequestMetadata(media_type="application/json")), - ] - - unstructured_api_key: Annotated[ - OptionalNullable[str], - pydantic.Field(alias="unstructured-api-key"), - FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), - ] = UNSET - - @model_serializer(mode="wrap") - def serialize_model(self, handler): - optional_fields = ["unstructured-api-key"] - nullable_fields = ["unstructured-api-key"] - 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 - - -class StoreSecretResponseTypedDict(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""" - secret_reference: NotRequired[shared_secretreference.SecretReferenceTypedDict] - r"""Successful Response""" - - -class StoreSecretResponse(BaseModel): - 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""" - - secret_reference: Optional[shared_secretreference.SecretReference] = None - r"""Successful Response""" diff --git a/src/unstructured_client/models/shared/__init__.py b/src/unstructured_client/models/shared/__init__.py index 246acfac..c954e490 100644 --- a/src/unstructured_client/models/shared/__init__.py +++ b/src/unstructured_client/models/shared/__init__.py @@ -132,11 +132,6 @@ ElasticsearchConnectorConfigInput, ElasticsearchConnectorConfigInputTypedDict, ) - from .encryptedsecret import EncryptedSecret, EncryptedSecretTypedDict - from .encryptioncertificateresponse import ( - EncryptionCertificateResponse, - EncryptionCertificateResponseTypedDict, - ) from .encryptiontype import EncryptionType from .failedfile import FailedFile, FailedFileTypedDict from .gcsdestinationconnectorconfig import ( @@ -479,10 +474,6 @@ "ElasticsearchConnectorConfigInput", "ElasticsearchConnectorConfigInputTypedDict", "ElasticsearchConnectorConfigTypedDict", - "EncryptedSecret", - "EncryptedSecretTypedDict", - "EncryptionCertificateResponse", - "EncryptionCertificateResponseTypedDict", "EncryptionType", "FailedFile", "FailedFileTypedDict", @@ -727,10 +718,6 @@ "ElasticsearchConnectorConfigTypedDict": ".elasticsearchconnectorconfig", "ElasticsearchConnectorConfigInput": ".elasticsearchconnectorconfiginput", "ElasticsearchConnectorConfigInputTypedDict": ".elasticsearchconnectorconfiginput", - "EncryptedSecret": ".encryptedsecret", - "EncryptedSecretTypedDict": ".encryptedsecret", - "EncryptionCertificateResponse": ".encryptioncertificateresponse", - "EncryptionCertificateResponseTypedDict": ".encryptioncertificateresponse", "EncryptionType": ".encryptiontype", "FailedFile": ".failedfile", "FailedFileTypedDict": ".failedfile", diff --git a/src/unstructured_client/models/shared/encryptedsecret.py b/src/unstructured_client/models/shared/encryptedsecret.py deleted file mode 100644 index faee5bb0..00000000 --- a/src/unstructured_client/models/shared/encryptedsecret.py +++ /dev/null @@ -1,61 +0,0 @@ -"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" - -from __future__ import annotations -from .encryptiontype import EncryptionType -from pydantic import model_serializer -from typing import Optional -from typing_extensions import NotRequired, TypedDict -from unstructured_client.types import ( - BaseModel, - Nullable, - OptionalNullable, - UNSET, - UNSET_SENTINEL, -) - - -class EncryptedSecretTypedDict(TypedDict): - encrypted_value: str - aes_iv: NotRequired[Nullable[str]] - encrypted_aes_key: NotRequired[Nullable[str]] - type: NotRequired[EncryptionType] - - -class EncryptedSecret(BaseModel): - encrypted_value: str - - aes_iv: OptionalNullable[str] = UNSET - - encrypted_aes_key: OptionalNullable[str] = UNSET - - type: Optional[EncryptionType] = None - - @model_serializer(mode="wrap") - def serialize_model(self, handler): - optional_fields = ["aes_iv", "encrypted_aes_key", "type"] - nullable_fields = ["aes_iv", "encrypted_aes_key"] - 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/models/shared/encryptioncertificateresponse.py b/src/unstructured_client/models/shared/encryptioncertificateresponse.py deleted file mode 100644 index 27d089e9..00000000 --- a/src/unstructured_client/models/shared/encryptioncertificateresponse.py +++ /dev/null @@ -1,26 +0,0 @@ -"""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/sdk.py b/src/unstructured_client/sdk.py index f8ddc981..014bb146 100644 --- a/src/unstructured_client/sdk.py +++ b/src/unstructured_client/sdk.py @@ -19,7 +19,6 @@ from unstructured_client.general import General from unstructured_client.jobs import Jobs from unstructured_client.sources import Sources - from unstructured_client.users import Users from unstructured_client.workflows import Workflows @@ -27,14 +26,12 @@ class UnstructuredClient(BaseSDK): destinations: "Destinations" jobs: "Jobs" sources: "Sources" - users: "Users" workflows: "Workflows" general: "General" _sub_sdk_map = { "destinations": ("unstructured_client.destinations", "Destinations"), "jobs": ("unstructured_client.jobs", "Jobs"), "sources": ("unstructured_client.sources", "Sources"), - "users": ("unstructured_client.users", "Users"), "workflows": ("unstructured_client.workflows", "Workflows"), "general": ("unstructured_client.general", "General"), } diff --git a/src/unstructured_client/users.py b/src/unstructured_client/users.py index a9315ce9..889fea62 100644 --- a/src/unstructured_client/users.py +++ b/src/unstructured_client/users.py @@ -1,587 +1,587 @@ -"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" - -from .basesdk import BaseSDK -from typing import Any, Mapping, Optional, Union, cast -from unstructured_client import utils -from unstructured_client._hooks import HookContext -from unstructured_client.models import errors, operations, shared -from unstructured_client.types import BaseModel, OptionalNullable, UNSET -from unstructured_client.utils.unmarshal_json_response import unmarshal_json_response - -# region imports -from cryptography import x509 -from cryptography.hazmat.primitives import serialization, hashes -from cryptography.hazmat.primitives.asymmetric import padding, rsa -from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes -from cryptography.hazmat.backends import default_backend -import os -import base64 -# endregion imports - - -class Users(BaseSDK): - # region sdk-class-body - def _encrypt_rsa_aes( - self, - public_key: rsa.RSAPublicKey, - plaintext: str, - ) -> dict: - # Generate a random AES key - aes_key = os.urandom(32) # 256-bit AES key - - # Generate a random IV - iv = os.urandom(16) - - # Encrypt using AES-CFB - cipher = Cipher( - algorithms.AES(aes_key), - modes.CFB(iv), - ) - encryptor = cipher.encryptor() - ciphertext = encryptor.update(plaintext.encode("utf-8")) + encryptor.finalize() - - # Encrypt the AES key using the RSA public key - encrypted_key = public_key.encrypt( - aes_key, - padding.OAEP( - mgf=padding.MGF1(algorithm=hashes.SHA256()), - algorithm=hashes.SHA256(), - label=None, - ), - ) - - return { - "encrypted_aes_key": base64.b64encode(encrypted_key).decode("utf-8"), - "aes_iv": base64.b64encode(iv).decode("utf-8"), - "encrypted_value": base64.b64encode(ciphertext).decode("utf-8"), - "type": "rsa_aes", - } - - def _encrypt_rsa( - self, - public_key: rsa.RSAPublicKey, - plaintext: str, - ) -> dict: - # Load public RSA key - ciphertext = public_key.encrypt( - plaintext.encode(), - padding.OAEP( - mgf=padding.MGF1(algorithm=hashes.SHA256()), - algorithm=hashes.SHA256(), - label=None, - ), - ) - return { - "encrypted_value": base64.b64encode(ciphertext).decode("utf-8"), - "type": "rsa", - "encrypted_aes_key": "", - "aes_iv": "", - } - - def decrypt_secret( - self, - private_key_pem: str, - encrypted_value: str, - secret_type: str, - encrypted_aes_key: str, - aes_iv: str, - ) -> str: - private_key = serialization.load_pem_private_key( - private_key_pem.encode("utf-8"), password=None, backend=default_backend() - ) - - if not isinstance(private_key, rsa.RSAPrivateKey): - raise TypeError("Private key must be a RSA private key for decryption.") - - if secret_type == "rsa": - ciphertext = base64.b64decode(encrypted_value) - plaintext = private_key.decrypt( - ciphertext, - padding.OAEP( - mgf=padding.MGF1(algorithm=hashes.SHA256()), - algorithm=hashes.SHA256(), - label=None, - ), - ) - return plaintext.decode("utf-8") - - # aes_rsa - encrypted_aes_key_decoded = base64.b64decode(encrypted_aes_key) - iv = base64.b64decode(aes_iv) - ciphertext = base64.b64decode(encrypted_value) - - aes_key = private_key.decrypt( - encrypted_aes_key_decoded, - padding.OAEP( - mgf=padding.MGF1(algorithm=hashes.SHA256()), - algorithm=hashes.SHA256(), - label=None, - ), - ) - cipher = Cipher( - algorithms.AES(aes_key), - modes.CFB(iv), - ) - decryptor = cipher.decryptor() - plaintext = decryptor.update(ciphertext) + decryptor.finalize() - return plaintext.decode("utf-8") - - def encrypt_secret( - self, - encryption_cert_or_key_pem: str, - plaintext: str, - encryption_type: Optional[str] = None, - ) -> dict: - """ - Encrypts a plaintext string for securely sending to the Unstructured API. - - Args: - encryption_cert_or_key_pem (str): A PEM-encoded RSA public key or certificate. - plaintext (str): The string to encrypt. - type (str, optional): Encryption type, either "rsa" or "rsa_aes". - - Returns: - dict: A dictionary with encrypted AES key, iv, and ciphertext (all base64-encoded). - """ - # If a cert is provided, extract the public key - if "BEGIN CERTIFICATE" in encryption_cert_or_key_pem: - cert = x509.load_pem_x509_certificate( - encryption_cert_or_key_pem.encode("utf-8"), - ) - - public_key = cert.public_key() # type: ignore[assignment] - else: - public_key = serialization.load_pem_public_key( - encryption_cert_or_key_pem.encode("utf-8"), backend=default_backend() - ) # type: ignore[assignment] - - if not isinstance(public_key, rsa.RSAPublicKey): - raise TypeError("Public key must be a RSA public key for encryption.") - - # If the plaintext is short, use RSA directly - # Otherwise, use a RSA_AES envelope hybrid - # Use the length of the public key to determine the encryption type - key_size_bytes = public_key.key_size // 8 - max_rsa_length = key_size_bytes - 66 # OAEP SHA256 overhead - - if not encryption_type: - encryption_type = "rsa" if len(plaintext) <= max_rsa_length else "rsa_aes" - - if encryption_type == "rsa": - return self._encrypt_rsa(public_key, plaintext) - - return self._encrypt_rsa_aes(public_key, plaintext) - - # endregion sdk-class-body - - def get_encryption_certificate( - self, - *, - 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.GetEncryptionCertificateResponse: - r"""Retrieve the user's public key for encryption. - - 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 - :param server_url: Override the default server URL for this method - :param timeout_ms: Override the default request timeout configuration for this method in milliseconds - :param http_headers: Additional headers to set or replace on requests. - """ - base_url = None - url_variables = None - if timeout_ms is None: - timeout_ms = self.sdk_configuration.timeout_ms - - if server_url is not None: - base_url = server_url - else: - base_url = self._get_url(base_url, url_variables) - - if not isinstance(request, BaseModel): - request = utils.unmarshal( - request, operations.GetEncryptionCertificateRequest - ) - request = cast(operations.GetEncryptionCertificateRequest, request) - - req = self._build_request( - method="GET", - path="/api/v1/users/secrets/encryption-certificate", - base_url=base_url, - url_variables=url_variables, - request=request, - request_body_required=False, - request_has_path_params=False, - request_has_query_params=True, - user_agent_header="user-agent", - accept_header_value="application/json", - http_headers=http_headers, - security=self.sdk_configuration.security, - timeout_ms=timeout_ms, - ) - - if retries == UNSET: - if self.sdk_configuration.retry_config is not UNSET: - retries = self.sdk_configuration.retry_config - else: - retries = utils.RetryConfig( - "backoff", utils.BackoffStrategy(3000, 720000, 1.88, 1800000), True - ) - - retry_config = None - if isinstance(retries, utils.RetryConfig): - retry_config = (retries, ["5xx"]) - - http_res = self.do_request( - hook_ctx=HookContext( - config=self.sdk_configuration, - base_url=base_url or "", - operation_id="get_encryption_certificate", - oauth2_scopes=[], - security_source=self.sdk_configuration.security, - ), - request=req, - error_status_codes=["422", "4XX", "5XX"], - retry_config=retry_config, - ) - - response_data: Any = None - if utils.match_response(http_res, "200", "application/json"): - return operations.GetEncryptionCertificateResponse( - encryption_certificate_response=unmarshal_json_response( - Optional[shared.EncryptionCertificateResponse], http_res - ), - status_code=http_res.status_code, - content_type=http_res.headers.get("Content-Type") or "", - raw_response=http_res, - ) - if utils.match_response(http_res, "422", "application/json"): - response_data = unmarshal_json_response( - errors.HTTPValidationErrorData, http_res - ) - raise errors.HTTPValidationError(response_data, http_res) - if utils.match_response(http_res, "4XX", "*"): - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError("API error occurred", http_res, http_res_text) - if utils.match_response(http_res, "5XX", "*"): - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError("API error occurred", http_res, http_res_text) - - raise errors.SDKError("Unexpected response received", http_res) - - async def get_encryption_certificate_async( - self, - *, - 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.GetEncryptionCertificateResponse: - r"""Retrieve the user's public key for encryption. - - 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 - :param server_url: Override the default server URL for this method - :param timeout_ms: Override the default request timeout configuration for this method in milliseconds - :param http_headers: Additional headers to set or replace on requests. - """ - base_url = None - url_variables = None - if timeout_ms is None: - timeout_ms = self.sdk_configuration.timeout_ms - - if server_url is not None: - base_url = server_url - else: - base_url = self._get_url(base_url, url_variables) - - if not isinstance(request, BaseModel): - request = utils.unmarshal( - request, operations.GetEncryptionCertificateRequest - ) - request = cast(operations.GetEncryptionCertificateRequest, request) - - req = self._build_request_async( - method="GET", - path="/api/v1/users/secrets/encryption-certificate", - base_url=base_url, - url_variables=url_variables, - request=request, - request_body_required=False, - request_has_path_params=False, - request_has_query_params=True, - user_agent_header="user-agent", - accept_header_value="application/json", - http_headers=http_headers, - security=self.sdk_configuration.security, - timeout_ms=timeout_ms, - ) - - if retries == UNSET: - if self.sdk_configuration.retry_config is not UNSET: - retries = self.sdk_configuration.retry_config - else: - retries = utils.RetryConfig( - "backoff", utils.BackoffStrategy(3000, 720000, 1.88, 1800000), True - ) - - retry_config = None - if isinstance(retries, utils.RetryConfig): - retry_config = (retries, ["5xx"]) - - http_res = await self.do_request_async( - hook_ctx=HookContext( - config=self.sdk_configuration, - base_url=base_url or "", - operation_id="get_encryption_certificate", - oauth2_scopes=[], - security_source=self.sdk_configuration.security, - ), - request=req, - error_status_codes=["422", "4XX", "5XX"], - retry_config=retry_config, - ) - - response_data: Any = None - if utils.match_response(http_res, "200", "application/json"): - return operations.GetEncryptionCertificateResponse( - encryption_certificate_response=unmarshal_json_response( - Optional[shared.EncryptionCertificateResponse], http_res - ), - status_code=http_res.status_code, - content_type=http_res.headers.get("Content-Type") or "", - raw_response=http_res, - ) - if utils.match_response(http_res, "422", "application/json"): - response_data = unmarshal_json_response( - errors.HTTPValidationErrorData, http_res - ) - raise errors.HTTPValidationError(response_data, http_res) - if utils.match_response(http_res, "4XX", "*"): - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError("API error occurred", http_res, http_res_text) - if utils.match_response(http_res, "5XX", "*"): - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError("API error occurred", http_res, http_res_text) - - raise errors.SDKError("Unexpected response received", http_res) - - def store_secret( - self, - *, - request: Union[ - operations.StoreSecretRequest, operations.StoreSecretRequestTypedDict - ], - retries: OptionalNullable[utils.RetryConfig] = UNSET, - server_url: Optional[str] = None, - timeout_ms: Optional[int] = None, - http_headers: Optional[Mapping[str, str]] = None, - ) -> operations.StoreSecretResponse: - r"""Store an encrypted secret - - After encrypting a secret locally, store it and get back a reference id. - - :param request: The request object to send. - :param retries: Override the default retry configuration for this method - :param server_url: Override the default server URL for this method - :param timeout_ms: Override the default request timeout configuration for this method in milliseconds - :param http_headers: Additional headers to set or replace on requests. - """ - base_url = None - url_variables = None - if timeout_ms is None: - timeout_ms = self.sdk_configuration.timeout_ms - - if server_url is not None: - base_url = server_url - else: - base_url = self._get_url(base_url, url_variables) - - if not isinstance(request, BaseModel): - request = utils.unmarshal(request, operations.StoreSecretRequest) - request = cast(operations.StoreSecretRequest, request) - - req = self._build_request( - method="POST", - path="/api/v1/users/secrets", - base_url=base_url, - url_variables=url_variables, - request=request, - request_body_required=True, - request_has_path_params=False, - request_has_query_params=True, - user_agent_header="user-agent", - accept_header_value="application/json", - http_headers=http_headers, - security=self.sdk_configuration.security, - get_serialized_body=lambda: utils.serialize_request_body( - request.encrypted_secret, False, False, "json", shared.EncryptedSecret - ), - timeout_ms=timeout_ms, - ) - - if retries == UNSET: - if self.sdk_configuration.retry_config is not UNSET: - retries = self.sdk_configuration.retry_config - else: - retries = utils.RetryConfig( - "backoff", utils.BackoffStrategy(3000, 720000, 1.88, 1800000), True - ) - - retry_config = None - if isinstance(retries, utils.RetryConfig): - retry_config = (retries, ["5xx"]) - - http_res = self.do_request( - hook_ctx=HookContext( - config=self.sdk_configuration, - base_url=base_url or "", - operation_id="store_secret", - oauth2_scopes=[], - security_source=self.sdk_configuration.security, - ), - request=req, - error_status_codes=["422", "4XX", "5XX"], - retry_config=retry_config, - ) - - response_data: Any = None - if utils.match_response(http_res, "200", "application/json"): - return operations.StoreSecretResponse( - secret_reference=unmarshal_json_response( - Optional[shared.SecretReference], http_res - ), - status_code=http_res.status_code, - content_type=http_res.headers.get("Content-Type") or "", - raw_response=http_res, - ) - if utils.match_response(http_res, "422", "application/json"): - response_data = unmarshal_json_response( - errors.HTTPValidationErrorData, http_res - ) - raise errors.HTTPValidationError(response_data, http_res) - if utils.match_response(http_res, "4XX", "*"): - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError("API error occurred", http_res, http_res_text) - if utils.match_response(http_res, "5XX", "*"): - http_res_text = utils.stream_to_text(http_res) - raise errors.SDKError("API error occurred", http_res, http_res_text) - - raise errors.SDKError("Unexpected response received", http_res) - - async def store_secret_async( - self, - *, - request: Union[ - operations.StoreSecretRequest, operations.StoreSecretRequestTypedDict - ], - retries: OptionalNullable[utils.RetryConfig] = UNSET, - server_url: Optional[str] = None, - timeout_ms: Optional[int] = None, - http_headers: Optional[Mapping[str, str]] = None, - ) -> operations.StoreSecretResponse: - r"""Store an encrypted secret - - After encrypting a secret locally, store it and get back a reference id. - - :param request: The request object to send. - :param retries: Override the default retry configuration for this method - :param server_url: Override the default server URL for this method - :param timeout_ms: Override the default request timeout configuration for this method in milliseconds - :param http_headers: Additional headers to set or replace on requests. - """ - base_url = None - url_variables = None - if timeout_ms is None: - timeout_ms = self.sdk_configuration.timeout_ms - - if server_url is not None: - base_url = server_url - else: - base_url = self._get_url(base_url, url_variables) - - if not isinstance(request, BaseModel): - request = utils.unmarshal(request, operations.StoreSecretRequest) - request = cast(operations.StoreSecretRequest, request) - - req = self._build_request_async( - method="POST", - path="/api/v1/users/secrets", - base_url=base_url, - url_variables=url_variables, - request=request, - request_body_required=True, - request_has_path_params=False, - request_has_query_params=True, - user_agent_header="user-agent", - accept_header_value="application/json", - http_headers=http_headers, - security=self.sdk_configuration.security, - get_serialized_body=lambda: utils.serialize_request_body( - request.encrypted_secret, False, False, "json", shared.EncryptedSecret - ), - timeout_ms=timeout_ms, - ) - - if retries == UNSET: - if self.sdk_configuration.retry_config is not UNSET: - retries = self.sdk_configuration.retry_config - else: - retries = utils.RetryConfig( - "backoff", utils.BackoffStrategy(3000, 720000, 1.88, 1800000), True - ) - - retry_config = None - if isinstance(retries, utils.RetryConfig): - retry_config = (retries, ["5xx"]) - - 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=[], - security_source=self.sdk_configuration.security, - ), - request=req, - error_status_codes=["422", "4XX", "5XX"], - retry_config=retry_config, - ) - - response_data: Any = None - if utils.match_response(http_res, "200", "application/json"): - return operations.StoreSecretResponse( - secret_reference=unmarshal_json_response( - Optional[shared.SecretReference], http_res - ), - status_code=http_res.status_code, - content_type=http_res.headers.get("Content-Type") or "", - raw_response=http_res, - ) - if utils.match_response(http_res, "422", "application/json"): - response_data = unmarshal_json_response( - errors.HTTPValidationErrorData, http_res - ) - raise errors.HTTPValidationError(response_data, http_res) - if utils.match_response(http_res, "4XX", "*"): - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError("API error occurred", http_res, http_res_text) - if utils.match_response(http_res, "5XX", "*"): - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.SDKError("API error occurred", http_res, http_res_text) - - raise errors.SDKError("Unexpected response received", http_res) +# """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +# from .basesdk import BaseSDK +# from typing import Any, Mapping, Optional, Union, cast +# from unstructured_client import utils +# from unstructured_client._hooks import HookContext +# from unstructured_client.models import errors, operations, shared +# from unstructured_client.types import BaseModel, OptionalNullable, UNSET +# from unstructured_client.utils.unmarshal_json_response import unmarshal_json_response + +# # region imports +# from cryptography import x509 +# from cryptography.hazmat.primitives import serialization, hashes +# from cryptography.hazmat.primitives.asymmetric import padding, rsa +# from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes +# from cryptography.hazmat.backends import default_backend +# import os +# import base64 +# # endregion imports + + +# class Users(BaseSDK): +# # region sdk-class-body +# def _encrypt_rsa_aes( +# self, +# public_key: rsa.RSAPublicKey, +# plaintext: str, +# ) -> dict: +# # Generate a random AES key +# aes_key = os.urandom(32) # 256-bit AES key + +# # Generate a random IV +# iv = os.urandom(16) + +# # Encrypt using AES-CFB +# cipher = Cipher( +# algorithms.AES(aes_key), +# modes.CFB(iv), +# ) +# encryptor = cipher.encryptor() +# ciphertext = encryptor.update(plaintext.encode("utf-8")) + encryptor.finalize() + +# # Encrypt the AES key using the RSA public key +# encrypted_key = public_key.encrypt( +# aes_key, +# padding.OAEP( +# mgf=padding.MGF1(algorithm=hashes.SHA256()), +# algorithm=hashes.SHA256(), +# label=None, +# ), +# ) + +# return { +# "encrypted_aes_key": base64.b64encode(encrypted_key).decode("utf-8"), +# "aes_iv": base64.b64encode(iv).decode("utf-8"), +# "encrypted_value": base64.b64encode(ciphertext).decode("utf-8"), +# "type": "rsa_aes", +# } + +# def _encrypt_rsa( +# self, +# public_key: rsa.RSAPublicKey, +# plaintext: str, +# ) -> dict: +# # Load public RSA key +# ciphertext = public_key.encrypt( +# plaintext.encode(), +# padding.OAEP( +# mgf=padding.MGF1(algorithm=hashes.SHA256()), +# algorithm=hashes.SHA256(), +# label=None, +# ), +# ) +# return { +# "encrypted_value": base64.b64encode(ciphertext).decode("utf-8"), +# "type": "rsa", +# "encrypted_aes_key": "", +# "aes_iv": "", +# } + +# def decrypt_secret( +# self, +# private_key_pem: str, +# encrypted_value: str, +# secret_type: str, +# encrypted_aes_key: str, +# aes_iv: str, +# ) -> str: +# private_key = serialization.load_pem_private_key( +# private_key_pem.encode("utf-8"), password=None, backend=default_backend() +# ) + +# if not isinstance(private_key, rsa.RSAPrivateKey): +# raise TypeError("Private key must be a RSA private key for decryption.") + +# if secret_type == "rsa": +# ciphertext = base64.b64decode(encrypted_value) +# plaintext = private_key.decrypt( +# ciphertext, +# padding.OAEP( +# mgf=padding.MGF1(algorithm=hashes.SHA256()), +# algorithm=hashes.SHA256(), +# label=None, +# ), +# ) +# return plaintext.decode("utf-8") + +# # aes_rsa +# encrypted_aes_key_decoded = base64.b64decode(encrypted_aes_key) +# iv = base64.b64decode(aes_iv) +# ciphertext = base64.b64decode(encrypted_value) + +# aes_key = private_key.decrypt( +# encrypted_aes_key_decoded, +# padding.OAEP( +# mgf=padding.MGF1(algorithm=hashes.SHA256()), +# algorithm=hashes.SHA256(), +# label=None, +# ), +# ) +# cipher = Cipher( +# algorithms.AES(aes_key), +# modes.CFB(iv), +# ) +# decryptor = cipher.decryptor() +# plaintext = decryptor.update(ciphertext) + decryptor.finalize() +# return plaintext.decode("utf-8") + +# def encrypt_secret( +# self, +# encryption_cert_or_key_pem: str, +# plaintext: str, +# encryption_type: Optional[str] = None, +# ) -> dict: +# """ +# Encrypts a plaintext string for securely sending to the Unstructured API. + +# Args: +# encryption_cert_or_key_pem (str): A PEM-encoded RSA public key or certificate. +# plaintext (str): The string to encrypt. +# type (str, optional): Encryption type, either "rsa" or "rsa_aes". + +# Returns: +# dict: A dictionary with encrypted AES key, iv, and ciphertext (all base64-encoded). +# """ +# # If a cert is provided, extract the public key +# if "BEGIN CERTIFICATE" in encryption_cert_or_key_pem: +# cert = x509.load_pem_x509_certificate( +# encryption_cert_or_key_pem.encode("utf-8"), +# ) + +# public_key = cert.public_key() # type: ignore[assignment] +# else: +# public_key = serialization.load_pem_public_key( +# encryption_cert_or_key_pem.encode("utf-8"), backend=default_backend() +# ) # type: ignore[assignment] + +# if not isinstance(public_key, rsa.RSAPublicKey): +# raise TypeError("Public key must be a RSA public key for encryption.") + +# # If the plaintext is short, use RSA directly +# # Otherwise, use a RSA_AES envelope hybrid +# # Use the length of the public key to determine the encryption type +# key_size_bytes = public_key.key_size // 8 +# max_rsa_length = key_size_bytes - 66 # OAEP SHA256 overhead + +# if not encryption_type: +# encryption_type = "rsa" if len(plaintext) <= max_rsa_length else "rsa_aes" + +# if encryption_type == "rsa": +# return self._encrypt_rsa(public_key, plaintext) + +# return self._encrypt_rsa_aes(public_key, plaintext) + +# # endregion sdk-class-body + +# def get_encryption_certificate( +# self, +# *, +# 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.GetEncryptionCertificateResponse: +# r"""Retrieve the user's public key for encryption. + +# 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 +# :param server_url: Override the default server URL for this method +# :param timeout_ms: Override the default request timeout configuration for this method in milliseconds +# :param http_headers: Additional headers to set or replace on requests. +# """ +# base_url = None +# url_variables = None +# if timeout_ms is None: +# timeout_ms = self.sdk_configuration.timeout_ms + +# if server_url is not None: +# base_url = server_url +# else: +# base_url = self._get_url(base_url, url_variables) + +# if not isinstance(request, BaseModel): +# request = utils.unmarshal( +# request, operations.GetEncryptionCertificateRequest +# ) +# request = cast(operations.GetEncryptionCertificateRequest, request) + +# req = self._build_request( +# method="GET", +# path="/api/v1/users/secrets/encryption-certificate", +# base_url=base_url, +# url_variables=url_variables, +# request=request, +# request_body_required=False, +# request_has_path_params=False, +# request_has_query_params=True, +# user_agent_header="user-agent", +# accept_header_value="application/json", +# http_headers=http_headers, +# security=self.sdk_configuration.security, +# timeout_ms=timeout_ms, +# ) + +# if retries == UNSET: +# if self.sdk_configuration.retry_config is not UNSET: +# retries = self.sdk_configuration.retry_config +# else: +# retries = utils.RetryConfig( +# "backoff", utils.BackoffStrategy(3000, 720000, 1.88, 1800000), True +# ) + +# retry_config = None +# if isinstance(retries, utils.RetryConfig): +# retry_config = (retries, ["5xx"]) + +# http_res = self.do_request( +# hook_ctx=HookContext( +# config=self.sdk_configuration, +# base_url=base_url or "", +# operation_id="get_encryption_certificate", +# oauth2_scopes=[], +# security_source=self.sdk_configuration.security, +# ), +# request=req, +# error_status_codes=["422", "4XX", "5XX"], +# retry_config=retry_config, +# ) + +# response_data: Any = None +# if utils.match_response(http_res, "200", "application/json"): +# return operations.GetEncryptionCertificateResponse( +# encryption_certificate_response=unmarshal_json_response( +# Optional[shared.EncryptionCertificateResponse], http_res +# ), +# status_code=http_res.status_code, +# content_type=http_res.headers.get("Content-Type") or "", +# raw_response=http_res, +# ) +# if utils.match_response(http_res, "422", "application/json"): +# response_data = unmarshal_json_response( +# errors.HTTPValidationErrorData, http_res +# ) +# raise errors.HTTPValidationError(response_data, http_res) +# if utils.match_response(http_res, "4XX", "*"): +# http_res_text = utils.stream_to_text(http_res) +# raise errors.SDKError("API error occurred", http_res, http_res_text) +# if utils.match_response(http_res, "5XX", "*"): +# http_res_text = utils.stream_to_text(http_res) +# raise errors.SDKError("API error occurred", http_res, http_res_text) + +# raise errors.SDKError("Unexpected response received", http_res) + +# async def get_encryption_certificate_async( +# self, +# *, +# 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.GetEncryptionCertificateResponse: +# r"""Retrieve the user's public key for encryption. + +# 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 +# :param server_url: Override the default server URL for this method +# :param timeout_ms: Override the default request timeout configuration for this method in milliseconds +# :param http_headers: Additional headers to set or replace on requests. +# """ +# base_url = None +# url_variables = None +# if timeout_ms is None: +# timeout_ms = self.sdk_configuration.timeout_ms + +# if server_url is not None: +# base_url = server_url +# else: +# base_url = self._get_url(base_url, url_variables) + +# if not isinstance(request, BaseModel): +# request = utils.unmarshal( +# request, operations.GetEncryptionCertificateRequest +# ) +# request = cast(operations.GetEncryptionCertificateRequest, request) + +# req = self._build_request_async( +# method="GET", +# path="/api/v1/users/secrets/encryption-certificate", +# base_url=base_url, +# url_variables=url_variables, +# request=request, +# request_body_required=False, +# request_has_path_params=False, +# request_has_query_params=True, +# user_agent_header="user-agent", +# accept_header_value="application/json", +# http_headers=http_headers, +# security=self.sdk_configuration.security, +# timeout_ms=timeout_ms, +# ) + +# if retries == UNSET: +# if self.sdk_configuration.retry_config is not UNSET: +# retries = self.sdk_configuration.retry_config +# else: +# retries = utils.RetryConfig( +# "backoff", utils.BackoffStrategy(3000, 720000, 1.88, 1800000), True +# ) + +# retry_config = None +# if isinstance(retries, utils.RetryConfig): +# retry_config = (retries, ["5xx"]) + +# http_res = await self.do_request_async( +# hook_ctx=HookContext( +# config=self.sdk_configuration, +# base_url=base_url or "", +# operation_id="get_encryption_certificate", +# oauth2_scopes=[], +# security_source=self.sdk_configuration.security, +# ), +# request=req, +# error_status_codes=["422", "4XX", "5XX"], +# retry_config=retry_config, +# ) + +# response_data: Any = None +# if utils.match_response(http_res, "200", "application/json"): +# return operations.GetEncryptionCertificateResponse( +# encryption_certificate_response=unmarshal_json_response( +# Optional[shared.EncryptionCertificateResponse], http_res +# ), +# status_code=http_res.status_code, +# content_type=http_res.headers.get("Content-Type") or "", +# raw_response=http_res, +# ) +# if utils.match_response(http_res, "422", "application/json"): +# response_data = unmarshal_json_response( +# errors.HTTPValidationErrorData, http_res +# ) +# raise errors.HTTPValidationError(response_data, http_res) +# if utils.match_response(http_res, "4XX", "*"): +# http_res_text = await utils.stream_to_text_async(http_res) +# raise errors.SDKError("API error occurred", http_res, http_res_text) +# if utils.match_response(http_res, "5XX", "*"): +# http_res_text = await utils.stream_to_text_async(http_res) +# raise errors.SDKError("API error occurred", http_res, http_res_text) + +# raise errors.SDKError("Unexpected response received", http_res) + +# def store_secret( +# self, +# *, +# request: Union[ +# operations.StoreSecretRequest, operations.StoreSecretRequestTypedDict +# ], +# retries: OptionalNullable[utils.RetryConfig] = UNSET, +# server_url: Optional[str] = None, +# timeout_ms: Optional[int] = None, +# http_headers: Optional[Mapping[str, str]] = None, +# ) -> operations.StoreSecretResponse: +# r"""Store an encrypted secret + +# After encrypting a secret locally, store it and get back a reference id. + +# :param request: The request object to send. +# :param retries: Override the default retry configuration for this method +# :param server_url: Override the default server URL for this method +# :param timeout_ms: Override the default request timeout configuration for this method in milliseconds +# :param http_headers: Additional headers to set or replace on requests. +# """ +# base_url = None +# url_variables = None +# if timeout_ms is None: +# timeout_ms = self.sdk_configuration.timeout_ms + +# if server_url is not None: +# base_url = server_url +# else: +# base_url = self._get_url(base_url, url_variables) + +# if not isinstance(request, BaseModel): +# request = utils.unmarshal(request, operations.StoreSecretRequest) +# request = cast(operations.StoreSecretRequest, request) + +# req = self._build_request( +# method="POST", +# path="/api/v1/users/secrets", +# base_url=base_url, +# url_variables=url_variables, +# request=request, +# request_body_required=True, +# request_has_path_params=False, +# request_has_query_params=True, +# user_agent_header="user-agent", +# accept_header_value="application/json", +# http_headers=http_headers, +# security=self.sdk_configuration.security, +# get_serialized_body=lambda: utils.serialize_request_body( +# request.encrypted_secret, False, False, "json", shared.EncryptedSecret +# ), +# timeout_ms=timeout_ms, +# ) + +# if retries == UNSET: +# if self.sdk_configuration.retry_config is not UNSET: +# retries = self.sdk_configuration.retry_config +# else: +# retries = utils.RetryConfig( +# "backoff", utils.BackoffStrategy(3000, 720000, 1.88, 1800000), True +# ) + +# retry_config = None +# if isinstance(retries, utils.RetryConfig): +# retry_config = (retries, ["5xx"]) + +# http_res = self.do_request( +# hook_ctx=HookContext( +# config=self.sdk_configuration, +# base_url=base_url or "", +# operation_id="store_secret", +# oauth2_scopes=[], +# security_source=self.sdk_configuration.security, +# ), +# request=req, +# error_status_codes=["422", "4XX", "5XX"], +# retry_config=retry_config, +# ) + +# response_data: Any = None +# if utils.match_response(http_res, "200", "application/json"): +# return operations.StoreSecretResponse( +# secret_reference=unmarshal_json_response( +# Optional[shared.SecretReference], http_res +# ), +# status_code=http_res.status_code, +# content_type=http_res.headers.get("Content-Type") or "", +# raw_response=http_res, +# ) +# if utils.match_response(http_res, "422", "application/json"): +# response_data = unmarshal_json_response( +# errors.HTTPValidationErrorData, http_res +# ) +# raise errors.HTTPValidationError(response_data, http_res) +# if utils.match_response(http_res, "4XX", "*"): +# http_res_text = utils.stream_to_text(http_res) +# raise errors.SDKError("API error occurred", http_res, http_res_text) +# if utils.match_response(http_res, "5XX", "*"): +# http_res_text = utils.stream_to_text(http_res) +# raise errors.SDKError("API error occurred", http_res, http_res_text) + +# raise errors.SDKError("Unexpected response received", http_res) + +# async def store_secret_async( +# self, +# *, +# request: Union[ +# operations.StoreSecretRequest, operations.StoreSecretRequestTypedDict +# ], +# retries: OptionalNullable[utils.RetryConfig] = UNSET, +# server_url: Optional[str] = None, +# timeout_ms: Optional[int] = None, +# http_headers: Optional[Mapping[str, str]] = None, +# ) -> operations.StoreSecretResponse: +# r"""Store an encrypted secret + +# After encrypting a secret locally, store it and get back a reference id. + +# :param request: The request object to send. +# :param retries: Override the default retry configuration for this method +# :param server_url: Override the default server URL for this method +# :param timeout_ms: Override the default request timeout configuration for this method in milliseconds +# :param http_headers: Additional headers to set or replace on requests. +# """ +# base_url = None +# url_variables = None +# if timeout_ms is None: +# timeout_ms = self.sdk_configuration.timeout_ms + +# if server_url is not None: +# base_url = server_url +# else: +# base_url = self._get_url(base_url, url_variables) + +# if not isinstance(request, BaseModel): +# request = utils.unmarshal(request, operations.StoreSecretRequest) +# request = cast(operations.StoreSecretRequest, request) + +# req = self._build_request_async( +# method="POST", +# path="/api/v1/users/secrets", +# base_url=base_url, +# url_variables=url_variables, +# request=request, +# request_body_required=True, +# request_has_path_params=False, +# request_has_query_params=True, +# user_agent_header="user-agent", +# accept_header_value="application/json", +# http_headers=http_headers, +# security=self.sdk_configuration.security, +# get_serialized_body=lambda: utils.serialize_request_body( +# request.encrypted_secret, False, False, "json", shared.EncryptedSecret +# ), +# timeout_ms=timeout_ms, +# ) + +# if retries == UNSET: +# if self.sdk_configuration.retry_config is not UNSET: +# retries = self.sdk_configuration.retry_config +# else: +# retries = utils.RetryConfig( +# "backoff", utils.BackoffStrategy(3000, 720000, 1.88, 1800000), True +# ) + +# retry_config = None +# if isinstance(retries, utils.RetryConfig): +# retry_config = (retries, ["5xx"]) + +# 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=[], +# security_source=self.sdk_configuration.security, +# ), +# request=req, +# error_status_codes=["422", "4XX", "5XX"], +# retry_config=retry_config, +# ) + +# response_data: Any = None +# if utils.match_response(http_res, "200", "application/json"): +# return operations.StoreSecretResponse( +# secret_reference=unmarshal_json_response( +# Optional[shared.SecretReference], http_res +# ), +# status_code=http_res.status_code, +# content_type=http_res.headers.get("Content-Type") or "", +# raw_response=http_res, +# ) +# if utils.match_response(http_res, "422", "application/json"): +# response_data = unmarshal_json_response( +# errors.HTTPValidationErrorData, http_res +# ) +# raise errors.HTTPValidationError(response_data, http_res) +# if utils.match_response(http_res, "4XX", "*"): +# http_res_text = await utils.stream_to_text_async(http_res) +# raise errors.SDKError("API error occurred", http_res, http_res_text) +# if utils.match_response(http_res, "5XX", "*"): +# http_res_text = await utils.stream_to_text_async(http_res) +# raise errors.SDKError("API error occurred", http_res, http_res_text) + +# raise errors.SDKError("Unexpected response received", http_res)