diff --git a/sdks/python/.gitignore b/sdks/python/.gitignore index b65ccd6fb..042ba0111 100644 --- a/sdks/python/.gitignore +++ b/sdks/python/.gitignore @@ -62,7 +62,7 @@ docs/_build/ # PyBuilder target/ -#Ipython Notebook +# Ipython Notebook .ipynb_checkpoints .openapi-generator diff --git a/sdks/python/.gitlab-ci.yml b/sdks/python/.gitlab-ci.yml index ccd6d9bd1..48c983172 100644 --- a/sdks/python/.gitlab-ci.yml +++ b/sdks/python/.gitlab-ci.yml @@ -14,12 +14,6 @@ stages: - pip install -r test-requirements.txt - pytest --cov=dropbox_sign -pytest-3.8: - extends: .pytest - image: python:3.8-alpine -pytest-3.9: - extends: .pytest - image: python:3.9-alpine pytest-3.10: extends: .pytest image: python:3.10-alpine @@ -29,3 +23,9 @@ pytest-3.11: pytest-3.12: extends: .pytest image: python:3.12-alpine +pytest-3.13: + extends: .pytest + image: python:3.13-alpine +pytest-3.14: + extends: .pytest + image: python:3.14-alpine diff --git a/sdks/python/.travis.yml b/sdks/python/.travis.yml index 757c4eee0..63474bd86 100644 --- a/sdks/python/.travis.yml +++ b/sdks/python/.travis.yml @@ -1,13 +1,13 @@ # ref: https://docs.travis-ci.com/user/languages/python language: python python: - - "3.8" - - "3.9" - "3.10" - "3.11" - "3.12" + - "3.13" + - "3.14" # uncomment the following if needed - #- "3.12-dev" # 3.12 development branch + #- "3.14-dev" # 3.14 development branch #- "nightly" # nightly build # command to install dependencies install: diff --git a/sdks/python/README.md b/sdks/python/README.md index 820c67eb6..734fb60d9 100644 --- a/sdks/python/README.md +++ b/sdks/python/README.md @@ -1,6 +1,19 @@ # dropbox-sign Dropbox Sign v3 API +## Upgrading to 2.0.0 + +Version 2.0.0 is generated with OpenAPI Generator 7.26.0. Existing code keeps working, with these changes: + +- **Python 3.10 or later is required.** Python 3.8 and 3.9 are no longer supported; pip keeps installing 1.x on those versions. +- **Dependencies:** `urllib3 >= 2.8.0` and `pydantic >= 2.11`. +- **Proxy settings are now detected automatically.** When `Configuration.proxy` is not set, the SDK uses the proxy configured in the environment (`HTTPS_PROXY`, `HTTP_PROXY`, `ALL_PROXY`) and, on macOS and Windows, the system proxy settings. Previously, a proxy was only used when set explicitly. + - To bypass the proxy for the Dropbox Sign API, set `NO_PROXY=hellosign.com` or `configuration.no_proxy = "hellosign.com"`. This covers both `api.hellosign.com` and `app.hellosign.com` (used by the OAuth endpoints). + - To ignore all proxy settings, set `configuration.proxy = None` after creating the `Configuration` and before creating the `ApiClient`. Passing `proxy=None` to the constructor does not disable detection. + - SOCKS proxies (for example `ALL_PROXY=socks5://...`) require `pip install "urllib3[socks]"`. + - Known limitations: the proxy decision is made once per `ApiClient` for the configured host, and macOS/Windows proxy exclusion lists and PAC files are not applied. If you rely on them, set `NO_PROXY` or `configuration.no_proxy` explicitly. +- **Behaviour changes:** `to_json()` now serializes datetimes, `to_dict()` keeps `None` items in lists, boolean query parameters are sent as `true` / `false`, and the `ApiException` message lists the response body and data separately. + ## Migrating from legacy SDK This SDK is generated from our officially maintained [OpenAPI spec](https://github.com/hellosign/hellosign-openapi/blob/main/openapi.yaml). @@ -42,7 +55,7 @@ this command. ### Requirements. -Python 3.8+ +Python 3.10+ ### pip @@ -406,4 +419,3 @@ This Python package is automatically generated by the [OpenAPI Generator](https: - API version: 3.0.0 - Package version: 1.11-dev - Build package: org.openapitools.codegen.languages.PythonClientCodegen - diff --git a/sdks/python/docs/ApiAppCreateRequest.md b/sdks/python/docs/ApiAppCreateRequest.md index 206b7539a..16f074e6e 100644 --- a/sdks/python/docs/ApiAppCreateRequest.md +++ b/sdks/python/docs/ApiAppCreateRequest.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes | `domains`*_required_ | ```List[str]``` | The domain names the ApiApp will be associated with. | | | `name`*_required_ | ```str``` | The name you want to assign to the ApiApp. | | | `callback_url` | ```str``` | The URL at which the ApiApp should receive event callbacks. | | -| `custom_logo_file` | ```io.IOBase``` | An image file to use as a custom logo in embedded contexts. (Only applies to some API plans) | | +| `custom_logo_file` | ```bytes``` | An image file to use as a custom logo in embedded contexts. (Only applies to some API plans) | | | `oauth` | [```SubOAuth```](SubOAuth.md) | | | | `options` | [```SubOptions```](SubOptions.md) | | | | `white_labeling_options` | [```SubWhiteLabelingOptions```](SubWhiteLabelingOptions.md) | | | diff --git a/sdks/python/docs/ApiAppUpdateRequest.md b/sdks/python/docs/ApiAppUpdateRequest.md index 58a3f8a18..7fc05a293 100644 --- a/sdks/python/docs/ApiAppUpdateRequest.md +++ b/sdks/python/docs/ApiAppUpdateRequest.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- | `callback_url` | ```str``` | The URL at which the API App should receive event callbacks. | | -| `custom_logo_file` | ```io.IOBase``` | An image file to use as a custom logo in embedded contexts. (Only applies to some API plans) | | +| `custom_logo_file` | ```bytes``` | An image file to use as a custom logo in embedded contexts. (Only applies to some API plans) | | | `domains` | ```List[str]``` | The domain names the ApiApp will be associated with. | | | `name` | ```str``` | The name you want to assign to the ApiApp. | | | `oauth` | [```SubOAuth```](SubOAuth.md) | | | diff --git a/sdks/python/docs/DocumentFieldDetectionRequest.md b/sdks/python/docs/DocumentFieldDetectionRequest.md index 8476b7ddd..b5976c280 100644 --- a/sdks/python/docs/DocumentFieldDetectionRequest.md +++ b/sdks/python/docs/DocumentFieldDetectionRequest.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- | `detection_mode`*_required_ | ```str``` | The field detection method to use. Set to `annotations` to detect PDF form annotations or `text_tags` to detect Dropbox Sign text tags. | | -| `file` | ```io.IOBase``` | The PDF file to analyze.

This endpoint requires either `file` or `file_url`, but not both. | | +| `file` | ```bytes``` | The PDF file to analyze.

This endpoint requires either `file` or `file_url`, but not both. | | | `file_url` | ```str``` | The URL of the PDF file to analyze.

This endpoint requires either `file` or `file_url`, but not both. | | | `page_range` | ```str``` | The zero-based page indexes to analyze. Accepts `all`, individual pages, inclusive ranges, or comma-separated combinations, such as `0-2,5,7-9`. Defaults to `all`. | | diff --git a/sdks/python/docs/FaxApi.md b/sdks/python/docs/FaxApi.md index 431d0ca9f..7a1c06676 100644 --- a/sdks/python/docs/FaxApi.md +++ b/sdks/python/docs/FaxApi.md @@ -72,7 +72,7 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # ```fax_files``` -> ```io.IOBase fax_files(fax_id)``` +> ```bytes fax_files(fax_id)``` Download Fax Files @@ -113,7 +113,7 @@ with ApiClient(configuration) as api_client: ### Return type -**io.IOBase** +**bytes** ### Authorization diff --git a/sdks/python/docs/FaxSendRequest.md b/sdks/python/docs/FaxSendRequest.md index 5f19b7374..ec1855384 100644 --- a/sdks/python/docs/FaxSendRequest.md +++ b/sdks/python/docs/FaxSendRequest.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- | `recipient`*_required_ | ```str``` | Recipient of the fax Can be a phone number in E.164 format or email address | | | `sender` | ```str``` | Fax Send From Sender (used only with fax number) | | -| `files` | ```List[io.IOBase]``` | Use `files[]` to indicate the uploaded file(s) to fax

This endpoint requires either **files** or **file_urls[]**, but not both. | | +| `files` | ```List[bytes]``` | Use `files[]` to indicate the uploaded file(s) to fax

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `file_urls` | ```List[str]``` | Use `file_urls[]` to have Dropbox Fax download the file(s) to fax

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `test_mode` | ```bool``` | API Test Mode Setting | [default to False] | | `cover_page_to` | ```str``` | Fax cover page recipient information | | diff --git a/sdks/python/docs/SignatureRequestApi.md b/sdks/python/docs/SignatureRequestApi.md index 79db31de2..307389d51 100644 --- a/sdks/python/docs/SignatureRequestApi.md +++ b/sdks/python/docs/SignatureRequestApi.md @@ -1078,7 +1078,7 @@ with ApiClient(configuration) as api_client: [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # ```signature_request_files``` -> ```io.IOBase signature_request_files(signature_request_id)``` +> ```bytes signature_request_files(signature_request_id)``` Download Files @@ -1124,11 +1124,11 @@ with ApiClient(configuration) as api_client: | Name | Type | Description | Notes | | ---- | ---- | ----------- | ----- | | `signature_request_id` | **str** | The id of the SignatureRequest to retrieve. | | -| `file_type` | **str** | Set to `pdf` for a single merged document or `zip` for a collection of individual documents. | [optional][default to pdf] | +| `file_type` | **str** | Set to `pdf` for a single merged document or `zip` for a collection of individual documents. | [optional][default to 'pdf'] | ### Return type -**io.IOBase** +**bytes** ### Authorization diff --git a/sdks/python/docs/SignatureRequestBulkCreateEmbeddedWithTemplateRequest.md b/sdks/python/docs/SignatureRequestBulkCreateEmbeddedWithTemplateRequest.md index 21530206a..2c65a33af 100644 --- a/sdks/python/docs/SignatureRequestBulkCreateEmbeddedWithTemplateRequest.md +++ b/sdks/python/docs/SignatureRequestBulkCreateEmbeddedWithTemplateRequest.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- | `template_ids`*_required_ | ```List[str]``` | Use `template_ids` to create a SignatureRequest from one or more templates, in the order in which the template will be used. | | | `client_id`*_required_ | ```str``` | Client id of the app you're using to create this embedded signature request. Used for security purposes. | | -| `signer_file` | ```io.IOBase``` | `signer_file` is a CSV file defining values and options for signer fields. Required unless a `signer_list` is used, you may not use both. The CSV can have the following columns:

- `name`: the name of the signer filling the role of RoleName - `email_address`: email address of the signer filling the role of RoleName - `pin`: the 4- to 12-character access code that will secure this signer's signature page (optional) - `sms_phone_number`: An E.164 formatted phone number that will receive a code via SMS to access this signer's signature page. (optional)

By using the feature, you agree you are responsible for obtaining a signer's consent to receive text messages from Dropbox Sign related to this signature request and confirm you have obtained such consent from all signers prior to enabling SMS delivery for this signature request. [Learn more](https://faq.hellosign.com/hc/en-us/articles/15815316468877-Dropbox-Sign-SMS-tools-add-on).

**NOTE:** Not available in test mode and requires a Standard plan or higher. - `*_field`: any column with a _field" suffix will be treated as a custom field (optional)

You may only specify field values here, any other options should be set in the custom_fields request parameter.

Example CSV:

``` name, email_address, pin, company_field George, george@example.com, d79a3td, ABC Corp Mary, mary@example.com, gd9as5b, 123 LLC ``` | | +| `signer_file` | ```bytes``` | `signer_file` is a CSV file defining values and options for signer fields. Required unless a `signer_list` is used, you may not use both. The CSV can have the following columns:

- `name`: the name of the signer filling the role of RoleName - `email_address`: email address of the signer filling the role of RoleName - `pin`: the 4- to 12-character access code that will secure this signer's signature page (optional) - `sms_phone_number`: An E.164 formatted phone number that will receive a code via SMS to access this signer's signature page. (optional)

By using the feature, you agree you are responsible for obtaining a signer's consent to receive text messages from Dropbox Sign related to this signature request and confirm you have obtained such consent from all signers prior to enabling SMS delivery for this signature request. [Learn more](https://faq.hellosign.com/hc/en-us/articles/15815316468877-Dropbox-Sign-SMS-tools-add-on).

**NOTE:** Not available in test mode and requires a Standard plan or higher. - `*_field`: any column with a _field" suffix will be treated as a custom field (optional)

You may only specify field values here, any other options should be set in the custom_fields request parameter.

Example CSV:

``` name, email_address, pin, company_field George, george@example.com, d79a3td, ABC Corp Mary, mary@example.com, gd9as5b, 123 LLC ``` | | | `signer_list` | [```List[SubBulkSignerList]```](SubBulkSignerList.md) | `signer_list` is an array defining values and options for signer fields. Required unless a `signer_file` is used, you may not use both. | | | `allow_decline` | ```bool``` | Allows signers to decline to sign a document if `true`. Defaults to `false`. | [default to False] | | `ccs` | [```List[SubCC]```](SubCC.md) | Add CC email recipients. Required when a CC role exists for the Template. | | diff --git a/sdks/python/docs/SignatureRequestBulkSendWithTemplateRequest.md b/sdks/python/docs/SignatureRequestBulkSendWithTemplateRequest.md index f400bd969..1c32b202b 100644 --- a/sdks/python/docs/SignatureRequestBulkSendWithTemplateRequest.md +++ b/sdks/python/docs/SignatureRequestBulkSendWithTemplateRequest.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- | `template_ids`*_required_ | ```List[str]``` | Use `template_ids` to create a SignatureRequest from one or more templates, in the order in which the template will be used. | | -| `signer_file` | ```io.IOBase``` | `signer_file` is a CSV file defining values and options for signer fields. Required unless a `signer_list` is used, you may not use both. The CSV can have the following columns:

- `name`: the name of the signer filling the role of RoleName - `email_address`: email address of the signer filling the role of RoleName - `pin`: the 4- to 12-character access code that will secure this signer's signature page (optional) - `sms_phone_number`: An E.164 formatted phone number that will receive a code via SMS to access this signer's signature page. (optional)

By using the feature, you agree you are responsible for obtaining a signer's consent to receive text messages from Dropbox Sign related to this signature request and confirm you have obtained such consent from all signers prior to enabling SMS delivery for this signature request. [Learn more](https://faq.hellosign.com/hc/en-us/articles/15815316468877-Dropbox-Sign-SMS-tools-add-on).

**NOTE:** Not available in test mode and requires a Standard plan or higher. - `*_field`: any column with a _field" suffix will be treated as a custom field (optional)

You may only specify field values here, any other options should be set in the custom_fields request parameter.

Example CSV:

``` name, email_address, pin, company_field George, george@example.com, d79a3td, ABC Corp Mary, mary@example.com, gd9as5b, 123 LLC ``` | | +| `signer_file` | ```bytes``` | `signer_file` is a CSV file defining values and options for signer fields. Required unless a `signer_list` is used, you may not use both. The CSV can have the following columns:

- `name`: the name of the signer filling the role of RoleName - `email_address`: email address of the signer filling the role of RoleName - `pin`: the 4- to 12-character access code that will secure this signer's signature page (optional) - `sms_phone_number`: An E.164 formatted phone number that will receive a code via SMS to access this signer's signature page. (optional)

By using the feature, you agree you are responsible for obtaining a signer's consent to receive text messages from Dropbox Sign related to this signature request and confirm you have obtained such consent from all signers prior to enabling SMS delivery for this signature request. [Learn more](https://faq.hellosign.com/hc/en-us/articles/15815316468877-Dropbox-Sign-SMS-tools-add-on).

**NOTE:** Not available in test mode and requires a Standard plan or higher. - `*_field`: any column with a _field" suffix will be treated as a custom field (optional)

You may only specify field values here, any other options should be set in the custom_fields request parameter.

Example CSV:

``` name, email_address, pin, company_field George, george@example.com, d79a3td, ABC Corp Mary, mary@example.com, gd9as5b, 123 LLC ``` | | | `signer_list` | [```List[SubBulkSignerList]```](SubBulkSignerList.md) | `signer_list` is an array defining values and options for signer fields. Required unless a `signer_file` is used, you may not use both. | | | `allow_decline` | ```bool``` | Allows signers to decline to sign a document if `true`. Defaults to `false`. | [default to False] | | `ccs` | [```List[SubCC]```](SubCC.md) | Add CC email recipients. Required when a CC role exists for the Template. | | diff --git a/sdks/python/docs/SignatureRequestCreateEmbeddedRequest.md b/sdks/python/docs/SignatureRequestCreateEmbeddedRequest.md index 737996807..ecc14bc1a 100644 --- a/sdks/python/docs/SignatureRequestCreateEmbeddedRequest.md +++ b/sdks/python/docs/SignatureRequestCreateEmbeddedRequest.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- | `client_id`*_required_ | ```str``` | Client id of the app you're using to create this embedded signature request. Used for security purposes. | | -| `files` | ```List[io.IOBase]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | +| `files` | ```List[bytes]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `file_urls` | ```List[str]``` | Use `file_urls[]` to have Dropbox Sign download the file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `signers` | [```List[SubSignatureRequestSigner]```](SubSignatureRequestSigner.md) | Add Signers to your Signature Request.

This endpoint requires either **signers** or **grouped_signers**, but not both. | | | `grouped_signers` | [```List[SubSignatureRequestGroupedSigners]```](SubSignatureRequestGroupedSigners.md) | Add Grouped Signers to your Signature Request.

This endpoint requires either **signers** or **grouped_signers**, but not both. | | diff --git a/sdks/python/docs/SignatureRequestCreateEmbeddedWithTemplateRequest.md b/sdks/python/docs/SignatureRequestCreateEmbeddedWithTemplateRequest.md index f9a07ce48..401ca321d 100644 --- a/sdks/python/docs/SignatureRequestCreateEmbeddedWithTemplateRequest.md +++ b/sdks/python/docs/SignatureRequestCreateEmbeddedWithTemplateRequest.md @@ -11,7 +11,7 @@ Name | Type | Description | Notes | `allow_decline` | ```bool``` | Allows signers to decline to sign a document if `true`. Defaults to `false`. | [default to False] | | `ccs` | [```List[SubCC]```](SubCC.md) | Add CC email recipients. Required when a CC role exists for the Template. | | | `custom_fields` | [```List[SubCustomField]```](SubCustomField.md) | An array defining values and options for custom fields. Required when a custom field exists in the Template. | | -| `files` | ```List[io.IOBase]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | +| `files` | ```List[bytes]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `file_urls` | ```List[str]``` | Use `file_urls[]` to have Dropbox Sign download the file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `message` | ```str``` | The custom message in the email that will be sent to the signers. | | | `metadata` | ```Dict[str, object]``` | Key-value data that should be attached to the signature request. This metadata is included in all API responses and events involving the signature request. For example, use the metadata field to store a signer's order number for look up when receiving events for the signature request.

Each request can include up to 10 metadata keys (or 50 nested metadata keys), with key names up to 40 characters long and values up to 1000 characters long. | | diff --git a/sdks/python/docs/SignatureRequestEditEmbeddedRequest.md b/sdks/python/docs/SignatureRequestEditEmbeddedRequest.md index ce0318240..267bffdc2 100644 --- a/sdks/python/docs/SignatureRequestEditEmbeddedRequest.md +++ b/sdks/python/docs/SignatureRequestEditEmbeddedRequest.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- | `client_id`*_required_ | ```str``` | Client id of the app you're using to create this embedded signature request. Used for security purposes. | | -| `files` | ```List[io.IOBase]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | +| `files` | ```List[bytes]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `file_urls` | ```List[str]``` | Use `file_urls[]` to have Dropbox Sign download the file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `signers` | [```List[SubSignatureRequestSigner]```](SubSignatureRequestSigner.md) | Add Signers to your Signature Request.

This endpoint requires either **signers** or **grouped_signers**, but not both. | | | `grouped_signers` | [```List[SubSignatureRequestGroupedSigners]```](SubSignatureRequestGroupedSigners.md) | Add Grouped Signers to your Signature Request.

This endpoint requires either **signers** or **grouped_signers**, but not both. | | diff --git a/sdks/python/docs/SignatureRequestEditEmbeddedWithTemplateRequest.md b/sdks/python/docs/SignatureRequestEditEmbeddedWithTemplateRequest.md index c0dcf6fd1..4cf8ed6d8 100644 --- a/sdks/python/docs/SignatureRequestEditEmbeddedWithTemplateRequest.md +++ b/sdks/python/docs/SignatureRequestEditEmbeddedWithTemplateRequest.md @@ -11,7 +11,7 @@ Name | Type | Description | Notes | `allow_decline` | ```bool``` | Allows signers to decline to sign a document if `true`. Defaults to `false`. | [default to False] | | `ccs` | [```List[SubCC]```](SubCC.md) | Add CC email recipients. Required when a CC role exists for the Template. | | | `custom_fields` | [```List[SubCustomField]```](SubCustomField.md) | An array defining values and options for custom fields. Required when a custom field exists in the Template. | | -| `files` | ```List[io.IOBase]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | +| `files` | ```List[bytes]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `file_urls` | ```List[str]``` | Use `file_urls[]` to have Dropbox Sign download the file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `message` | ```str``` | The custom message in the email that will be sent to the signers. | | | `metadata` | ```Dict[str, object]``` | Key-value data that should be attached to the signature request. This metadata is included in all API responses and events involving the signature request. For example, use the metadata field to store a signer's order number for look up when receiving events for the signature request.

Each request can include up to 10 metadata keys (or 50 nested metadata keys), with key names up to 40 characters long and values up to 1000 characters long. | | diff --git a/sdks/python/docs/SignatureRequestEditRequest.md b/sdks/python/docs/SignatureRequestEditRequest.md index 5965a588a..0a2f0719e 100644 --- a/sdks/python/docs/SignatureRequestEditRequest.md +++ b/sdks/python/docs/SignatureRequestEditRequest.md @@ -5,7 +5,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -| `files` | ```List[io.IOBase]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | +| `files` | ```List[bytes]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `file_urls` | ```List[str]``` | Use `file_urls[]` to have Dropbox Sign download the file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `signers` | [```List[SubSignatureRequestSigner]```](SubSignatureRequestSigner.md) | Add Signers to your Signature Request.

This endpoint requires either **signers** or **grouped_signers**, but not both. | | | `grouped_signers` | [```List[SubSignatureRequestGroupedSigners]```](SubSignatureRequestGroupedSigners.md) | Add Grouped Signers to your Signature Request.

This endpoint requires either **signers** or **grouped_signers**, but not both. | | diff --git a/sdks/python/docs/SignatureRequestEditWithTemplateRequest.md b/sdks/python/docs/SignatureRequestEditWithTemplateRequest.md index 978a0b38a..cd4733723 100644 --- a/sdks/python/docs/SignatureRequestEditWithTemplateRequest.md +++ b/sdks/python/docs/SignatureRequestEditWithTemplateRequest.md @@ -11,7 +11,7 @@ Name | Type | Description | Notes | `ccs` | [```List[SubCC]```](SubCC.md) | Add CC email recipients. Required when a CC role exists for the Template. | | | `client_id` | ```str``` | Client id of the app to associate with the signature request. Used to apply the branding and callback url defined for the app. | | | `custom_fields` | [```List[SubCustomField]```](SubCustomField.md) | An array defining values and options for custom fields. Required when a custom field exists in the Template. | | -| `files` | ```List[io.IOBase]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | +| `files` | ```List[bytes]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `file_urls` | ```List[str]``` | Use `file_urls[]` to have Dropbox Sign download the file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `is_eid` | ```bool``` | Send with a value of `true` if you wish to enable [electronic identification (eID)](https://www.hellosign.com/features/electronic-id), which requires the signer to verify their identity with an eID provider to sign a document.<br>
**NOTE:** You need the eID add-on to use this feature. Please [contact sales](https://sign.dropbox.com/form/contact-sales) for more information. Cannot be used in `test_mode`. Only works on requests with one signer. | [default to False] | | `message` | ```str``` | The custom message in the email that will be sent to the signers. | | diff --git a/sdks/python/docs/SignatureRequestSendRequest.md b/sdks/python/docs/SignatureRequestSendRequest.md index 26f3ba4dd..d3fa69457 100644 --- a/sdks/python/docs/SignatureRequestSendRequest.md +++ b/sdks/python/docs/SignatureRequestSendRequest.md @@ -5,7 +5,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -| `files` | ```List[io.IOBase]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | +| `files` | ```List[bytes]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `file_urls` | ```List[str]``` | Use `file_urls[]` to have Dropbox Sign download the file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `signers` | [```List[SubSignatureRequestSigner]```](SubSignatureRequestSigner.md) | Add Signers to your Signature Request.

This endpoint requires either **signers** or **grouped_signers**, but not both. | | | `grouped_signers` | [```List[SubSignatureRequestGroupedSigners]```](SubSignatureRequestGroupedSigners.md) | Add Grouped Signers to your Signature Request.

This endpoint requires either **signers** or **grouped_signers**, but not both. | | diff --git a/sdks/python/docs/SignatureRequestSendWithTemplateRequest.md b/sdks/python/docs/SignatureRequestSendWithTemplateRequest.md index 8b2637d01..52ac0fdf4 100644 --- a/sdks/python/docs/SignatureRequestSendWithTemplateRequest.md +++ b/sdks/python/docs/SignatureRequestSendWithTemplateRequest.md @@ -11,7 +11,7 @@ Name | Type | Description | Notes | `ccs` | [```List[SubCC]```](SubCC.md) | Add CC email recipients. Required when a CC role exists for the Template. | | | `client_id` | ```str``` | Client id of the app to associate with the signature request. Used to apply the branding and callback url defined for the app. | | | `custom_fields` | [```List[SubCustomField]```](SubCustomField.md) | An array defining values and options for custom fields. Required when a custom field exists in the Template. | | -| `files` | ```List[io.IOBase]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | +| `files` | ```List[bytes]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `file_urls` | ```List[str]``` | Use `file_urls[]` to have Dropbox Sign download the file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `is_qualified_signature` | ```bool``` | Send with a value of `true` if you wish to enable [Qualified Electronic Signatures](https://www.hellosign.com/features/qualified-electronic-signatures) (QES), which requires a face-to-face call to verify the signer's identity.<br>
**NOTE:** QES is only available on the Premium API plan as an add-on purchase. Cannot be used in `test_mode`. Only works on requests with one signer. | [default to False] | | `is_eid` | ```bool``` | Send with a value of `true` if you wish to enable [electronic identification (eID)](https://www.hellosign.com/features/electronic-id), which requires the signer to verify their identity with an eID provider to sign a document.<br>
**NOTE:** You need the eID add-on to use this feature. Please [contact sales](https://sign.dropbox.com/form/contact-sales) for more information. Cannot be used in `test_mode`. Only works on requests with one signer. | [default to False] | diff --git a/sdks/python/docs/TemplateApi.md b/sdks/python/docs/TemplateApi.md index 23d16d10b..ba5805593 100644 --- a/sdks/python/docs/TemplateApi.md +++ b/sdks/python/docs/TemplateApi.md @@ -423,7 +423,7 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # ```template_files``` -> ```io.IOBase template_files(template_id)``` +> ```bytes template_files(template_id)``` Get Template Files @@ -469,7 +469,7 @@ with ApiClient(configuration) as api_client: ### Return type -**io.IOBase** +**bytes** ### Authorization diff --git a/sdks/python/docs/TemplateCreateEmbeddedDraftRequest.md b/sdks/python/docs/TemplateCreateEmbeddedDraftRequest.md index 69969e708..3c14debef 100644 --- a/sdks/python/docs/TemplateCreateEmbeddedDraftRequest.md +++ b/sdks/python/docs/TemplateCreateEmbeddedDraftRequest.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- | `client_id`*_required_ | ```str``` | Client id of the app you're using to create this draft. Used to apply the branding and callback url defined for the app. | | -| `files` | ```List[io.IOBase]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | +| `files` | ```List[bytes]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `file_urls` | ```List[str]``` | Use `file_urls[]` to have Dropbox Sign download the file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `allow_ccs` | ```bool``` | This allows the requester to specify whether the user is allowed to provide email addresses to CC when creating a template. | [default to True] | | `allow_reassign` | ```bool``` | Allows signers to reassign their signature requests to other signers if set to `true`. Defaults to `false`.

**NOTE:** Only available for Premium plan and higher. | [default to False] | diff --git a/sdks/python/docs/TemplateCreateRequest.md b/sdks/python/docs/TemplateCreateRequest.md index dc99d24ed..e01aa750a 100644 --- a/sdks/python/docs/TemplateCreateRequest.md +++ b/sdks/python/docs/TemplateCreateRequest.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- | `form_fields_per_document`*_required_ | [```List[SubFormFieldsPerDocumentBase]```](SubFormFieldsPerDocumentBase.md) | The fields that should appear on the document, expressed as an array of objects. (For more details you can read about it here: [Using Form Fields per Document](/docs/openapi/form-fields-per-document).)

**NOTE:** Fields like **text**, **dropdown**, **checkbox**, **radio**, and **hyperlink** have additional required and optional parameters. Check out the list of [additional parameters](/api/reference/constants/#form-fields-per-document) for these field types.

* Text Field use `SubFormFieldsPerDocumentText`
* Dropdown Field use `SubFormFieldsPerDocumentDropdown`
* Hyperlink Field use `SubFormFieldsPerDocumentHyperlink`
* Checkbox Field use `SubFormFieldsPerDocumentCheckbox`
* Radio Field use `SubFormFieldsPerDocumentRadio`
* Signature Field use `SubFormFieldsPerDocumentSignature`
* Date Signed Field use `SubFormFieldsPerDocumentDateSigned`
* Initials Field use `SubFormFieldsPerDocumentInitials`
* Text Merge Field use `SubFormFieldsPerDocumentTextMerge`
* Checkbox Merge Field use `SubFormFieldsPerDocumentCheckboxMerge` | | | `signer_roles`*_required_ | [```List[SubTemplateRole]```](SubTemplateRole.md) | An array of the designated signer roles that must be specified when sending a SignatureRequest using this Template. | | -| `files` | ```List[io.IOBase]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | +| `files` | ```List[bytes]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `file_urls` | ```List[str]``` | Use `file_urls[]` to have Dropbox Sign download the file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `allow_reassign` | ```bool``` | Allows signers to reassign their signature requests to other signers if set to `true`. Defaults to `false`.

**NOTE:** Only available for Premium plan and higher. | [default to False] | | `attachments` | [```List[SubAttachment]```](SubAttachment.md) | A list describing the attachments | | diff --git a/sdks/python/docs/TemplateUpdateFilesRequest.md b/sdks/python/docs/TemplateUpdateFilesRequest.md index feb241954..c00e349be 100644 --- a/sdks/python/docs/TemplateUpdateFilesRequest.md +++ b/sdks/python/docs/TemplateUpdateFilesRequest.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- | `client_id` | ```str``` | Client id of the app you're using to update this template. | | -| `files` | ```List[io.IOBase]``` | Use `files[]` to indicate the uploaded file(s) to use for the template.

This endpoint requires either **files** or **file_urls[]**, but not both. | | +| `files` | ```List[bytes]``` | Use `files[]` to indicate the uploaded file(s) to use for the template.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `file_urls` | ```List[str]``` | Use `file_urls[]` to have Dropbox Sign download the file(s) to use for the template.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `message` | ```str``` | The new default template email message. | | | `subject` | ```str``` | The new default template email subject. | | diff --git a/sdks/python/docs/UnclaimedDraftCreateEmbeddedRequest.md b/sdks/python/docs/UnclaimedDraftCreateEmbeddedRequest.md index f5a8d88d2..4465b0b50 100644 --- a/sdks/python/docs/UnclaimedDraftCreateEmbeddedRequest.md +++ b/sdks/python/docs/UnclaimedDraftCreateEmbeddedRequest.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- | `client_id`*_required_ | ```str``` | Client id of the app used to create the draft. Used to apply the branding and callback url defined for the app. | | | `requester_email_address`*_required_ | ```str``` | The email address of the user that should be designated as the requester of this draft, if the draft type is `request_signature`. | | -| `files` | ```List[io.IOBase]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | +| `files` | ```List[bytes]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `file_urls` | ```List[str]``` | Use `file_urls[]` to have Dropbox Sign download the file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `allow_ccs` | ```bool``` | This allows the requester to specify whether the user is allowed to provide email addresses to CC when claiming the draft. | [default to True] | | `allow_decline` | ```bool``` | Allows signers to decline to sign a document if `true`. Defaults to `false`. | [default to False] | diff --git a/sdks/python/docs/UnclaimedDraftCreateEmbeddedWithTemplateRequest.md b/sdks/python/docs/UnclaimedDraftCreateEmbeddedWithTemplateRequest.md index 88a201846..be08c5911 100644 --- a/sdks/python/docs/UnclaimedDraftCreateEmbeddedWithTemplateRequest.md +++ b/sdks/python/docs/UnclaimedDraftCreateEmbeddedWithTemplateRequest.md @@ -14,7 +14,7 @@ Name | Type | Description | Notes | `custom_fields` | [```List[SubCustomField]```](SubCustomField.md) | An array defining values and options for custom fields. Required when a custom field exists in the Template. | | | `editor_options` | [```SubEditorOptions```](SubEditorOptions.md) | | | | `field_options` | [```SubFieldOptions```](SubFieldOptions.md) | | | -| `files` | ```List[io.IOBase]``` | Use `files[]` to append additional files to the signature request being created from the template. Dropbox Sign will parse the files for [text tags](https://app.hellosign.com/api/textTagsWalkthrough) and append it to the signature request. Text tags for signers not on the template(s) will be ignored.

**files** or **file_urls[]** is required, but not both. | | +| `files` | ```List[bytes]``` | Use `files[]` to append additional files to the signature request being created from the template. Dropbox Sign will parse the files for [text tags](https://app.hellosign.com/api/textTagsWalkthrough) and append it to the signature request. Text tags for signers not on the template(s) will be ignored.

**files** or **file_urls[]** is required, but not both. | | | `file_urls` | ```List[str]``` | Use file_urls[] to append additional files to the signature request being created from the template. Dropbox Sign will download the file, then parse it for [text tags](https://app.hellosign.com/api/textTagsWalkthrough), and append to the signature request. Text tags for signers not on the template(s) will be ignored.

**files** or **file_urls[]** is required, but not both. | | | `force_signer_roles` | ```bool``` | Provide users the ability to review/edit the template signer roles. | [default to False] | | `force_subject_message` | ```bool``` | Provide users the ability to review/edit the template subject and message. | [default to False] | diff --git a/sdks/python/docs/UnclaimedDraftCreateRequest.md b/sdks/python/docs/UnclaimedDraftCreateRequest.md index b30c17022..101db6bd3 100644 --- a/sdks/python/docs/UnclaimedDraftCreateRequest.md +++ b/sdks/python/docs/UnclaimedDraftCreateRequest.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- | `type`*_required_ | ```str``` | The type of unclaimed draft to create. Use `send_document` to create a claimable file, and `request_signature` for a claimable signature request. If the type is `request_signature` then signers name and email_address are not optional. | | -| `files` | ```List[io.IOBase]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | +| `files` | ```List[bytes]``` | Use `files[]` to indicate the uploaded file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `file_urls` | ```List[str]``` | Use `file_urls[]` to have Dropbox Sign download the file(s) to send for signature.

This endpoint requires either **files** or **file_urls[]**, but not both. | | | `allow_decline` | ```bool``` | Allows signers to decline to sign a document if `true`. Defaults to `false`. | [default to False] | | `attachments` | [```List[SubAttachment]```](SubAttachment.md) | A list describing the attachments | | diff --git a/sdks/python/dropbox_sign/api/account_api.py b/sdks/python/dropbox_sign/api/account_api.py index 887a72b51..01c249dd4 100644 --- a/sdks/python/dropbox_sign/api/account_api.py +++ b/sdks/python/dropbox_sign/api/account_api.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ Dropbox Sign API @@ -103,7 +101,6 @@ def account_create( "200": "AccountCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -171,7 +168,6 @@ def account_create_with_http_info( "200": "AccountCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -239,7 +235,6 @@ def account_create_without_preload_content( "200": "AccountCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -403,7 +398,6 @@ def account_get( "200": "AccountGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -485,7 +479,6 @@ def account_get_with_http_info( "200": "AccountGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -567,7 +560,6 @@ def account_get_without_preload_content( "200": "AccountGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -692,7 +684,6 @@ def account_update( "200": "AccountGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -760,7 +751,6 @@ def account_update_with_http_info( "200": "AccountGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -828,7 +818,6 @@ def account_update_without_preload_content( "200": "AccountGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -978,7 +967,6 @@ def account_verify( "200": "AccountVerifyResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1046,7 +1034,6 @@ def account_verify_with_http_info( "200": "AccountVerifyResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1114,7 +1101,6 @@ def account_verify_without_preload_content( "200": "AccountVerifyResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) diff --git a/sdks/python/dropbox_sign/api/api_app_api.py b/sdks/python/dropbox_sign/api/api_app_api.py index b626413f4..f500b21b4 100644 --- a/sdks/python/dropbox_sign/api/api_app_api.py +++ b/sdks/python/dropbox_sign/api/api_app_api.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ Dropbox Sign API @@ -101,7 +99,6 @@ def api_app_create( "201": "ApiAppGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -169,7 +166,6 @@ def api_app_create_with_http_info( "201": "ApiAppGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -237,7 +233,6 @@ def api_app_create_without_preload_content( "201": "ApiAppGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -389,7 +384,6 @@ def api_app_delete( "204": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -459,7 +453,6 @@ def api_app_delete_with_http_info( "204": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -529,7 +522,6 @@ def api_app_delete_without_preload_content( "204": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -649,7 +641,6 @@ def api_app_get( "200": "ApiAppGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -719,7 +710,6 @@ def api_app_get_with_http_info( "200": "ApiAppGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -789,7 +779,6 @@ def api_app_get_without_preload_content( "200": "ApiAppGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -921,7 +910,6 @@ def api_app_list( "200": "ApiAppListResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1003,7 +991,6 @@ def api_app_list_with_http_info( "200": "ApiAppListResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1085,7 +1072,6 @@ def api_app_list_without_preload_content( "200": "ApiAppListResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1216,7 +1202,6 @@ def api_app_update( "200": "ApiAppGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1290,7 +1275,6 @@ def api_app_update_with_http_info( "200": "ApiAppGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1364,7 +1348,6 @@ def api_app_update_without_preload_content( "200": "ApiAppGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) diff --git a/sdks/python/dropbox_sign/api/bulk_send_job_api.py b/sdks/python/dropbox_sign/api/bulk_send_job_api.py index 12eeb2cc1..a3b30796d 100644 --- a/sdks/python/dropbox_sign/api/bulk_send_job_api.py +++ b/sdks/python/dropbox_sign/api/bulk_send_job_api.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ Dropbox Sign API @@ -119,7 +117,6 @@ def bulk_send_job_get( "200": "BulkSendJobGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -207,7 +204,6 @@ def bulk_send_job_get_with_http_info( "200": "BulkSendJobGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -295,7 +291,6 @@ def bulk_send_job_get_without_preload_content( "200": "BulkSendJobGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -437,7 +432,6 @@ def bulk_send_job_list( "200": "BulkSendJobListResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -519,7 +513,6 @@ def bulk_send_job_list_with_http_info( "200": "BulkSendJobListResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -601,7 +594,6 @@ def bulk_send_job_list_without_preload_content( "200": "BulkSendJobListResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) diff --git a/sdks/python/dropbox_sign/api/document_api.py b/sdks/python/dropbox_sign/api/document_api.py index eb92dc1c2..3ff9f4a24 100644 --- a/sdks/python/dropbox_sign/api/document_api.py +++ b/sdks/python/dropbox_sign/api/document_api.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ Dropbox Sign API @@ -100,7 +98,6 @@ def document_detect_fields( "200": "DocumentFieldDetectionResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -168,7 +165,6 @@ def document_detect_fields_with_http_info( "200": "DocumentFieldDetectionResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -236,7 +232,6 @@ def document_detect_fields_without_preload_content( "200": "DocumentFieldDetectionResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) diff --git a/sdks/python/dropbox_sign/api/embedded_api.py b/sdks/python/dropbox_sign/api/embedded_api.py index 1a79db1be..8d9d1a865 100644 --- a/sdks/python/dropbox_sign/api/embedded_api.py +++ b/sdks/python/dropbox_sign/api/embedded_api.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ Dropbox Sign API @@ -105,7 +103,6 @@ def embedded_edit_url( "200": "EmbeddedEditUrlResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -179,7 +176,6 @@ def embedded_edit_url_with_http_info( "200": "EmbeddedEditUrlResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -253,7 +249,6 @@ def embedded_edit_url_without_preload_content( "200": "EmbeddedEditUrlResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -409,7 +404,6 @@ def embedded_sign_url( "200": "EmbeddedSignUrlResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -480,7 +474,6 @@ def embedded_sign_url_with_http_info( "200": "EmbeddedSignUrlResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -551,7 +544,6 @@ def embedded_sign_url_without_preload_content( "200": "EmbeddedSignUrlResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) diff --git a/sdks/python/dropbox_sign/api/fax_api.py b/sdks/python/dropbox_sign/api/fax_api.py index 682b26e40..aa7b582a5 100644 --- a/sdks/python/dropbox_sign/api/fax_api.py +++ b/sdks/python/dropbox_sign/api/fax_api.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ Dropbox Sign API @@ -100,7 +98,6 @@ def fax_delete( "204": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -168,7 +165,6 @@ def fax_delete_with_http_info( "204": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -236,7 +232,6 @@ def fax_delete_without_preload_content( "204": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -354,7 +349,6 @@ def fax_files( "200": "io.IOBase", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -422,7 +416,6 @@ def fax_files_with_http_info( "200": "io.IOBase", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -490,7 +483,6 @@ def fax_files_without_preload_content( "200": "io.IOBase", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -608,7 +600,6 @@ def fax_get( "200": "FaxGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -676,7 +667,6 @@ def fax_get_with_http_info( "200": "FaxGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -744,7 +734,6 @@ def fax_get_without_preload_content( "200": "FaxGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -876,7 +865,6 @@ def fax_list( "200": "FaxListResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -958,7 +946,6 @@ def fax_list_with_http_info( "200": "FaxListResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1040,7 +1027,6 @@ def fax_list_without_preload_content( "200": "FaxListResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1165,7 +1151,6 @@ def fax_send( "200": "FaxGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1233,7 +1218,6 @@ def fax_send_with_http_info( "200": "FaxGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1301,7 +1285,6 @@ def fax_send_without_preload_content( "200": "FaxGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) diff --git a/sdks/python/dropbox_sign/api/fax_line_api.py b/sdks/python/dropbox_sign/api/fax_line_api.py index f752698b0..cd09ed959 100644 --- a/sdks/python/dropbox_sign/api/fax_line_api.py +++ b/sdks/python/dropbox_sign/api/fax_line_api.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ Dropbox Sign API @@ -106,7 +104,6 @@ def fax_line_add_user( "200": "FaxLineResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -174,7 +171,6 @@ def fax_line_add_user_with_http_info( "200": "FaxLineResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -242,7 +238,6 @@ def fax_line_add_user_without_preload_content( "200": "FaxLineResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -412,7 +407,6 @@ def fax_line_area_code_get( "200": "FaxLineAreaCodeGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -500,7 +494,6 @@ def fax_line_area_code_get_with_http_info( "200": "FaxLineAreaCodeGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -588,7 +581,6 @@ def fax_line_area_code_get_without_preload_content( "200": "FaxLineAreaCodeGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -723,7 +715,6 @@ def fax_line_create( "200": "FaxLineResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -791,7 +782,6 @@ def fax_line_create_with_http_info( "200": "FaxLineResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -859,7 +849,6 @@ def fax_line_create_without_preload_content( "200": "FaxLineResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1009,7 +998,6 @@ def fax_line_delete( "200": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1077,7 +1065,6 @@ def fax_line_delete_with_http_info( "200": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1145,7 +1132,6 @@ def fax_line_delete_without_preload_content( "200": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1295,7 +1281,6 @@ def fax_line_get( "200": "FaxLineResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1363,7 +1348,6 @@ def fax_line_get_with_http_info( "200": "FaxLineResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1431,7 +1415,6 @@ def fax_line_get_without_preload_content( "200": "FaxLineResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1580,7 +1563,6 @@ def fax_line_list( "200": "FaxLineListResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1677,7 +1659,6 @@ def fax_line_list_with_http_info( "200": "FaxLineListResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1774,7 +1755,6 @@ def fax_line_list_without_preload_content( "200": "FaxLineListResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1909,7 +1889,6 @@ def fax_line_remove_user( "200": "FaxLineResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1977,7 +1956,6 @@ def fax_line_remove_user_with_http_info( "200": "FaxLineResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2045,7 +2023,6 @@ def fax_line_remove_user_without_preload_content( "200": "FaxLineResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) diff --git a/sdks/python/dropbox_sign/api/o_auth_api.py b/sdks/python/dropbox_sign/api/o_auth_api.py index c173208e2..513672f6e 100644 --- a/sdks/python/dropbox_sign/api/o_auth_api.py +++ b/sdks/python/dropbox_sign/api/o_auth_api.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ Dropbox Sign API @@ -97,7 +95,6 @@ def oauth_token_generate( "200": "OAuthTokenResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -165,7 +162,6 @@ def oauth_token_generate_with_http_info( "200": "OAuthTokenResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -233,7 +229,6 @@ def oauth_token_generate_without_preload_content( "200": "OAuthTokenResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -384,7 +379,6 @@ def oauth_token_refresh( "200": "OAuthTokenResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -452,7 +446,6 @@ def oauth_token_refresh_with_http_info( "200": "OAuthTokenResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -520,7 +513,6 @@ def oauth_token_refresh_without_preload_content( "200": "OAuthTokenResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) diff --git a/sdks/python/dropbox_sign/api/report_api.py b/sdks/python/dropbox_sign/api/report_api.py index 38b120b2a..893ecfac0 100644 --- a/sdks/python/dropbox_sign/api/report_api.py +++ b/sdks/python/dropbox_sign/api/report_api.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ Dropbox Sign API @@ -96,7 +94,6 @@ def report_create( "200": "ReportCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -164,7 +161,6 @@ def report_create_with_http_info( "200": "ReportCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -232,7 +228,6 @@ def report_create_without_preload_content( "200": "ReportCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) diff --git a/sdks/python/dropbox_sign/api/signature_request_api.py b/sdks/python/dropbox_sign/api/signature_request_api.py index 77f3c71bd..9ffcce52d 100644 --- a/sdks/python/dropbox_sign/api/signature_request_api.py +++ b/sdks/python/dropbox_sign/api/signature_request_api.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ Dropbox Sign API @@ -142,7 +140,6 @@ def signature_request_bulk_create_embedded_with_template( "200": "BulkSendJobSendResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -210,7 +207,6 @@ def signature_request_bulk_create_embedded_with_template_with_http_info( "200": "BulkSendJobSendResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -278,7 +274,6 @@ def signature_request_bulk_create_embedded_with_template_without_preload_content "200": "BulkSendJobSendResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -431,7 +426,6 @@ def signature_request_bulk_send_with_template( "200": "BulkSendJobSendResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -499,7 +493,6 @@ def signature_request_bulk_send_with_template_with_http_info( "200": "BulkSendJobSendResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -567,7 +560,6 @@ def signature_request_bulk_send_with_template_without_preload_content( "200": "BulkSendJobSendResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -723,7 +715,6 @@ def signature_request_cancel( "200": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -794,7 +785,6 @@ def signature_request_cancel_with_http_info( "200": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -865,7 +855,6 @@ def signature_request_cancel_without_preload_content( "200": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -983,7 +972,6 @@ def signature_request_create_embedded( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1051,7 +1039,6 @@ def signature_request_create_embedded_with_http_info( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1119,7 +1106,6 @@ def signature_request_create_embedded_without_preload_content( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1269,7 +1255,6 @@ def signature_request_create_embedded_with_template( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1337,7 +1322,6 @@ def signature_request_create_embedded_with_template_with_http_info( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1405,7 +1389,6 @@ def signature_request_create_embedded_with_template_without_preload_content( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1564,7 +1547,6 @@ def signature_request_edit( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1638,7 +1620,6 @@ def signature_request_edit_with_http_info( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1712,7 +1693,6 @@ def signature_request_edit_without_preload_content( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1871,7 +1851,6 @@ def signature_request_edit_embedded( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1945,7 +1924,6 @@ def signature_request_edit_embedded_with_http_info( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2019,7 +1997,6 @@ def signature_request_edit_embedded_without_preload_content( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2178,7 +2155,6 @@ def signature_request_edit_embedded_with_template( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2252,7 +2228,6 @@ def signature_request_edit_embedded_with_template_with_http_info( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2326,7 +2301,6 @@ def signature_request_edit_embedded_with_template_without_preload_content( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2488,7 +2462,6 @@ def signature_request_edit_with_template( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2562,7 +2535,6 @@ def signature_request_edit_with_template_with_http_info( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2636,7 +2608,6 @@ def signature_request_edit_with_template_without_preload_content( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2803,7 +2774,6 @@ def signature_request_files( "200": "io.IOBase", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2882,7 +2852,6 @@ def signature_request_files_with_http_info( "200": "io.IOBase", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2961,7 +2930,6 @@ def signature_request_files_without_preload_content( "200": "io.IOBase", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -3086,7 +3054,6 @@ def signature_request_files_as_data_uri( "200": "FileResponseDataUri", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -3156,7 +3123,6 @@ def signature_request_files_as_data_uri_with_http_info( "200": "FileResponseDataUri", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -3226,7 +3192,6 @@ def signature_request_files_as_data_uri_without_preload_content( "200": "FileResponseDataUri", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -3355,7 +3320,6 @@ def signature_request_files_as_file_url( "200": "FileResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -3434,7 +3398,6 @@ def signature_request_files_as_file_url_with_http_info( "200": "FileResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -3513,7 +3476,6 @@ def signature_request_files_as_file_url_without_preload_content( "200": "FileResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -3638,7 +3600,6 @@ def signature_request_get( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -3708,7 +3669,6 @@ def signature_request_get_with_http_info( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -3778,7 +3738,6 @@ def signature_request_get_without_preload_content( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -3928,7 +3887,6 @@ def signature_request_list( "200": "SignatureRequestListResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -4028,7 +3986,6 @@ def signature_request_list_with_http_info( "200": "SignatureRequestListResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -4128,7 +4085,6 @@ def signature_request_list_without_preload_content( "200": "SignatureRequestListResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -4265,7 +4221,6 @@ def signature_request_release_hold( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -4335,7 +4290,6 @@ def signature_request_release_hold_with_http_info( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -4405,7 +4359,6 @@ def signature_request_release_hold_without_preload_content( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -4530,7 +4483,6 @@ def signature_request_remind( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -4605,7 +4557,6 @@ def signature_request_remind_with_http_info( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -4680,7 +4631,6 @@ def signature_request_remind_without_preload_content( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -4835,7 +4785,6 @@ def signature_request_remove( "200": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -4905,7 +4854,6 @@ def signature_request_remove_with_http_info( "200": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -4975,7 +4923,6 @@ def signature_request_remove_without_preload_content( "200": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -5093,7 +5040,6 @@ def signature_request_send( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -5161,7 +5107,6 @@ def signature_request_send_with_http_info( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -5229,7 +5174,6 @@ def signature_request_send_without_preload_content( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -5379,7 +5323,6 @@ def signature_request_send_with_template( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -5447,7 +5390,6 @@ def signature_request_send_with_template_with_http_info( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -5515,7 +5457,6 @@ def signature_request_send_with_template_without_preload_content( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -5674,7 +5615,6 @@ def signature_request_update( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -5748,7 +5688,6 @@ def signature_request_update_with_http_info( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -5822,7 +5761,6 @@ def signature_request_update_without_preload_content( "200": "SignatureRequestGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) diff --git a/sdks/python/dropbox_sign/api/team_api.py b/sdks/python/dropbox_sign/api/team_api.py index db6adcc16..6cd2c89d5 100644 --- a/sdks/python/dropbox_sign/api/team_api.py +++ b/sdks/python/dropbox_sign/api/team_api.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ Dropbox Sign API @@ -112,7 +110,6 @@ def team_add_member( "200": "TeamGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -186,7 +183,6 @@ def team_add_member_with_http_info( "200": "TeamGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -260,7 +256,6 @@ def team_add_member_without_preload_content( "200": "TeamGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -415,7 +410,6 @@ def team_create( "200": "TeamGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -483,7 +477,6 @@ def team_create_with_http_info( "200": "TeamGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -551,7 +544,6 @@ def team_create_without_preload_content( "200": "TeamGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -697,7 +689,6 @@ def team_delete( "200": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -761,7 +752,6 @@ def team_delete_with_http_info( "200": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -825,7 +815,6 @@ def team_delete_without_preload_content( "200": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -936,7 +925,6 @@ def team_get( "200": "TeamGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1000,7 +988,6 @@ def team_get_with_http_info( "200": "TeamGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1064,7 +1051,6 @@ def team_get_without_preload_content( "200": "TeamGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1181,7 +1167,6 @@ def team_info( "200": "TeamGetInfoResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1251,7 +1236,6 @@ def team_info_with_http_info( "200": "TeamGetInfoResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1321,7 +1305,6 @@ def team_info_without_preload_content( "200": "TeamGetInfoResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1446,7 +1429,6 @@ def team_invites( "200": "TeamInvitesResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1519,7 +1501,6 @@ def team_invites_with_http_info( "200": "TeamInvitesResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1592,7 +1573,6 @@ def team_invites_without_preload_content( "200": "TeamInvitesResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1735,7 +1715,6 @@ def team_members( "200": "TeamMembersResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1826,7 +1805,6 @@ def team_members_with_http_info( "200": "TeamMembersResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1917,7 +1895,6 @@ def team_members_without_preload_content( "200": "TeamMembersResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2045,7 +2022,6 @@ def team_remove_member( "201": "TeamGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2113,7 +2089,6 @@ def team_remove_member_with_http_info( "201": "TeamGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2181,7 +2156,6 @@ def team_remove_member_without_preload_content( "201": "TeamGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2349,7 +2323,6 @@ def team_sub_teams( "200": "TeamSubTeamsResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2435,7 +2408,6 @@ def team_sub_teams_with_http_info( "200": "TeamSubTeamsResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2521,7 +2493,6 @@ def team_sub_teams_without_preload_content( "200": "TeamSubTeamsResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2649,7 +2620,6 @@ def team_update( "200": "TeamGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2717,7 +2687,6 @@ def team_update_with_http_info( "200": "TeamGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2785,7 +2754,6 @@ def team_update_without_preload_content( "200": "TeamGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) diff --git a/sdks/python/dropbox_sign/api/template_api.py b/sdks/python/dropbox_sign/api/template_api.py index 4ae3b449b..24a1c8b41 100644 --- a/sdks/python/dropbox_sign/api/template_api.py +++ b/sdks/python/dropbox_sign/api/template_api.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ Dropbox Sign API @@ -122,7 +120,6 @@ def template_add_user( "200": "TemplateGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -197,7 +194,6 @@ def template_add_user_with_http_info( "200": "TemplateGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -272,7 +268,6 @@ def template_add_user_without_preload_content( "200": "TemplateGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -425,7 +420,6 @@ def template_create( "200": "TemplateCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -493,7 +487,6 @@ def template_create_with_http_info( "200": "TemplateCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -561,7 +554,6 @@ def template_create_without_preload_content( "200": "TemplateCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -711,7 +703,6 @@ def template_create_embedded_draft( "200": "TemplateCreateEmbeddedDraftResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -779,7 +770,6 @@ def template_create_embedded_draft_with_http_info( "200": "TemplateCreateEmbeddedDraftResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -847,7 +837,6 @@ def template_create_embedded_draft_without_preload_content( "200": "TemplateCreateEmbeddedDraftResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -999,7 +988,6 @@ def template_delete( "200": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1069,7 +1057,6 @@ def template_delete_with_http_info( "200": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1139,7 +1126,6 @@ def template_delete_without_preload_content( "200": None, "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1268,7 +1254,6 @@ def template_files( "200": "io.IOBase", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1347,7 +1332,6 @@ def template_files_with_http_info( "200": "io.IOBase", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1426,7 +1410,6 @@ def template_files_without_preload_content( "200": "io.IOBase", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1551,7 +1534,6 @@ def template_files_as_data_uri( "200": "FileResponseDataUri", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1621,7 +1603,6 @@ def template_files_as_data_uri_with_http_info( "200": "FileResponseDataUri", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1691,7 +1672,6 @@ def template_files_as_data_uri_without_preload_content( "200": "FileResponseDataUri", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1820,7 +1800,6 @@ def template_files_as_file_url( "200": "FileResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1899,7 +1878,6 @@ def template_files_as_file_url_with_http_info( "200": "FileResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1978,7 +1956,6 @@ def template_files_as_file_url_without_preload_content( "200": "FileResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2103,7 +2080,6 @@ def template_get( "200": "TemplateGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2173,7 +2149,6 @@ def template_get_with_http_info( "200": "TemplateGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2243,7 +2218,6 @@ def template_get_without_preload_content( "200": "TemplateGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2393,7 +2367,6 @@ def template_list( "200": "TemplateListResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2493,7 +2466,6 @@ def template_list_with_http_info( "200": "TemplateListResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2593,7 +2565,6 @@ def template_list_without_preload_content( "200": "TemplateListResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2737,7 +2708,6 @@ def template_remove_user( "200": "TemplateGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2814,7 +2784,6 @@ def template_remove_user_with_http_info( "200": "TemplateGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -2891,7 +2860,6 @@ def template_remove_user_without_preload_content( "200": "TemplateGetResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -3051,7 +3019,6 @@ def template_update_files( "200": "TemplateUpdateFilesResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -3126,7 +3093,6 @@ def template_update_files_with_http_info( "200": "TemplateUpdateFilesResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -3201,7 +3167,6 @@ def template_update_files_without_preload_content( "200": "TemplateUpdateFilesResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) diff --git a/sdks/python/dropbox_sign/api/unclaimed_draft_api.py b/sdks/python/dropbox_sign/api/unclaimed_draft_api.py index 3c9936164..8910a62a3 100644 --- a/sdks/python/dropbox_sign/api/unclaimed_draft_api.py +++ b/sdks/python/dropbox_sign/api/unclaimed_draft_api.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ Dropbox Sign API @@ -111,7 +109,6 @@ def unclaimed_draft_create( "200": "UnclaimedDraftCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -179,7 +176,6 @@ def unclaimed_draft_create_with_http_info( "200": "UnclaimedDraftCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -247,7 +243,6 @@ def unclaimed_draft_create_without_preload_content( "200": "UnclaimedDraftCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -397,7 +392,6 @@ def unclaimed_draft_create_embedded( "200": "UnclaimedDraftCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -465,7 +459,6 @@ def unclaimed_draft_create_embedded_with_http_info( "200": "UnclaimedDraftCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -533,7 +526,6 @@ def unclaimed_draft_create_embedded_without_preload_content( "200": "UnclaimedDraftCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -683,7 +675,6 @@ def unclaimed_draft_create_embedded_with_template( "200": "UnclaimedDraftCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -751,7 +742,6 @@ def unclaimed_draft_create_embedded_with_template_with_http_info( "200": "UnclaimedDraftCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -819,7 +809,6 @@ def unclaimed_draft_create_embedded_with_template_without_preload_content( "200": "UnclaimedDraftCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -979,7 +968,6 @@ def unclaimed_draft_edit_and_resend( "200": "UnclaimedDraftCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1054,7 +1042,6 @@ def unclaimed_draft_edit_and_resend_with_http_info( "200": "UnclaimedDraftCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) @@ -1129,7 +1116,6 @@ def unclaimed_draft_edit_and_resend_without_preload_content( "200": "UnclaimedDraftCreateResponse", "4XX": "ErrorResponse", } - response_data = self.api_client.call_api( *_param, _request_timeout=_request_timeout ) diff --git a/sdks/python/dropbox_sign/api_client.py b/sdks/python/dropbox_sign/api_client.py index 008f7a64a..52122da5f 100644 --- a/sdks/python/dropbox_sign/api_client.py +++ b/sdks/python/dropbox_sign/api_client.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ Dropbox Sign API @@ -12,7 +10,6 @@ Do not edit the class manually. """ # noqa: E501 - import datetime from dateutil.parser import parse from enum import Enum @@ -23,6 +20,7 @@ import re import tempfile import io +import uuid from urllib.parse import quote from typing import Tuple, Optional, List, Dict, Union @@ -71,6 +69,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -296,11 +295,24 @@ def response_deserialize( str(response_data.status)[0] + "XX", None ) + # If the response_type has not matched (eg. did not match the previous if statements) and the default response is available, use it. + if ( + response_type is None + and str(response_data.status) not in response_types_map + and ( + not isinstance(response_data.status, int) + or not 100 <= response_data.status <= 599 + or str(response_data.status)[0] + "XX" not in response_types_map + ) + and "default" in response_types_map + ): + response_type = response_types_map["default"] + # deserialize response data response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "io.IOBase": return_data = self.__bytearray_to_iobase(response_data) @@ -308,7 +320,7 @@ def response_deserialize( return_data = self.__deserialize_file(response_data) elif response_type is not None: match = None - content_type = response_data.getheader("content-type") + content_type = response_data.headers.get("content-type") if content_type is not None: match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) encoding = match.group(1) if match else "utf-8" @@ -327,7 +339,7 @@ def response_deserialize( return ApiResponse( status_code=response_data.status, data=return_data, - headers=response_data.getheaders(), + headers=response_data.headers, raw_data=response_data.data, ) @@ -355,6 +367,8 @@ def sanitize_for_serialization(self, obj): return obj.get_secret_value() elif isinstance(obj, self.PRIMITIVE_TYPES): return obj + elif isinstance(obj, uuid.UUID): + return str(obj) elif isinstance(obj, list): return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj] elif isinstance(obj, tuple): @@ -363,23 +377,22 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return { + key: self.sanitize_for_serialization(val) for key, val in obj.items() + } + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ + obj_dict = obj.__dict__ - return { - key: self.sanitize_for_serialization(val) for key, val in obj_dict.items() - } + return self.sanitize_for_serialization(obj_dict) def deserialize( self, response_text: str, response_type: str, content_type: Optional[str] @@ -401,7 +414,7 @@ def deserialize( except ValueError: data = response_text elif re.match( - r"^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)", + r"^application/(json|[\w!#$&.+\-^_]+\+json)\s*(;|$)", content_type, re.IGNORECASE, ): @@ -430,6 +443,12 @@ def __deserialize(self, data, klass): return None if isinstance(klass, str): + if klass.startswith("Optional["): + m = re.match(r"Optional\[(.*)]", klass) + assert m is not None, "Malformed Optional type definition" + # data is not None here, so the optionality is already resolved + return self.__deserialize(data, m.group(1)) + if klass.startswith("List["): m = re.match(r"List\[(.*)]", klass) assert m is not None, "Malformed List type definition" @@ -450,14 +469,16 @@ def __deserialize(self, data, klass): if klass in self.PRIMITIVE_TYPES: return self.__deserialize_primitive(data, klass) - elif klass == object: + elif klass is object: return self.__deserialize_object(data) - elif klass == datetime.date: + elif klass is datetime.date: return self.__deserialize_date(data) - elif klass == datetime.datetime: + elif klass is datetime.datetime: return self.__deserialize_datetime(data) - elif klass == decimal.Decimal: + elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: @@ -474,10 +495,15 @@ def parameters_to_tuples(self, params, collection_formats): if collection_formats is None: collection_formats = {} for k, v in params.items() if isinstance(params, dict) else params: + if isinstance(v, bool): + v = str(v).lower() if k in collection_formats: collection_format = collection_formats[k] if collection_format == "multi": - new_params.extend((k, value) for value in v) + new_params.extend( + (k, str(value).lower() if isinstance(value, bool) else value) + for value in v + ) else: if collection_format == "ssv": delimiter = " " @@ -487,11 +513,35 @@ def parameters_to_tuples(self, params, collection_formats): delimiter = "|" else: # csv is the default delimiter = "," - new_params.append((k, delimiter.join(str(value) for value in v))) + new_params.append( + ( + k, + delimiter.join( + ( + str(value).lower() + if isinstance(value, bool) + else str(value) + ) + for value in v + ), + ) + ) else: new_params.append((k, v)) return new_params + def explode_query_object(self, name, obj): + """form style, explode: one query parameter per entry, keyed by the property name; a list repeats the name, None is left out""" + obj = self.sanitize_for_serialization(obj) + if not isinstance(obj, dict): + obj = {name: obj} + return [ + (k, item) + for k, v in obj.items() + for item in (v if isinstance(v, (list, tuple)) else [v]) + if item is not None + ] + def parameters_to_url_query(self, params, collection_formats): """Get parameters as list of tuples, formatting collections. @@ -510,10 +560,21 @@ def parameters_to_url_query(self, params, collection_formats): if isinstance(v, dict): v = json.dumps(v) - if k in collection_formats: + # a collection format applies only to a list; an exploded entry may share a declared array parameter's name + if k in collection_formats and isinstance(v, (list, tuple)): collection_format = collection_formats[k] if collection_format == "multi": - new_params.extend((k, quote(str(value))) for value in v) + new_params.extend( + ( + quote(str(k)), + quote( + str(value).lower() + if isinstance(value, bool) + else str(value) + ), + ) + for value in v + ) else: if collection_format == "ssv": delimiter = " " @@ -524,10 +585,21 @@ def parameters_to_url_query(self, params, collection_formats): else: # csv is the default delimiter = "," new_params.append( - (k, delimiter.join(quote(str(value)) for value in v)) + ( + quote(str(k)), + delimiter.join( + quote( + str(value).lower() + if isinstance(value, bool) + else str(value) + ) + for value in v + ), + ) ) else: - new_params.append((k, quote(str(v)))) + # names are quoted too: an exploded object's names are runtime data + new_params.append((quote(str(k)), quote(str(v)))) return "&".join(["=".join(map(str, item)) for item in new_params]) @@ -656,7 +728,15 @@ def _apply_auth_params( :param auth_setting: auth settings for the endpoint """ if auth_setting["in"] == "cookie": - headers["Cookie"] = auth_setting["value"] + if not "Cookie" in headers: + headers["Cookie"] = "" + else: + headers["Cookie"] += "; " + # Account for cookie value containing spaces and special characters, excluding base64 delimiters + cookie_value = quote( + str(auth_setting["value"]), safe="!#$%&'()*+-./:<=>?@[]^_`{|}~%+/=" + ) + headers["Cookie"] += f"{auth_setting['key']}={cookie_value}" elif auth_setting["in"] == "header": if auth_setting["type"] != "http-signature": headers[auth_setting["key"]] = auth_setting["value"] @@ -681,11 +761,13 @@ def __deserialize_file(self, response): os.close(fd) os.remove(path) - content_disposition = response.getheader("Content-Disposition") + content_disposition = response.headers.get("Content-Disposition") if content_disposition: m = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition) assert m is not None, "Unexpected 'content-disposition' header value" - filename = m.group(1) + filename = os.path.basename(m.group(1)) # Strip any directory traversal + if filename in ("", ".", ".."): # fall back to tmp filename + filename = os.path.basename(path) path = os.path.join(os.path.dirname(path), filename) with open(path, "wb") as f: diff --git a/sdks/python/dropbox_sign/configuration.py b/sdks/python/dropbox_sign/configuration.py index 15be2f037..088b9f68f 100644 --- a/sdks/python/dropbox_sign/configuration.py +++ b/sdks/python/dropbox_sign/configuration.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ Dropbox Sign API @@ -12,14 +10,16 @@ Do not edit the class manually. """ # noqa: E501 - import copy import http.client as httplib import logging from logging import FileHandler import multiprocessing +import ssl import sys from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union +from urllib.parse import urlparse +from urllib.request import getproxies from typing_extensions import NotRequired, Self import urllib3 @@ -167,11 +167,27 @@ class Configuration: string values to replace variables in templated server configuration. The validation of enums is performed for variables with defined enum values before. + :param verify_ssl: bool - Set this to false to skip verifying SSL certificate + when calling API from https server. :param ssl_ca_cert: str - the path to a file of concatenated CA certificates in PEM format. - :param retries: Number of retries for API requests. + :param retries: int | urllib3.util.retry.Retry - Retry configuration. :param ca_cert_data: verify the peer using concatenated CA certificate data in PEM (str) or DER (bytes) format. + :param cert_file: the path to a client certificate file, for mTLS. + :param key_file: the path to a client key file, for mTLS. + :param assert_hostname: Set this to True/False to enable/disable SSL hostname verification. + :param tls_server_name: SSL/TLS Server Name Indication (SNI). Set this to the SNI value expected by the server. + :param connection_pool_maxsize: Connection pool max size. None in the constructor is coerced to 100 for async and cpu_count * 5 for sync. + :param proxy: Proxy URL. + :param no_proxy: Comma-separated hosts that bypass the proxy. + :param proxy_headers: Proxy headers. + :param proxy_ssl_context: SSL context used only for the TLS handshake with the proxy itself, independent of the destination TLS settings. + :param safe_chars_for_path_param: Safe characters for path parameter encoding. + :param client_side_validation: Enable client-side validation. Default True. + :param socket_options: Options to pass down to the underlying urllib3 socket. + :param datetime_format: Datetime format string for serialization. + :param date_format: Date format string for serialization. :Example: @@ -207,8 +223,23 @@ def __init__( server_operation_variables: Optional[Dict[int, ServerVariablesT]] = None, ignore_operation_servers: bool = False, ssl_ca_cert: Optional[str] = None, - retries: Optional[int] = None, + retries: Optional[Union[int, urllib3.util.retry.Retry]] = None, ca_cert_data: Optional[Union[str, bytes]] = None, + cert_file: Optional[str] = None, + key_file: Optional[str] = None, + verify_ssl: bool = True, + assert_hostname: Optional[bool] = None, + tls_server_name: Optional[str] = None, + connection_pool_maxsize: Optional[int] = None, + proxy: Optional[str] = None, + no_proxy: Optional[str] = None, + proxy_headers: Optional[Any] = None, + proxy_ssl_context: Optional[ssl.SSLContext] = None, + safe_chars_for_path_param: str = "", + client_side_validation: bool = True, + socket_options: Optional[Any] = None, + datetime_format: str = "%Y-%m-%dT%H:%M:%S.%f%z", + date_format: str = "%Y-%m-%d", *, debug: Optional[bool] = None, ) -> None: @@ -277,7 +308,7 @@ def __init__( """Debug switch """ - self.verify_ssl = True + self.verify_ssl = verify_ssl """SSL/TLS verification Set this to false to skip verifying SSL certificate when calling API from https server. @@ -289,52 +320,70 @@ def __init__( """Set this to verify the peer using PEM (str) or DER (bytes) certificate data. """ - self.cert_file = None + self.cert_file = cert_file """client certificate file """ - self.key_file = None + self.key_file = key_file """client key file """ - self.assert_hostname = None + self.assert_hostname = assert_hostname """Set this to True/False to enable/disable SSL hostname verification. """ - self.tls_server_name = None + self.tls_server_name = tls_server_name """SSL/TLS Server Name Indication (SNI) Set this to the SNI value expected by the server. """ - self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 + self.connection_pool_maxsize = ( + connection_pool_maxsize + if connection_pool_maxsize is not None + else multiprocessing.cpu_count() * 5 + ) """urllib3 connection pool's maximum number of connections saved - per pool. urllib3 uses 1 connection as default value, but this is - not the best value when you are making a lot of possibly parallel - requests to the same host, which is often the case here. - cpu_count * 5 is used as default value to increase performance. - """ - - self.proxy: Optional[str] = None - """Proxy URL - """ - self.proxy_headers = None + per pool. None in the constructor is coerced to cpu_count * 5. + """ + + # urllib3 does not read proxy environment variables itself: + # https://github.com/urllib3/urllib3/issues/1785 + # A proxy taken from the environment is re-resolved when the host is + # assigned; see the host setter. + self._proxy_from_env = proxy is None + if proxy is None or no_proxy is None: + proxies = getproxies() + if proxy is None: + proxy = self._env_proxy(proxies, self.host) + if no_proxy is None: + no_proxy = proxies.get("no") + self._proxy = proxy + self.no_proxy = no_proxy + """Hosts that bypass the proxy + """ + self.proxy_headers = proxy_headers """Proxy headers """ - self.safe_chars_for_path_param = "" + self.proxy_ssl_context = proxy_ssl_context + """SSL context used only for the TLS handshake with the proxy itself + (e.g. an HTTPS CONNECT tunnel), independent of the destination TLS + settings above. + """ + self.safe_chars_for_path_param = safe_chars_for_path_param """Safe chars for path_param """ self.retries = retries - """Adding retries to override urllib3 default value 3 + """Retry configuration """ # Enable client side validation - self.client_side_validation = True + self.client_side_validation = client_side_validation - self.socket_options = None + self.socket_options = socket_options """Options to pass down to the underlying urllib3 socket """ - self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z" + self.datetime_format = datetime_format """datetime format """ - self.date_format = "%Y-%m-%d" + self.date_format = date_format """date format """ @@ -343,13 +392,17 @@ def __deepcopy__(self, memo: Dict[int, Any]) -> Self: result = cls.__new__(cls) memo[id(self)] = result for k, v in self.__dict__.items(): + if k == "proxy_ssl_context": + # ssl.SSLContext holds unpicklable C state and can't be deepcopied. + setattr(result, k, v) + continue if k not in ("logger", "logger_file_handler"): setattr(result, k, copy.deepcopy(v, memo)) # shallow copy of loggers result.logger = copy.copy(self.logger) - # use setters to configure loggers + # use setter to re-create the file handler (excluded from __dict__ copy) result.logger_file = self.logger_file - result.debug = self.debug + return result def __setattr__(self, name: str, value: Any) -> None: @@ -490,7 +543,10 @@ def get_api_key_with_prefix( identifier, self.api_key.get(alias) if alias is not None else None ) if key: - prefix = self.api_key_prefix.get(identifier) + prefix = self.api_key_prefix.get( + identifier, + self.api_key_prefix.get(alias) if alias is not None else None, + ) if prefix: return "%s %s" % (prefix, key) else: @@ -509,6 +565,7 @@ def get_basic_auth_token(self) -> Optional[str]: password = "" if self.password is not None: password = self.password + return urllib3.util.make_headers(basic_auth=username + ":" + password).get( "authorization" ) @@ -595,7 +652,11 @@ def get_host_from_settings( for variable_name, variable in server.get("variables", {}).items(): used_value = variables.get(variable_name, variable["default_value"]) - if "enum_values" in variable and used_value not in variable["enum_values"]: + if ( + "enum_values" in variable + and variable["enum_values"] + and used_value not in variable["enum_values"] + ): raise ValueError( "The variable `{0}` in the host URL has invalid value " "{1}. Must be {2}.".format( @@ -619,3 +680,22 @@ def host(self, value: str) -> None: """Fix base path.""" self._base_path = value self.server_index = None + if self._proxy_from_env: + # the scheme-specific proxy depends on the host, which is + # commonly assigned after construction + self._proxy = self._env_proxy(getproxies(), value) + + @staticmethod + def _env_proxy(proxies: Dict[str, str], host: str) -> Optional[str]: + """Pick the environment proxy that applies to `host`.""" + return proxies.get(urlparse(host).scheme) or proxies.get("all") + + @property + def proxy(self) -> Optional[str]: + """Proxy URL""" + return self._proxy + + @proxy.setter + def proxy(self, value: Optional[str]) -> None: + self._proxy = value + self._proxy_from_env = False diff --git a/sdks/python/dropbox_sign/exceptions.py b/sdks/python/dropbox_sign/exceptions.py index 4395d0c3d..ad136d3ae 100644 --- a/sdks/python/dropbox_sign/exceptions.py +++ b/sdks/python/dropbox_sign/exceptions.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ Dropbox Sign API @@ -132,7 +130,7 @@ def __init__( self.body = http_resp.data.decode("utf-8") except Exception: pass - self.headers = http_resp.getheaders() + self.headers = http_resp.headers @classmethod def from_response( @@ -173,8 +171,11 @@ def __str__(self): if self.headers: error_message += "HTTP response headers: {0}\n".format(self.headers) - if self.data or self.body: - error_message += "HTTP response body: {0}\n".format(self.data or self.body) + if self.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + if self.data: + error_message += "HTTP response data: {0}\n".format(self.data) return error_message diff --git a/sdks/python/dropbox_sign/models/__init__.py b/sdks/python/dropbox_sign/models/__init__.py index fd379ccb5..cea440b4e 100644 --- a/sdks/python/dropbox_sign/models/__init__.py +++ b/sdks/python/dropbox_sign/models/__init__.py @@ -13,7 +13,6 @@ Do not edit the class manually. """ # noqa: E501 - # import models into model package from dropbox_sign.models.account_create_request import AccountCreateRequest from dropbox_sign.models.account_create_response import AccountCreateResponse diff --git a/sdks/python/dropbox_sign/models/account_create_request.py b/sdks/python/dropbox_sign/models/account_create_request.py index 06eb22484..6057cf188 100644 --- a/sdks/python/dropbox_sign/models/account_create_request.py +++ b/sdks/python/dropbox_sign/models/account_create_request.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class AccountCreateRequest(BaseModel): @@ -55,7 +56,8 @@ class AccountCreateRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -67,8 +69,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/account_create_response.py b/sdks/python/dropbox_sign/models/account_create_response.py index 3bcabfd76..2fe87a536 100644 --- a/sdks/python/dropbox_sign/models/account_create_response.py +++ b/sdks/python/dropbox_sign/models/account_create_response.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class AccountCreateResponse(BaseModel): @@ -43,7 +44,8 @@ class AccountCreateResponse(BaseModel): __properties: ClassVar[List[str]] = ["account", "oauth_data", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -102,8 +103,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/account_get_response.py b/sdks/python/dropbox_sign/models/account_get_response.py index 9a12adb80..fec4fba86 100644 --- a/sdks/python/dropbox_sign/models/account_get_response.py +++ b/sdks/python/dropbox_sign/models/account_get_response.py @@ -27,6 +27,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class AccountGetResponse(BaseModel): @@ -41,7 +42,8 @@ class AccountGetResponse(BaseModel): __properties: ClassVar[List[str]] = ["account", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -97,8 +98,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/account_response.py b/sdks/python/dropbox_sign/models/account_response.py index 9f8beb4d2..323d4df51 100644 --- a/sdks/python/dropbox_sign/models/account_response.py +++ b/sdks/python/dropbox_sign/models/account_response.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class AccountResponse(BaseModel): @@ -85,7 +86,8 @@ class AccountResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -97,8 +99,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/account_response_quotas.py b/sdks/python/dropbox_sign/models/account_response_quotas.py index d2b2ffbb0..e4f9aa82b 100644 --- a/sdks/python/dropbox_sign/models/account_response_quotas.py +++ b/sdks/python/dropbox_sign/models/account_response_quotas.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class AccountResponseQuotas(BaseModel): @@ -60,7 +61,8 @@ class AccountResponseQuotas(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -72,8 +74,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/account_response_settings.py b/sdks/python/dropbox_sign/models/account_response_settings.py index 18fbe9844..a72f5f914 100644 --- a/sdks/python/dropbox_sign/models/account_response_settings.py +++ b/sdks/python/dropbox_sign/models/account_response_settings.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class AccountResponseSettings(BaseModel): @@ -51,7 +52,8 @@ class AccountResponseSettings(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -63,8 +65,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/account_response_usage.py b/sdks/python/dropbox_sign/models/account_response_usage.py index 6fc759346..b59c358b7 100644 --- a/sdks/python/dropbox_sign/models/account_response_usage.py +++ b/sdks/python/dropbox_sign/models/account_response_usage.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class AccountResponseUsage(BaseModel): @@ -38,7 +39,8 @@ class AccountResponseUsage(BaseModel): __properties: ClassVar[List[str]] = ["fax_pages_sent"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/account_update_request.py b/sdks/python/dropbox_sign/models/account_update_request.py index a0cafd7c4..a3bcadaf9 100644 --- a/sdks/python/dropbox_sign/models/account_update_request.py +++ b/sdks/python/dropbox_sign/models/account_update_request.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class AccountUpdateRequest(BaseModel): @@ -45,7 +46,8 @@ class AccountUpdateRequest(BaseModel): __properties: ClassVar[List[str]] = ["account_id", "callback_url", "locale"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/account_verify_request.py b/sdks/python/dropbox_sign/models/account_verify_request.py index 39804b0bc..8cc9d5105 100644 --- a/sdks/python/dropbox_sign/models/account_verify_request.py +++ b/sdks/python/dropbox_sign/models/account_verify_request.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class AccountVerifyRequest(BaseModel): @@ -38,7 +39,8 @@ class AccountVerifyRequest(BaseModel): __properties: ClassVar[List[str]] = ["email_address"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/account_verify_response.py b/sdks/python/dropbox_sign/models/account_verify_response.py index 3b0ee8ddf..d67ebd253 100644 --- a/sdks/python/dropbox_sign/models/account_verify_response.py +++ b/sdks/python/dropbox_sign/models/account_verify_response.py @@ -29,6 +29,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class AccountVerifyResponse(BaseModel): @@ -43,7 +44,8 @@ class AccountVerifyResponse(BaseModel): __properties: ClassVar[List[str]] = ["account", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -99,8 +100,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/account_verify_response_account.py b/sdks/python/dropbox_sign/models/account_verify_response_account.py index 98f5fb302..bbda18874 100644 --- a/sdks/python/dropbox_sign/models/account_verify_response_account.py +++ b/sdks/python/dropbox_sign/models/account_verify_response_account.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class AccountVerifyResponseAccount(BaseModel): @@ -38,7 +39,8 @@ class AccountVerifyResponseAccount(BaseModel): __properties: ClassVar[List[str]] = ["email_address"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/api_app_create_request.py b/sdks/python/dropbox_sign/models/api_app_create_request.py index 788c74a23..26989057c 100644 --- a/sdks/python/dropbox_sign/models/api_app_create_request.py +++ b/sdks/python/dropbox_sign/models/api_app_create_request.py @@ -29,6 +29,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class ApiAppCreateRequest(BaseModel): @@ -64,7 +65,8 @@ class ApiAppCreateRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -76,8 +78,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/api_app_get_response.py b/sdks/python/dropbox_sign/models/api_app_get_response.py index 4337be1ee..f9edc93f1 100644 --- a/sdks/python/dropbox_sign/models/api_app_get_response.py +++ b/sdks/python/dropbox_sign/models/api_app_get_response.py @@ -27,6 +27,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class ApiAppGetResponse(BaseModel): @@ -41,7 +42,8 @@ class ApiAppGetResponse(BaseModel): __properties: ClassVar[List[str]] = ["api_app", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -97,8 +98,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/api_app_list_response.py b/sdks/python/dropbox_sign/models/api_app_list_response.py index 98a950e09..5ddb71f39 100644 --- a/sdks/python/dropbox_sign/models/api_app_list_response.py +++ b/sdks/python/dropbox_sign/models/api_app_list_response.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class ApiAppListResponse(BaseModel): @@ -45,7 +46,8 @@ class ApiAppListResponse(BaseModel): __properties: ClassVar[List[str]] = ["api_apps", "list_info", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -98,8 +99,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.api_apps: for _item_api_apps in self.api_apps: - if _item_api_apps: - _items.append(_item_api_apps.to_dict()) + _items.append( + _item_api_apps.to_dict() if _item_api_apps is not None else None + ) _dict["api_apps"] = _items # override the default output from pydantic by calling `to_dict()` of list_info if self.list_info: @@ -108,8 +110,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/api_app_response.py b/sdks/python/dropbox_sign/models/api_app_response.py index ad4e87207..34069805b 100644 --- a/sdks/python/dropbox_sign/models/api_app_response.py +++ b/sdks/python/dropbox_sign/models/api_app_response.py @@ -33,6 +33,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class ApiAppResponse(BaseModel): @@ -74,7 +75,8 @@ class ApiAppResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -86,8 +88,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/api_app_response_o_auth.py b/sdks/python/dropbox_sign/models/api_app_response_o_auth.py index b078c1a71..2644d719d 100644 --- a/sdks/python/dropbox_sign/models/api_app_response_o_auth.py +++ b/sdks/python/dropbox_sign/models/api_app_response_o_auth.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class ApiAppResponseOAuth(BaseModel): @@ -54,7 +55,8 @@ class ApiAppResponseOAuth(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -66,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/api_app_response_options.py b/sdks/python/dropbox_sign/models/api_app_response_options.py index ec34ed913..95e44d7b4 100644 --- a/sdks/python/dropbox_sign/models/api_app_response_options.py +++ b/sdks/python/dropbox_sign/models/api_app_response_options.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class ApiAppResponseOptions(BaseModel): @@ -39,7 +40,8 @@ class ApiAppResponseOptions(BaseModel): __properties: ClassVar[List[str]] = ["can_insert_everywhere"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/api_app_response_owner_account.py b/sdks/python/dropbox_sign/models/api_app_response_owner_account.py index d57994800..3d790dd36 100644 --- a/sdks/python/dropbox_sign/models/api_app_response_owner_account.py +++ b/sdks/python/dropbox_sign/models/api_app_response_owner_account.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class ApiAppResponseOwnerAccount(BaseModel): @@ -41,7 +42,8 @@ class ApiAppResponseOwnerAccount(BaseModel): __properties: ClassVar[List[str]] = ["account_id", "email_address"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/api_app_response_white_labeling_options.py b/sdks/python/dropbox_sign/models/api_app_response_white_labeling_options.py index b5747219c..3434d056e 100644 --- a/sdks/python/dropbox_sign/models/api_app_response_white_labeling_options.py +++ b/sdks/python/dropbox_sign/models/api_app_response_white_labeling_options.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class ApiAppResponseWhiteLabelingOptions(BaseModel): @@ -64,7 +65,8 @@ class ApiAppResponseWhiteLabelingOptions(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -76,8 +78,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/api_app_update_request.py b/sdks/python/dropbox_sign/models/api_app_update_request.py index 7370a7e96..084c86d6d 100644 --- a/sdks/python/dropbox_sign/models/api_app_update_request.py +++ b/sdks/python/dropbox_sign/models/api_app_update_request.py @@ -29,6 +29,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class ApiAppUpdateRequest(BaseModel): @@ -66,7 +67,8 @@ class ApiAppUpdateRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -78,8 +80,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/bulk_send_job_get_response.py b/sdks/python/dropbox_sign/models/bulk_send_job_get_response.py index 9461ccfa6..0a473bb7a 100644 --- a/sdks/python/dropbox_sign/models/bulk_send_job_get_response.py +++ b/sdks/python/dropbox_sign/models/bulk_send_job_get_response.py @@ -31,6 +31,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class BulkSendJobGetResponse(BaseModel): @@ -54,7 +55,8 @@ class BulkSendJobGetResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -66,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -113,15 +114,19 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.signature_requests: for _item_signature_requests in self.signature_requests: - if _item_signature_requests: - _items.append(_item_signature_requests.to_dict()) + _items.append( + _item_signature_requests.to_dict() + if _item_signature_requests is not None + else None + ) _dict["signature_requests"] = _items # override the default output from pydantic by calling `to_dict()` of each item in warnings (list) _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/bulk_send_job_get_response_signature_requests.py b/sdks/python/dropbox_sign/models/bulk_send_job_get_response_signature_requests.py index 704089bef..b37268ae4 100644 --- a/sdks/python/dropbox_sign/models/bulk_send_job_get_response_signature_requests.py +++ b/sdks/python/dropbox_sign/models/bulk_send_job_get_response_signature_requests.py @@ -37,6 +37,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class BulkSendJobGetResponseSignatureRequests(BaseModel): @@ -166,7 +167,8 @@ class BulkSendJobGetResponseSignatureRequests(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -178,8 +180,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -219,29 +220,39 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.custom_fields: for _item_custom_fields in self.custom_fields: - if _item_custom_fields: - _items.append(_item_custom_fields.to_dict()) + _items.append( + _item_custom_fields.to_dict() + if _item_custom_fields is not None + else None + ) _dict["custom_fields"] = _items # override the default output from pydantic by calling `to_dict()` of each item in attachments (list) _items = [] if self.attachments: for _item_attachments in self.attachments: - if _item_attachments: - _items.append(_item_attachments.to_dict()) + _items.append( + _item_attachments.to_dict() + if _item_attachments is not None + else None + ) _dict["attachments"] = _items # override the default output from pydantic by calling `to_dict()` of each item in response_data (list) _items = [] if self.response_data: for _item_response_data in self.response_data: - if _item_response_data: - _items.append(_item_response_data.to_dict()) + _items.append( + _item_response_data.to_dict() + if _item_response_data is not None + else None + ) _dict["response_data"] = _items # override the default output from pydantic by calling `to_dict()` of each item in signatures (list) _items = [] if self.signatures: for _item_signatures in self.signatures: - if _item_signatures: - _items.append(_item_signatures.to_dict()) + _items.append( + _item_signatures.to_dict() if _item_signatures is not None else None + ) _dict["signatures"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/bulk_send_job_list_response.py b/sdks/python/dropbox_sign/models/bulk_send_job_list_response.py index 8f9791880..b1af1ce7e 100644 --- a/sdks/python/dropbox_sign/models/bulk_send_job_list_response.py +++ b/sdks/python/dropbox_sign/models/bulk_send_job_list_response.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class BulkSendJobListResponse(BaseModel): @@ -45,7 +46,8 @@ class BulkSendJobListResponse(BaseModel): __properties: ClassVar[List[str]] = ["bulk_send_jobs", "list_info", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -98,8 +99,11 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.bulk_send_jobs: for _item_bulk_send_jobs in self.bulk_send_jobs: - if _item_bulk_send_jobs: - _items.append(_item_bulk_send_jobs.to_dict()) + _items.append( + _item_bulk_send_jobs.to_dict() + if _item_bulk_send_jobs is not None + else None + ) _dict["bulk_send_jobs"] = _items # override the default output from pydantic by calling `to_dict()` of list_info if self.list_info: @@ -108,8 +112,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/bulk_send_job_response.py b/sdks/python/dropbox_sign/models/bulk_send_job_response.py index 8d6eeeee0..bd0c75e35 100644 --- a/sdks/python/dropbox_sign/models/bulk_send_job_response.py +++ b/sdks/python/dropbox_sign/models/bulk_send_job_response.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class BulkSendJobResponse(BaseModel): @@ -54,7 +55,8 @@ class BulkSendJobResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -66,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/bulk_send_job_send_response.py b/sdks/python/dropbox_sign/models/bulk_send_job_send_response.py index a2eca9737..5ddf8e3ba 100644 --- a/sdks/python/dropbox_sign/models/bulk_send_job_send_response.py +++ b/sdks/python/dropbox_sign/models/bulk_send_job_send_response.py @@ -27,6 +27,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class BulkSendJobSendResponse(BaseModel): @@ -41,7 +42,8 @@ class BulkSendJobSendResponse(BaseModel): __properties: ClassVar[List[str]] = ["bulk_send_job", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -97,8 +98,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/document_field_detection_request.py b/sdks/python/dropbox_sign/models/document_field_detection_request.py index 7c501fc01..762c95d36 100644 --- a/sdks/python/dropbox_sign/models/document_field_detection_request.py +++ b/sdks/python/dropbox_sign/models/document_field_detection_request.py @@ -33,6 +33,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class DocumentFieldDetectionRequest(BaseModel): @@ -56,6 +57,7 @@ class DocumentFieldDetectionRequest(BaseModel): page_range: Optional[Annotated[str, Field(strict=True)]] = Field( default=None, description="The zero-based page indexes to analyze. Accepts `all`, individual pages, inclusive ranges, or comma-separated combinations, such as `0-2,5,7-9`. Defaults to `all`.", + json_schema_extra={"examples": ["0-2,5,7-9"]}, ) __properties: ClassVar[List[str]] = [ "detection_mode", @@ -64,20 +66,23 @@ class DocumentFieldDetectionRequest(BaseModel): "page_range", ] - @field_validator("page_range") + @field_validator("page_range", mode="before") def page_range_validate_regular_expression(cls, value): """Validates the regular expression""" if value is None: return value - if not re.match(r"^(?:all|\d+(?:-\d+)?(?:,\d+(?:-\d+)?)*)$", value): + if isinstance(value, str) and not re.match( + r"^(?:all|\d+(?:-\d+)?(?:,\d+(?:-\d+)?)*)$", value + ): raise ValueError( r"must validate the regular expression /^(?:all|\d+(?:-\d+)?(?:,\d+(?:-\d+)?)*)$/" ) return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -89,8 +94,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/document_field_detection_response.py b/sdks/python/dropbox_sign/models/document_field_detection_response.py index c20a6a887..e3ca0aeeb 100644 --- a/sdks/python/dropbox_sign/models/document_field_detection_response.py +++ b/sdks/python/dropbox_sign/models/document_field_detection_response.py @@ -29,6 +29,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class DocumentFieldDetectionResponse(BaseModel): @@ -43,7 +44,8 @@ class DocumentFieldDetectionResponse(BaseModel): __properties: ClassVar[List[str]] = ["detection_result", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -99,8 +100,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/document_field_detection_response_detection_result.py b/sdks/python/dropbox_sign/models/document_field_detection_response_detection_result.py index e242b0859..08612697d 100644 --- a/sdks/python/dropbox_sign/models/document_field_detection_response_detection_result.py +++ b/sdks/python/dropbox_sign/models/document_field_detection_response_detection_result.py @@ -32,6 +32,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class DocumentFieldDetectionResponseDetectionResult(BaseModel): @@ -49,7 +50,8 @@ class DocumentFieldDetectionResponseDetectionResult(BaseModel): description="The total number of pages in the document." ) pages_analyzed: StrictStr = Field( - description="The zero-based page indexes analyzed, represented by the requested `page_range`, or `all` when every page was analyzed." + description="The zero-based page indexes analyzed, represented by the requested `page_range`, or `all` when every page was analyzed.", + json_schema_extra={"examples": ["all"]}, ) detected_at: StrictInt = Field( description="The Unix timestamp when the field detection result was generated." @@ -83,7 +85,8 @@ class DocumentFieldDetectionResponseDetectionResult(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -95,8 +98,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -136,29 +138,37 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.form_fields_per_document: for _item_form_fields_per_document in self.form_fields_per_document: - if _item_form_fields_per_document: - _items.append(_item_form_fields_per_document.to_dict()) + _items.append( + _item_form_fields_per_document.to_dict() + if _item_form_fields_per_document is not None + else None + ) _dict["form_fields_per_document"] = _items # override the default output from pydantic by calling `to_dict()` of each item in form_field_groups (list) _items = [] if self.form_field_groups: for _item_form_field_groups in self.form_field_groups: - if _item_form_field_groups: - _items.append(_item_form_field_groups.to_dict()) + _items.append( + _item_form_field_groups.to_dict() + if _item_form_field_groups is not None + else None + ) _dict["form_field_groups"] = _items # override the default output from pydantic by calling `to_dict()` of each item in warnings (list) _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items # override the default output from pydantic by calling `to_dict()` of each item in errors (list) _items = [] if self.errors: for _item_errors in self.errors: - if _item_errors: - _items.append(_item_errors.to_dict()) + _items.append( + _item_errors.to_dict() if _item_errors is not None else None + ) _dict["errors"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/embedded_edit_url_request.py b/sdks/python/dropbox_sign/models/embedded_edit_url_request.py index 849ebf426..5f4c005ef 100644 --- a/sdks/python/dropbox_sign/models/embedded_edit_url_request.py +++ b/sdks/python/dropbox_sign/models/embedded_edit_url_request.py @@ -27,6 +27,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class EmbeddedEditUrlRequest(BaseModel): @@ -85,7 +86,8 @@ class EmbeddedEditUrlRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -97,8 +99,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -141,8 +142,11 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.merge_fields: for _item_merge_fields in self.merge_fields: - if _item_merge_fields: - _items.append(_item_merge_fields.to_dict()) + _items.append( + _item_merge_fields.to_dict() + if _item_merge_fields is not None + else None + ) _dict["merge_fields"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/embedded_edit_url_response.py b/sdks/python/dropbox_sign/models/embedded_edit_url_response.py index 653ca7c2c..9be65f56c 100644 --- a/sdks/python/dropbox_sign/models/embedded_edit_url_response.py +++ b/sdks/python/dropbox_sign/models/embedded_edit_url_response.py @@ -29,6 +29,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class EmbeddedEditUrlResponse(BaseModel): @@ -43,7 +44,8 @@ class EmbeddedEditUrlResponse(BaseModel): __properties: ClassVar[List[str]] = ["embedded", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -99,8 +100,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/embedded_edit_url_response_embedded.py b/sdks/python/dropbox_sign/models/embedded_edit_url_response_embedded.py index 67413cb9a..c8e252603 100644 --- a/sdks/python/dropbox_sign/models/embedded_edit_url_response_embedded.py +++ b/sdks/python/dropbox_sign/models/embedded_edit_url_response_embedded.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class EmbeddedEditUrlResponseEmbedded(BaseModel): @@ -42,7 +43,8 @@ class EmbeddedEditUrlResponseEmbedded(BaseModel): __properties: ClassVar[List[str]] = ["edit_url", "expires_at"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/embedded_sign_url_response.py b/sdks/python/dropbox_sign/models/embedded_sign_url_response.py index f0e03a177..8a9bfbd95 100644 --- a/sdks/python/dropbox_sign/models/embedded_sign_url_response.py +++ b/sdks/python/dropbox_sign/models/embedded_sign_url_response.py @@ -29,6 +29,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class EmbeddedSignUrlResponse(BaseModel): @@ -43,7 +44,8 @@ class EmbeddedSignUrlResponse(BaseModel): __properties: ClassVar[List[str]] = ["embedded", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -99,8 +100,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/embedded_sign_url_response_embedded.py b/sdks/python/dropbox_sign/models/embedded_sign_url_response_embedded.py index dc7145702..dea6e9744 100644 --- a/sdks/python/dropbox_sign/models/embedded_sign_url_response_embedded.py +++ b/sdks/python/dropbox_sign/models/embedded_sign_url_response_embedded.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class EmbeddedSignUrlResponseEmbedded(BaseModel): @@ -42,7 +43,8 @@ class EmbeddedSignUrlResponseEmbedded(BaseModel): __properties: ClassVar[List[str]] = ["sign_url", "expires_at"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/error_response.py b/sdks/python/dropbox_sign/models/error_response.py index 98c6e5a90..023126401 100644 --- a/sdks/python/dropbox_sign/models/error_response.py +++ b/sdks/python/dropbox_sign/models/error_response.py @@ -26,6 +26,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class ErrorResponse(BaseModel): @@ -37,7 +38,8 @@ class ErrorResponse(BaseModel): __properties: ClassVar[List[str]] = ["error"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/error_response_error.py b/sdks/python/dropbox_sign/models/error_response_error.py index b8b0a47a1..f8156a697 100644 --- a/sdks/python/dropbox_sign/models/error_response_error.py +++ b/sdks/python/dropbox_sign/models/error_response_error.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class ErrorResponseError(BaseModel): @@ -42,7 +43,8 @@ class ErrorResponseError(BaseModel): __properties: ClassVar[List[str]] = ["error_msg", "error_name", "error_path"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/event_callback_request.py b/sdks/python/dropbox_sign/models/event_callback_request.py index f8ac8473d..0086cc510 100644 --- a/sdks/python/dropbox_sign/models/event_callback_request.py +++ b/sdks/python/dropbox_sign/models/event_callback_request.py @@ -29,6 +29,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class EventCallbackRequest(BaseModel): @@ -48,7 +49,8 @@ class EventCallbackRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -60,8 +62,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/event_callback_request_event.py b/sdks/python/dropbox_sign/models/event_callback_request_event.py index adada9bea..e0846fd35 100644 --- a/sdks/python/dropbox_sign/models/event_callback_request_event.py +++ b/sdks/python/dropbox_sign/models/event_callback_request_event.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class EventCallbackRequestEvent(BaseModel): @@ -95,7 +96,8 @@ def event_type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -107,8 +109,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/event_callback_request_event_metadata.py b/sdks/python/dropbox_sign/models/event_callback_request_event_metadata.py index fee5309d9..bb75aae27 100644 --- a/sdks/python/dropbox_sign/models/event_callback_request_event_metadata.py +++ b/sdks/python/dropbox_sign/models/event_callback_request_event_metadata.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class EventCallbackRequestEventMetadata(BaseModel): @@ -54,7 +55,8 @@ class EventCallbackRequestEventMetadata(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -66,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/fax_get_response.py b/sdks/python/dropbox_sign/models/fax_get_response.py index 25bf9d2fd..a706fa9e5 100644 --- a/sdks/python/dropbox_sign/models/fax_get_response.py +++ b/sdks/python/dropbox_sign/models/fax_get_response.py @@ -27,6 +27,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class FaxGetResponse(BaseModel): @@ -41,7 +42,8 @@ class FaxGetResponse(BaseModel): __properties: ClassVar[List[str]] = ["fax", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -97,8 +98,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/fax_line_add_user_request.py b/sdks/python/dropbox_sign/models/fax_line_add_user_request.py index 7a7a92b60..2d1f16429 100644 --- a/sdks/python/dropbox_sign/models/fax_line_add_user_request.py +++ b/sdks/python/dropbox_sign/models/fax_line_add_user_request.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class FaxLineAddUserRequest(BaseModel): @@ -33,14 +34,19 @@ class FaxLineAddUserRequest(BaseModel): """ # noqa: E501 number: StrictStr = Field(description="The Fax Line number") - account_id: Optional[StrictStr] = Field(default=None, description="Account ID") + account_id: Optional[StrictStr] = Field( + default=None, + description="Account ID", + json_schema_extra={"examples": ["ab55cd14a97219e36b5ff5fe23f2f9329b0c1e97"]}, + ) email_address: Optional[StrictStr] = Field( default=None, description="Email address" ) __properties: ClassVar[List[str]] = ["number", "account_id", "email_address"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -52,8 +58,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/fax_line_area_code_get_response.py b/sdks/python/dropbox_sign/models/fax_line_area_code_get_response.py index 4d41c9b56..3fac42946 100644 --- a/sdks/python/dropbox_sign/models/fax_line_area_code_get_response.py +++ b/sdks/python/dropbox_sign/models/fax_line_area_code_get_response.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class FaxLineAreaCodeGetResponse(BaseModel): @@ -36,7 +37,8 @@ class FaxLineAreaCodeGetResponse(BaseModel): __properties: ClassVar[List[str]] = ["area_codes"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/fax_line_create_request.py b/sdks/python/dropbox_sign/models/fax_line_create_request.py index 7a8d88c34..14c696a42 100644 --- a/sdks/python/dropbox_sign/models/fax_line_create_request.py +++ b/sdks/python/dropbox_sign/models/fax_line_create_request.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class FaxLineCreateRequest(BaseModel): @@ -38,6 +39,7 @@ class FaxLineCreateRequest(BaseModel): account_id: Optional[StrictStr] = Field( default=None, description="Account ID of the account that will be assigned this new Fax Line", + json_schema_extra={"examples": ["ab55cd14a97219e36b5ff5fe23f2f9329b0c1e97"]}, ) __properties: ClassVar[List[str]] = ["area_code", "country", "city", "account_id"] @@ -49,7 +51,8 @@ def country_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -61,8 +64,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/fax_line_delete_request.py b/sdks/python/dropbox_sign/models/fax_line_delete_request.py index 9e966098b..4ff0f3c0f 100644 --- a/sdks/python/dropbox_sign/models/fax_line_delete_request.py +++ b/sdks/python/dropbox_sign/models/fax_line_delete_request.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class FaxLineDeleteRequest(BaseModel): @@ -36,7 +37,8 @@ class FaxLineDeleteRequest(BaseModel): __properties: ClassVar[List[str]] = ["number"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/fax_line_list_response.py b/sdks/python/dropbox_sign/models/fax_line_list_response.py index 07581a37e..d559f8b69 100644 --- a/sdks/python/dropbox_sign/models/fax_line_list_response.py +++ b/sdks/python/dropbox_sign/models/fax_line_list_response.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class FaxLineListResponse(BaseModel): @@ -41,7 +42,8 @@ class FaxLineListResponse(BaseModel): __properties: ClassVar[List[str]] = ["list_info", "fax_lines", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -97,8 +98,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.fax_lines: for _item_fax_lines in self.fax_lines: - if _item_fax_lines: - _items.append(_item_fax_lines.to_dict()) + _items.append( + _item_fax_lines.to_dict() if _item_fax_lines is not None else None + ) _dict["fax_lines"] = _items # override the default output from pydantic by calling `to_dict()` of warnings if self.warnings: diff --git a/sdks/python/dropbox_sign/models/fax_line_remove_user_request.py b/sdks/python/dropbox_sign/models/fax_line_remove_user_request.py index 6021a0c84..458afdf53 100644 --- a/sdks/python/dropbox_sign/models/fax_line_remove_user_request.py +++ b/sdks/python/dropbox_sign/models/fax_line_remove_user_request.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class FaxLineRemoveUserRequest(BaseModel): @@ -34,7 +35,9 @@ class FaxLineRemoveUserRequest(BaseModel): number: StrictStr = Field(description="The Fax Line number") account_id: Optional[StrictStr] = Field( - default=None, description="Account ID of the user to remove access" + default=None, + description="Account ID of the user to remove access", + json_schema_extra={"examples": ["ab55cd14a97219e36b5ff5fe23f2f9329b0c1e97"]}, ) email_address: Optional[StrictStr] = Field( default=None, description="Email address of the user to remove access" @@ -42,7 +45,8 @@ class FaxLineRemoveUserRequest(BaseModel): __properties: ClassVar[List[str]] = ["number", "account_id", "email_address"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -54,8 +58,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/fax_line_response.py b/sdks/python/dropbox_sign/models/fax_line_response.py index bb733f4da..f14456928 100644 --- a/sdks/python/dropbox_sign/models/fax_line_response.py +++ b/sdks/python/dropbox_sign/models/fax_line_response.py @@ -27,6 +27,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class FaxLineResponse(BaseModel): @@ -39,7 +40,8 @@ class FaxLineResponse(BaseModel): __properties: ClassVar[List[str]] = ["fax_line", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/fax_line_response_fax_line.py b/sdks/python/dropbox_sign/models/fax_line_response_fax_line.py index 8a0676cbe..d09fddf38 100644 --- a/sdks/python/dropbox_sign/models/fax_line_response_fax_line.py +++ b/sdks/python/dropbox_sign/models/fax_line_response_fax_line.py @@ -26,6 +26,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class FaxLineResponseFaxLine(BaseModel): @@ -45,7 +46,8 @@ class FaxLineResponseFaxLine(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -98,8 +99,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.accounts: for _item_accounts in self.accounts: - if _item_accounts: - _items.append(_item_accounts.to_dict()) + _items.append( + _item_accounts.to_dict() if _item_accounts is not None else None + ) _dict["accounts"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/fax_list_response.py b/sdks/python/dropbox_sign/models/fax_list_response.py index 99140e3c0..97c6e1995 100644 --- a/sdks/python/dropbox_sign/models/fax_list_response.py +++ b/sdks/python/dropbox_sign/models/fax_list_response.py @@ -27,6 +27,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class FaxListResponse(BaseModel): @@ -39,7 +40,8 @@ class FaxListResponse(BaseModel): __properties: ClassVar[List[str]] = ["faxes", "list_info"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -92,8 +93,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.faxes: for _item_faxes in self.faxes: - if _item_faxes: - _items.append(_item_faxes.to_dict()) + _items.append( + _item_faxes.to_dict() if _item_faxes is not None else None + ) _dict["faxes"] = _items # override the default output from pydantic by calling `to_dict()` of list_info if self.list_info: diff --git a/sdks/python/dropbox_sign/models/fax_response.py b/sdks/python/dropbox_sign/models/fax_response.py index 2fab76f4d..360dfe3cb 100644 --- a/sdks/python/dropbox_sign/models/fax_response.py +++ b/sdks/python/dropbox_sign/models/fax_response.py @@ -26,6 +26,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class FaxResponse(BaseModel): @@ -68,7 +69,8 @@ class FaxResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -80,8 +82,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -121,8 +122,11 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.transmissions: for _item_transmissions in self.transmissions: - if _item_transmissions: - _items.append(_item_transmissions.to_dict()) + _items.append( + _item_transmissions.to_dict() + if _item_transmissions is not None + else None + ) _dict["transmissions"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/fax_response_transmission.py b/sdks/python/dropbox_sign/models/fax_response_transmission.py index 66c613dd2..2ae3ed7cb 100644 --- a/sdks/python/dropbox_sign/models/fax_response_transmission.py +++ b/sdks/python/dropbox_sign/models/fax_response_transmission.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class FaxResponseTransmission(BaseModel): @@ -60,7 +61,8 @@ def status_code_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -72,8 +74,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/fax_send_request.py b/sdks/python/dropbox_sign/models/fax_send_request.py index c4f0af8c1..ac2b1527c 100644 --- a/sdks/python/dropbox_sign/models/fax_send_request.py +++ b/sdks/python/dropbox_sign/models/fax_send_request.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class FaxSendRequest(BaseModel): @@ -33,10 +34,13 @@ class FaxSendRequest(BaseModel): """ # noqa: E501 recipient: StrictStr = Field( - description="Recipient of the fax Can be a phone number in E.164 format or email address" + description="Recipient of the fax Can be a phone number in E.164 format or email address", + json_schema_extra={"examples": ["recipient@example.com"]}, ) sender: Optional[StrictStr] = Field( - default=None, description="Fax Send From Sender (used only with fax number)" + default=None, + description="Fax Send From Sender (used only with fax number)", + json_schema_extra={"examples": ["sender@example.com"]}, ) files: Optional[ List[Union[StrictBytes, StrictStr, io.IOBase, Tuple[StrictStr, StrictBytes, io.IOBase]]] @@ -52,15 +56,25 @@ class FaxSendRequest(BaseModel): default=False, description="API Test Mode Setting" ) cover_page_to: Optional[StrictStr] = Field( - default=None, description="Fax cover page recipient information" + default=None, + description="Fax cover page recipient information", + json_schema_extra={"examples": ["Recipient Name"]}, ) cover_page_from: Optional[StrictStr] = Field( - default=None, description="Fax cover page sender information" + default=None, + description="Fax cover page sender information", + json_schema_extra={"examples": ["Sender Name"]}, ) cover_page_message: Optional[StrictStr] = Field( - default=None, description="Fax Cover Page Message" + default=None, + description="Fax Cover Page Message", + json_schema_extra={"examples": ["Please find the attached documents."]}, + ) + title: Optional[StrictStr] = Field( + default=None, + description="Fax Title", + json_schema_extra={"examples": ["Fax Title"]}, ) - title: Optional[StrictStr] = Field(default=None, description="Fax Title") __properties: ClassVar[List[str]] = [ "recipient", "sender", @@ -74,7 +88,8 @@ class FaxSendRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -86,8 +101,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/file_response.py b/sdks/python/dropbox_sign/models/file_response.py index 434a4f1be..14b676db4 100644 --- a/sdks/python/dropbox_sign/models/file_response.py +++ b/sdks/python/dropbox_sign/models/file_response.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class FileResponse(BaseModel): @@ -37,7 +38,8 @@ class FileResponse(BaseModel): __properties: ClassVar[List[str]] = ["file_url", "expires_at"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/file_response_data_uri.py b/sdks/python/dropbox_sign/models/file_response_data_uri.py index da1384d66..303191db6 100644 --- a/sdks/python/dropbox_sign/models/file_response_data_uri.py +++ b/sdks/python/dropbox_sign/models/file_response_data_uri.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class FileResponseDataUri(BaseModel): @@ -36,7 +37,8 @@ class FileResponseDataUri(BaseModel): __properties: ClassVar[List[str]] = ["data_uri"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/list_info_response.py b/sdks/python/dropbox_sign/models/list_info_response.py index cdca4fa28..e5f87fffe 100644 --- a/sdks/python/dropbox_sign/models/list_info_response.py +++ b/sdks/python/dropbox_sign/models/list_info_response.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class ListInfoResponse(BaseModel): @@ -52,7 +53,8 @@ class ListInfoResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -64,8 +66,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/o_auth_token_generate_request.py b/sdks/python/dropbox_sign/models/o_auth_token_generate_request.py index 06359f488..4feb6bc2f 100644 --- a/sdks/python/dropbox_sign/models/o_auth_token_generate_request.py +++ b/sdks/python/dropbox_sign/models/o_auth_token_generate_request.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class OAuthTokenGenerateRequest(BaseModel): @@ -52,7 +53,8 @@ class OAuthTokenGenerateRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -64,8 +66,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/o_auth_token_refresh_request.py b/sdks/python/dropbox_sign/models/o_auth_token_refresh_request.py index 7a1aa9ae1..365c0c2d5 100644 --- a/sdks/python/dropbox_sign/models/o_auth_token_refresh_request.py +++ b/sdks/python/dropbox_sign/models/o_auth_token_refresh_request.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class OAuthTokenRefreshRequest(BaseModel): @@ -54,7 +55,8 @@ class OAuthTokenRefreshRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -66,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/o_auth_token_response.py b/sdks/python/dropbox_sign/models/o_auth_token_response.py index 4b91161f4..ebb7fd86a 100644 --- a/sdks/python/dropbox_sign/models/o_auth_token_response.py +++ b/sdks/python/dropbox_sign/models/o_auth_token_response.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class OAuthTokenResponse(BaseModel): @@ -49,7 +50,8 @@ class OAuthTokenResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -61,8 +63,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/report_create_request.py b/sdks/python/dropbox_sign/models/report_create_request.py index ec6afec9c..e45ac6047 100644 --- a/sdks/python/dropbox_sign/models/report_create_request.py +++ b/sdks/python/dropbox_sign/models/report_create_request.py @@ -26,6 +26,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class ReportCreateRequest(BaseModel): @@ -57,7 +58,8 @@ def report_type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -69,8 +71,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/report_create_response.py b/sdks/python/dropbox_sign/models/report_create_response.py index 3d781b9bd..ff964c234 100644 --- a/sdks/python/dropbox_sign/models/report_create_response.py +++ b/sdks/python/dropbox_sign/models/report_create_response.py @@ -27,6 +27,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class ReportCreateResponse(BaseModel): @@ -41,7 +42,8 @@ class ReportCreateResponse(BaseModel): __properties: ClassVar[List[str]] = ["report", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -97,8 +98,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/report_response.py b/sdks/python/dropbox_sign/models/report_response.py index b3ed31ee4..a81973609 100644 --- a/sdks/python/dropbox_sign/models/report_response.py +++ b/sdks/python/dropbox_sign/models/report_response.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class ReportResponse(BaseModel): @@ -71,7 +72,8 @@ def report_type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -83,8 +85,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/signature_request_bulk_create_embedded_with_template_request.py b/sdks/python/dropbox_sign/models/signature_request_bulk_create_embedded_with_template_request.py index b1558bcc3..d20c66b06 100644 --- a/sdks/python/dropbox_sign/models/signature_request_bulk_create_embedded_with_template_request.py +++ b/sdks/python/dropbox_sign/models/signature_request_bulk_create_embedded_with_template_request.py @@ -37,6 +37,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestBulkCreateEmbeddedWithTemplateRequest(BaseModel): @@ -118,7 +119,8 @@ class SignatureRequestBulkCreateEmbeddedWithTemplateRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -130,8 +132,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -171,22 +172,27 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.signer_list: for _item_signer_list in self.signer_list: - if _item_signer_list: - _items.append(_item_signer_list.to_dict()) + _items.append( + _item_signer_list.to_dict() + if _item_signer_list is not None + else None + ) _dict["signer_list"] = _items # override the default output from pydantic by calling `to_dict()` of each item in ccs (list) _items = [] if self.ccs: for _item_ccs in self.ccs: - if _item_ccs: - _items.append(_item_ccs.to_dict()) + _items.append(_item_ccs.to_dict() if _item_ccs is not None else None) _dict["ccs"] = _items # override the default output from pydantic by calling `to_dict()` of each item in custom_fields (list) _items = [] if self.custom_fields: for _item_custom_fields in self.custom_fields: - if _item_custom_fields: - _items.append(_item_custom_fields.to_dict()) + _items.append( + _item_custom_fields.to_dict() + if _item_custom_fields is not None + else None + ) _dict["custom_fields"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/signature_request_bulk_send_with_template_request.py b/sdks/python/dropbox_sign/models/signature_request_bulk_send_with_template_request.py index 80abb08a6..915d0f0b1 100644 --- a/sdks/python/dropbox_sign/models/signature_request_bulk_send_with_template_request.py +++ b/sdks/python/dropbox_sign/models/signature_request_bulk_send_with_template_request.py @@ -37,6 +37,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestBulkSendWithTemplateRequest(BaseModel): @@ -119,7 +120,8 @@ class SignatureRequestBulkSendWithTemplateRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -131,8 +133,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -172,22 +173,27 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.signer_list: for _item_signer_list in self.signer_list: - if _item_signer_list: - _items.append(_item_signer_list.to_dict()) + _items.append( + _item_signer_list.to_dict() + if _item_signer_list is not None + else None + ) _dict["signer_list"] = _items # override the default output from pydantic by calling `to_dict()` of each item in ccs (list) _items = [] if self.ccs: for _item_ccs in self.ccs: - if _item_ccs: - _items.append(_item_ccs.to_dict()) + _items.append(_item_ccs.to_dict() if _item_ccs is not None else None) _dict["ccs"] = _items # override the default output from pydantic by calling `to_dict()` of each item in custom_fields (list) _items = [] if self.custom_fields: for _item_custom_fields in self.custom_fields: - if _item_custom_fields: - _items.append(_item_custom_fields.to_dict()) + _items.append( + _item_custom_fields.to_dict() + if _item_custom_fields is not None + else None + ) _dict["custom_fields"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/signature_request_create_embedded_request.py b/sdks/python/dropbox_sign/models/signature_request_create_embedded_request.py index 68c784e84..8a69d2cdf 100644 --- a/sdks/python/dropbox_sign/models/signature_request_create_embedded_request.py +++ b/sdks/python/dropbox_sign/models/signature_request_create_embedded_request.py @@ -47,6 +47,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestCreateEmbeddedRequest(BaseModel): @@ -176,7 +177,8 @@ class SignatureRequestCreateEmbeddedRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -188,8 +190,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -229,29 +230,39 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.signers: for _item_signers in self.signers: - if _item_signers: - _items.append(_item_signers.to_dict()) + _items.append( + _item_signers.to_dict() if _item_signers is not None else None + ) _dict["signers"] = _items # override the default output from pydantic by calling `to_dict()` of each item in grouped_signers (list) _items = [] if self.grouped_signers: for _item_grouped_signers in self.grouped_signers: - if _item_grouped_signers: - _items.append(_item_grouped_signers.to_dict()) + _items.append( + _item_grouped_signers.to_dict() + if _item_grouped_signers is not None + else None + ) _dict["grouped_signers"] = _items # override the default output from pydantic by calling `to_dict()` of each item in attachments (list) _items = [] if self.attachments: for _item_attachments in self.attachments: - if _item_attachments: - _items.append(_item_attachments.to_dict()) + _items.append( + _item_attachments.to_dict() + if _item_attachments is not None + else None + ) _dict["attachments"] = _items # override the default output from pydantic by calling `to_dict()` of each item in custom_fields (list) _items = [] if self.custom_fields: for _item_custom_fields in self.custom_fields: - if _item_custom_fields: - _items.append(_item_custom_fields.to_dict()) + _items.append( + _item_custom_fields.to_dict() + if _item_custom_fields is not None + else None + ) _dict["custom_fields"] = _items # override the default output from pydantic by calling `to_dict()` of field_options if self.field_options: @@ -260,22 +271,31 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.form_field_groups: for _item_form_field_groups in self.form_field_groups: - if _item_form_field_groups: - _items.append(_item_form_field_groups.to_dict()) + _items.append( + _item_form_field_groups.to_dict() + if _item_form_field_groups is not None + else None + ) _dict["form_field_groups"] = _items # override the default output from pydantic by calling `to_dict()` of each item in form_field_rules (list) _items = [] if self.form_field_rules: for _item_form_field_rules in self.form_field_rules: - if _item_form_field_rules: - _items.append(_item_form_field_rules.to_dict()) + _items.append( + _item_form_field_rules.to_dict() + if _item_form_field_rules is not None + else None + ) _dict["form_field_rules"] = _items # override the default output from pydantic by calling `to_dict()` of each item in form_fields_per_document (list) _items = [] if self.form_fields_per_document: for _item_form_fields_per_document in self.form_fields_per_document: - if _item_form_fields_per_document: - _items.append(_item_form_fields_per_document.to_dict()) + _items.append( + _item_form_fields_per_document.to_dict() + if _item_form_fields_per_document is not None + else None + ) _dict["form_fields_per_document"] = _items # override the default output from pydantic by calling `to_dict()` of signing_options if self.signing_options: diff --git a/sdks/python/dropbox_sign/models/signature_request_create_embedded_with_template_request.py b/sdks/python/dropbox_sign/models/signature_request_create_embedded_with_template_request.py index e0e069935..d2beab56c 100644 --- a/sdks/python/dropbox_sign/models/signature_request_create_embedded_with_template_request.py +++ b/sdks/python/dropbox_sign/models/signature_request_create_embedded_with_template_request.py @@ -40,6 +40,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestCreateEmbeddedWithTemplateRequest(BaseModel): @@ -127,7 +128,8 @@ class SignatureRequestCreateEmbeddedWithTemplateRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -139,8 +141,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -180,22 +181,25 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.signers: for _item_signers in self.signers: - if _item_signers: - _items.append(_item_signers.to_dict()) + _items.append( + _item_signers.to_dict() if _item_signers is not None else None + ) _dict["signers"] = _items # override the default output from pydantic by calling `to_dict()` of each item in ccs (list) _items = [] if self.ccs: for _item_ccs in self.ccs: - if _item_ccs: - _items.append(_item_ccs.to_dict()) + _items.append(_item_ccs.to_dict() if _item_ccs is not None else None) _dict["ccs"] = _items # override the default output from pydantic by calling `to_dict()` of each item in custom_fields (list) _items = [] if self.custom_fields: for _item_custom_fields in self.custom_fields: - if _item_custom_fields: - _items.append(_item_custom_fields.to_dict()) + _items.append( + _item_custom_fields.to_dict() + if _item_custom_fields is not None + else None + ) _dict["custom_fields"] = _items # override the default output from pydantic by calling `to_dict()` of signing_options if self.signing_options: diff --git a/sdks/python/dropbox_sign/models/signature_request_edit_embedded_request.py b/sdks/python/dropbox_sign/models/signature_request_edit_embedded_request.py index 4ea9149f2..71a433be4 100644 --- a/sdks/python/dropbox_sign/models/signature_request_edit_embedded_request.py +++ b/sdks/python/dropbox_sign/models/signature_request_edit_embedded_request.py @@ -47,6 +47,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestEditEmbeddedRequest(BaseModel): @@ -176,7 +177,8 @@ class SignatureRequestEditEmbeddedRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -188,8 +190,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -229,29 +230,39 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.signers: for _item_signers in self.signers: - if _item_signers: - _items.append(_item_signers.to_dict()) + _items.append( + _item_signers.to_dict() if _item_signers is not None else None + ) _dict["signers"] = _items # override the default output from pydantic by calling `to_dict()` of each item in grouped_signers (list) _items = [] if self.grouped_signers: for _item_grouped_signers in self.grouped_signers: - if _item_grouped_signers: - _items.append(_item_grouped_signers.to_dict()) + _items.append( + _item_grouped_signers.to_dict() + if _item_grouped_signers is not None + else None + ) _dict["grouped_signers"] = _items # override the default output from pydantic by calling `to_dict()` of each item in attachments (list) _items = [] if self.attachments: for _item_attachments in self.attachments: - if _item_attachments: - _items.append(_item_attachments.to_dict()) + _items.append( + _item_attachments.to_dict() + if _item_attachments is not None + else None + ) _dict["attachments"] = _items # override the default output from pydantic by calling `to_dict()` of each item in custom_fields (list) _items = [] if self.custom_fields: for _item_custom_fields in self.custom_fields: - if _item_custom_fields: - _items.append(_item_custom_fields.to_dict()) + _items.append( + _item_custom_fields.to_dict() + if _item_custom_fields is not None + else None + ) _dict["custom_fields"] = _items # override the default output from pydantic by calling `to_dict()` of field_options if self.field_options: @@ -260,22 +271,31 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.form_field_groups: for _item_form_field_groups in self.form_field_groups: - if _item_form_field_groups: - _items.append(_item_form_field_groups.to_dict()) + _items.append( + _item_form_field_groups.to_dict() + if _item_form_field_groups is not None + else None + ) _dict["form_field_groups"] = _items # override the default output from pydantic by calling `to_dict()` of each item in form_field_rules (list) _items = [] if self.form_field_rules: for _item_form_field_rules in self.form_field_rules: - if _item_form_field_rules: - _items.append(_item_form_field_rules.to_dict()) + _items.append( + _item_form_field_rules.to_dict() + if _item_form_field_rules is not None + else None + ) _dict["form_field_rules"] = _items # override the default output from pydantic by calling `to_dict()` of each item in form_fields_per_document (list) _items = [] if self.form_fields_per_document: for _item_form_fields_per_document in self.form_fields_per_document: - if _item_form_fields_per_document: - _items.append(_item_form_fields_per_document.to_dict()) + _items.append( + _item_form_fields_per_document.to_dict() + if _item_form_fields_per_document is not None + else None + ) _dict["form_fields_per_document"] = _items # override the default output from pydantic by calling `to_dict()` of signing_options if self.signing_options: diff --git a/sdks/python/dropbox_sign/models/signature_request_edit_embedded_with_template_request.py b/sdks/python/dropbox_sign/models/signature_request_edit_embedded_with_template_request.py index 0061169bb..0113daed4 100644 --- a/sdks/python/dropbox_sign/models/signature_request_edit_embedded_with_template_request.py +++ b/sdks/python/dropbox_sign/models/signature_request_edit_embedded_with_template_request.py @@ -32,6 +32,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestEditEmbeddedWithTemplateRequest(BaseModel): @@ -114,7 +115,8 @@ class SignatureRequestEditEmbeddedWithTemplateRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -126,8 +128,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -167,22 +168,25 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.signers: for _item_signers in self.signers: - if _item_signers: - _items.append(_item_signers.to_dict()) + _items.append( + _item_signers.to_dict() if _item_signers is not None else None + ) _dict["signers"] = _items # override the default output from pydantic by calling `to_dict()` of each item in ccs (list) _items = [] if self.ccs: for _item_ccs in self.ccs: - if _item_ccs: - _items.append(_item_ccs.to_dict()) + _items.append(_item_ccs.to_dict() if _item_ccs is not None else None) _dict["ccs"] = _items # override the default output from pydantic by calling `to_dict()` of each item in custom_fields (list) _items = [] if self.custom_fields: for _item_custom_fields in self.custom_fields: - if _item_custom_fields: - _items.append(_item_custom_fields.to_dict()) + _items.append( + _item_custom_fields.to_dict() + if _item_custom_fields is not None + else None + ) _dict["custom_fields"] = _items # override the default output from pydantic by calling `to_dict()` of signing_options if self.signing_options: diff --git a/sdks/python/dropbox_sign/models/signature_request_edit_request.py b/sdks/python/dropbox_sign/models/signature_request_edit_request.py index 181af59ff..b5fd5f7f7 100644 --- a/sdks/python/dropbox_sign/models/signature_request_edit_request.py +++ b/sdks/python/dropbox_sign/models/signature_request_edit_request.py @@ -47,6 +47,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestEditRequest(BaseModel): @@ -182,7 +183,8 @@ class SignatureRequestEditRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -194,8 +196,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -235,29 +236,39 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.signers: for _item_signers in self.signers: - if _item_signers: - _items.append(_item_signers.to_dict()) + _items.append( + _item_signers.to_dict() if _item_signers is not None else None + ) _dict["signers"] = _items # override the default output from pydantic by calling `to_dict()` of each item in grouped_signers (list) _items = [] if self.grouped_signers: for _item_grouped_signers in self.grouped_signers: - if _item_grouped_signers: - _items.append(_item_grouped_signers.to_dict()) + _items.append( + _item_grouped_signers.to_dict() + if _item_grouped_signers is not None + else None + ) _dict["grouped_signers"] = _items # override the default output from pydantic by calling `to_dict()` of each item in attachments (list) _items = [] if self.attachments: for _item_attachments in self.attachments: - if _item_attachments: - _items.append(_item_attachments.to_dict()) + _items.append( + _item_attachments.to_dict() + if _item_attachments is not None + else None + ) _dict["attachments"] = _items # override the default output from pydantic by calling `to_dict()` of each item in custom_fields (list) _items = [] if self.custom_fields: for _item_custom_fields in self.custom_fields: - if _item_custom_fields: - _items.append(_item_custom_fields.to_dict()) + _items.append( + _item_custom_fields.to_dict() + if _item_custom_fields is not None + else None + ) _dict["custom_fields"] = _items # override the default output from pydantic by calling `to_dict()` of field_options if self.field_options: @@ -266,22 +277,31 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.form_field_groups: for _item_form_field_groups in self.form_field_groups: - if _item_form_field_groups: - _items.append(_item_form_field_groups.to_dict()) + _items.append( + _item_form_field_groups.to_dict() + if _item_form_field_groups is not None + else None + ) _dict["form_field_groups"] = _items # override the default output from pydantic by calling `to_dict()` of each item in form_field_rules (list) _items = [] if self.form_field_rules: for _item_form_field_rules in self.form_field_rules: - if _item_form_field_rules: - _items.append(_item_form_field_rules.to_dict()) + _items.append( + _item_form_field_rules.to_dict() + if _item_form_field_rules is not None + else None + ) _dict["form_field_rules"] = _items # override the default output from pydantic by calling `to_dict()` of each item in form_fields_per_document (list) _items = [] if self.form_fields_per_document: for _item_form_fields_per_document in self.form_fields_per_document: - if _item_form_fields_per_document: - _items.append(_item_form_fields_per_document.to_dict()) + _items.append( + _item_form_fields_per_document.to_dict() + if _item_form_fields_per_document is not None + else None + ) _dict["form_fields_per_document"] = _items # override the default output from pydantic by calling `to_dict()` of signing_options if self.signing_options: diff --git a/sdks/python/dropbox_sign/models/signature_request_edit_with_template_request.py b/sdks/python/dropbox_sign/models/signature_request_edit_with_template_request.py index 1c5bf5a5b..e92c237b3 100644 --- a/sdks/python/dropbox_sign/models/signature_request_edit_with_template_request.py +++ b/sdks/python/dropbox_sign/models/signature_request_edit_with_template_request.py @@ -32,6 +32,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestEditWithTemplateRequest(BaseModel): @@ -118,7 +119,8 @@ class SignatureRequestEditWithTemplateRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -130,8 +132,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -171,22 +172,25 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.signers: for _item_signers in self.signers: - if _item_signers: - _items.append(_item_signers.to_dict()) + _items.append( + _item_signers.to_dict() if _item_signers is not None else None + ) _dict["signers"] = _items # override the default output from pydantic by calling `to_dict()` of each item in ccs (list) _items = [] if self.ccs: for _item_ccs in self.ccs: - if _item_ccs: - _items.append(_item_ccs.to_dict()) + _items.append(_item_ccs.to_dict() if _item_ccs is not None else None) _dict["ccs"] = _items # override the default output from pydantic by calling `to_dict()` of each item in custom_fields (list) _items = [] if self.custom_fields: for _item_custom_fields in self.custom_fields: - if _item_custom_fields: - _items.append(_item_custom_fields.to_dict()) + _items.append( + _item_custom_fields.to_dict() + if _item_custom_fields is not None + else None + ) _dict["custom_fields"] = _items # override the default output from pydantic by calling `to_dict()` of signing_options if self.signing_options: diff --git a/sdks/python/dropbox_sign/models/signature_request_get_response.py b/sdks/python/dropbox_sign/models/signature_request_get_response.py index 546c12ce3..0e63aed67 100644 --- a/sdks/python/dropbox_sign/models/signature_request_get_response.py +++ b/sdks/python/dropbox_sign/models/signature_request_get_response.py @@ -27,6 +27,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestGetResponse(BaseModel): @@ -41,7 +42,8 @@ class SignatureRequestGetResponse(BaseModel): __properties: ClassVar[List[str]] = ["signature_request", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -97,8 +98,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/signature_request_list_response.py b/sdks/python/dropbox_sign/models/signature_request_list_response.py index 2df4cbfe3..8e946a1d6 100644 --- a/sdks/python/dropbox_sign/models/signature_request_list_response.py +++ b/sdks/python/dropbox_sign/models/signature_request_list_response.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestListResponse(BaseModel): @@ -45,7 +46,8 @@ class SignatureRequestListResponse(BaseModel): __properties: ClassVar[List[str]] = ["signature_requests", "list_info", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -98,8 +99,11 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.signature_requests: for _item_signature_requests in self.signature_requests: - if _item_signature_requests: - _items.append(_item_signature_requests.to_dict()) + _items.append( + _item_signature_requests.to_dict() + if _item_signature_requests is not None + else None + ) _dict["signature_requests"] = _items # override the default output from pydantic by calling `to_dict()` of list_info if self.list_info: @@ -108,8 +112,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/signature_request_remind_request.py b/sdks/python/dropbox_sign/models/signature_request_remind_request.py index df37e043e..9a8c9db99 100644 --- a/sdks/python/dropbox_sign/models/signature_request_remind_request.py +++ b/sdks/python/dropbox_sign/models/signature_request_remind_request.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestRemindRequest(BaseModel): @@ -42,7 +43,8 @@ class SignatureRequestRemindRequest(BaseModel): __properties: ClassVar[List[str]] = ["email_address", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/signature_request_response.py b/sdks/python/dropbox_sign/models/signature_request_response.py index 7720256b8..26aa83075 100644 --- a/sdks/python/dropbox_sign/models/signature_request_response.py +++ b/sdks/python/dropbox_sign/models/signature_request_response.py @@ -37,6 +37,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestResponse(BaseModel): @@ -167,7 +168,8 @@ class SignatureRequestResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -179,8 +181,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -220,29 +221,39 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.custom_fields: for _item_custom_fields in self.custom_fields: - if _item_custom_fields: - _items.append(_item_custom_fields.to_dict()) + _items.append( + _item_custom_fields.to_dict() + if _item_custom_fields is not None + else None + ) _dict["custom_fields"] = _items # override the default output from pydantic by calling `to_dict()` of each item in attachments (list) _items = [] if self.attachments: for _item_attachments in self.attachments: - if _item_attachments: - _items.append(_item_attachments.to_dict()) + _items.append( + _item_attachments.to_dict() + if _item_attachments is not None + else None + ) _dict["attachments"] = _items # override the default output from pydantic by calling `to_dict()` of each item in response_data (list) _items = [] if self.response_data: for _item_response_data in self.response_data: - if _item_response_data: - _items.append(_item_response_data.to_dict()) + _items.append( + _item_response_data.to_dict() + if _item_response_data is not None + else None + ) _dict["response_data"] = _items # override the default output from pydantic by calling `to_dict()` of each item in signatures (list) _items = [] if self.signatures: for _item_signatures in self.signatures: - if _item_signatures: - _items.append(_item_signatures.to_dict()) + _items.append( + _item_signatures.to_dict() if _item_signatures is not None else None + ) _dict["signatures"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/signature_request_response_attachment.py b/sdks/python/dropbox_sign/models/signature_request_response_attachment.py index 30af75823..dd932e9ce 100644 --- a/sdks/python/dropbox_sign/models/signature_request_response_attachment.py +++ b/sdks/python/dropbox_sign/models/signature_request_response_attachment.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestResponseAttachment(BaseModel): @@ -56,7 +57,8 @@ class SignatureRequestResponseAttachment(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -68,8 +70,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/signature_request_response_custom_field_base.py b/sdks/python/dropbox_sign/models/signature_request_response_custom_field_base.py index 61ecdd69c..2dc624e64 100644 --- a/sdks/python/dropbox_sign/models/signature_request_response_custom_field_base.py +++ b/sdks/python/dropbox_sign/models/signature_request_response_custom_field_base.py @@ -26,6 +26,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python from typing import TYPE_CHECKING @@ -60,7 +61,8 @@ class SignatureRequestResponseCustomFieldBase(BaseModel): __properties: ClassVar[List[str]] = ["type", "name", "required", "api_id", "editor"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -78,7 +80,7 @@ class SignatureRequestResponseCustomFieldBase(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: @@ -90,8 +92,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/signature_request_response_custom_field_checkbox.py b/sdks/python/dropbox_sign/models/signature_request_response_custom_field_checkbox.py index de55b64e5..f7bed1273 100644 --- a/sdks/python/dropbox_sign/models/signature_request_response_custom_field_checkbox.py +++ b/sdks/python/dropbox_sign/models/signature_request_response_custom_field_checkbox.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestResponseCustomFieldCheckbox( @@ -53,7 +54,8 @@ class SignatureRequestResponseCustomFieldCheckbox( ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -65,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/signature_request_response_custom_field_text.py b/sdks/python/dropbox_sign/models/signature_request_response_custom_field_text.py index 48fa24f29..a8b5a2e9b 100644 --- a/sdks/python/dropbox_sign/models/signature_request_response_custom_field_text.py +++ b/sdks/python/dropbox_sign/models/signature_request_response_custom_field_text.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestResponseCustomFieldText(SignatureRequestResponseCustomFieldBase): @@ -51,7 +52,8 @@ class SignatureRequestResponseCustomFieldText(SignatureRequestResponseCustomFiel ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -63,8 +65,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/signature_request_response_data_base.py b/sdks/python/dropbox_sign/models/signature_request_response_data_base.py index 374d2cc50..522ec99c7 100644 --- a/sdks/python/dropbox_sign/models/signature_request_response_data_base.py +++ b/sdks/python/dropbox_sign/models/signature_request_response_data_base.py @@ -26,6 +26,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python from typing import TYPE_CHECKING @@ -87,7 +88,8 @@ class SignatureRequestResponseDataBase(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -112,7 +114,7 @@ class SignatureRequestResponseDataBase(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: @@ -124,8 +126,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/signature_request_response_data_value_checkbox.py b/sdks/python/dropbox_sign/models/signature_request_response_data_value_checkbox.py index 4e258335d..67e37a57a 100644 --- a/sdks/python/dropbox_sign/models/signature_request_response_data_value_checkbox.py +++ b/sdks/python/dropbox_sign/models/signature_request_response_data_value_checkbox.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestResponseDataValueCheckbox(SignatureRequestResponseDataBase): @@ -51,7 +52,8 @@ class SignatureRequestResponseDataValueCheckbox(SignatureRequestResponseDataBase ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -63,8 +65,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/signature_request_response_data_value_checkbox_merge.py b/sdks/python/dropbox_sign/models/signature_request_response_data_value_checkbox_merge.py index 0a25a7ca7..d12437363 100644 --- a/sdks/python/dropbox_sign/models/signature_request_response_data_value_checkbox_merge.py +++ b/sdks/python/dropbox_sign/models/signature_request_response_data_value_checkbox_merge.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestResponseDataValueCheckboxMerge(SignatureRequestResponseDataBase): @@ -52,7 +53,8 @@ class SignatureRequestResponseDataValueCheckboxMerge(SignatureRequestResponseDat ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -64,8 +66,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/signature_request_response_data_value_date_signed.py b/sdks/python/dropbox_sign/models/signature_request_response_data_value_date_signed.py index ac09c2600..1658377d4 100644 --- a/sdks/python/dropbox_sign/models/signature_request_response_data_value_date_signed.py +++ b/sdks/python/dropbox_sign/models/signature_request_response_data_value_date_signed.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestResponseDataValueDateSigned(SignatureRequestResponseDataBase): @@ -49,7 +50,8 @@ class SignatureRequestResponseDataValueDateSigned(SignatureRequestResponseDataBa ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -61,8 +63,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/signature_request_response_data_value_dropdown.py b/sdks/python/dropbox_sign/models/signature_request_response_data_value_dropdown.py index 9eb735261..fbccb780f 100644 --- a/sdks/python/dropbox_sign/models/signature_request_response_data_value_dropdown.py +++ b/sdks/python/dropbox_sign/models/signature_request_response_data_value_dropdown.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestResponseDataValueDropdown(SignatureRequestResponseDataBase): @@ -51,7 +52,8 @@ class SignatureRequestResponseDataValueDropdown(SignatureRequestResponseDataBase ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -63,8 +65,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/signature_request_response_data_value_initials.py b/sdks/python/dropbox_sign/models/signature_request_response_data_value_initials.py index 9a5f19055..bc23f5360 100644 --- a/sdks/python/dropbox_sign/models/signature_request_response_data_value_initials.py +++ b/sdks/python/dropbox_sign/models/signature_request_response_data_value_initials.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestResponseDataValueInitials(SignatureRequestResponseDataBase): @@ -56,7 +57,8 @@ class SignatureRequestResponseDataValueInitials(SignatureRequestResponseDataBase ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -68,8 +70,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/signature_request_response_data_value_radio.py b/sdks/python/dropbox_sign/models/signature_request_response_data_value_radio.py index 38b3cc04a..df35c9521 100644 --- a/sdks/python/dropbox_sign/models/signature_request_response_data_value_radio.py +++ b/sdks/python/dropbox_sign/models/signature_request_response_data_value_radio.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestResponseDataValueRadio(SignatureRequestResponseDataBase): @@ -51,7 +52,8 @@ class SignatureRequestResponseDataValueRadio(SignatureRequestResponseDataBase): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -63,8 +65,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/signature_request_response_data_value_signature.py b/sdks/python/dropbox_sign/models/signature_request_response_data_value_signature.py index a928d102b..c6c82f01b 100644 --- a/sdks/python/dropbox_sign/models/signature_request_response_data_value_signature.py +++ b/sdks/python/dropbox_sign/models/signature_request_response_data_value_signature.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestResponseDataValueSignature(SignatureRequestResponseDataBase): @@ -56,7 +57,8 @@ class SignatureRequestResponseDataValueSignature(SignatureRequestResponseDataBas ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -68,8 +70,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/signature_request_response_data_value_text.py b/sdks/python/dropbox_sign/models/signature_request_response_data_value_text.py index 7b5b782e5..cb59dd7ba 100644 --- a/sdks/python/dropbox_sign/models/signature_request_response_data_value_text.py +++ b/sdks/python/dropbox_sign/models/signature_request_response_data_value_text.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestResponseDataValueText(SignatureRequestResponseDataBase): @@ -49,7 +50,8 @@ class SignatureRequestResponseDataValueText(SignatureRequestResponseDataBase): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -61,8 +63,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/signature_request_response_data_value_text_merge.py b/sdks/python/dropbox_sign/models/signature_request_response_data_value_text_merge.py index 13b9591e9..a3f17d365 100644 --- a/sdks/python/dropbox_sign/models/signature_request_response_data_value_text_merge.py +++ b/sdks/python/dropbox_sign/models/signature_request_response_data_value_text_merge.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestResponseDataValueTextMerge(SignatureRequestResponseDataBase): @@ -52,7 +53,8 @@ class SignatureRequestResponseDataValueTextMerge(SignatureRequestResponseDataBas ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -64,8 +66,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/signature_request_response_signatures.py b/sdks/python/dropbox_sign/models/signature_request_response_signatures.py index 9b36e81f6..abaf1f1f0 100644 --- a/sdks/python/dropbox_sign/models/signature_request_response_signatures.py +++ b/sdks/python/dropbox_sign/models/signature_request_response_signatures.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestResponseSignatures(BaseModel): @@ -123,7 +124,8 @@ class SignatureRequestResponseSignatures(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -135,8 +137,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/signature_request_send_request.py b/sdks/python/dropbox_sign/models/signature_request_send_request.py index 8e61eb922..7a85302c4 100644 --- a/sdks/python/dropbox_sign/models/signature_request_send_request.py +++ b/sdks/python/dropbox_sign/models/signature_request_send_request.py @@ -47,6 +47,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestSendRequest(BaseModel): @@ -187,7 +188,8 @@ class SignatureRequestSendRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -199,8 +201,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -240,29 +241,39 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.signers: for _item_signers in self.signers: - if _item_signers: - _items.append(_item_signers.to_dict()) + _items.append( + _item_signers.to_dict() if _item_signers is not None else None + ) _dict["signers"] = _items # override the default output from pydantic by calling `to_dict()` of each item in grouped_signers (list) _items = [] if self.grouped_signers: for _item_grouped_signers in self.grouped_signers: - if _item_grouped_signers: - _items.append(_item_grouped_signers.to_dict()) + _items.append( + _item_grouped_signers.to_dict() + if _item_grouped_signers is not None + else None + ) _dict["grouped_signers"] = _items # override the default output from pydantic by calling `to_dict()` of each item in attachments (list) _items = [] if self.attachments: for _item_attachments in self.attachments: - if _item_attachments: - _items.append(_item_attachments.to_dict()) + _items.append( + _item_attachments.to_dict() + if _item_attachments is not None + else None + ) _dict["attachments"] = _items # override the default output from pydantic by calling `to_dict()` of each item in custom_fields (list) _items = [] if self.custom_fields: for _item_custom_fields in self.custom_fields: - if _item_custom_fields: - _items.append(_item_custom_fields.to_dict()) + _items.append( + _item_custom_fields.to_dict() + if _item_custom_fields is not None + else None + ) _dict["custom_fields"] = _items # override the default output from pydantic by calling `to_dict()` of field_options if self.field_options: @@ -271,22 +282,31 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.form_field_groups: for _item_form_field_groups in self.form_field_groups: - if _item_form_field_groups: - _items.append(_item_form_field_groups.to_dict()) + _items.append( + _item_form_field_groups.to_dict() + if _item_form_field_groups is not None + else None + ) _dict["form_field_groups"] = _items # override the default output from pydantic by calling `to_dict()` of each item in form_field_rules (list) _items = [] if self.form_field_rules: for _item_form_field_rules in self.form_field_rules: - if _item_form_field_rules: - _items.append(_item_form_field_rules.to_dict()) + _items.append( + _item_form_field_rules.to_dict() + if _item_form_field_rules is not None + else None + ) _dict["form_field_rules"] = _items # override the default output from pydantic by calling `to_dict()` of each item in form_fields_per_document (list) _items = [] if self.form_fields_per_document: for _item_form_fields_per_document in self.form_fields_per_document: - if _item_form_fields_per_document: - _items.append(_item_form_fields_per_document.to_dict()) + _items.append( + _item_form_fields_per_document.to_dict() + if _item_form_fields_per_document is not None + else None + ) _dict["form_fields_per_document"] = _items # override the default output from pydantic by calling `to_dict()` of signing_options if self.signing_options: diff --git a/sdks/python/dropbox_sign/models/signature_request_send_with_template_request.py b/sdks/python/dropbox_sign/models/signature_request_send_with_template_request.py index f5c064cd1..dd9f09c80 100644 --- a/sdks/python/dropbox_sign/models/signature_request_send_with_template_request.py +++ b/sdks/python/dropbox_sign/models/signature_request_send_with_template_request.py @@ -40,6 +40,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestSendWithTemplateRequest(BaseModel): @@ -136,7 +137,8 @@ class SignatureRequestSendWithTemplateRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -148,8 +150,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -189,22 +190,25 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.signers: for _item_signers in self.signers: - if _item_signers: - _items.append(_item_signers.to_dict()) + _items.append( + _item_signers.to_dict() if _item_signers is not None else None + ) _dict["signers"] = _items # override the default output from pydantic by calling `to_dict()` of each item in ccs (list) _items = [] if self.ccs: for _item_ccs in self.ccs: - if _item_ccs: - _items.append(_item_ccs.to_dict()) + _items.append(_item_ccs.to_dict() if _item_ccs is not None else None) _dict["ccs"] = _items # override the default output from pydantic by calling `to_dict()` of each item in custom_fields (list) _items = [] if self.custom_fields: for _item_custom_fields in self.custom_fields: - if _item_custom_fields: - _items.append(_item_custom_fields.to_dict()) + _items.append( + _item_custom_fields.to_dict() + if _item_custom_fields is not None + else None + ) _dict["custom_fields"] = _items # override the default output from pydantic by calling `to_dict()` of signing_options if self.signing_options: diff --git a/sdks/python/dropbox_sign/models/signature_request_update_request.py b/sdks/python/dropbox_sign/models/signature_request_update_request.py index a5ec1ddc1..5dbb8ea39 100644 --- a/sdks/python/dropbox_sign/models/signature_request_update_request.py +++ b/sdks/python/dropbox_sign/models/signature_request_update_request.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SignatureRequestUpdateRequest(BaseModel): @@ -53,7 +54,8 @@ class SignatureRequestUpdateRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -65,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_attachment.py b/sdks/python/dropbox_sign/models/sub_attachment.py index 82daeb1f5..649d15ab6 100644 --- a/sdks/python/dropbox_sign/models/sub_attachment.py +++ b/sdks/python/dropbox_sign/models/sub_attachment.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubAttachment(BaseModel): @@ -50,7 +51,8 @@ class SubAttachment(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -62,8 +64,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_bulk_signer_list.py b/sdks/python/dropbox_sign/models/sub_bulk_signer_list.py index 899f57701..aa4af7616 100644 --- a/sdks/python/dropbox_sign/models/sub_bulk_signer_list.py +++ b/sdks/python/dropbox_sign/models/sub_bulk_signer_list.py @@ -31,6 +31,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubBulkSignerList(BaseModel): @@ -48,7 +49,8 @@ class SubBulkSignerList(BaseModel): __properties: ClassVar[List[str]] = ["custom_fields", "signers"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -60,8 +62,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -101,15 +102,19 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.custom_fields: for _item_custom_fields in self.custom_fields: - if _item_custom_fields: - _items.append(_item_custom_fields.to_dict()) + _items.append( + _item_custom_fields.to_dict() + if _item_custom_fields is not None + else None + ) _dict["custom_fields"] = _items # override the default output from pydantic by calling `to_dict()` of each item in signers (list) _items = [] if self.signers: for _item_signers in self.signers: - if _item_signers: - _items.append(_item_signers.to_dict()) + _items.append( + _item_signers.to_dict() if _item_signers is not None else None + ) _dict["signers"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/sub_bulk_signer_list_custom_field.py b/sdks/python/dropbox_sign/models/sub_bulk_signer_list_custom_field.py index 0efdff283..a0323fa34 100644 --- a/sdks/python/dropbox_sign/models/sub_bulk_signer_list_custom_field.py +++ b/sdks/python/dropbox_sign/models/sub_bulk_signer_list_custom_field.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubBulkSignerListCustomField(BaseModel): @@ -39,7 +40,8 @@ class SubBulkSignerListCustomField(BaseModel): __properties: ClassVar[List[str]] = ["name", "value"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_cc.py b/sdks/python/dropbox_sign/models/sub_cc.py index fb14ef0c0..30da0d1f5 100644 --- a/sdks/python/dropbox_sign/models/sub_cc.py +++ b/sdks/python/dropbox_sign/models/sub_cc.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubCC(BaseModel): @@ -41,7 +42,8 @@ class SubCC(BaseModel): __properties: ClassVar[List[str]] = ["role", "email_address"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_custom_field.py b/sdks/python/dropbox_sign/models/sub_custom_field.py index ec74927d1..236cac81d 100644 --- a/sdks/python/dropbox_sign/models/sub_custom_field.py +++ b/sdks/python/dropbox_sign/models/sub_custom_field.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubCustomField(BaseModel): @@ -50,7 +51,8 @@ class SubCustomField(BaseModel): __properties: ClassVar[List[str]] = ["name", "editor", "required", "value"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -62,8 +64,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_editor_options.py b/sdks/python/dropbox_sign/models/sub_editor_options.py index 8693cfa02..b33d66972 100644 --- a/sdks/python/dropbox_sign/models/sub_editor_options.py +++ b/sdks/python/dropbox_sign/models/sub_editor_options.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubEditorOptions(BaseModel): @@ -42,7 +43,8 @@ class SubEditorOptions(BaseModel): __properties: ClassVar[List[str]] = ["allow_edit_signers", "allow_edit_documents"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_field_options.py b/sdks/python/dropbox_sign/models/sub_field_options.py index 12336e67e..daf95f690 100644 --- a/sdks/python/dropbox_sign/models/sub_field_options.py +++ b/sdks/python/dropbox_sign/models/sub_field_options.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubFieldOptions(BaseModel): @@ -56,7 +57,8 @@ def date_format_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -68,8 +70,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_form_field_group.py b/sdks/python/dropbox_sign/models/sub_form_field_group.py index a892d2147..bede298c2 100644 --- a/sdks/python/dropbox_sign/models/sub_form_field_group.py +++ b/sdks/python/dropbox_sign/models/sub_form_field_group.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubFormFieldGroup(BaseModel): @@ -42,7 +43,8 @@ class SubFormFieldGroup(BaseModel): __properties: ClassVar[List[str]] = ["group_id", "group_label", "requirement"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_form_field_rule.py b/sdks/python/dropbox_sign/models/sub_form_field_rule.py index f09ac200c..4f60532e5 100644 --- a/sdks/python/dropbox_sign/models/sub_form_field_rule.py +++ b/sdks/python/dropbox_sign/models/sub_form_field_rule.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubFormFieldRule(BaseModel): @@ -55,7 +56,8 @@ class SubFormFieldRule(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -67,8 +69,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -108,15 +109,17 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.triggers: for _item_triggers in self.triggers: - if _item_triggers: - _items.append(_item_triggers.to_dict()) + _items.append( + _item_triggers.to_dict() if _item_triggers is not None else None + ) _dict["triggers"] = _items # override the default output from pydantic by calling `to_dict()` of each item in actions (list) _items = [] if self.actions: for _item_actions in self.actions: - if _item_actions: - _items.append(_item_actions.to_dict()) + _items.append( + _item_actions.to_dict() if _item_actions is not None else None + ) _dict["actions"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/sub_form_field_rule_action.py b/sdks/python/dropbox_sign/models/sub_form_field_rule_action.py index 59be4336a..b9d758c5a 100644 --- a/sdks/python/dropbox_sign/models/sub_form_field_rule_action.py +++ b/sdks/python/dropbox_sign/models/sub_form_field_rule_action.py @@ -32,6 +32,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubFormFieldRuleAction(BaseModel): @@ -63,7 +64,8 @@ def type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -75,8 +77,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_form_field_rule_trigger.py b/sdks/python/dropbox_sign/models/sub_form_field_rule_trigger.py index ff6c5beca..fe7598a4a 100644 --- a/sdks/python/dropbox_sign/models/sub_form_field_rule_trigger.py +++ b/sdks/python/dropbox_sign/models/sub_form_field_rule_trigger.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubFormFieldRuleTrigger(BaseModel): @@ -58,7 +59,8 @@ def operator_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -70,8 +72,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_base.py b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_base.py index 615f1089e..c974d4964 100644 --- a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_base.py +++ b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_base.py @@ -26,6 +26,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python from typing import TYPE_CHECKING @@ -104,7 +105,8 @@ class SubFormFieldsPerDocumentBase(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -130,7 +132,7 @@ class SubFormFieldsPerDocumentBase(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: @@ -142,8 +144,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_checkbox.py b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_checkbox.py index 90538984b..22b4ae85c 100644 --- a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_checkbox.py +++ b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_checkbox.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubFormFieldsPerDocumentCheckbox(SubFormFieldsPerDocumentBase): @@ -62,7 +63,8 @@ class SubFormFieldsPerDocumentCheckbox(SubFormFieldsPerDocumentBase): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -74,8 +76,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_checkbox_merge.py b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_checkbox_merge.py index aa947338f..a3ac6557c 100644 --- a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_checkbox_merge.py +++ b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_checkbox_merge.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubFormFieldsPerDocumentCheckboxMerge(SubFormFieldsPerDocumentBase): @@ -53,7 +54,8 @@ class SubFormFieldsPerDocumentCheckboxMerge(SubFormFieldsPerDocumentBase): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -65,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_date_signed.py b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_date_signed.py index 583a3a8e6..26670b3cd 100644 --- a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_date_signed.py +++ b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_date_signed.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubFormFieldsPerDocumentDateSigned(SubFormFieldsPerDocumentBase): @@ -93,7 +94,8 @@ def font_family_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -105,8 +107,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_dropdown.py b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_dropdown.py index c668c354e..516f83ae5 100644 --- a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_dropdown.py +++ b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_dropdown.py @@ -29,6 +29,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubFormFieldsPerDocumentDropdown(SubFormFieldsPerDocumentBase): @@ -103,7 +104,8 @@ def font_family_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -115,8 +117,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_hyperlink.py b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_hyperlink.py index 650d76679..880914f1c 100644 --- a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_hyperlink.py +++ b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_hyperlink.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubFormFieldsPerDocumentHyperlink(SubFormFieldsPerDocumentBase): @@ -97,7 +98,8 @@ def font_family_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -109,8 +111,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_initials.py b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_initials.py index 3383d7151..f19b93316 100644 --- a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_initials.py +++ b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_initials.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubFormFieldsPerDocumentInitials(SubFormFieldsPerDocumentBase): @@ -53,7 +54,8 @@ class SubFormFieldsPerDocumentInitials(SubFormFieldsPerDocumentBase): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -65,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_radio.py b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_radio.py index a91bd8688..199dcce9e 100644 --- a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_radio.py +++ b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_radio.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubFormFieldsPerDocumentRadio(SubFormFieldsPerDocumentBase): @@ -61,7 +62,8 @@ class SubFormFieldsPerDocumentRadio(SubFormFieldsPerDocumentBase): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -73,8 +75,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_signature.py b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_signature.py index 11a056cb0..6ebf2c754 100644 --- a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_signature.py +++ b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_signature.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubFormFieldsPerDocumentSignature(SubFormFieldsPerDocumentBase): @@ -53,7 +54,8 @@ class SubFormFieldsPerDocumentSignature(SubFormFieldsPerDocumentBase): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -65,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_text.py b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_text.py index c2e2c3ae4..acb2a4f53 100644 --- a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_text.py +++ b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_text.py @@ -35,6 +35,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubFormFieldsPerDocumentText(SubFormFieldsPerDocumentBase): @@ -157,7 +158,8 @@ def font_family_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -169,8 +171,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_text_merge.py b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_text_merge.py index 990c2374a..4d2446782 100644 --- a/sdks/python/dropbox_sign/models/sub_form_fields_per_document_text_merge.py +++ b/sdks/python/dropbox_sign/models/sub_form_fields_per_document_text_merge.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubFormFieldsPerDocumentTextMerge(SubFormFieldsPerDocumentBase): @@ -93,7 +94,8 @@ def font_family_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -105,8 +107,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_merge_field.py b/sdks/python/dropbox_sign/models/sub_merge_field.py index e83058e97..cb5a50d63 100644 --- a/sdks/python/dropbox_sign/models/sub_merge_field.py +++ b/sdks/python/dropbox_sign/models/sub_merge_field.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubMergeField(BaseModel): @@ -44,7 +45,8 @@ def type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -56,8 +58,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_o_auth.py b/sdks/python/dropbox_sign/models/sub_o_auth.py index 2c11784aa..b04639fb4 100644 --- a/sdks/python/dropbox_sign/models/sub_o_auth.py +++ b/sdks/python/dropbox_sign/models/sub_o_auth.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubOAuth(BaseModel): @@ -67,7 +68,8 @@ def scopes_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -79,8 +81,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_options.py b/sdks/python/dropbox_sign/models/sub_options.py index e7965f446..83c93293d 100644 --- a/sdks/python/dropbox_sign/models/sub_options.py +++ b/sdks/python/dropbox_sign/models/sub_options.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubOptions(BaseModel): @@ -39,7 +40,8 @@ class SubOptions(BaseModel): __properties: ClassVar[List[str]] = ["can_insert_everywhere"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_signature_request_grouped_signers.py b/sdks/python/dropbox_sign/models/sub_signature_request_grouped_signers.py index a14f315f0..d000d17f3 100644 --- a/sdks/python/dropbox_sign/models/sub_signature_request_grouped_signers.py +++ b/sdks/python/dropbox_sign/models/sub_signature_request_grouped_signers.py @@ -26,6 +26,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubSignatureRequestGroupedSigners(BaseModel): @@ -44,7 +45,8 @@ class SubSignatureRequestGroupedSigners(BaseModel): __properties: ClassVar[List[str]] = ["group", "signers", "order"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -56,8 +58,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -97,8 +98,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.signers: for _item_signers in self.signers: - if _item_signers: - _items.append(_item_signers.to_dict()) + _items.append( + _item_signers.to_dict() if _item_signers is not None else None + ) _dict["signers"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/sub_signature_request_signer.py b/sdks/python/dropbox_sign/models/sub_signature_request_signer.py index 3337098c4..b60dae3de 100644 --- a/sdks/python/dropbox_sign/models/sub_signature_request_signer.py +++ b/sdks/python/dropbox_sign/models/sub_signature_request_signer.py @@ -26,6 +26,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubSignatureRequestSigner(BaseModel): @@ -74,7 +75,8 @@ def sms_phone_number_type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -86,8 +88,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_signature_request_template_signer.py b/sdks/python/dropbox_sign/models/sub_signature_request_template_signer.py index 4d1e239ec..d67adc987 100644 --- a/sdks/python/dropbox_sign/models/sub_signature_request_template_signer.py +++ b/sdks/python/dropbox_sign/models/sub_signature_request_template_signer.py @@ -26,6 +26,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubSignatureRequestTemplateSigner(BaseModel): @@ -74,7 +75,8 @@ def sms_phone_number_type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -86,8 +88,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_signing_options.py b/sdks/python/dropbox_sign/models/sub_signing_options.py index 7d442bacf..b396df4b8 100644 --- a/sdks/python/dropbox_sign/models/sub_signing_options.py +++ b/sdks/python/dropbox_sign/models/sub_signing_options.py @@ -32,6 +32,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubSigningOptions(BaseModel): @@ -77,7 +78,8 @@ def default_type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -89,8 +91,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_team_response.py b/sdks/python/dropbox_sign/models/sub_team_response.py index 5a3b7f74f..b62219aa2 100644 --- a/sdks/python/dropbox_sign/models/sub_team_response.py +++ b/sdks/python/dropbox_sign/models/sub_team_response.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubTeamResponse(BaseModel): @@ -37,7 +38,8 @@ class SubTeamResponse(BaseModel): __properties: ClassVar[List[str]] = ["team_id", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_template_role.py b/sdks/python/dropbox_sign/models/sub_template_role.py index fd407632c..1c7f204a7 100644 --- a/sdks/python/dropbox_sign/models/sub_template_role.py +++ b/sdks/python/dropbox_sign/models/sub_template_role.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubTemplateRole(BaseModel): @@ -43,7 +44,8 @@ class SubTemplateRole(BaseModel): __properties: ClassVar[List[str]] = ["name", "order"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_unclaimed_draft_signer.py b/sdks/python/dropbox_sign/models/sub_unclaimed_draft_signer.py index 318fd8056..47bc1ffa4 100644 --- a/sdks/python/dropbox_sign/models/sub_unclaimed_draft_signer.py +++ b/sdks/python/dropbox_sign/models/sub_unclaimed_draft_signer.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubUnclaimedDraftSigner(BaseModel): @@ -40,7 +41,8 @@ class SubUnclaimedDraftSigner(BaseModel): __properties: ClassVar[List[str]] = ["email_address", "name", "order"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -52,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_unclaimed_draft_template_signer.py b/sdks/python/dropbox_sign/models/sub_unclaimed_draft_template_signer.py index a668e9fdc..df8e0b444 100644 --- a/sdks/python/dropbox_sign/models/sub_unclaimed_draft_template_signer.py +++ b/sdks/python/dropbox_sign/models/sub_unclaimed_draft_template_signer.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubUnclaimedDraftTemplateSigner(BaseModel): @@ -44,7 +45,8 @@ class SubUnclaimedDraftTemplateSigner(BaseModel): __properties: ClassVar[List[str]] = ["role", "name", "email_address"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -56,8 +58,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/sub_white_labeling_options.py b/sdks/python/dropbox_sign/models/sub_white_labeling_options.py index 9fe6f145c..8d63f4f2a 100644 --- a/sdks/python/dropbox_sign/models/sub_white_labeling_options.py +++ b/sdks/python/dropbox_sign/models/sub_white_labeling_options.py @@ -32,6 +32,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class SubWhiteLabelingOptions(BaseModel): @@ -86,7 +87,8 @@ def legal_version_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -98,8 +100,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/team_add_member_request.py b/sdks/python/dropbox_sign/models/team_add_member_request.py index 9fa1fbc88..c18004278 100644 --- a/sdks/python/dropbox_sign/models/team_add_member_request.py +++ b/sdks/python/dropbox_sign/models/team_add_member_request.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TeamAddMemberRequest(BaseModel): @@ -59,7 +60,8 @@ def role_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -71,8 +73,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/team_create_request.py b/sdks/python/dropbox_sign/models/team_create_request.py index 94d38e66b..fe689af3f 100644 --- a/sdks/python/dropbox_sign/models/team_create_request.py +++ b/sdks/python/dropbox_sign/models/team_create_request.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TeamCreateRequest(BaseModel): @@ -38,7 +39,8 @@ class TeamCreateRequest(BaseModel): __properties: ClassVar[List[str]] = ["name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/team_get_info_response.py b/sdks/python/dropbox_sign/models/team_get_info_response.py index e716e4daa..397da6bfd 100644 --- a/sdks/python/dropbox_sign/models/team_get_info_response.py +++ b/sdks/python/dropbox_sign/models/team_get_info_response.py @@ -27,6 +27,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TeamGetInfoResponse(BaseModel): @@ -41,7 +42,8 @@ class TeamGetInfoResponse(BaseModel): __properties: ClassVar[List[str]] = ["team", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -97,8 +98,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/team_get_response.py b/sdks/python/dropbox_sign/models/team_get_response.py index 3c137e35a..63659a95c 100644 --- a/sdks/python/dropbox_sign/models/team_get_response.py +++ b/sdks/python/dropbox_sign/models/team_get_response.py @@ -27,6 +27,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TeamGetResponse(BaseModel): @@ -41,7 +42,8 @@ class TeamGetResponse(BaseModel): __properties: ClassVar[List[str]] = ["team", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -97,8 +98,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/team_info_response.py b/sdks/python/dropbox_sign/models/team_info_response.py index b10d7cb82..0ac2aa1bf 100644 --- a/sdks/python/dropbox_sign/models/team_info_response.py +++ b/sdks/python/dropbox_sign/models/team_info_response.py @@ -26,6 +26,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TeamInfoResponse(BaseModel): @@ -51,7 +52,8 @@ class TeamInfoResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -63,8 +65,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/team_invite_response.py b/sdks/python/dropbox_sign/models/team_invite_response.py index 0f377202b..0bca24434 100644 --- a/sdks/python/dropbox_sign/models/team_invite_response.py +++ b/sdks/python/dropbox_sign/models/team_invite_response.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TeamInviteResponse(BaseModel): @@ -58,7 +59,8 @@ class TeamInviteResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -70,8 +72,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/team_invites_response.py b/sdks/python/dropbox_sign/models/team_invites_response.py index e6171e8fe..fe185c003 100644 --- a/sdks/python/dropbox_sign/models/team_invites_response.py +++ b/sdks/python/dropbox_sign/models/team_invites_response.py @@ -27,6 +27,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TeamInvitesResponse(BaseModel): @@ -41,7 +42,8 @@ class TeamInvitesResponse(BaseModel): __properties: ClassVar[List[str]] = ["team_invites", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -94,15 +95,19 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.team_invites: for _item_team_invites in self.team_invites: - if _item_team_invites: - _items.append(_item_team_invites.to_dict()) + _items.append( + _item_team_invites.to_dict() + if _item_team_invites is not None + else None + ) _dict["team_invites"] = _items # override the default output from pydantic by calling `to_dict()` of each item in warnings (list) _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/team_member_response.py b/sdks/python/dropbox_sign/models/team_member_response.py index d59fc5d64..964cb999e 100644 --- a/sdks/python/dropbox_sign/models/team_member_response.py +++ b/sdks/python/dropbox_sign/models/team_member_response.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TeamMemberResponse(BaseModel): @@ -44,7 +45,8 @@ class TeamMemberResponse(BaseModel): __properties: ClassVar[List[str]] = ["account_id", "email_address", "role"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -56,8 +58,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/team_members_response.py b/sdks/python/dropbox_sign/models/team_members_response.py index 73ed1c490..e519a47db 100644 --- a/sdks/python/dropbox_sign/models/team_members_response.py +++ b/sdks/python/dropbox_sign/models/team_members_response.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TeamMembersResponse(BaseModel): @@ -43,7 +44,8 @@ class TeamMembersResponse(BaseModel): __properties: ClassVar[List[str]] = ["team_members", "list_info", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -96,8 +97,11 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.team_members: for _item_team_members in self.team_members: - if _item_team_members: - _items.append(_item_team_members.to_dict()) + _items.append( + _item_team_members.to_dict() + if _item_team_members is not None + else None + ) _dict["team_members"] = _items # override the default output from pydantic by calling `to_dict()` of list_info if self.list_info: @@ -106,8 +110,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/team_parent_response.py b/sdks/python/dropbox_sign/models/team_parent_response.py index 2478765be..337a03bdc 100644 --- a/sdks/python/dropbox_sign/models/team_parent_response.py +++ b/sdks/python/dropbox_sign/models/team_parent_response.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TeamParentResponse(BaseModel): @@ -37,7 +38,8 @@ class TeamParentResponse(BaseModel): __properties: ClassVar[List[str]] = ["team_id", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/team_remove_member_request.py b/sdks/python/dropbox_sign/models/team_remove_member_request.py index 0df67abe9..8e275ad6c 100644 --- a/sdks/python/dropbox_sign/models/team_remove_member_request.py +++ b/sdks/python/dropbox_sign/models/team_remove_member_request.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TeamRemoveMemberRequest(BaseModel): @@ -72,7 +73,8 @@ def new_role_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -84,8 +86,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/team_response.py b/sdks/python/dropbox_sign/models/team_response.py index 9f72e11fe..0cfc3aed5 100644 --- a/sdks/python/dropbox_sign/models/team_response.py +++ b/sdks/python/dropbox_sign/models/team_response.py @@ -26,6 +26,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TeamResponse(BaseModel): @@ -51,7 +52,8 @@ class TeamResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -63,8 +65,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -104,15 +105,19 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.accounts: for _item_accounts in self.accounts: - if _item_accounts: - _items.append(_item_accounts.to_dict()) + _items.append( + _item_accounts.to_dict() if _item_accounts is not None else None + ) _dict["accounts"] = _items # override the default output from pydantic by calling `to_dict()` of each item in invited_accounts (list) _items = [] if self.invited_accounts: for _item_invited_accounts in self.invited_accounts: - if _item_invited_accounts: - _items.append(_item_invited_accounts.to_dict()) + _items.append( + _item_invited_accounts.to_dict() + if _item_invited_accounts is not None + else None + ) _dict["invited_accounts"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/team_sub_teams_response.py b/sdks/python/dropbox_sign/models/team_sub_teams_response.py index 15e0a30c6..421fb48e5 100644 --- a/sdks/python/dropbox_sign/models/team_sub_teams_response.py +++ b/sdks/python/dropbox_sign/models/team_sub_teams_response.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TeamSubTeamsResponse(BaseModel): @@ -43,7 +44,8 @@ class TeamSubTeamsResponse(BaseModel): __properties: ClassVar[List[str]] = ["sub_teams", "list_info", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -96,8 +97,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.sub_teams: for _item_sub_teams in self.sub_teams: - if _item_sub_teams: - _items.append(_item_sub_teams.to_dict()) + _items.append( + _item_sub_teams.to_dict() if _item_sub_teams is not None else None + ) _dict["sub_teams"] = _items # override the default output from pydantic by calling `to_dict()` of list_info if self.list_info: @@ -106,8 +108,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/team_update_request.py b/sdks/python/dropbox_sign/models/team_update_request.py index 9c4b17e55..6668c2db0 100644 --- a/sdks/python/dropbox_sign/models/team_update_request.py +++ b/sdks/python/dropbox_sign/models/team_update_request.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TeamUpdateRequest(BaseModel): @@ -38,7 +39,8 @@ class TeamUpdateRequest(BaseModel): __properties: ClassVar[List[str]] = ["name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_add_user_request.py b/sdks/python/dropbox_sign/models/template_add_user_request.py index 2e4447115..63584f52e 100644 --- a/sdks/python/dropbox_sign/models/template_add_user_request.py +++ b/sdks/python/dropbox_sign/models/template_add_user_request.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateAddUserRequest(BaseModel): @@ -51,7 +52,8 @@ class TemplateAddUserRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -63,8 +65,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_create_embedded_draft_request.py b/sdks/python/dropbox_sign/models/template_create_embedded_draft_request.py index cf2090318..8c4dfebc6 100644 --- a/sdks/python/dropbox_sign/models/template_create_embedded_draft_request.py +++ b/sdks/python/dropbox_sign/models/template_create_embedded_draft_request.py @@ -36,6 +36,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateCreateEmbeddedDraftRequest(BaseModel): @@ -169,7 +170,8 @@ class TemplateCreateEmbeddedDraftRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -181,8 +183,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -222,8 +223,11 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.attachments: for _item_attachments in self.attachments: - if _item_attachments: - _items.append(_item_attachments.to_dict()) + _items.append( + _item_attachments.to_dict() + if _item_attachments is not None + else None + ) _dict["attachments"] = _items # override the default output from pydantic by calling `to_dict()` of editor_options if self.editor_options: @@ -235,36 +239,51 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.form_field_groups: for _item_form_field_groups in self.form_field_groups: - if _item_form_field_groups: - _items.append(_item_form_field_groups.to_dict()) + _items.append( + _item_form_field_groups.to_dict() + if _item_form_field_groups is not None + else None + ) _dict["form_field_groups"] = _items # override the default output from pydantic by calling `to_dict()` of each item in form_field_rules (list) _items = [] if self.form_field_rules: for _item_form_field_rules in self.form_field_rules: - if _item_form_field_rules: - _items.append(_item_form_field_rules.to_dict()) + _items.append( + _item_form_field_rules.to_dict() + if _item_form_field_rules is not None + else None + ) _dict["form_field_rules"] = _items # override the default output from pydantic by calling `to_dict()` of each item in form_fields_per_document (list) _items = [] if self.form_fields_per_document: for _item_form_fields_per_document in self.form_fields_per_document: - if _item_form_fields_per_document: - _items.append(_item_form_fields_per_document.to_dict()) + _items.append( + _item_form_fields_per_document.to_dict() + if _item_form_fields_per_document is not None + else None + ) _dict["form_fields_per_document"] = _items # override the default output from pydantic by calling `to_dict()` of each item in merge_fields (list) _items = [] if self.merge_fields: for _item_merge_fields in self.merge_fields: - if _item_merge_fields: - _items.append(_item_merge_fields.to_dict()) + _items.append( + _item_merge_fields.to_dict() + if _item_merge_fields is not None + else None + ) _dict["merge_fields"] = _items # override the default output from pydantic by calling `to_dict()` of each item in signer_roles (list) _items = [] if self.signer_roles: for _item_signer_roles in self.signer_roles: - if _item_signer_roles: - _items.append(_item_signer_roles.to_dict()) + _items.append( + _item_signer_roles.to_dict() + if _item_signer_roles is not None + else None + ) _dict["signer_roles"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/template_create_embedded_draft_response.py b/sdks/python/dropbox_sign/models/template_create_embedded_draft_response.py index fb9a0eb9a..de3306c46 100644 --- a/sdks/python/dropbox_sign/models/template_create_embedded_draft_response.py +++ b/sdks/python/dropbox_sign/models/template_create_embedded_draft_response.py @@ -29,6 +29,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateCreateEmbeddedDraftResponse(BaseModel): @@ -43,7 +44,8 @@ class TemplateCreateEmbeddedDraftResponse(BaseModel): __properties: ClassVar[List[str]] = ["template", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -99,8 +100,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/template_create_embedded_draft_response_template.py b/sdks/python/dropbox_sign/models/template_create_embedded_draft_response_template.py index 3016dce2e..789078527 100644 --- a/sdks/python/dropbox_sign/models/template_create_embedded_draft_response_template.py +++ b/sdks/python/dropbox_sign/models/template_create_embedded_draft_response_template.py @@ -26,6 +26,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateCreateEmbeddedDraftResponseTemplate(BaseModel): @@ -53,7 +54,8 @@ class TemplateCreateEmbeddedDraftResponseTemplate(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -65,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -106,8 +107,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/template_create_request.py b/sdks/python/dropbox_sign/models/template_create_request.py index 447c5abc8..7a6153839 100644 --- a/sdks/python/dropbox_sign/models/template_create_request.py +++ b/sdks/python/dropbox_sign/models/template_create_request.py @@ -35,6 +35,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateCreateRequest(BaseModel): @@ -135,7 +136,8 @@ class TemplateCreateRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -147,8 +149,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -188,22 +189,31 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.form_fields_per_document: for _item_form_fields_per_document in self.form_fields_per_document: - if _item_form_fields_per_document: - _items.append(_item_form_fields_per_document.to_dict()) + _items.append( + _item_form_fields_per_document.to_dict() + if _item_form_fields_per_document is not None + else None + ) _dict["form_fields_per_document"] = _items # override the default output from pydantic by calling `to_dict()` of each item in signer_roles (list) _items = [] if self.signer_roles: for _item_signer_roles in self.signer_roles: - if _item_signer_roles: - _items.append(_item_signer_roles.to_dict()) + _items.append( + _item_signer_roles.to_dict() + if _item_signer_roles is not None + else None + ) _dict["signer_roles"] = _items # override the default output from pydantic by calling `to_dict()` of each item in attachments (list) _items = [] if self.attachments: for _item_attachments in self.attachments: - if _item_attachments: - _items.append(_item_attachments.to_dict()) + _items.append( + _item_attachments.to_dict() + if _item_attachments is not None + else None + ) _dict["attachments"] = _items # override the default output from pydantic by calling `to_dict()` of field_options if self.field_options: @@ -212,22 +222,31 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.form_field_groups: for _item_form_field_groups in self.form_field_groups: - if _item_form_field_groups: - _items.append(_item_form_field_groups.to_dict()) + _items.append( + _item_form_field_groups.to_dict() + if _item_form_field_groups is not None + else None + ) _dict["form_field_groups"] = _items # override the default output from pydantic by calling `to_dict()` of each item in form_field_rules (list) _items = [] if self.form_field_rules: for _item_form_field_rules in self.form_field_rules: - if _item_form_field_rules: - _items.append(_item_form_field_rules.to_dict()) + _items.append( + _item_form_field_rules.to_dict() + if _item_form_field_rules is not None + else None + ) _dict["form_field_rules"] = _items # override the default output from pydantic by calling `to_dict()` of each item in merge_fields (list) _items = [] if self.merge_fields: for _item_merge_fields in self.merge_fields: - if _item_merge_fields: - _items.append(_item_merge_fields.to_dict()) + _items.append( + _item_merge_fields.to_dict() + if _item_merge_fields is not None + else None + ) _dict["merge_fields"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/template_create_response.py b/sdks/python/dropbox_sign/models/template_create_response.py index bc5f6c6a2..a66b99a0c 100644 --- a/sdks/python/dropbox_sign/models/template_create_response.py +++ b/sdks/python/dropbox_sign/models/template_create_response.py @@ -29,6 +29,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateCreateResponse(BaseModel): @@ -43,7 +44,8 @@ class TemplateCreateResponse(BaseModel): __properties: ClassVar[List[str]] = ["template", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -99,8 +100,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/template_create_response_template.py b/sdks/python/dropbox_sign/models/template_create_response_template.py index 25d9bd7bd..cee458dc2 100644 --- a/sdks/python/dropbox_sign/models/template_create_response_template.py +++ b/sdks/python/dropbox_sign/models/template_create_response_template.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateCreateResponseTemplate(BaseModel): @@ -38,7 +39,8 @@ class TemplateCreateResponseTemplate(BaseModel): __properties: ClassVar[List[str]] = ["template_id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_get_response.py b/sdks/python/dropbox_sign/models/template_get_response.py index 10d714c52..a9ba6ade8 100644 --- a/sdks/python/dropbox_sign/models/template_get_response.py +++ b/sdks/python/dropbox_sign/models/template_get_response.py @@ -27,6 +27,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateGetResponse(BaseModel): @@ -41,7 +42,8 @@ class TemplateGetResponse(BaseModel): __properties: ClassVar[List[str]] = ["template", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -97,8 +98,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/template_list_response.py b/sdks/python/dropbox_sign/models/template_list_response.py index 5ccaba716..80f6f40b8 100644 --- a/sdks/python/dropbox_sign/models/template_list_response.py +++ b/sdks/python/dropbox_sign/models/template_list_response.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateListResponse(BaseModel): @@ -45,7 +46,8 @@ class TemplateListResponse(BaseModel): __properties: ClassVar[List[str]] = ["templates", "list_info", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -98,8 +99,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.templates: for _item_templates in self.templates: - if _item_templates: - _items.append(_item_templates.to_dict()) + _items.append( + _item_templates.to_dict() if _item_templates is not None else None + ) _dict["templates"] = _items # override the default output from pydantic by calling `to_dict()` of list_info if self.list_info: @@ -108,8 +110,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/template_remove_user_request.py b/sdks/python/dropbox_sign/models/template_remove_user_request.py index 44ddbf42e..8ec44a6ff 100644 --- a/sdks/python/dropbox_sign/models/template_remove_user_request.py +++ b/sdks/python/dropbox_sign/models/template_remove_user_request.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateRemoveUserRequest(BaseModel): @@ -43,7 +44,8 @@ class TemplateRemoveUserRequest(BaseModel): __properties: ClassVar[List[str]] = ["account_id", "email_address"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response.py b/sdks/python/dropbox_sign/models/template_response.py index 667465fff..c5810958e 100644 --- a/sdks/python/dropbox_sign/models/template_response.py +++ b/sdks/python/dropbox_sign/models/template_response.py @@ -38,6 +38,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponse(BaseModel): @@ -124,7 +125,8 @@ class TemplateResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -136,8 +138,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -177,50 +178,65 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.signer_roles: for _item_signer_roles in self.signer_roles: - if _item_signer_roles: - _items.append(_item_signer_roles.to_dict()) + _items.append( + _item_signer_roles.to_dict() + if _item_signer_roles is not None + else None + ) _dict["signer_roles"] = _items # override the default output from pydantic by calling `to_dict()` of each item in cc_roles (list) _items = [] if self.cc_roles: for _item_cc_roles in self.cc_roles: - if _item_cc_roles: - _items.append(_item_cc_roles.to_dict()) + _items.append( + _item_cc_roles.to_dict() if _item_cc_roles is not None else None + ) _dict["cc_roles"] = _items # override the default output from pydantic by calling `to_dict()` of each item in documents (list) _items = [] if self.documents: for _item_documents in self.documents: - if _item_documents: - _items.append(_item_documents.to_dict()) + _items.append( + _item_documents.to_dict() if _item_documents is not None else None + ) _dict["documents"] = _items # override the default output from pydantic by calling `to_dict()` of each item in custom_fields (list) _items = [] if self.custom_fields: for _item_custom_fields in self.custom_fields: - if _item_custom_fields: - _items.append(_item_custom_fields.to_dict()) + _items.append( + _item_custom_fields.to_dict() + if _item_custom_fields is not None + else None + ) _dict["custom_fields"] = _items # override the default output from pydantic by calling `to_dict()` of each item in named_form_fields (list) _items = [] if self.named_form_fields: for _item_named_form_fields in self.named_form_fields: - if _item_named_form_fields: - _items.append(_item_named_form_fields.to_dict()) + _items.append( + _item_named_form_fields.to_dict() + if _item_named_form_fields is not None + else None + ) _dict["named_form_fields"] = _items # override the default output from pydantic by calling `to_dict()` of each item in accounts (list) _items = [] if self.accounts: for _item_accounts in self.accounts: - if _item_accounts: - _items.append(_item_accounts.to_dict()) + _items.append( + _item_accounts.to_dict() if _item_accounts is not None else None + ) _dict["accounts"] = _items # override the default output from pydantic by calling `to_dict()` of each item in attachments (list) _items = [] if self.attachments: for _item_attachments in self.attachments: - if _item_attachments: - _items.append(_item_attachments.to_dict()) + _items.append( + _item_attachments.to_dict() + if _item_attachments is not None + else None + ) _dict["attachments"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/template_response_account.py b/sdks/python/dropbox_sign/models/template_response_account.py index d29db33d0..314407780 100644 --- a/sdks/python/dropbox_sign/models/template_response_account.py +++ b/sdks/python/dropbox_sign/models/template_response_account.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseAccount(BaseModel): @@ -64,7 +65,8 @@ class TemplateResponseAccount(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -76,8 +78,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_account_quota.py b/sdks/python/dropbox_sign/models/template_response_account_quota.py index e4fa3668b..42b722baa 100644 --- a/sdks/python/dropbox_sign/models/template_response_account_quota.py +++ b/sdks/python/dropbox_sign/models/template_response_account_quota.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseAccountQuota(BaseModel): @@ -52,7 +53,8 @@ class TemplateResponseAccountQuota(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -64,8 +66,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_cc_role.py b/sdks/python/dropbox_sign/models/template_response_cc_role.py index 89a3b4c88..ccbee99ae 100644 --- a/sdks/python/dropbox_sign/models/template_response_cc_role.py +++ b/sdks/python/dropbox_sign/models/template_response_cc_role.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseCCRole(BaseModel): @@ -36,7 +37,8 @@ class TemplateResponseCCRole(BaseModel): __properties: ClassVar[List[str]] = ["name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document.py b/sdks/python/dropbox_sign/models/template_response_document.py index d2f0cafb6..ee5c0c79c 100644 --- a/sdks/python/dropbox_sign/models/template_response_document.py +++ b/sdks/python/dropbox_sign/models/template_response_document.py @@ -37,6 +37,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocument(BaseModel): @@ -76,7 +77,8 @@ class TemplateResponseDocument(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -88,8 +90,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -129,29 +130,41 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.field_groups: for _item_field_groups in self.field_groups: - if _item_field_groups: - _items.append(_item_field_groups.to_dict()) + _items.append( + _item_field_groups.to_dict() + if _item_field_groups is not None + else None + ) _dict["field_groups"] = _items # override the default output from pydantic by calling `to_dict()` of each item in form_fields (list) _items = [] if self.form_fields: for _item_form_fields in self.form_fields: - if _item_form_fields: - _items.append(_item_form_fields.to_dict()) + _items.append( + _item_form_fields.to_dict() + if _item_form_fields is not None + else None + ) _dict["form_fields"] = _items # override the default output from pydantic by calling `to_dict()` of each item in custom_fields (list) _items = [] if self.custom_fields: for _item_custom_fields in self.custom_fields: - if _item_custom_fields: - _items.append(_item_custom_fields.to_dict()) + _items.append( + _item_custom_fields.to_dict() + if _item_custom_fields is not None + else None + ) _dict["custom_fields"] = _items # override the default output from pydantic by calling `to_dict()` of each item in static_fields (list) _items = [] if self.static_fields: for _item_static_fields in self.static_fields: - if _item_static_fields: - _items.append(_item_static_fields.to_dict()) + _items.append( + _item_static_fields.to_dict() + if _item_static_fields is not None + else None + ) _dict["static_fields"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/template_response_document_custom_field_base.py b/sdks/python/dropbox_sign/models/template_response_document_custom_field_base.py index 6c6a35b7e..4ca2f0dce 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_custom_field_base.py +++ b/sdks/python/dropbox_sign/models/template_response_document_custom_field_base.py @@ -26,6 +26,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python from typing import TYPE_CHECKING @@ -87,7 +88,8 @@ class TemplateResponseDocumentCustomFieldBase(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -105,7 +107,7 @@ class TemplateResponseDocumentCustomFieldBase(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: @@ -117,8 +119,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_custom_field_checkbox.py b/sdks/python/dropbox_sign/models/template_response_document_custom_field_checkbox.py index 35e391517..2ef61854b 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_custom_field_checkbox.py +++ b/sdks/python/dropbox_sign/models/template_response_document_custom_field_checkbox.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocumentCustomFieldCheckbox( @@ -54,7 +55,8 @@ class TemplateResponseDocumentCustomFieldCheckbox( ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -66,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_custom_field_text.py b/sdks/python/dropbox_sign/models/template_response_document_custom_field_text.py index 09a85e20f..23c6ba0c1 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_custom_field_text.py +++ b/sdks/python/dropbox_sign/models/template_response_document_custom_field_text.py @@ -31,6 +31,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocumentCustomFieldText(TemplateResponseDocumentCustomFieldBase): @@ -75,7 +76,8 @@ class TemplateResponseDocumentCustomFieldText(TemplateResponseDocumentCustomFiel ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -87,8 +89,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_field_group.py b/sdks/python/dropbox_sign/models/template_response_document_field_group.py index 8f3bc1a16..74103c8ed 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_field_group.py +++ b/sdks/python/dropbox_sign/models/template_response_document_field_group.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocumentFieldGroup(BaseModel): @@ -42,7 +43,8 @@ class TemplateResponseDocumentFieldGroup(BaseModel): __properties: ClassVar[List[str]] = ["name", "rule"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_field_group_rule.py b/sdks/python/dropbox_sign/models/template_response_document_field_group_rule.py index 17d81cbd9..20fd0dcc3 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_field_group_rule.py +++ b/sdks/python/dropbox_sign/models/template_response_document_field_group_rule.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocumentFieldGroupRule(BaseModel): @@ -42,7 +43,8 @@ class TemplateResponseDocumentFieldGroupRule(BaseModel): __properties: ClassVar[List[str]] = ["requirement", "groupLabel"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_form_field_base.py b/sdks/python/dropbox_sign/models/template_response_document_form_field_base.py index 6f8777a3b..3a89122e6 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_form_field_base.py +++ b/sdks/python/dropbox_sign/models/template_response_document_form_field_base.py @@ -26,6 +26,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python from typing import TYPE_CHECKING @@ -100,7 +101,8 @@ class TemplateResponseDocumentFormFieldBase(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -124,7 +126,7 @@ class TemplateResponseDocumentFormFieldBase(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: @@ -136,8 +138,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_form_field_checkbox.py b/sdks/python/dropbox_sign/models/template_response_document_form_field_checkbox.py index d81d6572a..2cad4bed8 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_form_field_checkbox.py +++ b/sdks/python/dropbox_sign/models/template_response_document_form_field_checkbox.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocumentFormFieldCheckbox(TemplateResponseDocumentFormFieldBase): @@ -56,7 +57,8 @@ class TemplateResponseDocumentFormFieldCheckbox(TemplateResponseDocumentFormFiel ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -68,8 +70,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_form_field_date_signed.py b/sdks/python/dropbox_sign/models/template_response_document_form_field_date_signed.py index 8ee5fe31b..2f6339f22 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_form_field_date_signed.py +++ b/sdks/python/dropbox_sign/models/template_response_document_form_field_date_signed.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocumentFormFieldDateSigned( @@ -58,7 +59,8 @@ class TemplateResponseDocumentFormFieldDateSigned( ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -70,8 +72,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_form_field_dropdown.py b/sdks/python/dropbox_sign/models/template_response_document_form_field_dropdown.py index 808f449b0..c233b12f7 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_form_field_dropdown.py +++ b/sdks/python/dropbox_sign/models/template_response_document_form_field_dropdown.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocumentFormFieldDropdown(TemplateResponseDocumentFormFieldBase): @@ -60,7 +61,8 @@ class TemplateResponseDocumentFormFieldDropdown(TemplateResponseDocumentFormFiel ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -72,8 +74,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_form_field_hyperlink.py b/sdks/python/dropbox_sign/models/template_response_document_form_field_hyperlink.py index 0102248d3..908330262 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_form_field_hyperlink.py +++ b/sdks/python/dropbox_sign/models/template_response_document_form_field_hyperlink.py @@ -31,6 +31,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocumentFormFieldHyperlink(TemplateResponseDocumentFormFieldBase): @@ -79,7 +80,8 @@ class TemplateResponseDocumentFormFieldHyperlink(TemplateResponseDocumentFormFie ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -91,8 +93,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_form_field_initials.py b/sdks/python/dropbox_sign/models/template_response_document_form_field_initials.py index 64321add8..2c9d9c066 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_form_field_initials.py +++ b/sdks/python/dropbox_sign/models/template_response_document_form_field_initials.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocumentFormFieldInitials(TemplateResponseDocumentFormFieldBase): @@ -56,7 +57,8 @@ class TemplateResponseDocumentFormFieldInitials(TemplateResponseDocumentFormFiel ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -68,8 +70,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_form_field_radio.py b/sdks/python/dropbox_sign/models/template_response_document_form_field_radio.py index 0f0c3443a..9c897731a 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_form_field_radio.py +++ b/sdks/python/dropbox_sign/models/template_response_document_form_field_radio.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocumentFormFieldRadio(TemplateResponseDocumentFormFieldBase): @@ -55,7 +56,8 @@ class TemplateResponseDocumentFormFieldRadio(TemplateResponseDocumentFormFieldBa ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -67,8 +69,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_form_field_signature.py b/sdks/python/dropbox_sign/models/template_response_document_form_field_signature.py index c509f92ce..39f408f15 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_form_field_signature.py +++ b/sdks/python/dropbox_sign/models/template_response_document_form_field_signature.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocumentFormFieldSignature(TemplateResponseDocumentFormFieldBase): @@ -56,7 +57,8 @@ class TemplateResponseDocumentFormFieldSignature(TemplateResponseDocumentFormFie ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -68,8 +70,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_form_field_text.py b/sdks/python/dropbox_sign/models/template_response_document_form_field_text.py index 6280970f4..ce9a5e01b 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_form_field_text.py +++ b/sdks/python/dropbox_sign/models/template_response_document_form_field_text.py @@ -38,6 +38,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocumentFormFieldText(TemplateResponseDocumentFormFieldBase): @@ -126,7 +127,8 @@ def validation_type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -138,8 +140,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_static_field_base.py b/sdks/python/dropbox_sign/models/template_response_document_static_field_base.py index d9735c703..19d04637c 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_static_field_base.py +++ b/sdks/python/dropbox_sign/models/template_response_document_static_field_base.py @@ -26,6 +26,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python from typing import TYPE_CHECKING @@ -106,7 +107,8 @@ class TemplateResponseDocumentStaticFieldBase(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -130,7 +132,7 @@ class TemplateResponseDocumentStaticFieldBase(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: @@ -142,8 +144,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_static_field_checkbox.py b/sdks/python/dropbox_sign/models/template_response_document_static_field_checkbox.py index 0afba0d9f..920299e17 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_static_field_checkbox.py +++ b/sdks/python/dropbox_sign/models/template_response_document_static_field_checkbox.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocumentStaticFieldCheckbox( @@ -54,7 +55,8 @@ class TemplateResponseDocumentStaticFieldCheckbox( ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -66,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_static_field_date_signed.py b/sdks/python/dropbox_sign/models/template_response_document_static_field_date_signed.py index 0b232a6c9..ba72fa755 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_static_field_date_signed.py +++ b/sdks/python/dropbox_sign/models/template_response_document_static_field_date_signed.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocumentStaticFieldDateSigned( @@ -54,7 +55,8 @@ class TemplateResponseDocumentStaticFieldDateSigned( ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -66,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_static_field_dropdown.py b/sdks/python/dropbox_sign/models/template_response_document_static_field_dropdown.py index 7ac71ec4e..4d18fb57f 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_static_field_dropdown.py +++ b/sdks/python/dropbox_sign/models/template_response_document_static_field_dropdown.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocumentStaticFieldDropdown( @@ -54,7 +55,8 @@ class TemplateResponseDocumentStaticFieldDropdown( ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -66,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_static_field_hyperlink.py b/sdks/python/dropbox_sign/models/template_response_document_static_field_hyperlink.py index bdd27c9d2..364912b03 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_static_field_hyperlink.py +++ b/sdks/python/dropbox_sign/models/template_response_document_static_field_hyperlink.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocumentStaticFieldHyperlink( @@ -54,7 +55,8 @@ class TemplateResponseDocumentStaticFieldHyperlink( ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -66,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_static_field_initials.py b/sdks/python/dropbox_sign/models/template_response_document_static_field_initials.py index bd755ee8e..ce490af99 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_static_field_initials.py +++ b/sdks/python/dropbox_sign/models/template_response_document_static_field_initials.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocumentStaticFieldInitials( @@ -54,7 +55,8 @@ class TemplateResponseDocumentStaticFieldInitials( ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -66,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_static_field_radio.py b/sdks/python/dropbox_sign/models/template_response_document_static_field_radio.py index a78d5b803..b9f85f0c4 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_static_field_radio.py +++ b/sdks/python/dropbox_sign/models/template_response_document_static_field_radio.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocumentStaticFieldRadio(TemplateResponseDocumentStaticFieldBase): @@ -52,7 +53,8 @@ class TemplateResponseDocumentStaticFieldRadio(TemplateResponseDocumentStaticFie ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -64,8 +66,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_static_field_signature.py b/sdks/python/dropbox_sign/models/template_response_document_static_field_signature.py index c0ff8eee6..e78e4af9e 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_static_field_signature.py +++ b/sdks/python/dropbox_sign/models/template_response_document_static_field_signature.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocumentStaticFieldSignature( @@ -54,7 +55,8 @@ class TemplateResponseDocumentStaticFieldSignature( ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -66,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_document_static_field_text.py b/sdks/python/dropbox_sign/models/template_response_document_static_field_text.py index 03a3a4831..e057ebafe 100644 --- a/sdks/python/dropbox_sign/models/template_response_document_static_field_text.py +++ b/sdks/python/dropbox_sign/models/template_response_document_static_field_text.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseDocumentStaticFieldText(TemplateResponseDocumentStaticFieldBase): @@ -52,7 +53,8 @@ class TemplateResponseDocumentStaticFieldText(TemplateResponseDocumentStaticFiel ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -64,8 +66,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_field_avg_text_length.py b/sdks/python/dropbox_sign/models/template_response_field_avg_text_length.py index 1936e75ee..f338dab6e 100644 --- a/sdks/python/dropbox_sign/models/template_response_field_avg_text_length.py +++ b/sdks/python/dropbox_sign/models/template_response_field_avg_text_length.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseFieldAvgTextLength(BaseModel): @@ -39,7 +40,8 @@ class TemplateResponseFieldAvgTextLength(BaseModel): __properties: ClassVar[List[str]] = ["num_lines", "num_chars_per_line"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_response_signer_role.py b/sdks/python/dropbox_sign/models/template_response_signer_role.py index 2cada158d..3a87a9d67 100644 --- a/sdks/python/dropbox_sign/models/template_response_signer_role.py +++ b/sdks/python/dropbox_sign/models/template_response_signer_role.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateResponseSignerRole(BaseModel): @@ -40,7 +41,8 @@ class TemplateResponseSignerRole(BaseModel): __properties: ClassVar[List[str]] = ["name", "order"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -52,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_update_files_request.py b/sdks/python/dropbox_sign/models/template_update_files_request.py index 18612ddbf..6abb737a7 100644 --- a/sdks/python/dropbox_sign/models/template_update_files_request.py +++ b/sdks/python/dropbox_sign/models/template_update_files_request.py @@ -26,6 +26,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateUpdateFilesRequest(BaseModel): @@ -67,7 +68,8 @@ class TemplateUpdateFilesRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -79,8 +81,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_update_files_response.py b/sdks/python/dropbox_sign/models/template_update_files_response.py index 67b1d3b68..2ff3c4b2a 100644 --- a/sdks/python/dropbox_sign/models/template_update_files_response.py +++ b/sdks/python/dropbox_sign/models/template_update_files_response.py @@ -28,6 +28,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateUpdateFilesResponse(BaseModel): @@ -39,7 +40,8 @@ class TemplateUpdateFilesResponse(BaseModel): __properties: ClassVar[List[str]] = ["template"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/template_update_files_response_template.py b/sdks/python/dropbox_sign/models/template_update_files_response_template.py index 2a8cd11ad..c31b70f76 100644 --- a/sdks/python/dropbox_sign/models/template_update_files_response_template.py +++ b/sdks/python/dropbox_sign/models/template_update_files_response_template.py @@ -26,6 +26,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class TemplateUpdateFilesResponseTemplate(BaseModel): @@ -42,7 +43,8 @@ class TemplateUpdateFilesResponseTemplate(BaseModel): __properties: ClassVar[List[str]] = ["template_id", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -95,8 +96,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/unclaimed_draft_create_embedded_request.py b/sdks/python/dropbox_sign/models/unclaimed_draft_create_embedded_request.py index 26e98fb43..f49bccf44 100644 --- a/sdks/python/dropbox_sign/models/unclaimed_draft_create_embedded_request.py +++ b/sdks/python/dropbox_sign/models/unclaimed_draft_create_embedded_request.py @@ -46,6 +46,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class UnclaimedDraftCreateEmbeddedRequest(BaseModel): @@ -241,7 +242,8 @@ def type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -253,8 +255,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -294,15 +295,21 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.attachments: for _item_attachments in self.attachments: - if _item_attachments: - _items.append(_item_attachments.to_dict()) + _items.append( + _item_attachments.to_dict() + if _item_attachments is not None + else None + ) _dict["attachments"] = _items # override the default output from pydantic by calling `to_dict()` of each item in custom_fields (list) _items = [] if self.custom_fields: for _item_custom_fields in self.custom_fields: - if _item_custom_fields: - _items.append(_item_custom_fields.to_dict()) + _items.append( + _item_custom_fields.to_dict() + if _item_custom_fields is not None + else None + ) _dict["custom_fields"] = _items # override the default output from pydantic by calling `to_dict()` of editor_options if self.editor_options: @@ -314,29 +321,39 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.form_field_groups: for _item_form_field_groups in self.form_field_groups: - if _item_form_field_groups: - _items.append(_item_form_field_groups.to_dict()) + _items.append( + _item_form_field_groups.to_dict() + if _item_form_field_groups is not None + else None + ) _dict["form_field_groups"] = _items # override the default output from pydantic by calling `to_dict()` of each item in form_field_rules (list) _items = [] if self.form_field_rules: for _item_form_field_rules in self.form_field_rules: - if _item_form_field_rules: - _items.append(_item_form_field_rules.to_dict()) + _items.append( + _item_form_field_rules.to_dict() + if _item_form_field_rules is not None + else None + ) _dict["form_field_rules"] = _items # override the default output from pydantic by calling `to_dict()` of each item in form_fields_per_document (list) _items = [] if self.form_fields_per_document: for _item_form_fields_per_document in self.form_fields_per_document: - if _item_form_fields_per_document: - _items.append(_item_form_fields_per_document.to_dict()) + _items.append( + _item_form_fields_per_document.to_dict() + if _item_form_fields_per_document is not None + else None + ) _dict["form_fields_per_document"] = _items # override the default output from pydantic by calling `to_dict()` of each item in signers (list) _items = [] if self.signers: for _item_signers in self.signers: - if _item_signers: - _items.append(_item_signers.to_dict()) + _items.append( + _item_signers.to_dict() if _item_signers is not None else None + ) _dict["signers"] = _items # override the default output from pydantic by calling `to_dict()` of signing_options if self.signing_options: diff --git a/sdks/python/dropbox_sign/models/unclaimed_draft_create_embedded_with_template_request.py b/sdks/python/dropbox_sign/models/unclaimed_draft_create_embedded_with_template_request.py index 3ab702393..0784768ee 100644 --- a/sdks/python/dropbox_sign/models/unclaimed_draft_create_embedded_with_template_request.py +++ b/sdks/python/dropbox_sign/models/unclaimed_draft_create_embedded_with_template_request.py @@ -34,6 +34,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class UnclaimedDraftCreateEmbeddedWithTemplateRequest(BaseModel): @@ -185,7 +186,8 @@ class UnclaimedDraftCreateEmbeddedWithTemplateRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -197,8 +199,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -238,15 +239,17 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.ccs: for _item_ccs in self.ccs: - if _item_ccs: - _items.append(_item_ccs.to_dict()) + _items.append(_item_ccs.to_dict() if _item_ccs is not None else None) _dict["ccs"] = _items # override the default output from pydantic by calling `to_dict()` of each item in custom_fields (list) _items = [] if self.custom_fields: for _item_custom_fields in self.custom_fields: - if _item_custom_fields: - _items.append(_item_custom_fields.to_dict()) + _items.append( + _item_custom_fields.to_dict() + if _item_custom_fields is not None + else None + ) _dict["custom_fields"] = _items # override the default output from pydantic by calling `to_dict()` of editor_options if self.editor_options: @@ -258,8 +261,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.signers: for _item_signers in self.signers: - if _item_signers: - _items.append(_item_signers.to_dict()) + _items.append( + _item_signers.to_dict() if _item_signers is not None else None + ) _dict["signers"] = _items # override the default output from pydantic by calling `to_dict()` of signing_options if self.signing_options: diff --git a/sdks/python/dropbox_sign/models/unclaimed_draft_create_request.py b/sdks/python/dropbox_sign/models/unclaimed_draft_create_request.py index deacb02c8..7c5340508 100644 --- a/sdks/python/dropbox_sign/models/unclaimed_draft_create_request.py +++ b/sdks/python/dropbox_sign/models/unclaimed_draft_create_request.py @@ -45,6 +45,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class UnclaimedDraftCreateRequest(BaseModel): @@ -181,7 +182,8 @@ def type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -193,8 +195,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -234,15 +235,21 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.attachments: for _item_attachments in self.attachments: - if _item_attachments: - _items.append(_item_attachments.to_dict()) + _items.append( + _item_attachments.to_dict() + if _item_attachments is not None + else None + ) _dict["attachments"] = _items # override the default output from pydantic by calling `to_dict()` of each item in custom_fields (list) _items = [] if self.custom_fields: for _item_custom_fields in self.custom_fields: - if _item_custom_fields: - _items.append(_item_custom_fields.to_dict()) + _items.append( + _item_custom_fields.to_dict() + if _item_custom_fields is not None + else None + ) _dict["custom_fields"] = _items # override the default output from pydantic by calling `to_dict()` of field_options if self.field_options: @@ -251,29 +258,39 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.form_field_groups: for _item_form_field_groups in self.form_field_groups: - if _item_form_field_groups: - _items.append(_item_form_field_groups.to_dict()) + _items.append( + _item_form_field_groups.to_dict() + if _item_form_field_groups is not None + else None + ) _dict["form_field_groups"] = _items # override the default output from pydantic by calling `to_dict()` of each item in form_field_rules (list) _items = [] if self.form_field_rules: for _item_form_field_rules in self.form_field_rules: - if _item_form_field_rules: - _items.append(_item_form_field_rules.to_dict()) + _items.append( + _item_form_field_rules.to_dict() + if _item_form_field_rules is not None + else None + ) _dict["form_field_rules"] = _items # override the default output from pydantic by calling `to_dict()` of each item in form_fields_per_document (list) _items = [] if self.form_fields_per_document: for _item_form_fields_per_document in self.form_fields_per_document: - if _item_form_fields_per_document: - _items.append(_item_form_fields_per_document.to_dict()) + _items.append( + _item_form_fields_per_document.to_dict() + if _item_form_fields_per_document is not None + else None + ) _dict["form_fields_per_document"] = _items # override the default output from pydantic by calling `to_dict()` of each item in signers (list) _items = [] if self.signers: for _item_signers in self.signers: - if _item_signers: - _items.append(_item_signers.to_dict()) + _items.append( + _item_signers.to_dict() if _item_signers is not None else None + ) _dict["signers"] = _items # override the default output from pydantic by calling `to_dict()` of signing_options if self.signing_options: diff --git a/sdks/python/dropbox_sign/models/unclaimed_draft_create_response.py b/sdks/python/dropbox_sign/models/unclaimed_draft_create_response.py index 085e5b907..2d48454f1 100644 --- a/sdks/python/dropbox_sign/models/unclaimed_draft_create_response.py +++ b/sdks/python/dropbox_sign/models/unclaimed_draft_create_response.py @@ -27,6 +27,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class UnclaimedDraftCreateResponse(BaseModel): @@ -41,7 +42,8 @@ class UnclaimedDraftCreateResponse(BaseModel): __properties: ClassVar[List[str]] = ["unclaimed_draft", "warnings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None @@ -97,8 +98,9 @@ def to_dict(self, excluded_fields: Set[str] = None) -> Dict[str, Any]: _items = [] if self.warnings: for _item_warnings in self.warnings: - if _item_warnings: - _items.append(_item_warnings.to_dict()) + _items.append( + _item_warnings.to_dict() if _item_warnings is not None else None + ) _dict["warnings"] = _items return _dict diff --git a/sdks/python/dropbox_sign/models/unclaimed_draft_edit_and_resend_request.py b/sdks/python/dropbox_sign/models/unclaimed_draft_edit_and_resend_request.py index 38903beef..ddc2c29c6 100644 --- a/sdks/python/dropbox_sign/models/unclaimed_draft_edit_and_resend_request.py +++ b/sdks/python/dropbox_sign/models/unclaimed_draft_edit_and_resend_request.py @@ -26,6 +26,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class UnclaimedDraftEditAndResendRequest(BaseModel): @@ -73,7 +74,8 @@ class UnclaimedDraftEditAndResendRequest(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -85,8 +87,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/unclaimed_draft_response.py b/sdks/python/dropbox_sign/models/unclaimed_draft_response.py index 51fdcfa9b..c25764839 100644 --- a/sdks/python/dropbox_sign/models/unclaimed_draft_response.py +++ b/sdks/python/dropbox_sign/models/unclaimed_draft_response.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class UnclaimedDraftResponse(BaseModel): @@ -64,7 +65,8 @@ class UnclaimedDraftResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -76,8 +78,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/models/warning_response.py b/sdks/python/dropbox_sign/models/warning_response.py index d2a26d5c3..574edda06 100644 --- a/sdks/python/dropbox_sign/models/warning_response.py +++ b/sdks/python/dropbox_sign/models/warning_response.py @@ -25,6 +25,7 @@ from typing import Tuple, Union import io from pydantic import StrictBool +from pydantic_core import to_jsonable_python class WarningResponse(BaseModel): @@ -37,7 +38,8 @@ class WarningResponse(BaseModel): __properties: ClassVar[List[str]] = ["warning_msg", "warning_name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), arbitrary_types_allowed=True, @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) def to_json_form_params( self, excluded_fields: Set[str] = None diff --git a/sdks/python/dropbox_sign/rest.py b/sdks/python/dropbox_sign/rest.py index 4aaa80dbe..f0f87e527 100644 --- a/sdks/python/dropbox_sign/rest.py +++ b/sdks/python/dropbox_sign/rest.py @@ -13,10 +13,12 @@ """ # noqa: E501 +import ipaddress import io import json import re import ssl +from urllib.parse import urlparse import urllib3 @@ -36,6 +38,61 @@ def is_socks_proxy_url(url): return split_section[0].lower() in SUPPORTED_SOCKS_PROXIES +def contenttype_matches(contenttype, maintype, subtype): + """Matches the given contenttype against the given type and subtype + + :param contenttype: the content type to match + :param maintype: the expected maintype + :param subtype: the expected subtype + :return: `true` when the given content type matches the given type and subtype, + regardless of the presence of mime type parameters, otherwise returns `false`. + :rtype: bool + """ + pattern = "{type}/(?:[^+;]+\\+)?{subtype}(?:[ \t]*;.*)?".format( + type=re.escape(maintype), + subtype=re.escape(subtype), + ) + return re.fullmatch(pattern, contenttype, re.IGNORECASE) is not None + + +def should_bypass_proxies(url: str, no_proxy: str) -> bool: + """Return whether ``url`` matches the comma-separated ``no_proxy`` rules.""" + parsed_url = urlparse(url) + if not parsed_url.hostname: + return True + + host = parsed_url.hostname.lower() + host_and_port = parsed_url.netloc.lower() + try: + host_ip = ipaddress.ip_address(host) + except ValueError: + host_ip = None + + for entry in (entry.strip().lower() for entry in no_proxy.split(",")): + if not entry: + continue + if entry == "*": + return True + + if host_ip is not None: + try: + if host_ip in ipaddress.ip_network(entry, strict=False): + return True + except ValueError: + pass + + entry = entry.lstrip(".") + if ( + host == entry + or host.endswith("." + entry) + or host_and_port == entry + or host_and_port.endswith("." + entry) + ): + return True + + return False + + class RESTResponse(io.IOBase): def __init__(self, resp) -> None: @@ -49,12 +106,17 @@ def read(self): self.data = self.response.data return self.data + @property + def headers(self): + """Returns a dictionary of response headers.""" + return self.response.headers + def getheaders(self): - """Returns a dictionary of the response headers.""" + """Returns a dictionary of the response headers; use ``headers`` instead.""" return self.response.headers def getheader(self, name, default=None): - """Returns a given response header.""" + """Returns a given response header; use ``headers.get()`` instead.""" return self.response.headers.get(name, default) @@ -97,7 +159,9 @@ def __init__(self, configuration) -> None: # https pool manager self.pool_manager: urllib3.PoolManager - if configuration.proxy: + if configuration.proxy and not should_bypass_proxies( + configuration.host, configuration.no_proxy or "" + ): if is_socks_proxy_url(configuration.proxy): from urllib3.contrib.socks import SOCKSProxyManager @@ -107,6 +171,8 @@ def __init__(self, configuration) -> None: else: pool_args["proxy_url"] = configuration.proxy pool_args["proxy_headers"] = configuration.proxy_headers + if configuration.proxy_ssl_context is not None: + pool_args["proxy_ssl_context"] = configuration.proxy_ssl_context self.pool_manager = urllib3.ProxyManager(**pool_args) else: self.pool_manager = urllib3.PoolManager(**pool_args) @@ -158,9 +224,23 @@ def request( # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` if method in ["POST", "PUT", "PATCH", "OPTIONS", "DELETE"]: - # no content type provided or payload is json content_type = headers.get("Content-Type") - if not content_type or re.search("json", content_type, re.IGNORECASE): + is_json = not content_type or contenttype_matches( + content_type, "application", "json" + ) + # JSON is valid YAML 1.2, so structured YAML bodies can use + # the existing JSON serializer: + # https://yaml.org/spec/1.2.2/#13-relation-to-json + is_structured_yaml = ( + content_type + and ( + contenttype_matches(content_type, "application", "yaml") + or contenttype_matches(content_type, "text", "yaml") + or contenttype_matches(content_type, "text", "x-yaml") + ) + and not isinstance(body, (str, bytes)) + ) + if is_json or is_structured_yaml: request_body = None if body is not None: request_body = json.dumps(body) @@ -172,7 +252,9 @@ def request( headers=headers, preload_content=False, ) - elif content_type == "application/x-www-form-urlencoded": + elif contenttype_matches( + content_type, "application", "x-www-form-urlencoded" + ): r = self.pool_manager.request( method, url, @@ -182,7 +264,7 @@ def request( headers=headers, preload_content=False, ) - elif content_type == "multipart/form-data": + elif contenttype_matches(content_type, "multipart", "form-data"): # must del headers['Content-Type'], or the correct # Content-Type which generated by urllib3 will be # overwritten. @@ -213,9 +295,7 @@ def request( headers=headers, preload_content=False, ) - elif headers["Content-Type"].startswith("text/") and isinstance( - body, bool - ): + elif content_type.startswith("text/") and isinstance(body, bool): request_body = "true" if body else "false" r = self.pool_manager.request( method, diff --git a/sdks/python/openapi-config.yaml b/sdks/python/openapi-config.yaml index 750aa245d..607fc703b 100644 --- a/sdks/python/openapi-config.yaml +++ b/sdks/python/openapi-config.yaml @@ -2,7 +2,7 @@ generatorName: python typeMappings: "bytearray": "io.IOBase" additionalProperties: - generatorLanguageVersion: ">=3.8" + generatorLanguageVersion: ">=3.10" packageName: dropbox_sign projectName: dropbox-sign packageVersion: 1.11-dev diff --git a/sdks/python/pyproject.toml b/sdks/python/pyproject.toml index 53d823bc6..05c2a0436 100644 --- a/sdks/python/pyproject.toml +++ b/sdks/python/pyproject.toml @@ -1,32 +1,34 @@ -[tool.poetry] -name = "dropbox_sign" +[project] +name = "dropbox-sign" version = "1.11-dev" description = "Dropbox Sign API" -authors = ["Official Python SDK for the Dropbox Sign API "] -license = "MIT" +authors = [ + {name = "Dropbox Sign API Team",email = "apisupport@hellosign.com"}, +] +license = { text = "MIT" } readme = "README.md" -repository = "https://github.com/GIT_USER_ID/GIT_REPO_ID" keywords = ["OpenAPI", "OpenAPI-Generator", "Dropbox Sign API"] -include = ["dropbox_sign/py.typed"] - -[tool.poetry.dependencies] -python = "^3.8" +requires-python = ">=3.10" -urllib3 = [ - { version = ">= 2.8.0, < 3.0.0", python = ">=3.10" }, - { version = ">= 1.25.3, < 3.0.0", python = "<3.10" }, +dependencies = [ + "urllib3 (>=2.8.0,<3.0.0)", + "python-dateutil (>=2.8.2)", + "pydantic (>=2.11)", + "typing-extensions (>=4.7.1)", ] -python-dateutil = ">= 2.8.2" -pydantic = ">= 2" -typing-extensions = ">= 4.7.1" -[tool.poetry.dev-dependencies] -pytest = ">= 7.2.1" -pytest-cov = ">= 2.8.1" -tox = ">= 3.9.0" -flake8 = ">= 4.0.0" -types-python-dateutil = ">= 2.8.19.14" -mypy = ">= 1.5" +[project.urls] +Repository = "https://github.com/hellosign/dropbox-sign-python" + +[dependency-groups] +dev = [ + "pytest>=9.0.3", + "pytest-cov>=2.8.1", + "tox>=3.9.0", + "flake8>=4.0.0", + "types-python-dateutil>=2.8.19.14", + "mypy>=1.5", +] [build-system] diff --git a/sdks/python/requirements.txt b/sdks/python/requirements.txt index c5d71d486..80af060dc 100644 --- a/sdks/python/requirements.txt +++ b/sdks/python/requirements.txt @@ -1,5 +1,4 @@ -urllib3 >= 2.8.0, < 3.0.0; python_version >= "3.10" -urllib3 >= 1.25.3, < 3.0.0; python_version < "3.10" +urllib3 >= 2.8.0, < 3.0.0 python_dateutil >= 2.8.2 -pydantic >= 2 +pydantic >= 2.11 typing-extensions >= 4.7.1 diff --git a/sdks/python/run-build b/sdks/python/run-build index 09284e82c..da2e342d5 100755 --- a/sdks/python/run-build +++ b/sdks/python/run-build @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# see https://github.com/OpenAPITools/openapi-generator/tree/v7.8.0/modules/openapi-generator/src/main/resources/python +# see https://github.com/OpenAPITools/openapi-generator/tree/v7.26.0/modules/openapi-generator/src/main/resources/python set -e @@ -18,7 +18,7 @@ rm -f "${DIR}/dropbox_sign/models/"*.py docker run --rm \ -v "${DIR}/:/local" \ - openapitools/openapi-generator-cli:v7.12.0 generate \ + openapitools/openapi-generator-cli:v7.26.0 generate \ -i "/local/openapi-sdk.yaml" \ -c "/local/openapi-config.yaml" \ -t "/local/templates" \ diff --git a/sdks/python/setup.py b/sdks/python/setup.py index eafe3b87c..23c7ecee4 100644 --- a/sdks/python/setup.py +++ b/sdks/python/setup.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ Dropbox Sign API @@ -24,12 +22,11 @@ # http://pypi.python.org/pypi/setuptools NAME = "dropbox-sign" VERSION = "1.11-dev" -PYTHON_REQUIRES = ">= 3.8" +PYTHON_REQUIRES = ">= 3.10" REQUIRES = [ - "urllib3 >= 2.8.0, < 3.0.0; python_version >= '3.10'", - "urllib3 >= 1.25.3, < 3.0.0; python_version < '3.10'", + "urllib3 >= 2.8.0, < 3.0.0", "python-dateutil >= 2.8.2", - "pydantic >= 2", + "pydantic >= 2.11", "typing-extensions >= 4.7.1", ] diff --git a/sdks/python/templates/README.mustache b/sdks/python/templates/README.mustache index bcbbacfdf..66319e86c 100644 --- a/sdks/python/templates/README.mustache +++ b/sdks/python/templates/README.mustache @@ -21,6 +21,25 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) Python {{{generatorLanguageVersion}}} +{{#poetry1}} +Packaging retains the deprecated `[tool.poetry.dev-dependencies]` table for +compatibility with legacy Poetry 1 releases. Generate with `poetry1=false` to use +standard project metadata and PEP 735 development dependency groups. +{{/poetry1}} +{{^poetry1}} +Packaging uses standard `[project]` metadata and `[dependency-groups]` (PEP 621/735). +Install the package with `python -m pip install .`; install development dependencies +with Poetry 2.2 or newer using `poetry install`, or pip 25.1 or newer using +`python -m pip install --group dev`. The latter installs the group, not the package. +{{/poetry1}} + +{{#httpx2}} +The HTTP transport is HTTPX2 (`httpx2 >= 2.13.0, < 3`). API methods are asynchronous. + +{{#supportHttpxSync}} +Synchronous `_sync` variants are also available through `supportHttpxSync=true`. +{{/supportHttpxSync}} +{{/httpx2}} ## Installation & Usage ### pip install @@ -46,6 +65,19 @@ python setup.py install --user (or `sudo python setup.py install` to install the package for all users) {{/useCustomTemplateCode}} {{#useCustomTemplateCode}} +## Upgrading to 2.0.0 + +Version 2.0.0 is generated with OpenAPI Generator 7.26.0. Existing code keeps working, with these changes: + +- **Python 3.10 or later is required.** Python 3.8 and 3.9 are no longer supported; pip keeps installing 1.x on those versions. +- **Dependencies:** `urllib3 >= 2.8.0` and `pydantic >= 2.11`. +- **Proxy settings are now detected automatically.** When `Configuration.proxy` is not set, the SDK uses the proxy configured in the environment (`HTTPS_PROXY`, `HTTP_PROXY`, `ALL_PROXY`) and, on macOS and Windows, the system proxy settings. Previously, a proxy was only used when set explicitly. + - To bypass the proxy for the Dropbox Sign API, set `NO_PROXY=hellosign.com` or `configuration.no_proxy = "hellosign.com"`. This covers both `api.hellosign.com` and `app.hellosign.com` (used by the OAuth endpoints). + - To ignore all proxy settings, set `configuration.proxy = None` after creating the `Configuration` and before creating the `ApiClient`. Passing `proxy=None` to the constructor does not disable detection. + - SOCKS proxies (for example `ALL_PROXY=socks5://...`) require `pip install "urllib3[socks]"`. + - Known limitations: the proxy decision is made once per `ApiClient` for the configured host, and macOS/Windows proxy exclusion lists and PAC files are not applied. If you rely on them, set `NO_PROXY` or `configuration.no_proxy` explicitly. +- **Behaviour changes:** `to_json()` now serializes datetimes, `to_dict()` keeps `None` items in lists, boolean query parameters are sent as `true` / `false`, and the `ApiException` message lists the response body and data separately. + ## Migrating from legacy SDK This SDK is generated from our officially maintained [OpenAPI spec](https://github.com/hellosign/hellosign-openapi/blob/main/openapi.yaml). diff --git a/sdks/python/templates/README_onlypackage.mustache b/sdks/python/templates/README_onlypackage.mustache index f01667685..8669159cb 100644 --- a/sdks/python/templates/README_onlypackage.mustache +++ b/sdks/python/templates/README_onlypackage.mustache @@ -27,24 +27,21 @@ This python library package is generated without supporting files like setup.py To be able to use it, you will need these dependencies in your own package that uses this library: {{^useCustomTemplateCode}} -* urllib3 >= 1.25.3, < 3.0.0 +* urllib3 >= 2.1.0, < 3.0.0 {{/useCustomTemplateCode}} {{#useCustomTemplateCode}} -* urllib3 >= 2.8.0, < 3.0.0 (Python 3.10+) or >= 1.25.3, < 3.0.0 (Python 3.8 and 3.9) +* urllib3 >= 2.8.0, < 3.0.0 {{/useCustomTemplateCode}} * python-dateutil >= 2.8.2 -{{#asyncio}} +{{#async}} * aiohttp >= 3.8.4 * aiohttp-retry >= 2.8.3 -{{/asyncio}} -{{#tornado}} -* tornado >= 4.2, < 5 -{{/tornado}} +{{/async}} {{#hasHttpSignatureMethods}} * pem >= 19.3.0 * pycryptodome >= 3.9.0 {{/hasHttpSignatureMethods}} -* pydantic >= 2 +* pydantic >= 2.11 * typing-extensions >= 4.7.1 ## Getting Started @@ -53,3 +50,4 @@ In your own code, to use this library to connect and interact with {{{projectNam you can run the following: {{> common_README }} + diff --git a/sdks/python/templates/__init__api.mustache b/sdks/python/templates/__init__api.mustache index 8870835c8..06fbaa8a5 100644 --- a/sdks/python/templates/__init__api.mustache +++ b/sdks/python/templates/__init__api.mustache @@ -1,5 +1,30 @@ # flake8: noqa -# import apis into api package -{{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classFilename}} import {{classname}} -{{/apis}}{{/apiInfo}} +{{^lazyImports}} +{{>exports_api}} +{{/lazyImports}} +{{#lazyImports}}__all__ = [ +{{#apiInfo}}{{#apis}} "{{classname}}", +{{/apis}}{{/apiInfo}}] + +import typing as _typing + +if _typing.TYPE_CHECKING: + {{>exports_api}} +else: + from importlib import import_module + + _exports = { +{{#apiInfo}}{{#apis}} "{{classname}}": ".{{classFilename}}", +{{/apis}}{{/apiInfo}} } + + def __getattr__(name: str) -> object: + if (module_name := _exports.get(name)) is None: + raise AttributeError(f"module {__name__!r} has no attribute {name!r}") + value = getattr(import_module(module_name, __name__), name) + globals()[name] = value + return value + + def __dir__() -> list[str]: + return sorted(globals().keys() | _exports.keys()) +{{/lazyImports}} diff --git a/sdks/python/templates/__init__model.mustache b/sdks/python/templates/__init__model.mustache index 0e1b55e2a..5c51b315e 100644 --- a/sdks/python/templates/__init__model.mustache +++ b/sdks/python/templates/__init__model.mustache @@ -3,9 +3,31 @@ # flake8: noqa {{>partial_header}} -# import models into model package -{{#models}} -{{#model}} -from {{modelPackage}}.{{classFilename}} import {{classname}} -{{/model}} -{{/models}} +{{^lazyImports}} +{{>exports_model}} +{{/lazyImports}} +{{#lazyImports}}__all__ = [ +{{#models}}{{#model}} "{{classname}}", +{{/model}}{{/models}}] + +import typing as _typing + +if _typing.TYPE_CHECKING: + {{>exports_model}} +else: + from importlib import import_module + + _exports = { +{{#models}}{{#model}} "{{classname}}": ".{{classFilename}}", +{{/model}}{{/models}} } + + def __getattr__(name: str) -> object: + if (module_name := _exports.get(name)) is None: + raise AttributeError(f"module {__name__!r} has no attribute {name!r}") + value = getattr(import_module(module_name, __name__), name) + globals()[name] = value + return value + + def __dir__() -> list[str]: + return sorted(globals().keys() | _exports.keys()) +{{/lazyImports}} diff --git a/sdks/python/templates/__init__package.mustache b/sdks/python/templates/__init__package.mustache index e4d04b65b..c8c9464c5 100644 --- a/sdks/python/templates/__init__package.mustache +++ b/sdks/python/templates/__init__package.mustache @@ -4,17 +4,67 @@ {{>partial_header}} + __version__ = "{{packageVersion}}" -# import apis into sdk package {{^useCustomTemplateCode}} -{{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classFilename}} import {{classname}} -{{/apis}}{{/apiInfo}} +# Define package exports +__all__ = [ + {{#apiInfo}}{{#apis}}"{{classname}}", + {{/apis}}{{/apiInfo}}"ApiResponse", + "ApiClient", + "Configuration", + "OpenApiException", + "ApiTypeError", + "ApiValueError", + "ApiKeyError", + "ApiAttributeError", + "ApiException", + {{#hasHttpSignatureMethods}}"HttpSigningConfiguration", + {{/hasHttpSignatureMethods}}{{#models}}{{#model}}"{{classname}}"{{^-last}}, + {{/-last}}{{#-last}},{{/-last}}{{/model}}{{/models}} +] + +{{^lazyImports}} +{{>exports_package}} +{{/lazyImports}} +{{#lazyImports}}import typing as _typing + +if _typing.TYPE_CHECKING: + {{>exports_package}} +else: + from importlib import import_module + + _exports = { +{{#apiInfo}}{{#apis}} "{{classname}}": ".api.{{classFilename}}", +{{/apis}}{{/apiInfo}} "ApiResponse": ".api_response", + "ApiClient": ".api_client", + "Configuration": ".configuration", + "OpenApiException": ".exceptions", + "ApiTypeError": ".exceptions", + "ApiValueError": ".exceptions", + "ApiKeyError": ".exceptions", + "ApiAttributeError": ".exceptions", + "ApiException": ".exceptions", +{{#hasHttpSignatureMethods}} "HttpSigningConfiguration": ".signing", +{{/hasHttpSignatureMethods}}{{#models}}{{#model}} "{{classname}}": ".models.{{classFilename}}", +{{/model}}{{/models}} } + + def __getattr__(name: str) -> object: + if (module_name := _exports.get(name)) is None: + raise AttributeError(f"module {__name__!r} has no attribute {name!r}") + value = getattr(import_module(module_name, __name__), name) + globals()[name] = value + return value + + def __dir__() -> list[str]: + return sorted(globals().keys() | _exports.keys()) +{{/lazyImports}} {{/useCustomTemplateCode}} {{#useCustomTemplateCode}} +# import apis into sdk package from dropbox_sign.apis import * -{{/useCustomTemplateCode}} # import ApiClient from {{packageName}}.api_response import ApiResponse from {{packageName}}.api_client import ApiClient @@ -35,7 +85,6 @@ from {{packageName}}.signing import HttpSigningConfiguration from {{modelPackage}}.{{classFilename}} import {{classname}} {{/model}} {{/models}} -{{#useCustomTemplateCode}} from dropbox_sign.event_callback_helper import EventCallbackHelper {{/useCustomTemplateCode}} {{#recursionLimit}} diff --git a/sdks/python/templates/api.mustache b/sdks/python/templates/api.mustache index f723aea42..87d022809 100644 --- a/sdks/python/templates/api.mustache +++ b/sdks/python/templates/api.mustache @@ -1,6 +1,8 @@ -# coding: utf-8 - {{>partial_header}} + +{{#x-python-has-json-header}} +import json +{{/x-python-has-json-header}} import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union @@ -16,6 +18,9 @@ from {{packageName}}.rest import RESTResponseType {{#useCustomTemplateCode}} import io {{/useCustomTemplateCode}} +{{#supportHttpxSync}} +from {{packageName}}.sync_helper import run_sync +{{/supportHttpxSync}} {{#operations}} @@ -27,50 +32,264 @@ class {{classname}}: """ def __init__(self, api_client=None) -> None: +{{#useIndependentImplicitClients}} + # api_client remains publicly assignable. Retain the client acquired at + # construction so reassignment cannot transfer or discard ownership. + if api_client is None: + api_client, owns_api_client = ApiClient._get_default_or_new() + else: + owns_api_client = False +{{/useIndependentImplicitClients}} +{{^useIndependentImplicitClients}} if api_client is None: api_client = ApiClient.get_default() +{{/useIndependentImplicitClients}} self.api_client = api_client +{{#useIndependentImplicitClients}} + self._owned_api_client: Optional[ApiClient] = ( + api_client if owns_api_client else None + ) + +{{#async}} + async def close(self) -> None: + owned_api_client = self._owned_api_client + self._owned_api_client = None + if owned_api_client is not None: + await owned_api_client.close() + + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc_value, traceback): + await self.close() +{{#supportHttpxSync}} + + def close_sync(self) -> None: + run_sync(self.close()) + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.close_sync() +{{/supportHttpxSync}} +{{/async}} +{{^async}} + + def close(self) -> None: + owned_api_client = self._owned_api_client + self._owned_api_client = None + if owned_api_client is not None: + owned_api_client.close() + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.close() +{{/async}} +{{/useIndependentImplicitClients}} {{#operation}} +{{#compatibleWithPythonLegacyApi}} +{{^async}} +{{! +Synchronous urllib3 legacy flags can return a future or raw response. Keep the ordinary data +annotation precise because Kubernetes Watch inspects it: +https://github.com/kubernetes-client/python/blob/6cc5456d79dd8c0ccc9e275a0811aeb025714bea/kubernetes/watch/watch.py#L36-L48 +}} + @validate_call + def {{operationId}}{{>partial_api_args_legacy}} -> {{{returnType}}}{{^returnType}}None{{/returnType}}: +{{/async}} +{{#async}} + @validate_call + async def {{operationId}}{{>partial_api_args}} -> {{{returnType}}}{{^returnType}}None{{/returnType}}: +{{/async}} +{{/compatibleWithPythonLegacyApi}} +{{^compatibleWithPythonLegacyApi}} @validate_call - {{#asyncio}}async {{/asyncio}}def {{operationId}}{{>partial_api_args}} -> {{{returnType}}}{{^returnType}}None{{/returnType}}: +{{^useCustomTemplateCode}} + {{#async}}async {{/async}}def {{operationId}}{{>partial_api_args}} -> {{{returnType}}}{{^returnType}}None{{/returnType}}: +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + {{#async}}async {{/async}}def {{operationId}}{{>partial_api_args}} -> {{#isResponseBinary}}io.IOBase{{/isResponseBinary}}{{^isResponseBinary}}{{{returnType}}}{{^returnType}}None{{/returnType}}{{/isResponseBinary}}: +{{/useCustomTemplateCode}} +{{/compatibleWithPythonLegacyApi}} {{>partial_api}} - response_data = {{#asyncio}}await {{/asyncio}}self.api_client.call_api( +{{#compatibleWithPythonLegacyApi}} +{{^async}} + return self.api_client._call_with_legacy_options( + _param, + _response_types_map, + async_req, + _preload_content, + _request_timeout, +{{! +python-legacy ordinary wrappers always forced data-only: +https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/api.mustache#L69-L70 +}} + True, + ) +{{/async}} +{{#async}} + response_data = {{#async}}await {{/async}}self.api_client.call_api( *_param, _request_timeout=_request_timeout ) - {{#asyncio}}await {{/asyncio}}response_data.read() + {{#async}}await {{/async}}response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ).data +{{/async}} +{{/compatibleWithPythonLegacyApi}} +{{^compatibleWithPythonLegacyApi}} + response_data = {{#async}}await {{/async}}self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + {{#async}}await {{/async}}response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data +{{/compatibleWithPythonLegacyApi}} +{{#compatibleWithPythonLegacyApi}} +{{^async}} @validate_call - {{#asyncio}}async {{/asyncio}}def {{operationId}}_with_http_info{{>partial_api_args}} -> ApiResponse[{{{returnType}}}{{^returnType}}None{{/returnType}}]: + def {{operationId}}_with_http_info{{>partial_api_args_legacy}} -> Tuple[{{{returnType}}}{{^returnType}}None{{/returnType}}, int, Any]: +{{/async}} +{{#async}} + @validate_call + async def {{operationId}}_with_http_info{{>partial_api_args}} -> ApiResponse[{{{returnType}}}{{^returnType}}None{{/returnType}}]: +{{/async}} +{{/compatibleWithPythonLegacyApi}} +{{^compatibleWithPythonLegacyApi}} + @validate_call +{{^useCustomTemplateCode}} + {{#async}}async {{/async}}def {{operationId}}_with_http_info{{>partial_api_args}} -> ApiResponse[{{{returnType}}}{{^returnType}}None{{/returnType}}]: +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + {{#async}}async {{/async}}def {{operationId}}_with_http_info{{>partial_api_args}} -> ApiResponse[{{#isResponseBinary}}io.IOBase{{/isResponseBinary}}{{^isResponseBinary}}{{{returnType}}}{{^returnType}}None{{/returnType}}{{/isResponseBinary}}]: +{{/useCustomTemplateCode}} +{{/compatibleWithPythonLegacyApi}} {{>partial_api}} - response_data = {{#asyncio}}await {{/asyncio}}self.api_client.call_api( +{{#compatibleWithPythonLegacyApi}} +{{^async}} + return self.api_client._call_with_legacy_options( + _param, + _response_types_map, + async_req, + _preload_content, + _request_timeout, + _return_http_data_only, + ) +{{/async}} +{{#async}} + response_data = {{#async}}await {{/async}}self.api_client.call_api( *_param, _request_timeout=_request_timeout ) - {{#asyncio}}await {{/asyncio}}response_data.read() + {{#async}}await {{/async}}response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ) +{{/async}} +{{/compatibleWithPythonLegacyApi}} +{{^compatibleWithPythonLegacyApi}} + response_data = {{#async}}await {{/async}}self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + {{#async}}await {{/async}}response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) +{{/compatibleWithPythonLegacyApi}} +{{^compatibleWithPythonLegacyApi}} @validate_call - {{#asyncio}}async {{/asyncio}}def {{operationId}}_without_preload_content{{>partial_api_args}} -> RESTResponseType: + {{#async}}async {{/async}}def {{operationId}}_without_preload_content{{>partial_api_args}} -> RESTResponseType: {{>partial_api}} - response_data = {{#asyncio}}await {{/asyncio}}self.api_client.call_api( + response_data = {{#async}}await {{/async}}self.api_client.call_api( *_param, _request_timeout=_request_timeout ) return response_data.response +{{/compatibleWithPythonLegacyApi}} + +{{#supportHttpxSync}} + @validate_call + def {{operationId}}_sync{{>partial_api_args}} -> {{{returnType}}}{{^returnType}}None{{/returnType}}: + """{{#isDeprecated}}(Deprecated) {{/isDeprecated}}{{{summary}}}{{^summary}}{{operationId}}{{/summary}} (synchronous) + + Synchronous variant of :meth:`{{operationId}}`. It calls the asynchronous + method and blocks until it completes. + """ # noqa: E501 + return run_sync( + self.{{operationId}}( + {{#allParams}} + {{paramName}}={{paramName}}, + {{/allParams}} + _request_timeout=_request_timeout, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + ) + + + @validate_call + def {{operationId}}_sync_with_http_info{{>partial_api_args}} -> ApiResponse[{{{returnType}}}{{^returnType}}None{{/returnType}}]: + """{{#isDeprecated}}(Deprecated) {{/isDeprecated}}{{{summary}}}{{^summary}}{{operationId}}{{/summary}} (synchronous) + + Synchronous variant of :meth:`{{operationId}}_with_http_info`. It calls the + asynchronous method and blocks until it completes. + """ # noqa: E501 + return run_sync( + self.{{operationId}}_with_http_info( + {{#allParams}} + {{paramName}}={{paramName}}, + {{/allParams}} + _request_timeout=_request_timeout, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + ) + + @validate_call + def {{operationId}}_sync_without_preload_content{{>partial_api_args}} -> RESTResponseType: + """{{#isDeprecated}}(Deprecated) {{/isDeprecated}}{{{summary}}}{{^summary}}{{operationId}}{{/summary}} (synchronous) + + Synchronous variant of :meth:`{{operationId}}_without_preload_content`. It calls + the asynchronous method and blocks until it completes. + """ # noqa: E501 + return run_sync( + self.{{operationId}}_without_preload_content( + {{#allParams}} + {{paramName}}={{paramName}}, + {{/allParams}} + _request_timeout=_request_timeout, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + ) + + +{{/supportHttpxSync}} def _{{operationId}}_serialize( self, {{#allParams}} @@ -170,13 +389,50 @@ class {{classname}}: _query_params.append(('{{baseName}}', {{paramName}})) {{/isDate}} {{^isDateTime}}{{^isDate}} + {{#isMap}} + {{#isExplode}} + {{#isDeepObject}} + _query_params.append(('{{baseName}}', {{paramName}})) + {{/isDeepObject}} + {{^isDeepObject}} + _query_params.extend(self.api_client.explode_query_object('{{baseName}}', {{paramName}})) + {{/isDeepObject}} + {{/isExplode}} + {{^isExplode}} + _query_params.append(('{{baseName}}', {{paramName}})) + {{/isExplode}} + {{/isMap}} + {{#isModel}} + {{#isExplode}} + {{#isDeepObject}} + _query_params.append(('{{baseName}}', {{paramName}})) + {{/isDeepObject}} + {{^isDeepObject}} + _query_params.extend(self.api_client.explode_query_object('{{baseName}}', {{paramName}})) + {{/isDeepObject}} + {{/isExplode}} + {{^isExplode}} + _query_params.append(('{{baseName}}', {{paramName}})) + {{/isExplode}} + {{/isModel}} + {{^isMap}} + {{^isModel}} _query_params.append(('{{baseName}}', {{paramName}}{{#isEnumRef}}.value{{/isEnumRef}})) + {{/isModel}} + {{/isMap}} {{/isDate}}{{/isDateTime}} {{/queryParams}} # process the header parameters {{#headerParams}} if {{paramName}} is not None: + {{#vendorExtensions.x-python-json-header}} + _header_params['{{baseName}}'] = json.dumps( + self.api_client.sanitize_for_serialization({{paramName}}) + ) + {{/vendorExtensions.x-python-json-header}} + {{^vendorExtensions.x-python-json-header}} _header_params['{{baseName}}'] = {{paramName}} + {{/vendorExtensions.x-python-json-header}} {{/headerParams}} # process the form parameters {{#formParams}} diff --git a/sdks/python/templates/api_client.mustache b/sdks/python/templates/api_client.mustache index 3fd4b3952..fddd1acd6 100644 --- a/sdks/python/templates/api_client.mustache +++ b/sdks/python/templates/api_client.mustache @@ -1,7 +1,6 @@ -# coding: utf-8 - {{>partial_header}} + import datetime from dateutil.parser import parse from enum import Enum @@ -14,13 +13,18 @@ import tempfile {{#useCustomTemplateCode}} import io {{/useCustomTemplateCode}} +import uuid +{{#compatibleWithPythonLegacyApi}} +{{^async}} +import atexit +from multiprocessing.pool import ThreadPool +from threading import Lock +{{/async}} +{{/compatibleWithPythonLegacyApi}} from urllib.parse import quote -from typing import Tuple, Optional, List, Dict, Union +from typing import Tuple, Optional, List, Dict, Union{{#compatibleWithPythonLegacy}}, Any{{/compatibleWithPythonLegacy}} from pydantic import SecretStr -{{#tornado}} -import tornado.gen -{{/tornado}} from {{packageName}}.configuration import Configuration from {{packageName}}.api_response import ApiResponse, T as ApiResponseT @@ -36,6 +40,12 @@ from {{packageName}}.exceptions import ( ServiceException ) +{{#compatibleWithPythonLegacy}} + +{{>_legacy_model_identity}} + + +{{/compatibleWithPythonLegacy}} RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]] class ApiClient: @@ -52,6 +62,11 @@ class ApiClient: the API. :param cookie: a cookie to include in the header when making calls to the API +{{#compatibleWithPythonLegacyApi}} +{{^async}} + :param pool_threads: number of threads for legacy async requests. +{{/async}} +{{/compatibleWithPythonLegacyApi}} """ PRIMITIVE_TYPES = (float, bool, bytes, str, int) @@ -64,6 +79,7 @@ class ApiClient: 'date': datetime.date, 'datetime': datetime.datetime, 'decimal': decimal.Decimal, + 'UUID': uuid.UUID, 'object': object, } _pool = None @@ -73,11 +89,17 @@ class ApiClient: configuration=None, header_name=None, header_value=None, - cookie=None + cookie=None{{#compatibleWithPythonLegacyApi}}{{^async}}, + pool_threads=1{{/async}}{{/compatibleWithPythonLegacyApi}} ) -> None: # use default configuration if none is provided if configuration is None: +{{#useIndependentImplicitClients}} + configuration = Configuration.get_default_copy() +{{/useIndependentImplicitClients}} +{{^useIndependentImplicitClients}} configuration = Configuration.get_default() +{{/useIndependentImplicitClients}} self.configuration = configuration self.rest_client = rest.RESTClientObject(configuration) @@ -85,11 +107,17 @@ class ApiClient: if header_name is not None: self.default_headers[header_name] = header_value self.cookie = cookie +{{#compatibleWithPythonLegacyApi}} +{{^async}} + self.pool_threads = pool_threads + self._pool_lock = Lock() +{{/async}} +{{/compatibleWithPythonLegacyApi}} # Set default User-Agent. self.user_agent = '{{{httpUserAgent}}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/python{{/httpUserAgent}}' self.client_side_validation = configuration.client_side_validation -{{#asyncio}} +{{#async}} async def __aenter__(self): return self @@ -98,14 +126,110 @@ class ApiClient: async def close(self): await self.rest_client.close() -{{/asyncio}} -{{^asyncio}} +{{/async}} +{{^async}} +{{#compatibleWithPythonLegacyApi}} + def close(self): + # Pool creation, submission, and close share one lock so an async + # request cannot lose its pool while another thread closes the client. + with self._pool_lock: + if self._pool is not None: + self._pool.close() + self._pool.join() + self._pool = None + if hasattr(atexit, 'unregister'): + atexit.unregister(self.close) +{{#useIndependentImplicitClients}} + self.rest_client.close() + +{{/useIndependentImplicitClients}} + + def _get_pool(self): + if self._pool is None: + atexit.register(self.close) + self._pool = ThreadPool(self.pool_threads) + return self._pool + + @property + def pool(self): + """Create the thread pool only for legacy async requests.""" + with self._pool_lock: + return self._get_pool() + +{{! +python-legacy scheduled one prepared request and selected raw, data-only, or +tuple output in ApiClient: +https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/api_client.mustache#L350-L417 +https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/api_client.mustache#L207-L237 +}} + def _call_with_legacy_options( + self, + request: RequestSerialized, + response_types_map: Dict[str, Optional[str]], + async_req: Optional[bool], + preload_content: bool, + request_timeout: Any, + return_http_data_only: bool, + ) -> Any: + def call(): + response_data = self.call_api( + *request, + _request_timeout=request_timeout, + ) + if not preload_content: + # python-legacy raised non-2xx responses in the REST layer + # before returning raw data: + # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/rest.mustache#L213-L226 + if not 200 <= response_data.status <= 299: + response_data.read() + raise ApiException.from_response( + http_resp=response_data, + body=None, + data=None, + ) + return response_data.response + response_data.read() + api_response = self.response_deserialize( + response_data=response_data, + response_types_map=response_types_map, + ) + if return_http_data_only: + return api_response.data + return ( + api_response.data, + api_response.status_code, + response_data.getheaders(), + ) + + if async_req: + with self._pool_lock: + return self._get_pool().apply_async(call) + return call() + +{{/compatibleWithPythonLegacyApi}} +{{^compatibleWithPythonLegacyApi}} +{{#useIndependentImplicitClients}} + def close(self): + self.rest_client.close() + +{{/useIndependentImplicitClients}} +{{/compatibleWithPythonLegacyApi}} def __enter__(self): return self def __exit__(self, exc_type, exc_value, traceback): +{{#compatibleWithPythonLegacyApi}} + self.close() +{{/compatibleWithPythonLegacyApi}} +{{^compatibleWithPythonLegacyApi}} +{{#useIndependentImplicitClients}} + self.close() +{{/useIndependentImplicitClients}} +{{^useIndependentImplicitClients}} pass -{{/asyncio}} +{{/useIndependentImplicitClients}} +{{/compatibleWithPythonLegacyApi}} +{{/async}} @property def user_agent(self): @@ -122,8 +246,21 @@ class ApiClient: _default = None +{{#useIndependentImplicitClients}} + @classmethod + def _get_default_or_new(cls): + if cls._default is not None: + return cls._default, False + return cls(), True + +{{/useIndependentImplicitClients}} @classmethod def get_default(cls): +{{#useIndependentImplicitClients}} + """Return the registered default ApiClient, or a new client.""" + return cls._get_default_or_new()[0] +{{/useIndependentImplicitClients}} +{{^useIndependentImplicitClients}} """Return new instance of ApiClient. This method returns newly created, based on default constructor, @@ -135,6 +272,7 @@ class ApiClient: if cls._default is None: cls._default = ApiClient() return cls._default +{{/useIndependentImplicitClients}} @classmethod def set_default(cls, default): @@ -254,11 +392,7 @@ class ApiClient: return method, url, header_params, body, post_params - - {{#tornado}} - @tornado.gen.coroutine - {{/tornado}} - {{#asyncio}}async {{/asyncio}}def call_api( + {{#async}}async {{/async}}def call_api( self, method, url, @@ -281,7 +415,7 @@ class ApiClient: try: # perform request and return response - response_data = {{#asyncio}}await {{/asyncio}}{{#tornado}}yield {{/tornado}}self.rest_client.request( + response_data = {{#async}}await {{/async}}self.rest_client.request( method, url, headers=header_params, body=body, post_params=post_params, @@ -312,11 +446,17 @@ class ApiClient: # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + # If the response_type has not matched (eg. did not match the previous if statements) and the default response is available, use it. + if response_type is None and str(response_data.status) not in response_types_map \ + and (not isinstance(response_data.status, int) or not 100 <= response_data.status <= 599 or str(response_data.status)[0] + "XX" not in response_types_map) \ + and 'default' in response_types_map: + response_type = response_types_map['default'] + # deserialize response data response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data {{#useCustomTemplateCode}} elif response_type == "io.IOBase": @@ -326,7 +466,7 @@ class ApiClient: return_data = self.__deserialize_file(response_data) elif response_type is not None: match = None - content_type = response_data.getheader('content-type') + content_type = response_data.headers.get('content-type') if content_type is not None: match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) encoding = match.group(1) if match else "utf-8" @@ -343,7 +483,7 @@ class ApiClient: return ApiResponse( status_code = response_data.status, data = return_data, - headers = response_data.getheaders(), + headers = response_data.headers, raw_data = response_data.data ) @@ -371,6 +511,8 @@ class ApiClient: return obj.get_secret_value() elif isinstance(obj, self.PRIMITIVE_TYPES): return obj + elif isinstance(obj, uuid.UUID): + return str(obj) elif isinstance(obj, list): return [ self.sanitize_for_serialization(sub_obj) for sub_obj in obj @@ -383,24 +525,34 @@ class ApiClient: return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return { + key: self.sanitize_for_serialization(val) + for key, val in obj.items() + } + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. +{{#compatibleWithPythonLegacy}} + to_dict = getattr(obj, 'to_dict', None) + to_openapi_dict = _get_openapi_to_dict(obj) + if to_openapi_dict is not None: + obj_dict = to_openapi_dict(obj) + elif callable(to_dict): + obj_dict = to_dict() +{{/compatibleWithPythonLegacy}} +{{^compatibleWithPythonLegacy}} + if hasattr(obj, 'to_dict') and callable(getattr(obj, 'to_dict')): + obj_dict = obj.to_dict() +{{/compatibleWithPythonLegacy}} else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, 'to_dict') and callable(getattr(obj, 'to_dict')): - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ + obj_dict = obj.__dict__ + + return self.sanitize_for_serialization(obj_dict) - return { - key: self.sanitize_for_serialization(val) - for key, val in obj_dict.items() - } def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -419,7 +571,7 @@ class ApiClient: data = json.loads(response_text) except ValueError: data = response_text - elif re.match(r'^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)', content_type, re.IGNORECASE): + elif re.match(r'^application/(json|[\w!#$&.+\-^_]+\+json)\s*(;|$)', content_type, re.IGNORECASE): if response_text == "": data = "" else: @@ -446,6 +598,12 @@ class ApiClient: return None if isinstance(klass, str): + if klass.startswith('Optional['): + m = re.match(r'Optional\[(.*)]', klass) + assert m is not None, "Malformed Optional type definition" + # data is not None here, so the optionality is already resolved + return self.__deserialize(data, m.group(1)) + if klass.startswith('List['): m = re.match(r'List\[(.*)]', klass) assert m is not None, "Malformed List type definition" @@ -468,14 +626,16 @@ class ApiClient: if klass in self.PRIMITIVE_TYPES: return self.__deserialize_primitive(data, klass) - elif klass == object: + elif klass is object: return self.__deserialize_object(data) - elif klass == datetime.date: + elif klass is datetime.date: return self.__deserialize_date(data) - elif klass == datetime.datetime: + elif klass is datetime.datetime: return self.__deserialize_datetime(data) - elif klass == decimal.Decimal: + elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: @@ -492,10 +652,15 @@ class ApiClient: if collection_formats is None: collection_formats = {} for k, v in params.items() if isinstance(params, dict) else params: + if isinstance(v, bool): + v = str(v).lower() if k in collection_formats: collection_format = collection_formats[k] if collection_format == 'multi': - new_params.extend((k, value) for value in v) + new_params.extend( + (k, str(value).lower() if isinstance(value, bool) else value) + for value in v + ) else: if collection_format == 'ssv': delimiter = ' ' @@ -506,11 +671,20 @@ class ApiClient: else: # csv is the default delimiter = ',' new_params.append( - (k, delimiter.join(str(value) for value in v))) + (k, delimiter.join( + str(value).lower() if isinstance(value, bool) else str(value) + for value in v))) else: new_params.append((k, v)) return new_params + def explode_query_object(self, name, obj): + """form style, explode: one query parameter per entry, keyed by the property name; a list repeats the name, None is left out""" + obj = self.sanitize_for_serialization(obj) + if not isinstance(obj, dict): + obj = {name: obj} + return [(k, item) for k, v in obj.items() for item in (v if isinstance(v, (list, tuple)) else [v]) if item is not None] + def parameters_to_url_query(self, params, collection_formats): """Get parameters as list of tuples, formatting collections. @@ -529,10 +703,14 @@ class ApiClient: if isinstance(v, dict): v = json.dumps(v) - if k in collection_formats: + # a collection format applies only to a list; an exploded entry may share a declared array parameter's name + if k in collection_formats and isinstance(v, (list, tuple)): collection_format = collection_formats[k] if collection_format == 'multi': - new_params.extend((k, quote(str(value))) for value in v) + new_params.extend( + (quote(str(k)), quote(str(value).lower() if isinstance(value, bool) else str(value))) + for value in v + ) else: if collection_format == 'ssv': delimiter = ' ' @@ -543,10 +721,13 @@ class ApiClient: else: # csv is the default delimiter = ',' new_params.append( - (k, delimiter.join(quote(str(value)) for value in v)) + (quote(str(k)), delimiter.join( + quote(str(value).lower() if isinstance(value, bool) else str(value)) + for value in v)) ) else: - new_params.append((k, quote(str(v)))) + # names are quoted too: an exploded object's names are runtime data + new_params.append((quote(str(k)), quote(str(v)))) return "&".join(["=".join(map(str, item)) for item in new_params]) @@ -692,7 +873,13 @@ class ApiClient: :param auth_setting: auth settings for the endpoint """ if auth_setting['in'] == 'cookie': - headers['Cookie'] = auth_setting['value'] + if not 'Cookie' in headers: + headers['Cookie'] = "" + else: + headers['Cookie'] += "; " + # Account for cookie value containing spaces and special characters, excluding base64 delimiters + cookie_value = quote(str(auth_setting['value']), safe="!#$%&'()*+-./:<=>?@[]^_`{|}~%+/=") + headers['Cookie'] += f"{auth_setting['key']}={cookie_value}" elif auth_setting['in'] == 'header': if auth_setting['type'] != 'http-signature': headers[auth_setting['key']] = auth_setting['value'] @@ -728,14 +915,16 @@ class ApiClient: os.close(fd) os.remove(path) - content_disposition = response.getheader("Content-Disposition") + content_disposition = response.headers.get("Content-Disposition") if content_disposition: m = re.search( r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition ) assert m is not None, "Unexpected 'content-disposition' header value" - filename = m.group(1) + filename = os.path.basename(m.group(1)) # Strip any directory traversal + if filename in ("", ".", ".."): # fall back to tmp filename + filename = os.path.basename(path) path = os.path.join(os.path.dirname(path), filename) with open(path, "wb") as f: diff --git a/sdks/python/templates/api_doc.mustache b/sdks/python/templates/api_doc.mustache index b4e3ef55b..8548ad788 100644 --- a/sdks/python/templates/api_doc.mustache +++ b/sdks/python/templates/api_doc.mustache @@ -30,6 +30,10 @@ Method | HTTP request | Description # ```{{{operationId}}}``` > ```{{#returnType}}{{{.}}} {{/returnType}}{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{^-last}}, {{/-last}}{{/defaultValue}}{{/requiredParams}})``` {{/useCustomTemplateCode}} +{{#supportHttpxSync}} + +**Synchronous variant:** `{{{operationId}}}_sync(...)` — same parameters and return type, but blocks until completion instead of requiring `await`. +{{/supportHttpxSync}} {{#summary}} {{{summary}}} @@ -61,6 +65,7 @@ Method | HTTP request | Description {{/hasAuthMethods}} {{> api_doc_example }} + ### Parameters {{^useCustomTemplateCode}} {{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} diff --git a/sdks/python/templates/api_doc_example.mustache b/sdks/python/templates/api_doc_example.mustache index 2392430e9..3679228bb 100644 --- a/sdks/python/templates/api_doc_example.mustache +++ b/sdks/python/templates/api_doc_example.mustache @@ -9,8 +9,9 @@ from {{{packageName}}}.rest import ApiException from pprint import pprint {{> python_doc_auth_partial}} + # Enter a context with an instance of the API client -{{#asyncio}}async {{/asyncio}}with {{{packageName}}}.ApiClient(configuration) as api_client: +{{#async}}async {{/async}}with {{{packageName}}}.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = {{{packageName}}}.{{{classname}}}(api_client) {{#allParams}} @@ -21,7 +22,7 @@ from pprint import pprint {{#summary}} # {{{.}}} {{/summary}} - {{#returnType}}api_response = {{/returnType}}{{#asyncio}}await {{/asyncio}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) + {{#returnType}}api_response = {{/returnType}}{{#async}}await {{/async}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) {{#returnType}} print("The response of {{classname}}->{{operationId}}:\n") pprint(api_response) diff --git a/sdks/python/templates/api_test.mustache b/sdks/python/templates/api_test.mustache index 9d11c83f7..250474378 100644 --- a/sdks/python/templates/api_test.mustache +++ b/sdks/python/templates/api_test.mustache @@ -2,36 +2,37 @@ {{>partial_header}} + import unittest from {{apiPackage}}.{{classFilename}} import {{classname}} -class {{#operations}}Test{{classname}}(unittest.{{#asyncio}}IsolatedAsyncio{{/asyncio}}TestCase): +class {{#operations}}Test{{classname}}(unittest.{{#async}}IsolatedAsyncio{{/async}}TestCase): """{{classname}} unit test stubs""" - {{#asyncio}} + {{#async}} async def asyncSetUp(self) -> None: self.api = {{classname}}() async def asyncTearDown(self) -> None: await self.api.api_client.close() - {{/asyncio}} - {{^asyncio}} + {{/async}} + {{^async}} def setUp(self) -> None: self.api = {{classname}}() def tearDown(self) -> None: pass - {{/asyncio}} + {{/async}} - {{#operation}} - {{#asyncio}} + {{#operation}} + {{#async}} async def test_{{operationId}}(self) -> None: - {{/asyncio}} - {{^asyncio}} + {{/async}} + {{^async}} def test_{{operationId}}(self) -> None: - {{/asyncio}} + {{/async}} """Test case for {{{operationId}}} {{#summary}} @@ -40,6 +41,17 @@ class {{#operations}}Test{{classname}}(unittest.{{#asyncio}}IsolatedAsyncio{{/as """ pass +{{#supportHttpxSync}} + def test_{{operationId}}_sync(self) -> None: + """Test case for {{{operationId}}} (synchronous) + +{{#summary}} + {{{.}}} +{{/summary}} + """ + pass + +{{/supportHttpxSync}} {{/operation}} {{/operations}} diff --git a/sdks/python/templates/asyncio/rest.mustache b/sdks/python/templates/asyncio/rest.mustache index 937e76ed5..fefd5e2af 100644 --- a/sdks/python/templates/asyncio/rest.mustache +++ b/sdks/python/templates/asyncio/rest.mustache @@ -2,11 +2,12 @@ {{>partial_header}} + import io import json import re import ssl -from typing import Optional, Union +from typing import Any, Dict, Optional, Union import aiohttp import aiohttp_retry @@ -30,12 +31,17 @@ class RESTResponse(io.IOBase): self.data = await self.response.read() return self.data + @property + def headers(self): + """Returns a CIMultiDictProxy of response headers.""" + return self.response.headers + def getheaders(self): - """Returns a CIMultiDictProxy of the response headers.""" + """Returns a CIMultiDictProxy of the response headers; use ``headers`` instead.""" return self.response.headers def getheader(self, name, default=None): - """Returns a given response header.""" + """Returns a given response header; use ``headers.get()`` instead.""" return self.response.headers.get(name, default) @@ -43,6 +49,10 @@ class RESTClientObject: def __init__(self, configuration) -> None: + # Keep a reference so factory methods (_create_pool_manager / _create_connector) + # and subclasses can read extension fields like trace_configs. + self.configuration = configuration + # maxsize is number of requests to host that are allowed in parallel self.maxsize = configuration.connection_pool_maxsize @@ -62,7 +72,20 @@ class RESTClientObject: self.proxy = configuration.proxy self.proxy_headers = configuration.proxy_headers - self.retries = configuration.retries + retries = configuration.retries + if retries is None: + self._effective_retry_options = None + elif isinstance(retries, aiohttp_retry.RetryOptionsBase): + self._effective_retry_options = retries + elif isinstance(retries, int): + self._effective_retry_options = aiohttp_retry.ExponentialRetry( + attempts=retries, + factor=2.0, + start_timeout=0.1, + max_timeout=120.0 + ) + else: + self._effective_retry_options = None self.pool_manager: Optional[aiohttp.ClientSession] = None self.retry_client: Optional[aiohttp_retry.RetryClient] = None @@ -73,6 +96,61 @@ class RESTClientObject: if self.retry_client is not None: await self.retry_client.close() + def _create_connector(self) -> aiohttp.TCPConnector: + """Build the TCPConnector used by the ClientSession. + + Override in a subclass to customize DNS resolver, keepalive, etc. + """ + kwargs: Dict[str, Any] = { + "limit": self.maxsize, + "ssl": self.ssl_context, + } + limit_per_host = getattr(self.configuration, "tcp_connector_limit_per_host", None) + if limit_per_host is not None: + kwargs["limit_per_host"] = limit_per_host + return aiohttp.TCPConnector(**kwargs) + + def _create_pool_manager(self) -> aiohttp.ClientSession: + """Build the aiohttp.ClientSession used as the connection pool. + + Override in a subclass to fully customize the session (e.g. attach + aiohttp.TraceConfig, swap json_serialize, etc.). Typed Configuration + fields (trace_configs / client_session_kwargs) are read via getattr + so older Configuration objects remain compatible. + """ + extra = getattr(self.configuration, "client_session_kwargs", None) + kwargs: Dict[str, Any] = { +{{#useIndependentImplicitClients}} + # Preserve an explicit connector=None override. ClientSession then + # creates and owns its default connector instead of using ours: + # https://github.com/aio-libs/aiohttp/blob/v3.8.4/aiohttp/client.py#L238-L257 + "connector": ( + extra["connector"] + if extra is not None and "connector" in extra + else self._create_connector() + ), +{{/useIndependentImplicitClients}} +{{^useIndependentImplicitClients}} + "connector": self._create_connector(), +{{/useIndependentImplicitClients}} + "trust_env": True, + } + trace_configs = getattr(self.configuration, "trace_configs", None) + if trace_configs is not None: + kwargs["trace_configs"] = trace_configs + if extra: + kwargs.update(extra) +{{#useIndependentImplicitClients}} + if extra.get("connector") is not None: + # Copied configurations can share a caller-supplied connector. + # aiohttp requires connector_owner=False for shared connectors: + # https://docs.aiohttp.org/en/stable/client_advanced.html#connectors + kwargs["connector_owner"] = False + else: + kwargs["connector_owner"] = True +{{/useIndependentImplicitClients}} + return aiohttp.ClientSession(**kwargs) + async def request( self, method, @@ -137,6 +215,8 @@ class RESTClientObject: if re.search('json', headers['Content-Type'], re.IGNORECASE): if body is not None: body = json.dumps(body) + if body is None and post_params: + body = json.dumps(dict(post_params)) args["data"] = body elif headers['Content-Type'] == 'application/x-www-form-urlencoded': args["data"] = aiohttp.FormData(post_params) @@ -179,22 +259,14 @@ class RESTClientObject: # https pool manager if self.pool_manager is None: - self.pool_manager = aiohttp.ClientSession( - connector=aiohttp.TCPConnector(limit=self.maxsize, ssl=self.ssl_context), - trust_env=True, - ) + self.pool_manager = self._create_pool_manager() pool_manager = self.pool_manager - if self.retries is not None and method in ALLOW_RETRY_METHODS: + if self._effective_retry_options is not None and method in ALLOW_RETRY_METHODS: if self.retry_client is None: self.retry_client = aiohttp_retry.RetryClient( client_session=self.pool_manager, - retry_options=aiohttp_retry.ExponentialRetry( - attempts=self.retries, - factor=2.0, - start_timeout=0.1, - max_timeout=120.0 - ) + retry_options=self._effective_retry_options ) pool_manager = self.retry_client diff --git a/sdks/python/templates/common_README.mustache b/sdks/python/templates/common_README.mustache index 163470c0b..a2bc9605b 100644 --- a/sdks/python/templates/common_README.mustache +++ b/sdks/python/templates/common_README.mustache @@ -7,8 +7,9 @@ from pprint import pprint {{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} {{> python_doc_auth_partial}} + # Enter a context with an instance of the API client -{{#asyncio}}async {{/asyncio}}with {{{packageName}}}.ApiClient(configuration) as api_client: +{{#async}}async {{/async}}with {{{packageName}}}.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = {{{packageName}}}.{{{classname}}}(api_client) {{#allParams}} @@ -19,7 +20,7 @@ from pprint import pprint {{#summary}} # {{{.}}} {{/summary}} - {{#returnType}}api_response = {{/returnType}}{{#asyncio}}await {{/asyncio}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) + {{#returnType}}api_response = {{/returnType}}{{#async}}await {{/async}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) {{#returnType}} print("The response of {{classname}}->{{operationId}}:\n") pprint(api_response) @@ -37,6 +38,31 @@ REPLACE_ME_WITH_EXAMPLE_FOR__{{{operationId}}}_Python_CODE {{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} {{/useCustomTemplateCode}} +{{#useIndependentImplicitClients}} +An API instance constructed without an explicit or registered default +`ApiClient` owns its client. Use the API as a context manager: + +```python +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#async}}async {{/async}}with {{{packageName}}}.{{{classname}}}() as api_instance: + # Call API methods through api_instance. + pass +{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} +``` + +Direct construction requires +`{{#async}}await {{/async}}api_instance.close()`. Closing an API constructed +with an explicit or registered default client is a no-op; the caller remains +responsible for that client. Configuration-owned values are copied for an +implicit client. Logging resources retain their identity. Configuration +containers and proxy-header mappings are copied; other stateful transport +extension objects remain caller-owned. + +`Configuration.set_default()` stores a copy, so later changes to the supplied +object do not affect new implicit clients. `Configuration.get_default()` +returns that stored baseline, while `Configuration.get_default_copy()` returns +a copy. + +{{/useIndependentImplicitClients}} ## Documentation for API Endpoints All URIs are relative to *{{{basePath}}}* diff --git a/sdks/python/templates/configuration.mustache b/sdks/python/templates/configuration.mustache index 9dfedc794..97962709c 100644 --- a/sdks/python/templates/configuration.mustache +++ b/sdks/python/templates/configuration.mustache @@ -1,19 +1,33 @@ -# coding: utf-8 - {{>partial_header}} +{{#asyncio}} +import aiohttp +import aiohttp_retry +{{/asyncio}} +{{#async}} +import base64 +{{/async}} import copy import http.client as httplib import logging from logging import FileHandler -{{^asyncio}} +{{^async}} import multiprocessing -{{/asyncio}} +{{/async}} +{{^async}} +import ssl +{{/async}} import sys from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union +{{^async}} +from urllib.parse import urlparse +from urllib.request import getproxies +{{/async}} from typing_extensions import NotRequired, Self +{{^async}} import urllib3 +{{/async}} {{#hasHttpSignatureMethods}} from {{packageName}}.signing import HttpSigningConfiguration @@ -180,11 +194,50 @@ class Configuration: string values to replace variables in templated server configuration. The validation of enums is performed for variables with defined enum values before. + :param verify_ssl: bool - Set this to false to skip verifying SSL certificate + when calling API from https server. :param ssl_ca_cert: str - the path to a file of concatenated CA certificates in PEM format. - :param retries: Number of retries for API requests. +{{#asyncio}} + :param retries: int | aiohttp_retry.RetryOptionsBase - Retry configuration. + :param trace_configs: list of aiohttp.TraceConfig instances forwarded to + aiohttp.ClientSession for tracing/instrumentation (e.g. OpenTelemetry). + :param tcp_connector_limit_per_host: Per-host concurrency cap forwarded to + aiohttp.TCPConnector(limit_per_host=...). None leaves aiohttp's default (0 = unlimited). + :param client_session_kwargs: Extra keyword arguments merged into + aiohttp.ClientSession(**kwargs) (e.g. json_serialize=orjson.dumps, + cookie_jar=aiohttp.DummyCookieJar()). +{{#useIndependentImplicitClients}} + A non-None connector remains caller-owned because copied configurations + may share it. +{{/useIndependentImplicitClients}} +{{/asyncio}} +{{#httpxLibrary}} + :param retries: int - Retry configuration. +{{/httpxLibrary}} +{{^async}} + :param retries: int | urllib3.util.retry.Retry - Retry configuration. +{{/async}} :param ca_cert_data: verify the peer using concatenated CA certificate data in PEM (str) or DER (bytes) format. + :param cert_file: the path to a client certificate file, for mTLS. + :param key_file: the path to a client key file, for mTLS. + :param assert_hostname: Set this to True/False to enable/disable SSL hostname verification. + :param tls_server_name: SSL/TLS Server Name Indication (SNI). Set this to the SNI value expected by the server. + :param connection_pool_maxsize: Connection pool max size. None in the constructor is coerced to 100 for async and cpu_count * 5 for sync. + :param proxy: Proxy URL. +{{^async}} + :param no_proxy: Comma-separated hosts that bypass the proxy. +{{/async}} + :param proxy_headers: Proxy headers. +{{^async}} + :param proxy_ssl_context: SSL context used only for the TLS handshake with the proxy itself, independent of the destination TLS settings. +{{/async}} + :param safe_chars_for_path_param: Safe characters for path parameter encoding. + :param client_side_validation: Enable client-side validation. Default True. + :param socket_options: Options to pass down to the underlying urllib3 socket. + :param datetime_format: Datetime format string for serialization. + :param date_format: Date format string for serialization. {{#hasAuthMethods}} :Example: @@ -295,8 +348,38 @@ conf = {{{packageName}}}.Configuration( server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None, ignore_operation_servers: bool=False, ssl_ca_cert: Optional[str]=None, +{{#asyncio}} + retries: Optional[Union[int, aiohttp_retry.RetryOptionsBase]] = None, + trace_configs: Optional[List[aiohttp.TraceConfig]] = None, + tcp_connector_limit_per_host: Optional[int] = None, + client_session_kwargs: Optional[Dict[str, Any]] = None, +{{/asyncio}} +{{#httpxLibrary}} retries: Optional[int] = None, +{{/httpxLibrary}} +{{^async}} + retries: Optional[Union[int, urllib3.util.retry.Retry]] = None, +{{/async}} ca_cert_data: Optional[Union[str, bytes]] = None, + cert_file: Optional[str]=None, + key_file: Optional[str]=None, + verify_ssl: bool=True, + assert_hostname: Optional[bool]=None, + tls_server_name: Optional[str]=None, + connection_pool_maxsize: Optional[int]=None, + proxy: Optional[str]=None, +{{^async}} + no_proxy: Optional[str]=None, +{{/async}} + proxy_headers: Optional[Any]=None, +{{^async}} + proxy_ssl_context: Optional[ssl.SSLContext]=None, +{{/async}} + safe_chars_for_path_param: str='', + client_side_validation: bool=True, + socket_options: Optional[Any]=None, + datetime_format: str="{{{datetimeFormat}}}", + date_format: str="{{{dateFormat}}}", *, debug: Optional[bool] = None, ) -> None: @@ -358,7 +441,9 @@ conf = {{{packageName}}}.Configuration( """Logging Settings """ self.logger["package_logger"] = logging.getLogger("{{packageName}}") + {{^async}} self.logger["urllib3_logger"] = logging.getLogger("urllib3") + {{/async}} self.logger_format = '%(asctime)s %(levelname)s %(message)s' """Log format """ @@ -378,7 +463,7 @@ conf = {{{packageName}}}.Configuration( """Debug switch """ - self.verify_ssl = True + self.verify_ssl = verify_ssl """SSL/TLS verification Set this to false to skip verifying SSL certificate when calling API from https server. @@ -390,60 +475,98 @@ conf = {{{packageName}}}.Configuration( """Set this to verify the peer using PEM (str) or DER (bytes) certificate data. """ - self.cert_file = None + self.cert_file = cert_file """client certificate file """ - self.key_file = None + self.key_file = key_file """client key file """ - self.assert_hostname = None + self.assert_hostname = assert_hostname """Set this to True/False to enable/disable SSL hostname verification. """ - self.tls_server_name = None + self.tls_server_name = tls_server_name """SSL/TLS Server Name Indication (SNI) Set this to the SNI value expected by the server. """ - {{#asyncio}} - self.connection_pool_maxsize = 100 + {{#async}} + self.connection_pool_maxsize = connection_pool_maxsize if connection_pool_maxsize is not None else 100 """This value is passed to the aiohttp to limit simultaneous connections. - Default values is 100, None means no-limit. + None in the constructor is coerced to default 100. """ - {{/asyncio}} - {{^asyncio}} - self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 + {{/async}} + {{^async}} + self.connection_pool_maxsize = connection_pool_maxsize if connection_pool_maxsize is not None else multiprocessing.cpu_count() * 5 """urllib3 connection pool's maximum number of connections saved - per pool. urllib3 uses 1 connection as default value, but this is - not the best value when you are making a lot of possibly parallel - requests to the same host, which is often the case here. - cpu_count * 5 is used as default value to increase performance. + per pool. None in the constructor is coerced to cpu_count * 5. """ - {{/asyncio}} - - self.proxy: Optional[str] = None + {{/async}} + +{{^async}} + # urllib3 does not read proxy environment variables itself: + # https://github.com/urllib3/urllib3/issues/1785 + # A proxy taken from the environment is re-resolved when the host is + # assigned; see the host setter. + self._proxy_from_env = proxy is None + if proxy is None or no_proxy is None: + proxies = getproxies() + if proxy is None: + proxy = self._env_proxy(proxies, self.host) + if no_proxy is None: + no_proxy = proxies.get("no") + self._proxy = proxy + self.no_proxy = no_proxy + """Hosts that bypass the proxy + """ +{{/async}} +{{#async}} + self.proxy = proxy """Proxy URL """ - self.proxy_headers = None +{{/async}} + self.proxy_headers = proxy_headers """Proxy headers """ - self.safe_chars_for_path_param = '' +{{^async}} + self.proxy_ssl_context = proxy_ssl_context + """SSL context used only for the TLS handshake with the proxy itself + (e.g. an HTTPS CONNECT tunnel), independent of the destination TLS + settings above. + """ +{{/async}} + self.safe_chars_for_path_param = safe_chars_for_path_param """Safe chars for path_param """ self.retries = retries - """Adding retries to override urllib3 default value 3 + """Retry configuration + """ +{{#asyncio}} + self.trace_configs = trace_configs + """aiohttp.TraceConfig list forwarded to ClientSession for tracing. """ + self.tcp_connector_limit_per_host = tcp_connector_limit_per_host + """Per-host concurrency cap forwarded to TCPConnector. + """ + self.client_session_kwargs = client_session_kwargs + """Extra kwargs merged into aiohttp.ClientSession(**kwargs). + +{{#useIndependentImplicitClients}} + A non-None connector remains caller-owned. +{{/useIndependentImplicitClients}} + """ +{{/asyncio}} # Enable client side validation - self.client_side_validation = True + self.client_side_validation = client_side_validation - self.socket_options = None + self.socket_options = socket_options """Options to pass down to the underlying urllib3 socket """ - self.datetime_format = "{{{datetimeFormat}}}" + self.datetime_format = datetime_format """datetime format """ - self.date_format = "{{{dateFormat}}}" + self.date_format = date_format """date format """ @@ -452,13 +575,58 @@ conf = {{{packageName}}}.Configuration( result = cls.__new__(cls) memo[id(self)] = result for k, v in self.__dict__.items(): +{{#useIndependentImplicitClients}} + if k in ('logger', 'logger_file_handler', 'logger_stream_handler'): + continue + if k == 'proxy_headers': + # MultiDictProxy rejects generic copying, but copy() returns an + # independent mutable multidict and preserves duplicate headers: + # https://multidict.aio-libs.org/en/stable/multidict/ + copy_method = getattr(v, 'copy', None) + if callable(copy_method): + setattr(result, k, copy_method()) + continue +{{^async}} + if k == 'proxy_ssl_context': + # ssl.SSLContext holds unpicklable C state and can't be deepcopied. + setattr(result, k, v) + continue +{{/async}} +{{#asyncio}} + if k in ('client_session_kwargs', 'trace_configs'): + setattr(result, k, copy.copy(v)) + continue + if k == 'retries': + setattr(result, k, v) + continue +{{/asyncio}} + setattr(result, k, copy.deepcopy(v, memo)) + + # Loggers and their handlers are process-global. +{{#asyncio}} + # Aiohttp retry, trace, and session extension objects may contain + # event-loop state. Their containers are copied above, but the objects + # remain caller-owned. +{{/asyncio}} + result.logger = copy.copy(self.logger) + result.logger_file_handler = self.logger_file_handler + result.logger_stream_handler = self.logger_stream_handler +{{/useIndependentImplicitClients}} +{{^useIndependentImplicitClients}} +{{^async}} + if k == 'proxy_ssl_context': + # ssl.SSLContext holds unpicklable C state and can't be deepcopied. + setattr(result, k, v) + continue +{{/async}} if k not in ('logger', 'logger_file_handler'): setattr(result, k, copy.deepcopy(v, memo)) # shallow copy of loggers result.logger = copy.copy(self.logger) - # use setters to configure loggers + # use setter to re-create the file handler (excluded from __dict__ copy) result.logger_file = self.logger_file - result.debug = self.debug +{{/useIndependentImplicitClients}} + return result def __setattr__(self, name: str, value: Any) -> None: @@ -472,6 +640,17 @@ conf = {{{packageName}}}.Configuration( @classmethod def set_default(cls, default: Optional[Self]) -> None: +{{#useIndependentImplicitClients}} + """Store a copy as the default configuration. + + Later changes to ``default`` do not affect the stored configuration. + ``get_default`` returns the stored object, while ``get_default_copy`` + returns a copy of it. + + :param default: object of Configuration + """ +{{/useIndependentImplicitClients}} +{{^useIndependentImplicitClients}} """Set default instance of configuration. It stores default configuration, which can be @@ -479,10 +658,23 @@ conf = {{{packageName}}}.Configuration( :param default: object of Configuration """ +{{/useIndependentImplicitClients}} +{{#useIndependentImplicitClients}} + cls._default = copy.deepcopy(default) +{{/useIndependentImplicitClients}} +{{^useIndependentImplicitClients}} cls._default = default +{{/useIndependentImplicitClients}} @classmethod def get_default_copy(cls) -> Self: +{{#useIndependentImplicitClients}} + """Return a copy of the configured default, or a new configuration.""" + if cls._default is not None: + return copy.deepcopy(cls._default) + return cls() +{{/useIndependentImplicitClients}} +{{^useIndependentImplicitClients}} """Deprecated. Please use `get_default` instead. Deprecated. Please use `get_default` instead. @@ -490,9 +682,17 @@ conf = {{{packageName}}}.Configuration( :return: The configuration object. """ return cls.get_default() +{{/useIndependentImplicitClients}} @classmethod def get_default(cls) -> Self: +{{#useIndependentImplicitClients}} + """Return the shared default configuration, creating it if needed. + + :return: The configuration object. + """ +{{/useIndependentImplicitClients}} +{{^useIndependentImplicitClients}} """Return the default configuration. This method returns newly created, based on default constructor, @@ -501,6 +701,7 @@ conf = {{{packageName}}}.Configuration( :return: The configuration object. """ +{{/useIndependentImplicitClients}} if cls._default is None: cls._default = cls() return cls._default @@ -601,7 +802,8 @@ conf = {{{packageName}}}.Configuration( self.refresh_api_key_hook(self) key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None) if key: - prefix = self.api_key_prefix.get(identifier) + prefix = self.api_key_prefix.get( + identifier, self.api_key_prefix.get(alias) if alias is not None else None) if prefix: return "%s %s" % (prefix, key) else: @@ -620,9 +822,17 @@ conf = {{{packageName}}}.Configuration( password = "" if self.password is not None: password = self.password + + {{#async}} + return "Basic " + base64.b64encode( + (username + ":" + password).encode('utf-8') + ).decode('utf-8') + {{/async}} + {{^async}} return urllib3.util.make_headers( basic_auth=username + ':' + password ).get('authorization') + {{/async}} def auth_settings(self)-> AuthSettings: """Gets Auth Settings dict for api client. @@ -730,6 +940,11 @@ conf = {{{packageName}}}.Configuration( ] {{/-last}} {{/enumValues}} + {{^enumValues}} + {{#async}} + 'enum_values': [] + {{/async}} + {{/enumValues}} }{{^-last}},{{/-last}} {{#-last}} } @@ -772,6 +987,7 @@ conf = {{{packageName}}}.Configuration( variable_name, variable['default_value']) if 'enum_values' in variable \ + and variable['enum_values'] \ and used_value not in variable['enum_values']: raise ValueError( "The variable `{0}` in the host URL has invalid value " @@ -793,3 +1009,25 @@ conf = {{{packageName}}}.Configuration( """Fix base path.""" self._base_path = value self.server_index = None +{{^async}} + if self._proxy_from_env: + # the scheme-specific proxy depends on the host, which is + # commonly assigned after construction + self._proxy = self._env_proxy(getproxies(), value) + + @staticmethod + def _env_proxy(proxies: Dict[str, str], host: str) -> Optional[str]: + """Pick the environment proxy that applies to `host`.""" + return proxies.get(urlparse(host).scheme) or proxies.get("all") + + @property + def proxy(self) -> Optional[str]: + """Proxy URL + """ + return self._proxy + + @proxy.setter + def proxy(self, value: Optional[str]) -> None: + self._proxy = value + self._proxy_from_env = False +{{/async}} diff --git a/sdks/python/templates/exceptions.mustache b/sdks/python/templates/exceptions.mustache index 00157e3dd..48637ee11 100644 --- a/sdks/python/templates/exceptions.mustache +++ b/sdks/python/templates/exceptions.mustache @@ -1,6 +1,5 @@ -# coding: utf-8 - {{>partial_header}} + from typing import Any, Optional from typing_extensions import Self {{#useCustomTemplateCode}} @@ -126,7 +125,7 @@ class ApiException(OpenApiException): self.body = http_resp.data.decode('utf-8') except Exception: pass - self.headers = http_resp.getheaders() + self.headers = http_resp.headers @classmethod def from_response( @@ -167,8 +166,11 @@ class ApiException(OpenApiException): error_message += "HTTP response headers: {0}\n".format( self.headers) - if self.data or self.body: - error_message += "HTTP response body: {0}\n".format(self.data or self.body) + if self.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + if self.data: + error_message += "HTTP response data: {0}\n".format(self.data) return error_message diff --git a/sdks/python/templates/github-workflow.mustache b/sdks/python/templates/github-workflow.mustache index 82ff5e8f1..f6f72ae69 100644 --- a/sdks/python/templates/github-workflow.mustache +++ b/sdks/python/templates/github-workflow.mustache @@ -8,13 +8,16 @@ name: {{packageName}} Python package on: [push, pull_request] +permissions: + contents: read + jobs: build: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] steps: - uses: actions/checkout@v4 diff --git a/sdks/python/templates/gitignore.mustache b/sdks/python/templates/gitignore.mustache index 62f505ef1..8be63e472 100644 --- a/sdks/python/templates/gitignore.mustache +++ b/sdks/python/templates/gitignore.mustache @@ -62,7 +62,7 @@ docs/_build/ # PyBuilder target/ -#Ipython Notebook +# Ipython Notebook .ipynb_checkpoints {{#useCustomTemplateCode}} diff --git a/sdks/python/templates/gitlab-ci.mustache b/sdks/python/templates/gitlab-ci.mustache index 10c70f616..701ffbfd7 100644 --- a/sdks/python/templates/gitlab-ci.mustache +++ b/sdks/python/templates/gitlab-ci.mustache @@ -14,12 +14,6 @@ stages: - pip install -r test-requirements.txt - pytest --cov={{{packageName}}} -pytest-3.8: - extends: .pytest - image: python:3.8-alpine -pytest-3.9: - extends: .pytest - image: python:3.9-alpine pytest-3.10: extends: .pytest image: python:3.10-alpine @@ -29,3 +23,9 @@ pytest-3.11: pytest-3.12: extends: .pytest image: python:3.12-alpine +pytest-3.13: + extends: .pytest + image: python:3.13-alpine +pytest-3.14: + extends: .pytest + image: python:3.14-alpine diff --git a/sdks/python/templates/model.mustache b/sdks/python/templates/model.mustache index 84792dde1..3ffd50e57 100644 --- a/sdks/python/templates/model.mustache +++ b/sdks/python/templates/model.mustache @@ -2,10 +2,12 @@ {{>partial_header}} + {{#models}} {{#model}} {{#isEnum}} {{>model_enum}} + {{/isEnum}} {{^isEnum}} {{#oneOf}}{{#-first}}{{>model_oneof}}{{/-first}}{{/oneOf}}{{^oneOf}}{{#anyOf}}{{#-first}}{{>model_anyof}}{{/-first}}{{/anyOf}}{{^anyOf}}{{>model_generic}}{{/anyOf}}{{/oneOf}} diff --git a/sdks/python/templates/model_anyof.mustache b/sdks/python/templates/model_anyof.mustache index e035e4829..7a7f52f75 100644 --- a/sdks/python/templates/model_anyof.mustache +++ b/sdks/python/templates/model_anyof.mustache @@ -12,6 +12,13 @@ import re # noqa: F401 from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self from pydantic import Field +{{#compatibleWithPythonLegacy}} +from pydantic_core import to_jsonable_python + + +{{>_legacy_model_dict_helpers}} + +{{/compatibleWithPythonLegacy}} {{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ANY_OF_SCHEMAS = [{{#anyOf}}"{{.}}"{{^-last}}, {{/-last}}{{/anyOf}}] @@ -156,9 +163,36 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): return self.actual_instance.to_json() +{{#compatibleWithPythonLegacy}} + return json.dumps( + to_jsonable_python( + _to_openapi_value(self.actual_instance) + ) + ) +{{/compatibleWithPythonLegacy}} +{{^compatibleWithPythonLegacy}} else: return json.dumps(self.actual_instance) +{{/compatibleWithPythonLegacy}} + +{{#compatibleWithPythonLegacy}} + def to_dict(self, serialize: bool = False) -> Any: + """Returns the public or wire representation of the actual instance""" + if self.actual_instance is None: + return None + + return _to_legacy_value(self.actual_instance, serialize) + + def __openapi_generator_modern_projection(self) -> Any: + """Returns the wire representation of the actual instance""" + if self.actual_instance is None: + return None + + return _to_openapi_value(self.actual_instance) +{{>_legacy_model_dict_registration}} +{{/compatibleWithPythonLegacy}} +{{^compatibleWithPythonLegacy}} def to_dict(self) -> Optional[Union[Dict[str, Any], {{#anyOf}}{{.}}{{^-last}}, {{/-last}}{{/anyOf}}]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: @@ -168,6 +202,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} return self.actual_instance.to_dict() else: return self.actual_instance +{{/compatibleWithPythonLegacy}} def to_str(self) -> str: """Returns the string representation of the actual instance""" diff --git a/sdks/python/templates/model_doc.mustache b/sdks/python/templates/model_doc.mustache index 5b130c259..b6cabc3a4 100644 --- a/sdks/python/templates/model_doc.mustache +++ b/sdks/python/templates/model_doc.mustache @@ -14,7 +14,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} +{{#vars}}**{{#vendorExtensions.x-py-public-name-differs-from-storage}}{{vendorExtensions.x-py-public-name}}{{/vendorExtensions.x-py-public-name-differs-from-storage}}{{^vendorExtensions.x-py-public-name-differs-from-storage}}{{name}}{{/vendorExtensions.x-py-public-name-differs-from-storage}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} |{{#vendorExtensions.x-py-public-name-differs-from-storage}}{{^required}} [optional]{{/required}}{{#isReadOnly}} [readonly]{{/isReadOnly}}{{#defaultValue}} [default to {{{.}}}]{{/defaultValue}}{{/vendorExtensions.x-py-public-name-differs-from-storage}}{{^vendorExtensions.x-py-public-name-differs-from-storage}} {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}{{/vendorExtensions.x-py-public-name-differs-from-storage}} {{/vars}} ## Example diff --git a/sdks/python/templates/model_generic.mustache b/sdks/python/templates/model_generic.mustache index 919bcd1f5..9bf00dbec 100644 --- a/sdks/python/templates/model_generic.mustache +++ b/sdks/python/templates/model_generic.mustache @@ -16,11 +16,21 @@ from typing import Tuple, Union import io from pydantic import StrictBool {{/useCustomTemplateCode}} +from pydantic_core import to_jsonable_python +{{#vendorExtensions.x-py-has-public-name-properties}} +from typing import TYPE_CHECKING +{{/vendorExtensions.x-py-has-public-name-properties}} +{{^vendorExtensions.x-py-has-public-name-properties}} {{#hasChildren}} {{#discriminator}} -{{! If this model is a super class, importlib is used. So import the necessary modules for the type here. }} from typing import TYPE_CHECKING +{{/discriminator}} +{{/hasChildren}} +{{/vendorExtensions.x-py-has-public-name-properties}} +{{#hasChildren}} +{{#discriminator}} +{{! If this model is a super class, importlib is used. So import the necessary modules for the type here. }} if TYPE_CHECKING: {{#mappedModels}} from {{packageName}}.models.{{model.classFilename}} import {{modelName}} @@ -28,9 +38,28 @@ if TYPE_CHECKING: {{/discriminator}} {{/hasChildren}} +{{#compatibleWithPythonLegacy}} + +{{>_legacy_model_dict_helpers}} + + +{{/compatibleWithPythonLegacy}} class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}): """ {{#description}}{{{description}}}{{/description}}{{^description}}{{{classname}}}{{/description}} +{{#compatibleWithPythonLegacy}} +{{! +python-legacy generic models exposed metadata and value helpers: +https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L37-L55 +https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L255 +}} + + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. +{{/compatibleWithPythonLegacy}} """ # noqa: E501 {{#vars}} {{^useCustomTemplateCode}} @@ -43,11 +72,24 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{#isAdditionalPropertiesTrue}} additional_properties: Dict[str, Any] = {} {{/isAdditionalPropertiesTrue}} - __properties: ClassVar[List[str]] = [{{#allVars}}"{{baseName}}"{{^-last}}, {{/-last}}{{/allVars}}] +{{#compatibleWithPythonLegacy}} + openapi_types: ClassVar[Dict[str, str]] = { +{{#allVars}} + {{#vendorExtensions.x-py-public-name-literal}}{{{vendorExtensions.x-py-public-name-literal}}}{{/vendorExtensions.x-py-public-name-literal}}{{^vendorExtensions.x-py-public-name-literal}}{{#lambda.pythonStringLiteral}}{{{name}}}{{/lambda.pythonStringLiteral}}{{/vendorExtensions.x-py-public-name-literal}}: {{#lambda.pythonStringLiteral}}{{{dataType}}}{{/lambda.pythonStringLiteral}}{{^-last}},{{/-last}} +{{/allVars}} + } + + attribute_map: ClassVar[Dict[str, str]] = { +{{#allVars}} + {{#vendorExtensions.x-py-public-name-literal}}{{{vendorExtensions.x-py-public-name-literal}}}{{/vendorExtensions.x-py-public-name-literal}}{{^vendorExtensions.x-py-public-name-literal}}{{#lambda.pythonStringLiteral}}{{{name}}}{{/lambda.pythonStringLiteral}}{{/vendorExtensions.x-py-public-name-literal}}: {{{vendorExtensions.x-py-wire-name-literal}}}{{^-last}},{{/-last}} +{{/allVars}} + } +{{/compatibleWithPythonLegacy}} + __properties: ClassVar[List[str]] = [{{#allVars}}{{{vendorExtensions.x-py-wire-name-literal}}}{{^-last}}, {{/-last}}{{/allVars}}] {{#vars}} {{#vendorExtensions.x-regex}} - @field_validator('{{{name}}}') + @field_validator('{{{name}}}', mode="before") def {{{name}}}_validate_regular_expression(cls, value): """Validates the regular expression""" {{^required}} @@ -62,7 +104,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{/isNullable}} {{/required}} - if not re.match(r"{{{.}}}", value{{#vendorExtensions.x-modifiers}} ,re.{{{.}}}{{/vendorExtensions.x-modifiers}}): + if isinstance(value, str) and not re.match(r"{{{.}}}", value{{#vendorExtensions.x-modifiers}} ,re.{{{.}}}{{/vendorExtensions.x-modifiers}}): raise ValueError(r"must validate the regular expression {{{vendorExtensions.x-pattern}}}") return value {{/vendorExtensions.x-regex}} @@ -101,11 +143,96 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{/isContainer}} return value {{/isEnum}} + {{#vendorExtensions.x-python-not-string-enum-values.size}} + @field_validator('{{{name}}}') + def {{{name}}}_validate_not_enum(cls, value): + """Validates values excluded by not""" + {{^required}} + if value is None: + return value + + {{/required}} + {{#required}} + {{#isNullable}} + if value is None: + return value + + {{/isNullable}} + {{/required}} + if value in set([{{#vendorExtensions.x-python-not-string-enum-values}}{{#lambda.pythonStringLiteral}}{{{.}}}{{/lambda.pythonStringLiteral}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-python-not-string-enum-values}}]): + raise ValueError("must not be one of excluded enum values") + return value + {{/vendorExtensions.x-python-not-string-enum-values.size}} {{/vars}} +{{#vendorExtensions.x-py-preprocesses-input-names}} + @classmethod + def __preprocess_input_names( + cls, + obj: Any, + remove_hidden_storage_names: bool = True, + ) -> Any: + if not isinstance(obj, _Mapping): + return obj + obj = dict(obj) +{{#vendorExtensions.x-py-input-name-properties}} +{{#vendorExtensions.x-py-public-name-differs-from-wire}} +{{#vendorExtensions.x-py-explicit-public-name}} + if ( + {{{vendorExtensions.x-py-wire-name-literal}}} in obj + and {{{vendorExtensions.x-py-public-name-literal}}} in obj + ): + raise ValueError( + "%s received both %r and %r" + % ( + cls.__name__, + {{{vendorExtensions.x-py-wire-name-literal}}}, + {{{vendorExtensions.x-py-public-name-literal}}}, + ) + ) +{{/vendorExtensions.x-py-explicit-public-name}} + if {{{vendorExtensions.x-py-wire-name-literal}}} not in obj and {{{vendorExtensions.x-py-public-name-literal}}} in obj: + obj[{{{vendorExtensions.x-py-wire-name-literal}}}] = obj[{{{vendorExtensions.x-py-public-name-literal}}}] + obj.pop({{{vendorExtensions.x-py-public-name-literal}}}, None) +{{/vendorExtensions.x-py-public-name-differs-from-wire}} +{{/vendorExtensions.x-py-input-name-properties}} +{{#vendorExtensions.x-py-hidden-storage-names.size}} + if remove_hidden_storage_names: +{{#vendorExtensions.x-py-hidden-storage-names}} + obj.pop({{#lambda.pythonStringLiteral}}{{{.}}}{{/lambda.pythonStringLiteral}}, None) +{{/vendorExtensions.x-py-hidden-storage-names}} +{{/vendorExtensions.x-py-hidden-storage-names.size}} + return obj + +{{/vendorExtensions.x-py-preprocesses-input-names}} +{{#vendorExtensions.x-py-validates-input-names}} + # Pydantic passes the model instance to wrap validators during assignment: + # https://docs.pydantic.dev/2.11/migration/#changes-to-validators + # Private names also keep inherited model validators distinct: + # https://docs.pydantic.dev/2.11/concepts/validators/#on-inheritance + @_model_validator(mode="wrap") + @classmethod + def __validate_input_names( + cls, + obj: Any, + handler: _ModelWrapValidatorHandler[Self], + ) -> Self: + if not isinstance(obj, cls): + obj = cls.__preprocess_input_names(obj) + return handler(obj) + +{{/vendorExtensions.x-py-validates-input-names}} model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, +{{#compatibleWithPythonLegacy}} +{{! +python-legacy generated explicit constructor parameters, so unknown kwargs failed: +https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L64-L100 +}} + extra="forbid", +{{/compatibleWithPythonLegacy}} protected_namespaces=(), {{#useCustomTemplateCode}} arbitrary_types_allowed=True, @@ -116,17 +243,17 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{#hasChildren}} {{#discriminator}} # JSON field name that stores the object type - __discriminator_property_name: ClassVar[str] = '{{discriminator.propertyBaseName}}' + __discriminator_property_name: ClassVar[str] = {{#lambda.pythonSingleQuotedStringLiteral}}{{{discriminator.propertyBaseName}}}{{/lambda.pythonSingleQuotedStringLiteral}} # discriminator mappings __discriminator_value_class_map: ClassVar[Dict[str, str]] = { - {{#mappedModels}}'{{{mappingName}}}': '{{{modelName}}}'{{^-last}},{{/-last}}{{/mappedModels}} + {{#mappedModels}}{{#lambda.pythonSingleQuotedStringLiteral}}{{{mappingName}}}{{/lambda.pythonSingleQuotedStringLiteral}}: '{{{modelName}}}'{{^-last}},{{/-last}}{{/mappedModels}} } @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: @@ -135,13 +262,55 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{/discriminator}} {{/hasChildren}} def to_str(self) -> str: +{{#compatibleWithPythonLegacy}} + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) +{{/compatibleWithPythonLegacy}} +{{^compatibleWithPythonLegacy}} """Returns the string representation of the model using alias""" return pprint.pformat(self.model_dump(by_alias=True)) +{{/compatibleWithPythonLegacy}} +{{#compatibleWithPythonLegacy}} + + def __repr__(self) -> str: + """For print and pprint""" + return self.to_str() + + def __eq__(self, other: object) -> bool: + """Returns true if both objects are equal""" + if not isinstance(other, {{classname}}): + return False + +{{#isAdditionalPropertiesTrue}} + return ( + self.to_dict() == other.to_dict() + and self.additional_properties == other.additional_properties + ) +{{/isAdditionalPropertiesTrue}} +{{^isAdditionalPropertiesTrue}} + return self.to_dict() == other.to_dict() +{{/isAdditionalPropertiesTrue}} + + def __ne__(self, other: object) -> bool: + """Returns true if both objects are not equal""" + if not isinstance(other, {{classname}}): + return True + + return not (self == other) + +{{/compatibleWithPythonLegacy}} def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) +{{#compatibleWithPythonLegacy}} + to_openapi_dict = _get_openapi_to_dict(self) + if to_openapi_dict is not None: + return json.dumps(to_jsonable_python(to_openapi_dict(self))) + return json.dumps(to_jsonable_python(self.to_dict())) +{{/compatibleWithPythonLegacy}} +{{^compatibleWithPythonLegacy}} + return json.dumps(to_jsonable_python(self.to_dict())) +{{/compatibleWithPythonLegacy}} {{#useCustomTemplateCode}} def to_json_form_params(self, excluded_fields: Set[str] = None) -> List[Tuple[str, str]]: @@ -161,7 +330,20 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} """Create an instance of {{{classname}}} from a JSON string""" return cls.from_dict(json.loads(json_str)) +{{#compatibleWithPythonLegacy}} + def to_dict(self, serialize: bool = False) -> Dict[str, Any]: + """Return all declared model fields using public or wire names.""" + return { +{{#allVars}} + ({{{vendorExtensions.x-py-wire-name-literal}}} if serialize else {{#vendorExtensions.x-py-public-name-literal}}{{{vendorExtensions.x-py-public-name-literal}}}{{/vendorExtensions.x-py-public-name-literal}}{{^vendorExtensions.x-py-public-name-literal}}{{#lambda.pythonStringLiteral}}{{{name}}}{{/lambda.pythonStringLiteral}}{{/vendorExtensions.x-py-public-name-literal}}): _to_legacy_value(getattr(self, {{#lambda.pythonStringLiteral}}{{{name}}}{{/lambda.pythonStringLiteral}}, None), serialize), +{{/allVars}} + } + + def __openapi_generator_modern_projection(self) -> Dict[str, Any]: +{{/compatibleWithPythonLegacy}} +{{^compatibleWithPythonLegacy}} def to_dict(self{{#useCustomTemplateCode}}, excluded_fields: Set[str] = None{{/useCustomTemplateCode}}) -> Dict[str, Any]: +{{/compatibleWithPythonLegacy}} """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -202,25 +384,37 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} _items = [] if self.{{{name}}}: for _item_{{{name}}} in self.{{{name}}}: - if _item_{{{name}}}: - _items.append( - [_inner_item.to_dict() for _inner_item in _item_{{{name}}} if _inner_item is not None] - ) - _dict['{{{baseName}}}'] = _items + _items.append( + [{{#compatibleWithPythonLegacy}}_to_openapi_value(_inner_item){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}_inner_item.to_dict(){{/compatibleWithPythonLegacy}} if _inner_item is not None else None for _inner_item in _item_{{{name}}}] if _item_{{{name}}} is not None else None + ) + _dict[{{#lambda.pythonSingleQuotedStringLiteral}}{{{baseName}}}{{/lambda.pythonSingleQuotedStringLiteral}}] = _items {{/items.items.isPrimitiveType}} {{/items.isArray}} + {{#items.isMap}} + {{^items.items.isPrimitiveType}} + # override the default output from pydantic by calling `to_dict()` of each item in {{{name}}} (list of dict) + _items = [] + if self.{{{name}}}: + for _item_{{{name}}} in self.{{{name}}}: + _items.append( + {_inner_key: {{#compatibleWithPythonLegacy}}_to_openapi_value(_inner_value){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}_inner_value.to_dict(){{/compatibleWithPythonLegacy}} if _inner_value is not None else None for _inner_key, _inner_value in _item_{{{name}}}.items()} if _item_{{{name}}} is not None else None + ) + _dict[{{#lambda.pythonSingleQuotedStringLiteral}}{{{baseName}}}{{/lambda.pythonSingleQuotedStringLiteral}}] = _items + {{/items.items.isPrimitiveType}} + {{/items.isMap}} {{^items.isArray}} + {{^items.isMap}} {{^items.isPrimitiveType}} {{^items.isEnumOrRef}} # override the default output from pydantic by calling `to_dict()` of each item in {{{name}}} (list) _items = [] if self.{{{name}}}: for _item_{{{name}}} in self.{{{name}}}: - if _item_{{{name}}}: - _items.append(_item_{{{name}}}.to_dict()) - _dict['{{{baseName}}}'] = _items + _items.append({{#compatibleWithPythonLegacy}}_to_openapi_value(_item_{{{name}}}){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}_item_{{{name}}}.to_dict(){{/compatibleWithPythonLegacy}} if _item_{{{name}}} is not None else None) + _dict[{{#lambda.pythonSingleQuotedStringLiteral}}{{{baseName}}}{{/lambda.pythonSingleQuotedStringLiteral}}] = _items {{/items.isEnumOrRef}} {{/items.isPrimitiveType}} + {{/items.isMap}} {{/items.isArray}} {{/isArray}} {{#isMap}} @@ -230,13 +424,25 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} _field_dict_of_array = {} if self.{{{name}}}: for _key_{{{name}}} in self.{{{name}}}: - if self.{{{name}}}[_key_{{{name}}}] is not None: - _field_dict_of_array[_key_{{{name}}}] = [ - _item.to_dict() for _item in self.{{{name}}}[_key_{{{name}}}] - ] - _dict['{{{baseName}}}'] = _field_dict_of_array + _field_dict_of_array[_key_{{{name}}}] = [ + {{#compatibleWithPythonLegacy}}_to_openapi_value(_item){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}_item.to_dict(){{/compatibleWithPythonLegacy}} if _item is not None else None for _item in self.{{{name}}}[_key_{{{name}}}] + ] if self.{{{name}}}[_key_{{{name}}}] is not None else None + _dict[{{#lambda.pythonSingleQuotedStringLiteral}}{{{baseName}}}{{/lambda.pythonSingleQuotedStringLiteral}}] = _field_dict_of_array {{/items.items.isPrimitiveType}} {{/items.isArray}} + {{#items.isMap}} + {{^items.items.isPrimitiveType}} + # override the default output from pydantic by calling `to_dict()` of each value in {{{name}}} (dict of dict) + _field_dict_of_dict = {} + if self.{{{name}}}: + for _key_{{{name}}}, _value_{{{name}}} in self.{{{name}}}.items(): + _field_dict_of_dict[_key_{{{name}}}] = { + _key: {{#compatibleWithPythonLegacy}}_to_openapi_value(_value){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}_value.to_dict(){{/compatibleWithPythonLegacy}} if _value is not None else None for _key, _value in _value_{{{name}}}.items() + } if _value_{{{name}}} is not None else None + _dict[{{#lambda.pythonSingleQuotedStringLiteral}}{{{baseName}}}{{/lambda.pythonSingleQuotedStringLiteral}}] = _field_dict_of_dict + {{/items.items.isPrimitiveType}} + {{/items.isMap}} + {{^items.isMap}} {{^items.isArray}} {{^items.isPrimitiveType}} {{^items.isEnumOrRef}} @@ -244,12 +450,12 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} _field_dict = {} if self.{{{name}}}: for _key_{{{name}}} in self.{{{name}}}: - if self.{{{name}}}[_key_{{{name}}}]: - _field_dict[_key_{{{name}}}] = self.{{{name}}}[_key_{{{name}}}].to_dict() - _dict['{{{baseName}}}'] = _field_dict + _field_dict[_key_{{{name}}}] = {{#compatibleWithPythonLegacy}}_to_openapi_value(self.{{{name}}}[_key_{{{name}}}]){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}self.{{{name}}}[_key_{{{name}}}].to_dict(){{/compatibleWithPythonLegacy}} if self.{{{name}}}[_key_{{{name}}}] is not None else None + _dict[{{#lambda.pythonSingleQuotedStringLiteral}}{{{baseName}}}{{/lambda.pythonSingleQuotedStringLiteral}}] = _field_dict {{/items.isEnumOrRef}} {{/items.isPrimitiveType}} {{/items.isArray}} + {{/items.isMap}} {{/isMap}} {{/isContainer}} {{^isContainer}} @@ -257,7 +463,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{^isEnumOrRef}} # override the default output from pydantic by calling `to_dict()` of {{{name}}} if self.{{{name}}}: - _dict['{{{baseName}}}'] = self.{{{name}}}.to_dict() + _dict[{{#lambda.pythonSingleQuotedStringLiteral}}{{{baseName}}}{{/lambda.pythonSingleQuotedStringLiteral}}] = {{#compatibleWithPythonLegacy}}_to_openapi_value(self.{{{name}}}){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}self.{{{name}}}.to_dict(){{/compatibleWithPythonLegacy}} {{/isEnumOrRef}} {{/isPrimitiveType}} {{/isContainer}} @@ -275,17 +481,44 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} # set to None if {{{name}}} (nullable) is None # and model_fields_set contains the field if self.{{name}} is None and "{{{name}}}" in self.model_fields_set: - _dict['{{{baseName}}}'] = None + _dict[{{#lambda.pythonSingleQuotedStringLiteral}}{{{baseName}}}{{/lambda.pythonSingleQuotedStringLiteral}}] = None {{/isNullable}} {{/allVars}} {{/useCustomTemplateCode}} return _dict +{{#compatibleWithPythonLegacy}} +{{>_legacy_model_dict_registration}} + +{{/compatibleWithPythonLegacy}} {{#hasChildren}} @classmethod def from_dict(cls, obj: Dict[str, Any]) -> Optional[{{#discriminator}}Union[{{#mappedModels}}{{{modelName}}}{{^-last}}, {{/-last}}{{/mappedModels}}]{{/discriminator}}{{^discriminator}}Self{{/discriminator}}]: """Create an instance of {{{classname}}} from a dict""" + {{/hasChildren}} + {{^hasChildren}} + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of {{{classname}}} from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + {{/hasChildren}} +{{#vendorExtensions.x-py-preprocesses-input-names}} + + obj = _cast( + Dict[str, Any], + cls.__preprocess_input_names( + obj, + remove_hidden_storage_names={{#hasChildren}}{{#discriminator}}False{{/discriminator}}{{^discriminator}}True{{/discriminator}}{{/hasChildren}}{{^hasChildren}}True{{/hasChildren}}, + ), + ) + +{{/vendorExtensions.x-py-preprocesses-input-names}} + {{#hasChildren}} {{#discriminator}} # look up the object type based on discriminator mapping object_type = cls.get_discriminator_value(obj) @@ -300,15 +533,9 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{/discriminator}} {{/hasChildren}} {{^hasChildren}} - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of {{{classname}}} from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) +{{^vendorExtensions.x-py-preprocesses-input-names}} +{{/vendorExtensions.x-py-preprocesses-input-names}} {{#disallowAdditionalPropertiesIfNotPresent}} {{^isAdditionalPropertiesTrue}} # raise errors for additional fields in the input @@ -322,37 +549,50 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{#allVars}} {{#isContainer}} {{#isArray}} + {{#items.isContainer}} {{#items.isArray}} {{#items.items.isPrimitiveType}} - "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} + {{{vendorExtensions.x-py-wire-name-literal}}}: obj.get({{{vendorExtensions.x-py-wire-name-literal}}}){{^-last}},{{/-last}} {{/items.items.isPrimitiveType}} {{^items.items.isPrimitiveType}} - "{{{baseName}}}": [ - [{{{items.items.dataType}}}.from_dict(_inner_item) for _inner_item in _item] - for _item in obj["{{{baseName}}}"] - ] if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} + {{{vendorExtensions.x-py-wire-name-literal}}}: [ + [{{{items.items.dataType}}}.from_dict(_inner_item) for _inner_item in _item] if _item is not None else None + for _item in obj[{{{vendorExtensions.x-py-wire-name-literal}}}] + ] if obj.get({{{vendorExtensions.x-py-wire-name-literal}}}) is not None else None{{^-last}},{{/-last}} {{/items.items.isPrimitiveType}} {{/items.isArray}} - {{^items.isArray}} + {{#items.isMap}} + {{#items.items.isPrimitiveType}} + {{{vendorExtensions.x-py-wire-name-literal}}}: obj.get({{{vendorExtensions.x-py-wire-name-literal}}}){{^-last}},{{/-last}} + {{/items.items.isPrimitiveType}} + {{^items.items.isPrimitiveType}} + {{{vendorExtensions.x-py-wire-name-literal}}}: [ + {_inner_key: {{{items.items.dataType}}}.from_dict(_inner_value) for _inner_key, _inner_value in _item.items()} if _item is not None else None + for _item in obj[{{{vendorExtensions.x-py-wire-name-literal}}}] + ] if obj.get({{{vendorExtensions.x-py-wire-name-literal}}}) is not None else None{{^-last}},{{/-last}} + {{/items.items.isPrimitiveType}} + {{/items.isMap}} + {{/items.isContainer}} + {{^items.isContainer}} {{^items.isPrimitiveType}} {{#items.isEnumOrRef}} - "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} + {{{vendorExtensions.x-py-wire-name-literal}}}: obj.get({{{vendorExtensions.x-py-wire-name-literal}}}){{^-last}},{{/-last}} {{/items.isEnumOrRef}} {{^items.isEnumOrRef}} - "{{{baseName}}}": [{{{items.dataType}}}.from_dict(_item) for _item in obj["{{{baseName}}}"]] if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} + {{{vendorExtensions.x-py-wire-name-literal}}}: [{{{items.dataType}}}.from_dict(_item) for _item in obj[{{{vendorExtensions.x-py-wire-name-literal}}}]] if obj.get({{{vendorExtensions.x-py-wire-name-literal}}}) is not None else None{{^-last}},{{/-last}} {{/items.isEnumOrRef}} {{/items.isPrimitiveType}} {{#items.isPrimitiveType}} - "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} + {{{vendorExtensions.x-py-wire-name-literal}}}: obj.get({{{vendorExtensions.x-py-wire-name-literal}}}){{^-last}},{{/-last}} {{/items.isPrimitiveType}} - {{/items.isArray}} + {{/items.isContainer}} {{/isArray}} {{#isMap}} {{^items.isPrimitiveType}} {{^items.isEnumOrRef}} {{#items.isContainer}} {{#items.isMap}} - "{{{baseName}}}": dict( + {{{vendorExtensions.x-py-wire-name-literal}}}: dict( (_k, dict( (_ik, {{{items.items.dataType}}}.from_dict(_iv)) for _ik, _iv in _v.items() @@ -360,55 +600,53 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} if _v is not None else None ) - for _k, _v in obj.get("{{{baseName}}}").items() + for _k, _v in obj[{{{vendorExtensions.x-py-wire-name-literal}}}].items() ) - if obj.get("{{{baseName}}}") is not None + if obj.get({{{vendorExtensions.x-py-wire-name-literal}}}) is not None else None{{^-last}},{{/-last}} {{/items.isMap}} {{#items.isArray}} - "{{{baseName}}}": dict( - (_k, - [{{{items.items.dataType}}}.from_dict(_item) for _item in _v] - if _v is not None - else None - ) - for _k, _v in obj.get("{{{baseName}}}", {}).items() - ){{^-last}},{{/-last}} + {{{vendorExtensions.x-py-wire-name-literal}}}: { + _k: [{{{items.items.dataType}}}.from_dict(_item) for _item in _v] if _v is not None else None + for _k, _v in obj[{{{vendorExtensions.x-py-wire-name-literal}}}].items() + } + if obj.get({{{vendorExtensions.x-py-wire-name-literal}}}) is not None + else None{{^-last}},{{/-last}} {{/items.isArray}} {{/items.isContainer}} {{^items.isContainer}} - "{{{baseName}}}": dict( + {{{vendorExtensions.x-py-wire-name-literal}}}: dict( (_k, {{{items.dataType}}}.from_dict(_v)) - for _k, _v in obj["{{{baseName}}}"].items() + for _k, _v in obj[{{{vendorExtensions.x-py-wire-name-literal}}}].items() ) - if obj.get("{{{baseName}}}") is not None + if obj.get({{{vendorExtensions.x-py-wire-name-literal}}}) is not None else None{{^-last}},{{/-last}} {{/items.isContainer}} {{/items.isEnumOrRef}} {{#items.isEnumOrRef}} - "{{{baseName}}}": dict((_k, _v) for _k, _v in obj.get("{{{baseName}}}").items()) if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} + {{{vendorExtensions.x-py-wire-name-literal}}}: dict((_k, _v) for _k, _v in obj.get({{{vendorExtensions.x-py-wire-name-literal}}}).items()) if obj.get({{{vendorExtensions.x-py-wire-name-literal}}}) is not None else None{{^-last}},{{/-last}} {{/items.isEnumOrRef}} {{/items.isPrimitiveType}} {{#items.isPrimitiveType}} - "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} + {{{vendorExtensions.x-py-wire-name-literal}}}: obj.get({{{vendorExtensions.x-py-wire-name-literal}}}){{^-last}},{{/-last}} {{/items.isPrimitiveType}} {{/isMap}} {{/isContainer}} {{^isContainer}} {{^isPrimitiveType}} {{^isEnumOrRef}} - "{{{baseName}}}": {{{dataType}}}.from_dict(obj["{{{baseName}}}"]) if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} + {{{vendorExtensions.x-py-wire-name-literal}}}: {{{dataType}}}.from_dict(obj[{{{vendorExtensions.x-py-wire-name-literal}}}]) if obj.get({{{vendorExtensions.x-py-wire-name-literal}}}) is not None else None{{^-last}},{{/-last}} {{/isEnumOrRef}} {{#isEnumOrRef}} - "{{{baseName}}}": obj.get("{{{baseName}}}"){{#defaultValue}} if obj.get("{{baseName}}") is not None else {{defaultValue}}{{/defaultValue}}{{^-last}},{{/-last}} + {{{vendorExtensions.x-py-wire-name-literal}}}: obj.get({{{vendorExtensions.x-py-wire-name-literal}}}){{#defaultValue}} if {{#isNullable}}{{{vendorExtensions.x-py-wire-name-literal}}} in obj{{/isNullable}}{{^isNullable}}obj.get({{{vendorExtensions.x-py-wire-name-literal}}}) is not None{{/isNullable}} else {{{defaultValue}}}{{/defaultValue}}{{^-last}},{{/-last}} {{/isEnumOrRef}} {{/isPrimitiveType}} {{#isPrimitiveType}} {{#defaultValue}} - "{{{baseName}}}": obj.get("{{{baseName}}}") if obj.get("{{{baseName}}}") is not None else {{{defaultValue}}}{{^-last}},{{/-last}} + {{{vendorExtensions.x-py-wire-name-literal}}}: obj.get({{{vendorExtensions.x-py-wire-name-literal}}}) if {{#isNullable}}{{{vendorExtensions.x-py-wire-name-literal}}} in obj{{/isNullable}}{{^isNullable}}obj.get({{{vendorExtensions.x-py-wire-name-literal}}}) is not None{{/isNullable}} else {{{defaultValue}}}{{^-last}},{{/-last}} {{/defaultValue}} {{^defaultValue}} - "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} + {{{vendorExtensions.x-py-wire-name-literal}}}: obj.get({{{vendorExtensions.x-py-wire-name-literal}}}){{^-last}},{{/-last}} {{/defaultValue}} {{/isPrimitiveType}} {{/isContainer}} @@ -423,6 +661,22 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{/isAdditionalPropertiesTrue}} return _obj {{/hasChildren}} +{{#vendorExtensions.x-py-has-public-name-properties}} + + if TYPE_CHECKING: +{{#vars}} + {{#vendorExtensions.x-py-public-name-differs-from-storage}} + + @property{{#vendorExtensions.x-py-public-name-overrides-base-model}} # type: ignore[override]{{/vendorExtensions.x-py-public-name-overrides-base-model}} + def {{{vendorExtensions.x-py-public-name}}}(self) -> _{{classname}}_{{name}}_public_type: + return self.{{{name}}} + + @{{{vendorExtensions.x-py-public-name}}}.setter + def {{{vendorExtensions.x-py-public-name}}}(self, value: _{{classname}}_{{name}}_public_type) -> None:{{#vendorExtensions.x-py-public-name-overrides-base-model}} # pyright: ignore[reportIncompatibleMethodOverride]{{/vendorExtensions.x-py-public-name-overrides-base-model}} + self.{{{name}}} = value + {{/vendorExtensions.x-py-public-name-differs-from-storage}} +{{/vars}} +{{/vendorExtensions.x-py-has-public-name-properties}} {{#useCustomTemplateCode}} {{^discriminator}} @@ -441,10 +695,10 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} def openapi_types(cls) -> Dict[str, str]: return { {{#requiredVars}} - "{{name}}": "({{#vendorExtensions.x-int-or-string}}int, str{{/vendorExtensions.x-int-or-string}}{{^vendorExtensions.x-int-or-string}}{{{dataType}}}{{/vendorExtensions.x-int-or-string}},)", + "{{name}}": "({{#vendorExtensions.x-int-or-string}}int, str{{/vendorExtensions.x-int-or-string}}{{^vendorExtensions.x-int-or-string}}{{#isBinary}}io.IOBase{{/isBinary}}{{^isBinary}}{{#isArray}}{{#items.isBinary}}List[io.IOBase]{{/items.isBinary}}{{^items.isBinary}}{{{dataType}}}{{/items.isBinary}}{{/isArray}}{{^isArray}}{{{dataType}}}{{/isArray}}{{/isBinary}}{{/vendorExtensions.x-int-or-string}},)", {{/requiredVars}} {{#optionalVars}} - "{{name}}": "({{#vendorExtensions.x-int-or-string}}int, str{{/vendorExtensions.x-int-or-string}}{{^vendorExtensions.x-int-or-string}}{{{dataType}}}{{/vendorExtensions.x-int-or-string}},)", + "{{name}}": "({{#vendorExtensions.x-int-or-string}}int, str{{/vendorExtensions.x-int-or-string}}{{^vendorExtensions.x-int-or-string}}{{#isBinary}}io.IOBase{{/isBinary}}{{^isBinary}}{{#isArray}}{{#items.isBinary}}List[io.IOBase]{{/items.isBinary}}{{^items.isBinary}}{{{dataType}}}{{/items.isBinary}}{{/isArray}}{{^isArray}}{{{dataType}}}{{/isArray}}{{/isBinary}}{{/vendorExtensions.x-int-or-string}},)", {{/optionalVars}} } @@ -465,3 +719,31 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} # TODO: Rewrite to not use raise_errors {{classname}}.model_rebuild(raise_errors=False) {{/vendorExtensions.x-py-postponed-model-imports.size}} +{{#vendorExtensions.x-py-has-public-name-properties}} + +if TYPE_CHECKING: +{{#vars}} +{{#vendorExtensions.x-py-public-name-differs-from-storage}} + _{{classname}}_{{name}}_public_type = {{{vendorExtensions.x-py-public-name-typing}}} +{{/vendorExtensions.x-py-public-name-differs-from-storage}} +{{/vars}} + +# Install forwarding properties after Pydantic has consumed the class +# namespace and resolved any postponed model annotations. +{{#vars}} +{{#vendorExtensions.x-py-public-name-differs-from-storage}} +setattr( + {{classname}}, + {{{vendorExtensions.x-py-public-name-literal}}}, + property( + lambda self: self.{{{name}}}, + lambda self, value: setattr( + self, + {{#lambda.pythonStringLiteral}}{{{name}}}{{/lambda.pythonStringLiteral}}, + value, + ), + ), +) +{{/vendorExtensions.x-py-public-name-differs-from-storage}} +{{/vars}} +{{/vendorExtensions.x-py-has-public-name-properties}} diff --git a/sdks/python/templates/model_oneof.mustache b/sdks/python/templates/model_oneof.mustache index 07a4d93f9..8365ae0bb 100644 --- a/sdks/python/templates/model_oneof.mustache +++ b/sdks/python/templates/model_oneof.mustache @@ -10,6 +10,13 @@ import pprint from pydantic import StrictStr, Field from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self +{{#compatibleWithPythonLegacy}} +from pydantic_core import to_jsonable_python + + +{{>_legacy_model_dict_helpers}} + +{{/compatibleWithPythonLegacy}} {{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ONE_OF_SCHEMAS = [{{#oneOf}}"{{.}}"{{^-last}}, {{/-last}}{{/oneOf}}] @@ -33,7 +40,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} discriminator_value_class_map: Dict[str, str] = { {{#children}} - '{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': '{{{classname}}}'{{^-last}},{{/-last}} + {{#lambda.pythonSingleQuotedStringLiteral}}{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}{{/lambda.pythonSingleQuotedStringLiteral}}: '{{{classname}}}'{{^-last}},{{/-last}} {{/children}} } {{/discriminator}} @@ -118,13 +125,14 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{#mappedModels}} {{#-first}} # use oneOf discriminator to lookup the data type - _data_type = json.loads(json_str).get("{{{propertyBaseName}}}") + _discriminator_property = {{#lambda.pythonStringLiteral}}{{{propertyBaseName}}}{{/lambda.pythonStringLiteral}} + _data_type = json.loads(json_str).get(_discriminator_property) if not _data_type: - raise ValueError("Failed to lookup data type from the field `{{{propertyBaseName}}}` in the input.") + raise ValueError(f"Failed to lookup data type from the field `{_discriminator_property}` in the input.") {{/-first}} # check if data type is `{{{modelName}}}` - if _data_type == "{{{mappingName}}}": + if _data_type == {{#lambda.pythonStringLiteral}}{{{mappingName}}}{{/lambda.pythonStringLiteral}}: instance.actual_instance = {{{modelName}}}.from_json(json_str) return instance @@ -182,9 +190,36 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): return self.actual_instance.to_json() +{{#compatibleWithPythonLegacy}} + return json.dumps( + to_jsonable_python( + _to_openapi_value(self.actual_instance) + ) + ) +{{/compatibleWithPythonLegacy}} +{{^compatibleWithPythonLegacy}} else: return json.dumps(self.actual_instance) +{{/compatibleWithPythonLegacy}} + +{{#compatibleWithPythonLegacy}} + def to_dict(self, serialize: bool = False) -> Any: + """Returns the public or wire representation of the actual instance""" + if self.actual_instance is None: + return None + + return _to_legacy_value(self.actual_instance, serialize) + + def __openapi_generator_modern_projection(self) -> Any: + """Returns the wire representation of the actual instance""" + if self.actual_instance is None: + return None + + return _to_openapi_value(self.actual_instance) +{{>_legacy_model_dict_registration}} +{{/compatibleWithPythonLegacy}} +{{^compatibleWithPythonLegacy}} def to_dict(self) -> Optional[Union[Dict[str, Any], {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: @@ -195,6 +230,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} else: # primitive type return self.actual_instance +{{/compatibleWithPythonLegacy}} def to_str(self) -> str: """Returns the string representation of the actual instance""" diff --git a/sdks/python/templates/model_test.mustache b/sdks/python/templates/model_test.mustache index 08088557c..8333f8fd3 100644 --- a/sdks/python/templates/model_test.mustache +++ b/sdks/python/templates/model_test.mustache @@ -2,6 +2,7 @@ {{>partial_header}} + import unittest {{#models}} @@ -29,14 +30,14 @@ class Test{{classname}}(unittest.TestCase): if include_optional: return {{classname}}( {{#vars}} - {{name}} = {{{example}}}{{^example}}None{{/example}}{{^-last}},{{/-last}} + {{#vendorExtensions.x-py-public-name}}{{.}}{{/vendorExtensions.x-py-public-name}}{{^vendorExtensions.x-py-public-name}}{{name}}{{/vendorExtensions.x-py-public-name}} = {{{example}}}{{^example}}None{{/example}}{{^-last}},{{/-last}} {{/vars}} ) else: return {{classname}}( {{#vars}} {{#required}} - {{name}} = {{{example}}}{{^example}}None{{/example}}, + {{#vendorExtensions.x-py-public-name}}{{.}}{{/vendorExtensions.x-py-public-name}}{{^vendorExtensions.x-py-public-name}}{{name}}{{/vendorExtensions.x-py-public-name}} = {{{example}}}{{^example}}None{{/example}}, {{/required}} {{/vars}} ) diff --git a/sdks/python/templates/partial_api.mustache b/sdks/python/templates/partial_api.mustache index 58a9269b3..749a1351c 100644 --- a/sdks/python/templates/partial_api.mustache +++ b/sdks/python/templates/partial_api.mustache @@ -10,6 +10,19 @@ :param {{paramName}}:{{#description}} {{{.}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}} :type {{paramName}}: {{dataType}}{{#optional}}, optional{{/optional}} {{/allParams}} +{{#compatibleWithPythonLegacyApi}} +{{^async}} + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _return_http_data_only: only affects with_http_info; ordinary + methods always return data only. + :type _return_http_data_only: bool, optional + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :type _preload_content: bool, optional +{{/async}} +{{/compatibleWithPythonLegacyApi}} :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -48,7 +61,17 @@ _response_types_map: Dict[str, Optional[str]] = { {{#responses}} {{^isWildcard}} +{{^useCustomTemplateCode}} '{{code}}': {{#dataType}}"{{.}}"{{/dataType}}{{^dataType}}None{{/dataType}}, +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + '{{code}}': {{#isBinary}}"io.IOBase"{{/isBinary}}{{^isBinary}}{{#dataType}}"{{.}}"{{/dataType}}{{^dataType}}None{{/dataType}}{{/isBinary}}, +{{/useCustomTemplateCode}} + {{/isWildcard}} + {{#isWildcard}} + {{#dataType}} + 'default': "{{dataType}}", + {{/dataType}} {{/isWildcard}} {{/responses}} } diff --git a/sdks/python/templates/pyproject.mustache b/sdks/python/templates/pyproject.mustache index 5539d1468..1e0c9c40a 100644 --- a/sdks/python/templates/pyproject.mustache +++ b/sdks/python/templates/pyproject.mustache @@ -1,60 +1,160 @@ +{{#poetry1}} [tool.poetry] +{{/poetry1}} +{{^poetry1}} +[project] +{{/poetry1}} +{{^useCustomTemplateCode}} name = "{{{packageName}}}" +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} +name = "{{{projectName}}}" +{{/useCustomTemplateCode}} version = "{{{packageVersion}}}" description = "{{{appName}}}" +{{#poetry1}} authors = ["{{infoName}}{{^infoName}}OpenAPI Generator Community{{/infoName}} <{{infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}>"] -license = "{{{licenseInfo}}}{{^licenseInfo}}NoLicense{{/licenseInfo}}" +{{/poetry1}} +{{^poetry1}} +{{^useCustomTemplateCode}} +authors = [ + {name = "{{infoName}}{{^infoName}}OpenAPI Generator Community{{/infoName}}",email = "{{infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}"}, +] +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} +authors = [ + {name = "{{packageAuthor}}",email = "{{infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}"}, +] +{{/useCustomTemplateCode}} +{{/poetry1}} +{{#licenseInfo}} +{{#poetry1}} +license = "{{{licenseInfo}}}" +{{/poetry1}} +{{^poetry1}} +license = { text = "{{{licenseInfo}}}" } +{{/poetry1}} +{{/licenseInfo}} readme = "README.md" +{{#poetry1}} repository = "https://{{{gitHost}}}/{{{gitUserId}}}/{{{gitRepoId}}}" +{{/poetry1}} keywords = ["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"] -include = ["{{packageName}}/py.typed"] +{{#poetry1}} +{{#sourceFolder}} +packages = [ + { include = "{{{packageName}}}", from = "{{{sourceFolder}}}" }, +] +{{/sourceFolder}} +include = ["{{#sourceFolder}}{{{sourceFolder}}}/{{/sourceFolder}}{{packageName}}/py.typed"] [tool.poetry.dependencies] -python = "^3.8" - +python = "^3.10" +{{^async}} {{^useCustomTemplateCode}} -urllib3 = ">= 1.25.3, < 3.0.0" +urllib3 = ">= 2.7.0, < 3.0.0" {{/useCustomTemplateCode}} {{#useCustomTemplateCode}} -urllib3 = [ - { version = ">= 2.8.0, < 3.0.0", python = ">=3.10" }, - { version = ">= 1.25.3, < 3.0.0", python = "<3.10" }, -] +urllib3 = ">= 2.8.0, < 3.0.0" {{/useCustomTemplateCode}} +{{/async}} python-dateutil = ">= 2.8.2" {{#asyncio}} -aiohttp = ">= 3.8.4" +aiohttp = ">= 3.14.1" aiohttp-retry = ">= 2.8.3" {{/asyncio}} -{{#tornado}} -tornado = ">=4.2, <5" -{{/tornado}} +{{#httpx}} +httpx = ">= 0.28.1" +{{/httpx}} +{{#httpx2}} +httpx2 = ">= 2.13.0, < 3" +{{/httpx2}} {{#hasHttpSignatureMethods}} pem = ">= 19.3.0" pycryptodome = ">= 3.9.0" {{/hasHttpSignatureMethods}} -pydantic = ">= 2" +pydantic = ">= 2.11" typing-extensions = ">= 4.7.1" +{{/poetry1}} +{{^poetry1}} +requires-python = ">=3.10" +dependencies = [ +{{^async}} +{{^useCustomTemplateCode}} + "urllib3 (>=2.7.0,<3.0.0)", +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} + "urllib3 (>=2.8.0,<3.0.0)", +{{/useCustomTemplateCode}} +{{/async}} + "python-dateutil (>=2.8.2)", +{{#httpx}} + "httpx (>=0.28.1)", +{{/httpx}} +{{#httpx2}} + "httpx2 (>=2.13.0,<3)", +{{/httpx2}} +{{#asyncio}} + "aiohttp (>=3.14.1)", + "aiohttp-retry (>=2.8.3)", +{{/asyncio}} +{{#hasHttpSignatureMethods}} + "pem (>=19.3.0)", + "pycryptodome (>=3.9.0)", +{{/hasHttpSignatureMethods}} + "pydantic (>=2.11)", + "typing-extensions (>=4.7.1)", +] + +[project.urls] +{{^useCustomTemplateCode}} +Repository = "https://{{{gitHost}}}/{{{gitUserId}}}/{{{gitRepoId}}}" +{{/useCustomTemplateCode}} +{{#useCustomTemplateCode}} +Repository = "{{{packageUrl}}}" +{{/useCustomTemplateCode}} + +{{/poetry1}} +{{#poetry1}} +# Deprecated by Poetry; retained for compatibility with legacy Poetry 1 releases. [tool.poetry.dev-dependencies] -pytest = ">= 7.2.1" +pytest = ">= 9.0.3" pytest-cov = ">= 2.8.1" tox = ">= 3.9.0" flake8 = ">= 4.0.0" types-python-dateutil = ">= 2.8.19.14" mypy = ">= 1.5" +{{/poetry1}} +{{^poetry1}} +[dependency-groups] +dev = [ + "pytest>=9.0.3", + "pytest-cov>=2.8.1", + "tox>=3.9.0", + "flake8>=4.0.0", + "types-python-dateutil>=2.8.19.14", + "mypy>=1.5", +] +{{/poetry1}} [build-system] +{{#hatchling}} +requires = ["hatchling"] +build-backend = "hatchling.build" +{{/hatchling}} +{{^hatchling}} requires = ["setuptools"] build-backend = "setuptools.build_meta" +{{/hatchling}} [tool.pylint.'MESSAGES CONTROL'] extension-pkg-whitelist = "pydantic" [tool.mypy] files = [ - "{{{packageName}}}", + "{{#sourceFolder}}{{{sourceFolder}}}/{{/sourceFolder}}{{{packageName}}}", #"test", # auto-generated tests "tests", # hand-written tests ] diff --git a/sdks/python/templates/requirements.mustache b/sdks/python/templates/requirements.mustache index ee1e9efae..5091adeb0 100644 --- a/sdks/python/templates/requirements.mustache +++ b/sdks/python/templates/requirements.mustache @@ -1,21 +1,25 @@ +{{^async}} {{^useCustomTemplateCode}} -urllib3 >= 1.25.3, < 3.0.0 +urllib3 >= 2.7.0, < 3.0.0 {{/useCustomTemplateCode}} {{#useCustomTemplateCode}} -urllib3 >= 2.8.0, < 3.0.0; python_version >= "3.10" -urllib3 >= 1.25.3, < 3.0.0; python_version < "3.10" +urllib3 >= 2.8.0, < 3.0.0 {{/useCustomTemplateCode}} +{{/async}} python_dateutil >= 2.8.2 {{#asyncio}} -aiohttp >= 3.8.4 +aiohttp >= 3.14.1 aiohttp-retry >= 2.8.3 {{/asyncio}} -{{#tornado}} -tornado = ">= 4.2, < 5" -{{/tornado}} +{{#httpx}} +httpx >= 0.28.1 +{{/httpx}} +{{#httpx2}} +httpx2 >= 2.13.0, < 3 +{{/httpx2}} {{#hasHttpSignatureMethods}} pem >= 19.3.0 pycryptodome >= 3.9.0 {{/hasHttpSignatureMethods}} -pydantic >= 2 +pydantic >= 2.11 typing-extensions >= 4.7.1 diff --git a/sdks/python/templates/rest.mustache b/sdks/python/templates/rest.mustache index f545066bb..5f56a2d60 100644 --- a/sdks/python/templates/rest.mustache +++ b/sdks/python/templates/rest.mustache @@ -2,10 +2,13 @@ {{>partial_header}} + +import ipaddress import io import json import re import ssl +from urllib.parse import urlparse import urllib3 @@ -24,6 +27,59 @@ def is_socks_proxy_url(url): else: return split_section[0].lower() in SUPPORTED_SOCKS_PROXIES +def contenttype_matches(contenttype, maintype, subtype): + """Matches the given contenttype against the given type and subtype + + :param contenttype: the content type to match + :param maintype: the expected maintype + :param subtype: the expected subtype + :return: `true` when the given content type matches the given type and subtype, + regardless of the presence of mime type parameters, otherwise returns `false`. + :rtype: bool + """ + pattern = '{type}/(?:[^+;]+\\+)?{subtype}(?:[ \t]*;.*)?'.format( + type = re.escape(maintype), + subtype = re.escape(subtype), + ) + return re.fullmatch(pattern, contenttype, re.IGNORECASE) is not None + +def should_bypass_proxies(url: str, no_proxy: str) -> bool: + """Return whether ``url`` matches the comma-separated ``no_proxy`` rules.""" + parsed_url = urlparse(url) + if not parsed_url.hostname: + return True + + host = parsed_url.hostname.lower() + host_and_port = parsed_url.netloc.lower() + try: + host_ip = ipaddress.ip_address(host) + except ValueError: + host_ip = None + + for entry in (entry.strip().lower() for entry in no_proxy.split(',')): + if not entry: + continue + if entry == '*': + return True + + if host_ip is not None: + try: + if host_ip in ipaddress.ip_network(entry, strict=False): + return True + except ValueError: + pass + + entry = entry.lstrip('.') + if ( + host == entry + or host.endswith('.' + entry) + or host_and_port == entry + or host_and_port.endswith('.' + entry) + ): + return True + + return False + class RESTResponse(io.IOBase): @@ -38,12 +94,17 @@ class RESTResponse(io.IOBase): self.data = self.response.data return self.data + @property + def headers(self): + """Returns a dictionary of response headers.""" + return self.response.headers + def getheaders(self): - """Returns a dictionary of the response headers.""" + """Returns a dictionary of the response headers; use ``headers`` instead.""" return self.response.headers def getheader(self, name, default=None): - """Returns a given response header.""" + """Returns a given response header; use ``headers.get()`` instead.""" return self.response.headers.get(name, default) @@ -89,7 +150,9 @@ class RESTClientObject: # https pool manager self.pool_manager: urllib3.PoolManager - if configuration.proxy: + if configuration.proxy and not should_bypass_proxies( + configuration.host, configuration.no_proxy or '' + ): if is_socks_proxy_url(configuration.proxy): from urllib3.contrib.socks import SOCKSProxyManager pool_args["proxy_url"] = configuration.proxy @@ -98,10 +161,17 @@ class RESTClientObject: else: pool_args["proxy_url"] = configuration.proxy pool_args["proxy_headers"] = configuration.proxy_headers + if configuration.proxy_ssl_context is not None: + pool_args["proxy_ssl_context"] = configuration.proxy_ssl_context self.pool_manager = urllib3.ProxyManager(**pool_args) else: self.pool_manager = urllib3.PoolManager(**pool_args) +{{#useIndependentImplicitClients}} + def close(self) -> None: + self.pool_manager.clear() + +{{/useIndependentImplicitClients}} def request( self, method, @@ -161,12 +231,24 @@ class RESTClientObject: # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: - # no content type provided or payload is json content_type = headers.get('Content-Type') - if ( + is_json = ( not content_type - or re.search('json', content_type, re.IGNORECASE) - ): + or contenttype_matches(content_type, 'application', 'json') + ) + # JSON is valid YAML 1.2, so structured YAML bodies can use + # the existing JSON serializer: + # https://yaml.org/spec/1.2.2/#13-relation-to-json + is_structured_yaml = ( + content_type + and ( + contenttype_matches(content_type, 'application', 'yaml') + or contenttype_matches(content_type, 'text', 'yaml') + or contenttype_matches(content_type, 'text', 'x-yaml') + ) + and not isinstance(body, (str, bytes)) + ) + if is_json or is_structured_yaml: request_body = None if body is not None: request_body = json.dumps(body{{#setEnsureAsciiToFalse}}, ensure_ascii=False{{/setEnsureAsciiToFalse}}) @@ -178,7 +260,7 @@ class RESTClientObject: headers=headers, preload_content=False ) - elif content_type == 'application/x-www-form-urlencoded': + elif contenttype_matches(content_type, 'application', 'x-www-form-urlencoded'): r = self.pool_manager.request( method, url, @@ -188,7 +270,7 @@ class RESTClientObject: headers=headers, preload_content=False ) - elif content_type == 'multipart/form-data': + elif contenttype_matches(content_type, 'multipart', 'form-data'): # must del headers['Content-Type'], or the correct # Content-Type which generated by urllib3 will be # overwritten. @@ -216,7 +298,7 @@ class RESTClientObject: headers=headers, preload_content=False ) - elif headers['Content-Type'].startswith('text/') and isinstance(body, bool): + elif content_type.startswith('text/') and isinstance(body, bool): request_body = "true" if body else "false" r = self.pool_manager.request( method, diff --git a/sdks/python/templates/setup.mustache b/sdks/python/templates/setup.mustache index 1c4359641..29687a60e 100644 --- a/sdks/python/templates/setup.mustache +++ b/sdks/python/templates/setup.mustache @@ -1,5 +1,3 @@ -# coding: utf-8 - {{>partial_header}} from setuptools import setup, find_packages # noqa: H301 @@ -15,28 +13,32 @@ from pathlib import Path # http://pypi.python.org/pypi/setuptools NAME = "{{{projectName}}}" VERSION = "{{packageVersion}}" -PYTHON_REQUIRES = ">= 3.8" +PYTHON_REQUIRES = ">= 3.10" REQUIRES = [ +{{^async}} {{^useCustomTemplateCode}} - "urllib3 >= 1.25.3, < 3.0.0", + "urllib3 >= 2.7.0, < 3.0.0", {{/useCustomTemplateCode}} {{#useCustomTemplateCode}} - "urllib3 >= 2.8.0, < 3.0.0; python_version >= '3.10'", - "urllib3 >= 1.25.3, < 3.0.0; python_version < '3.10'", + "urllib3 >= 2.8.0, < 3.0.0", {{/useCustomTemplateCode}} +{{/async}} "python-dateutil >= 2.8.2", {{#asyncio}} - "aiohttp >= 3.8.4", + "aiohttp >= 3.14.1", "aiohttp-retry >= 2.8.3", {{/asyncio}} -{{#tornado}} - "tornado>=4.2, < 5", -{{/tornado}} +{{#httpx}} + "httpx >= 0.28.1", +{{/httpx}} +{{#httpx2}} + "httpx2 >= 2.13.0, < 3", +{{/httpx2}} {{#hasHttpSignatureMethods}} "pem >= 19.3.0", "pycryptodome >= 3.9.0", {{/hasHttpSignatureMethods}} - "pydantic >= 2", + "pydantic >= 2.11", "typing-extensions >= 4.7.1", ] @@ -59,7 +61,10 @@ setup( url="{{packageUrl}}", keywords=["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"], install_requires=REQUIRES, - packages=find_packages(exclude=["test", "tests"]), +{{#sourceFolder}} + package_dir={"": "{{{sourceFolder}}}"}, +{{/sourceFolder}} + packages=find_packages({{#sourceFolder}}where="{{{sourceFolder}}}", {{/sourceFolder}}exclude=["test", "tests"]), include_package_data=True, {{^useCustomTemplateCode}} {{#licenseInfo}}license="{{.}}", diff --git a/sdks/python/templates/test-requirements.mustache b/sdks/python/templates/test-requirements.mustache index e8273336c..6cc0351ab 100644 --- a/sdks/python/templates/test-requirements.mustache +++ b/sdks/python/templates/test-requirements.mustache @@ -1,4 +1,4 @@ -pytest >= 7.2.1 +pytest >= 9.0.3 pytest-cov >= 2.8.1 tox >= 3.9.0 flake8 >= 4.0.0 diff --git a/sdks/python/templates/tornado/rest.mustache b/sdks/python/templates/tornado/rest.mustache deleted file mode 100644 index f4bfbfb23..000000000 --- a/sdks/python/templates/tornado/rest.mustache +++ /dev/null @@ -1,142 +0,0 @@ -# coding: utf-8 - -{{>partial_header}} - -import io -import json -import re - -from urllib.parse import urlencode -import tornado -import tornado.gen -from tornado import httpclient -from urllib3.filepost import encode_multipart_formdata - -from {{packageName}}.exceptions import ApiException, ApiValueError - -RESTResponseType = httpclient.HTTPResponse - -class RESTResponse(io.IOBase): - - def __init__(self, resp) -> None: - self.response = resp - self.status = resp.code - self.reason = resp.reason - self.data = None - - def read(self): - if self.data is None: - self.data = self.response.body - return self.data - - def getheaders(self): - """Returns a CIMultiDictProxy of the response headers.""" - return self.response.headers - - def getheader(self, name, default=None): - """Returns a given response header.""" - return self.response.headers.get(name, default) - - -class RESTClientObject: - - def __init__(self, configuration) -> None: - - self.ca_certs = configuration.ssl_ca_cert - self.client_key = configuration.key_file - self.client_cert = configuration.cert_file - - self.proxy_port = self.proxy_host = None - - # https pool manager - if configuration.proxy: - self.proxy_port = 80 - self.proxy_host = configuration.proxy - - self.pool_manager = httpclient.AsyncHTTPClient() - - @tornado.gen.coroutine - def request( - self, - method, - url, - headers=None, - body=None, - post_params=None, - _request_timeout=None - ): - """Execute Request - - :param method: http request method - :param url: http request url - :param headers: http request headers - :param body: request json body, for `application/json` - :param post_params: request post parameters, - `application/x-www-form-urlencoded` - and `multipart/form-data` - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - """ - method = method.upper() - assert method in [ - 'GET', - 'HEAD', - 'DELETE', - 'POST', - 'PUT', - 'PATCH', - 'OPTIONS' - ] - - if post_params and body: - raise ApiValueError( - "body parameter cannot be used with post_params parameter." - ) - - request = httpclient.HTTPRequest(url) - request.allow_nonstandard_methods = True - request.ca_certs = self.ca_certs - request.client_key = self.client_key - request.client_cert = self.client_cert - request.proxy_host = self.proxy_host - request.proxy_port = self.proxy_port - request.method = method - if headers: - request.headers = headers - if 'Content-Type' not in headers: - request.headers['Content-Type'] = 'application/json' - request.request_timeout = _request_timeout or 5 * 60 - - post_params = post_params or {} - - # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` - if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: - if re.search('json', headers['Content-Type'], re.IGNORECASE): - if body: - body = json.dumps(body) - request.body = body - elif headers['Content-Type'] == 'application/x-www-form-urlencoded': - request.body = urlencode(post_params) - elif headers['Content-Type'] == 'multipart/form-data': - multipart = encode_multipart_formdata(post_params) - request.body, headers['Content-Type'] = multipart - # Pass a `bytes` parameter directly in the body to support - # other content types than Json when `body` argument is provided - # in serialized form - elif isinstance(body, bytes): - request.body = body - else: - # Cannot generate the request from given parameters - msg = """Cannot prepare a request message for provided - arguments. Please check that your arguments match - declared content type.""" - raise ApiException(status=0, reason=msg) - - r = yield self.pool_manager.fetch(request, raise_error=False) - - - r = RESTResponse(r) - - raise tornado.gen.Return(r) diff --git a/sdks/python/templates/travis.mustache b/sdks/python/templates/travis.mustache index 155d9a763..983251a46 100644 --- a/sdks/python/templates/travis.mustache +++ b/sdks/python/templates/travis.mustache @@ -1,13 +1,13 @@ # ref: https://docs.travis-ci.com/user/languages/python language: python python: - - "3.8" - - "3.9" - "3.10" - "3.11" - "3.12" + - "3.13" + - "3.14" # uncomment the following if needed - #- "3.12-dev" # 3.12 development branch + #- "3.14-dev" # 3.14 development branch #- "nightly" # nightly build # command to install dependencies install: diff --git a/sdks/python/test-requirements.txt b/sdks/python/test-requirements.txt index 29d3726e6..97e27f8bd 100644 --- a/sdks/python/test-requirements.txt +++ b/sdks/python/test-requirements.txt @@ -1,4 +1,4 @@ -pytest >= 7.2.1 +pytest >= 9.0.3 pytest-cov >= 2.8.1 tox >= 3.9.0 flake8 >= 4.0.0