From 6f599f40c85d3e1bfcc53a670f98220587fe0a1a Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Fri, 17 Jan 2025 00:26:34 +0000 Subject: [PATCH] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.468.9 --- .speakeasy/gen.lock | 21 ++- .speakeasy/gen.yaml | 3 +- .speakeasy/workflow.lock | 14 +- RELEASES.md | 12 +- codeSamples.yaml | 5 +- .../operations/gettagsqueryparamsortby.md | 11 ++ .../operations/gettagsqueryparamsortorder.md | 11 ++ docs/models/operations/gettagsrequest.md | 13 ++ docs/models/operations/ids.md | 19 +++ .../operations/tracksaleresponsebody.md | 10 +- docs/sdks/tags/README.md | 12 +- pyproject.toml | 2 +- src/dub/_version.py | 6 +- src/dub/analytics.py | 14 +- src/dub/customers.py | 70 +++++++-- src/dub/domains.py | 56 ++++++- src/dub/embed_tokens.py | 14 +- src/dub/events.py | 14 +- src/dub/links.py | 140 +++++++++++++++--- src/dub/metatags.py | 14 +- src/dub/models/operations/__init__.py | 14 ++ src/dub/models/operations/gettags.py | 87 +++++++++++ src/dub/models/operations/tracksale.py | 38 ++++- src/dub/qr_codes.py | 14 +- src/dub/tags.py | 74 +++++++-- src/dub/track.py | 28 +++- src/dub/workspaces.py | 28 +++- 27 files changed, 645 insertions(+), 99 deletions(-) create mode 100644 docs/models/operations/gettagsqueryparamsortby.md create mode 100644 docs/models/operations/gettagsqueryparamsortorder.md create mode 100644 docs/models/operations/gettagsrequest.md create mode 100644 docs/models/operations/ids.md create mode 100644 src/dub/models/operations/gettags.py diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 950b230..1eb7fd3 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: ab657d60-207e-43a4-8cc8-692a672950ed management: - docChecksum: 810d019618d329428080463b7bf165c7 + docChecksum: c7226fc27f4fb4b6c492bc7d8bb0ce6d docVersion: 0.0.1 - speakeasyVersion: 1.468.6 - generationVersion: 2.493.13 - releaseVersion: 0.17.2 - configChecksum: 27829e9e655969641d4494982fa8a837 + speakeasyVersion: 1.468.9 + generationVersion: 2.493.21 + releaseVersion: 0.17.3 + configChecksum: 57196fc5b5b758adf94f83e6e5eee8ba repoURL: https://github.com/dubinc/dub-python.git installationURL: https://github.com/dubinc/dub-python.git published: true @@ -14,7 +14,7 @@ features: python: additionalDependencies: 1.0.0 constsAndDefaults: 1.0.5 - core: 5.10.1 + core: 5.10.2 defaultEnabledRetries: 0.2.0 deprecations: 3.0.2 enumUnions: 0.1.0 @@ -221,8 +221,12 @@ generatedFiles: - docs/models/operations/getmetatagsrequest.md - docs/models/operations/getmetatagsresponsebody.md - docs/models/operations/getqrcoderequest.md + - docs/models/operations/gettagsqueryparamsortby.md + - docs/models/operations/gettagsqueryparamsortorder.md + - docs/models/operations/gettagsrequest.md - docs/models/operations/getworkspacerequest.md - docs/models/operations/groupby.md + - docs/models/operations/ids.md - docs/models/operations/interval.md - docs/models/operations/level.md - docs/models/operations/link.md @@ -380,6 +384,7 @@ generatedFiles: - src/dub/models/operations/getlinkscount.py - src/dub/models/operations/getmetatags.py - src/dub/models/operations/getqrcode.py + - src/dub/models/operations/gettags.py - src/dub/models/operations/getworkspace.py - src/dub/models/operations/listdomains.py - src/dub/models/operations/listevents.py @@ -818,6 +823,10 @@ examples: application/json: {"error": {"code": "internal_server_error", "message": "The requested resource was not found.", "doc_url": "https://dub.co/docs/api-reference/errors#internal-server_error"}} getTags: speakeasy-default-get-tags: + parameters: + query: + page: 1 + pageSize: 50 responses: "200": application/json: [] diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 23ca0d6..249965b 100755 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -13,7 +13,7 @@ generation: oAuth2ClientCredentialsEnabled: true oAuth2PasswordEnabled: false python: - version: 0.17.2 + version: 0.17.3 additionalDependencies: dev: {} main: {} @@ -23,6 +23,7 @@ python: clientServerStatusCodesAsErrors: true defaultErrorName: SDKError description: Python Client SDK Generated by Speakeasy + enableCustomCodeRegions: false enumFormat: enum fixFlags: responseRequiredSep2024: false diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 9e71749..30392f8 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,21 +1,21 @@ -speakeasyVersion: 1.468.6 +speakeasyVersion: 1.468.9 sources: dub: sourceNamespace: dub - sourceRevisionDigest: sha256:9ece271b2b29213d07d843152b55788d12255a77ff95cd936f75a9fc0581d129 - sourceBlobDigest: sha256:584f9a57bd02dbf990d2e6a17ba90d848f8ee7e52db00bd30b17a438f35549b2 + sourceRevisionDigest: sha256:a8bc05b0060aca3195d0dce6b4014115e5187e3b78ac72a2dc81dd4dcf08de21 + sourceBlobDigest: sha256:3a497f2adc2e94717c3da9975cb28e719879942f74434e18ffe44db7b99adc7b tags: - latest - - speakeasy-sdk-regen-1736900762 + - speakeasy-sdk-regen-1737073531 - 0.0.1 targets: my-first-target: source: dub sourceNamespace: dub - sourceRevisionDigest: sha256:9ece271b2b29213d07d843152b55788d12255a77ff95cd936f75a9fc0581d129 - sourceBlobDigest: sha256:584f9a57bd02dbf990d2e6a17ba90d848f8ee7e52db00bd30b17a438f35549b2 + sourceRevisionDigest: sha256:a8bc05b0060aca3195d0dce6b4014115e5187e3b78ac72a2dc81dd4dcf08de21 + sourceBlobDigest: sha256:3a497f2adc2e94717c3da9975cb28e719879942f74434e18ffe44db7b99adc7b codeSamplesNamespace: code-samples-python-my-first-target - codeSamplesRevisionDigest: sha256:933161ae498c450f06968155e872818145f6c06c047fc9b93412be00bca2fd20 + codeSamplesRevisionDigest: sha256:10bb1467c970f1ece9dd5ab4f1bd8540471ef70d179ce483d68b4c207b1ae4d6 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/RELEASES.md b/RELEASES.md index 18e76a4..f43ed3c 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -746,4 +746,14 @@ Based on: ### Generated - [python v0.17.2] . ### Releases -- [PyPI v0.17.2] https://pypi.org/project/dub/0.17.2 - . \ No newline at end of file +- [PyPI v0.17.2] https://pypi.org/project/dub/0.17.2 - . + +## 2025-01-17 00:25:16 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.468.9 (2.493.21) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v0.17.3] . +### Releases +- [PyPI v0.17.3] https://pypi.org/project/dub/0.17.3 - . \ No newline at end of file diff --git a/codeSamples.yaml b/codeSamples.yaml index 33283dd..02b5e9a 100644 --- a/codeSamples.yaml +++ b/codeSamples.yaml @@ -519,7 +519,10 @@ actions: token="DUB_API_KEY", ) as dub: - res = dub.tags.list() + res = dub.tags.list(request={ + "page": 1, + "page_size": 50, + }) assert res is not None diff --git a/docs/models/operations/gettagsqueryparamsortby.md b/docs/models/operations/gettagsqueryparamsortby.md new file mode 100644 index 0000000..dad31ee --- /dev/null +++ b/docs/models/operations/gettagsqueryparamsortby.md @@ -0,0 +1,11 @@ +# GetTagsQueryParamSortBy + +The field to sort the tags by. + + +## Values + +| Name | Value | +| ------------ | ------------ | +| `NAME` | name | +| `CREATED_AT` | createdAt | \ No newline at end of file diff --git a/docs/models/operations/gettagsqueryparamsortorder.md b/docs/models/operations/gettagsqueryparamsortorder.md new file mode 100644 index 0000000..4cc0792 --- /dev/null +++ b/docs/models/operations/gettagsqueryparamsortorder.md @@ -0,0 +1,11 @@ +# GetTagsQueryParamSortOrder + +The order to sort the tags by. + + +## Values + +| Name | Value | +| ------ | ------ | +| `ASC` | asc | +| `DESC` | desc | \ No newline at end of file diff --git a/docs/models/operations/gettagsrequest.md b/docs/models/operations/gettagsrequest.md new file mode 100644 index 0000000..93906c3 --- /dev/null +++ b/docs/models/operations/gettagsrequest.md @@ -0,0 +1,13 @@ +# GetTagsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | +| `sort_by` | [Optional[operations.GetTagsQueryParamSortBy]](../../models/operations/gettagsqueryparamsortby.md) | :heavy_minus_sign: | The field to sort the tags by. | | +| `sort_order` | [Optional[operations.GetTagsQueryParamSortOrder]](../../models/operations/gettagsqueryparamsortorder.md) | :heavy_minus_sign: | The order to sort the tags by. | | +| `search` | *Optional[str]* | :heavy_minus_sign: | The search term to filter the tags by. | | +| `ids` | [Optional[operations.Ids]](../../models/operations/ids.md) | :heavy_minus_sign: | IDs of tags to filter by. | | +| `page` | *Optional[float]* | :heavy_minus_sign: | The page number for pagination. | 1 | +| `page_size` | *Optional[float]* | :heavy_minus_sign: | The number of items per page. | 50 | \ No newline at end of file diff --git a/docs/models/operations/ids.md b/docs/models/operations/ids.md new file mode 100644 index 0000000..e492f59 --- /dev/null +++ b/docs/models/operations/ids.md @@ -0,0 +1,19 @@ +# Ids + +IDs of tags to filter by. + + +## Supported Types + +### `str` + +```python +value: str = /* values here */ +``` + +### `List[str]` + +```python +value: List[str] = /* values here */ +``` + diff --git a/docs/models/operations/tracksaleresponsebody.md b/docs/models/operations/tracksaleresponsebody.md index dc877f6..81e2b62 100644 --- a/docs/models/operations/tracksaleresponsebody.md +++ b/docs/models/operations/tracksaleresponsebody.md @@ -5,8 +5,8 @@ A sale was tracked. ## Fields -| Field | Type | Required | Description | -| ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | -| `event_name` | *str* | :heavy_check_mark: | N/A | -| `customer` | [operations.TrackSaleCustomer](../../models/operations/tracksalecustomer.md) | :heavy_check_mark: | N/A | -| `sale` | [operations.Sale](../../models/operations/sale.md) | :heavy_check_mark: | N/A | \ No newline at end of file +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | +| `event_name` | *str* | :heavy_check_mark: | N/A | +| `customer` | [Nullable[operations.TrackSaleCustomer]](../../models/operations/tracksalecustomer.md) | :heavy_check_mark: | N/A | +| `sale` | [Nullable[operations.Sale]](../../models/operations/sale.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/sdks/tags/README.md b/docs/sdks/tags/README.md index 3561106..29de871 100644 --- a/docs/sdks/tags/README.md +++ b/docs/sdks/tags/README.md @@ -71,7 +71,10 @@ with Dub( token="DUB_API_KEY", ) as dub: - res = dub.tags.list() + res = dub.tags.list(request={ + "page": 1, + "page_size": 50, + }) assert res is not None @@ -82,9 +85,10 @@ with Dub( ### Parameters -| Parameter | Type | Required | Description | -| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | -| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | +| `request` | [operations.GetTagsRequest](../../models/operations/gettagsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | ### Response diff --git a/pyproject.toml b/pyproject.toml index ff60abc..59bf803 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "dub" -version = "0.17.2" +version = "0.17.3" description = "Python Client SDK Generated by Speakeasy" authors = [{ name = "Speakeasy" },] readme = "README-PYPI.md" diff --git a/src/dub/_version.py b/src/dub/_version.py index 4e83269..fe62144 100644 --- a/src/dub/_version.py +++ b/src/dub/_version.py @@ -3,10 +3,10 @@ import importlib.metadata __title__: str = "dub" -__version__: str = "0.17.2" +__version__: str = "0.17.3" __openapi_doc_version__: str = "0.0.1" -__gen_version__: str = "2.493.13" -__user_agent__: str = "speakeasy-sdk/python 0.17.2 2.493.13 0.0.1 dub" +__gen_version__: str = "2.493.21" +__user_agent__: str = "speakeasy-sdk/python 0.17.3 2.493.21 0.0.1 dub" try: if __package__ is not None: diff --git a/src/dub/analytics.py b/src/dub/analytics.py index c14245c..d6e1476 100644 --- a/src/dub/analytics.py +++ b/src/dub/analytics.py @@ -122,7 +122,12 @@ def retrieve( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -250,7 +255,12 @@ async def retrieve_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res diff --git a/src/dub/customers.py b/src/dub/customers.py index 8fec71c..ac969d0 100644 --- a/src/dub/customers.py +++ b/src/dub/customers.py @@ -121,7 +121,12 @@ def list( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -248,7 +253,12 @@ async def list_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -387,7 +397,12 @@ def create( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -526,7 +541,12 @@ async def create_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -653,7 +673,12 @@ def get( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -780,7 +805,12 @@ async def get_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -914,7 +944,12 @@ def update( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -1048,7 +1083,12 @@ async def update_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -1173,7 +1213,12 @@ def delete( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -1298,7 +1343,12 @@ async def delete_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res diff --git a/src/dub/domains.py b/src/dub/domains.py index 625c710..9aa942e 100644 --- a/src/dub/domains.py +++ b/src/dub/domains.py @@ -134,7 +134,12 @@ def create( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -273,7 +278,12 @@ async def create_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -427,7 +437,12 @@ def next_func() -> Optional[operations.ListDomainsResponse]: if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -581,7 +596,12 @@ def next_func() -> Optional[operations.ListDomainsResponse]: if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -723,7 +743,12 @@ def update( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -865,7 +890,12 @@ async def update_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -990,7 +1020,12 @@ def delete( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -1115,7 +1150,12 @@ async def delete_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res diff --git a/src/dub/embed_tokens.py b/src/dub/embed_tokens.py index 33cfe8c..0a88cbe 100644 --- a/src/dub/embed_tokens.py +++ b/src/dub/embed_tokens.py @@ -133,7 +133,12 @@ def create( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -272,7 +277,12 @@ async def create_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res diff --git a/src/dub/events.py b/src/dub/events.py index 8a4cf74..a4d688a 100644 --- a/src/dub/events.py +++ b/src/dub/events.py @@ -121,7 +121,12 @@ def list( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -248,7 +253,12 @@ async def list_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res diff --git a/src/dub/links.py b/src/dub/links.py index d8c2dcc..534d72c 100644 --- a/src/dub/links.py +++ b/src/dub/links.py @@ -128,7 +128,12 @@ def create( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -261,7 +266,12 @@ async def create_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -423,7 +433,12 @@ def next_func() -> Optional[operations.GetLinksResponse]: if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -585,7 +600,12 @@ def next_func() -> Optional[operations.GetLinksResponse]: if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -710,7 +730,12 @@ def count( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -835,7 +860,12 @@ async def count_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -960,7 +990,12 @@ def get( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -1085,7 +1120,12 @@ async def get_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -1225,7 +1265,12 @@ def update( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -1365,7 +1410,12 @@ async def update_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -1490,7 +1540,12 @@ def delete( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -1615,7 +1670,12 @@ async def delete_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -1745,7 +1805,12 @@ def create_many( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -1875,7 +1940,12 @@ async def create_many_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -2014,7 +2084,12 @@ def update_many( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -2153,7 +2228,12 @@ async def update_many_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -2281,7 +2361,12 @@ def delete_many( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -2409,7 +2494,12 @@ async def delete_many_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -2542,7 +2632,12 @@ def upsert( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -2675,7 +2770,12 @@ async def upsert_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res diff --git a/src/dub/metatags.py b/src/dub/metatags.py index 989aae5..a2c3b8e 100644 --- a/src/dub/metatags.py +++ b/src/dub/metatags.py @@ -81,7 +81,12 @@ def get( return utils.unmarshal_json( http_res.text, Optional[operations.GetMetatagsResponseBody] ) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -168,7 +173,12 @@ async def get_async( return utils.unmarshal_json( http_res.text, Optional[operations.GetMetatagsResponseBody] ) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res diff --git a/src/dub/models/operations/__init__.py b/src/dub/models/operations/__init__.py index c99c5b9..988523a 100644 --- a/src/dub/models/operations/__init__.py +++ b/src/dub/models/operations/__init__.py @@ -142,6 +142,14 @@ GetMetatagsResponseBodyTypedDict, ) from .getqrcode import GetQRCodeRequest, GetQRCodeRequestTypedDict, Level +from .gettags import ( + GetTagsQueryParamSortBy, + GetTagsQueryParamSortOrder, + GetTagsRequest, + GetTagsRequestTypedDict, + Ids, + IdsTypedDict, +) from .getworkspace import GetWorkspaceRequest, GetWorkspaceRequestTypedDict from .listdomains import ( ListDomainsRequest, @@ -349,10 +357,16 @@ "GetMetatagsResponseBodyTypedDict", "GetQRCodeRequest", "GetQRCodeRequestTypedDict", + "GetTagsQueryParamSortBy", + "GetTagsQueryParamSortOrder", + "GetTagsRequest", + "GetTagsRequestTypedDict", "GetWorkspaceRequest", "GetWorkspaceRequestTypedDict", "GroupBy", "GroupByTypedDict", + "Ids", + "IdsTypedDict", "Interval", "Level", "Link", diff --git a/src/dub/models/operations/gettags.py b/src/dub/models/operations/gettags.py new file mode 100644 index 0000000..c287c0b --- /dev/null +++ b/src/dub/models/operations/gettags.py @@ -0,0 +1,87 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from dub.types import BaseModel +from dub.utils import FieldMetadata, QueryParamMetadata +from enum import Enum +import pydantic +from typing import List, Optional, Union +from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict + + +class GetTagsQueryParamSortBy(str, Enum): + r"""The field to sort the tags by.""" + + NAME = "name" + CREATED_AT = "createdAt" + + +class GetTagsQueryParamSortOrder(str, Enum): + r"""The order to sort the tags by.""" + + ASC = "asc" + DESC = "desc" + + +IdsTypedDict = TypeAliasType("IdsTypedDict", Union[str, List[str]]) +r"""IDs of tags to filter by.""" + + +Ids = TypeAliasType("Ids", Union[str, List[str]]) +r"""IDs of tags to filter by.""" + + +class GetTagsRequestTypedDict(TypedDict): + sort_by: NotRequired[GetTagsQueryParamSortBy] + r"""The field to sort the tags by.""" + sort_order: NotRequired[GetTagsQueryParamSortOrder] + r"""The order to sort the tags by.""" + search: NotRequired[str] + r"""The search term to filter the tags by.""" + ids: NotRequired[IdsTypedDict] + r"""IDs of tags to filter by.""" + page: NotRequired[float] + r"""The page number for pagination.""" + page_size: NotRequired[float] + r"""The number of items per page.""" + + +class GetTagsRequest(BaseModel): + sort_by: Annotated[ + Optional[GetTagsQueryParamSortBy], + pydantic.Field(alias="sortBy"), + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), + ] = GetTagsQueryParamSortBy.NAME + r"""The field to sort the tags by.""" + + sort_order: Annotated[ + Optional[GetTagsQueryParamSortOrder], + pydantic.Field(alias="sortOrder"), + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), + ] = GetTagsQueryParamSortOrder.ASC + r"""The order to sort the tags by.""" + + search: Annotated[ + Optional[str], + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), + ] = None + r"""The search term to filter the tags by.""" + + ids: Annotated[ + Optional[Ids], + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), + ] = None + r"""IDs of tags to filter by.""" + + page: Annotated[ + Optional[float], + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), + ] = 1 + r"""The page number for pagination.""" + + page_size: Annotated[ + Optional[float], + pydantic.Field(alias="pageSize"), + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), + ] = 100 + r"""The number of items per page.""" diff --git a/src/dub/models/operations/tracksale.py b/src/dub/models/operations/tracksale.py index c3669d6..69db5db 100644 --- a/src/dub/models/operations/tracksale.py +++ b/src/dub/models/operations/tracksale.py @@ -213,8 +213,8 @@ class TrackSaleResponseBodyTypedDict(TypedDict): r"""A sale was tracked.""" event_name: str - customer: TrackSaleCustomerTypedDict - sale: SaleTypedDict + customer: Nullable[TrackSaleCustomerTypedDict] + sale: Nullable[SaleTypedDict] class TrackSaleResponseBody(BaseModel): @@ -222,6 +222,36 @@ class TrackSaleResponseBody(BaseModel): event_name: Annotated[str, pydantic.Field(alias="eventName")] - customer: TrackSaleCustomer + customer: Nullable[TrackSaleCustomer] - sale: Sale + sale: Nullable[Sale] + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = [] + nullable_fields = ["customer", "sale"] + null_default_fields = [] + + serialized = handler(self) + + m = {} + + for n, f in self.model_fields.items(): + k = f.alias or n + val = serialized.get(k) + serialized.pop(k, None) + + optional_nullable = k in optional_fields and k in nullable_fields + is_set = ( + self.__pydantic_fields_set__.intersection({n}) + or k in null_default_fields + ) # pylint: disable=no-member + + if val is not None and val != UNSET_SENTINEL: + m[k] = val + elif val != UNSET_SENTINEL and ( + not k in optional_fields or (optional_nullable and is_set) + ): + m[k] = val + + return m diff --git a/src/dub/qr_codes.py b/src/dub/qr_codes.py index 151df8c..8e8cde4 100644 --- a/src/dub/qr_codes.py +++ b/src/dub/qr_codes.py @@ -119,7 +119,12 @@ def get( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -244,7 +249,12 @@ async def get_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res diff --git a/src/dub/tags.py b/src/dub/tags.py index c8ad1a2..7e5ab12 100644 --- a/src/dub/tags.py +++ b/src/dub/tags.py @@ -127,7 +127,12 @@ def create( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -260,7 +265,12 @@ async def create_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -278,6 +288,7 @@ async def create_async( def list( self, *, + request: Union[operations.GetTagsRequest, operations.GetTagsRequestTypedDict], retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, timeout_ms: Optional[int] = None, @@ -287,6 +298,7 @@ def list( Retrieve a list of tags for the authenticated workspace. + :param request: The request object to send. :param retries: Override the default retry configuration for this method :param server_url: Override the default server URL for this method :param timeout_ms: Override the default request timeout configuration for this method in milliseconds @@ -299,12 +311,17 @@ def list( if server_url is not None: base_url = server_url + + if not isinstance(request, BaseModel): + request = utils.unmarshal(request, operations.GetTagsRequest) + request = cast(operations.GetTagsRequest, request) + req = self._build_request( method="GET", path="/tags", base_url=base_url, url_variables=url_variables, - request=None, + request=request, request_body_required=False, request_has_path_params=False, request_has_query_params=True, @@ -378,7 +395,12 @@ def list( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -396,6 +418,7 @@ def list( async def list_async( self, *, + request: Union[operations.GetTagsRequest, operations.GetTagsRequestTypedDict], retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, timeout_ms: Optional[int] = None, @@ -405,6 +428,7 @@ async def list_async( Retrieve a list of tags for the authenticated workspace. + :param request: The request object to send. :param retries: Override the default retry configuration for this method :param server_url: Override the default server URL for this method :param timeout_ms: Override the default request timeout configuration for this method in milliseconds @@ -417,12 +441,17 @@ async def list_async( if server_url is not None: base_url = server_url + + if not isinstance(request, BaseModel): + request = utils.unmarshal(request, operations.GetTagsRequest) + request = cast(operations.GetTagsRequest, request) + req = self._build_request_async( method="GET", path="/tags", base_url=base_url, url_variables=url_variables, - request=None, + request=request, request_body_required=False, request_has_path_params=False, request_has_query_params=True, @@ -496,7 +525,12 @@ async def list_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -636,7 +670,12 @@ def update( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -776,7 +815,12 @@ async def update_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -901,7 +945,12 @@ def delete( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -1026,7 +1075,12 @@ async def delete_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res diff --git a/src/dub/track.py b/src/dub/track.py index 208b1d0..f339100 100644 --- a/src/dub/track.py +++ b/src/dub/track.py @@ -129,7 +129,12 @@ def lead( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -264,7 +269,12 @@ async def lead_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -399,7 +409,12 @@ def sale( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -534,7 +549,12 @@ async def sale_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res diff --git a/src/dub/workspaces.py b/src/dub/workspaces.py index 5d686bc..c0b32cb 100644 --- a/src/dub/workspaces.py +++ b/src/dub/workspaces.py @@ -121,7 +121,12 @@ def get( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -248,7 +253,12 @@ async def get_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -390,7 +400,12 @@ def update( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res @@ -532,7 +547,12 @@ async def update_async( if utils.match_response(http_res, "500", "application/json"): data = utils.unmarshal_json(http_res.text, errors.InternalServerErrorData) raise errors.InternalServerError(data=data) - if utils.match_response(http_res, ["4XX", "5XX"], "*"): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + if utils.match_response(http_res, "5XX", "*"): http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( "API error occurred", http_res.status_code, http_res_text, http_res