dub 0.26.12__tar.gz → 0.27.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dub-0.26.12 → dub-0.27.1}/PKG-INFO +50 -56
- {dub-0.26.12 → dub-0.27.1}/README-PYPI.md +50 -56
- {dub-0.26.12 → dub-0.27.1}/pyproject.toml +1 -1
- {dub-0.26.12 → dub-0.27.1}/src/dub/_version.py +3 -3
- {dub-0.26.12 → dub-0.27.1}/src/dub/analytics.py +53 -78
- {dub-0.26.12 → dub-0.27.1}/src/dub/basesdk.py +4 -4
- {dub-0.26.12 → dub-0.27.1}/src/dub/commissions.py +105 -156
- {dub-0.26.12 → dub-0.27.1}/src/dub/customers.py +261 -390
- {dub-0.26.12 → dub-0.27.1}/src/dub/domains.py +309 -472
- {dub-0.26.12 → dub-0.27.1}/src/dub/embed_tokens.py +53 -80
- {dub-0.26.12 → dub-0.27.1}/src/dub/events.py +53 -78
- {dub-0.26.12 → dub-0.27.1}/src/dub/folders.py +205 -316
- {dub-0.26.12 → dub-0.27.1}/src/dub/links.py +511 -770
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/errors/__init__.py +9 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/errors/badrequest.py +12 -6
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/errors/conflict.py +12 -6
- dub-0.27.1/src/dub/models/errors/duberror.py +26 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/errors/forbidden.py +12 -6
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/errors/internalservererror.py +12 -6
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/errors/inviteexpired.py +12 -6
- dub-0.27.1/src/dub/models/errors/no_response_error.py +13 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/errors/notfound.py +12 -6
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/errors/ratelimitexceeded.py +12 -6
- dub-0.27.1/src/dub/models/errors/responsevalidationerror.py +25 -0
- dub-0.27.1/src/dub/models/errors/sdkerror.py +38 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/errors/unauthorized.py +12 -6
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/errors/unprocessableentity.py +12 -6
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/createcustomer.py +3 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/getcustomer.py +3 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/getcustomers.py +3 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/tracklead.py +2 -2
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/tracksale.py +2 -2
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/updatecustomer.py +3 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/partners.py +255 -384
- {dub-0.26.12 → dub-0.27.1}/src/dub/qr_codes.py +49 -74
- {dub-0.26.12 → dub-0.27.1}/src/dub/tags.py +205 -308
- {dub-0.26.12 → dub-0.27.1}/src/dub/track.py +105 -156
- {dub-0.26.12 → dub-0.27.1}/src/dub/utils/serializers.py +3 -2
- dub-0.27.1/src/dub/utils/unmarshal_json_response.py +24 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/workspaces.py +105 -156
- dub-0.26.12/src/dub/models/errors/sdkerror.py +0 -22
- {dub-0.26.12 → dub-0.27.1}/LICENSE +0 -0
- {dub-0.26.12 → dub-0.27.1}/py.typed +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/__init__.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/_hooks/__init__.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/_hooks/registration.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/_hooks/sdkhooks.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/_hooks/types.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/httpclient.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/__init__.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/__init__.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/analyticsbrowsers.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/analyticscities.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/analyticscontinents.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/analyticscount.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/analyticscountries.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/analyticsdevices.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/analyticsos.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/analyticsreferers.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/analyticsrefererurls.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/analyticsregions.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/analyticstimeseries.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/analyticstoplinks.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/analyticstopurls.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/analyticstriggers.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/clickevent.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/continentcode.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/countrycode.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/domainschema.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/folderschema.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/leadcreatedevent.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/leadevent.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/linkclickedevent.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/linkerrorschema.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/linkgeotargeting.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/linkschema.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/linkwebhookevent.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/partneranalyticscount.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/partneranalyticstimeseries.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/partneranalyticstoplinks.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/partnerenrolledevent.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/salecreatedevent.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/saleevent.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/security.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/tagschema.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/webhookevent.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/components/workspaceschema.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/__init__.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/bulkcreatelinks.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/bulkdeletelinks.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/bulkupdatelinks.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/checkdomainstatus.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/createdomain.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/createfolder.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/createlink.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/createpartner.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/createpartnerlink.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/createreferralsembedtoken.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/createtag.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/deletecustomer.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/deletedomain.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/deletefolder.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/deletelink.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/deletetag.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/getlinkinfo.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/getlinks.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/getlinkscount.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/getqrcode.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/gettags.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/getworkspace.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/listcommissions.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/listdomains.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/listevents.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/listfolders.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/registerdomain.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/retrieveanalytics.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/retrievelinks.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/retrievepartneranalytics.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/updatecommission.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/updatedomain.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/updatefolder.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/updatelink.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/updatetag.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/updateworkspace.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/upsertlink.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/models/operations/upsertpartnerlink.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/py.typed +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/sdk.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/sdkconfiguration.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/types/__init__.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/types/basemodel.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/utils/__init__.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/utils/annotations.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/utils/datetimes.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/utils/enums.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/utils/eventstreaming.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/utils/forms.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/utils/headers.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/utils/logger.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/utils/metadata.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/utils/queryparams.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/utils/requestbodies.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/utils/retries.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/utils/security.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/utils/url.py +0 -0
- {dub-0.26.12 → dub-0.27.1}/src/dub/utils/values.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: dub
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.27.1
|
|
4
4
|
Summary: Python Client SDK Generated by Speakeasy
|
|
5
5
|
Author: Speakeasy
|
|
6
6
|
Requires-Python: >=3.9.2
|
|
@@ -363,34 +363,18 @@ asyncio.run(main())
|
|
|
363
363
|
<!-- Start Error Handling [errors] -->
|
|
364
364
|
## Error Handling
|
|
365
365
|
|
|
366
|
-
|
|
366
|
+
[`DubError`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/duberror.py) is the base class for all HTTP error responses. It has the following properties:
|
|
367
367
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
|
371
|
-
|
|
372
|
-
|
|
|
373
|
-
|
|
|
374
|
-
|
|
|
375
|
-
|
|
|
376
|
-
|
|
377
|
-
When custom error responses are specified for an operation, the SDK may also raise their associated exceptions. You can refer to respective *Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the `create_async` method may raise the following exceptions:
|
|
378
|
-
|
|
379
|
-
| Error Type | Status Code | Content Type |
|
|
380
|
-
| -------------------------- | ----------- | ---------------- |
|
|
381
|
-
| errors.BadRequest | 400 | application/json |
|
|
382
|
-
| errors.Unauthorized | 401 | application/json |
|
|
383
|
-
| errors.Forbidden | 403 | application/json |
|
|
384
|
-
| errors.NotFound | 404 | application/json |
|
|
385
|
-
| errors.Conflict | 409 | application/json |
|
|
386
|
-
| errors.InviteExpired | 410 | application/json |
|
|
387
|
-
| errors.UnprocessableEntity | 422 | application/json |
|
|
388
|
-
| errors.RateLimitExceeded | 429 | application/json |
|
|
389
|
-
| errors.InternalServerError | 500 | application/json |
|
|
390
|
-
| errors.SDKError | 4XX, 5XX | \*/\* |
|
|
368
|
+
| Property | Type | Description |
|
|
369
|
+
| ------------------ | ---------------- | --------------------------------------------------------------------------------------- |
|
|
370
|
+
| `err.message` | `str` | Error message |
|
|
371
|
+
| `err.status_code` | `int` | HTTP response status code eg `404` |
|
|
372
|
+
| `err.headers` | `httpx.Headers` | HTTP response headers |
|
|
373
|
+
| `err.body` | `str` | HTTP body. Can be empty string if no body is returned. |
|
|
374
|
+
| `err.raw_response` | `httpx.Response` | Raw HTTP response |
|
|
375
|
+
| `err.data` | | Optional. Some errors may contain structured data. [See Error Classes](https://github.com/dubinc/dub-python/blob/master/#error-classes). |
|
|
391
376
|
|
|
392
377
|
### Example
|
|
393
|
-
|
|
394
378
|
```python
|
|
395
379
|
from dub import Dub
|
|
396
380
|
from dub.models import errors
|
|
@@ -425,37 +409,47 @@ with Dub(
|
|
|
425
409
|
# Handle response
|
|
426
410
|
print(res)
|
|
427
411
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
except errors.Conflict as e:
|
|
441
|
-
# handle e.data: errors.ConflictData
|
|
442
|
-
raise(e)
|
|
443
|
-
except errors.InviteExpired as e:
|
|
444
|
-
# handle e.data: errors.InviteExpiredData
|
|
445
|
-
raise(e)
|
|
446
|
-
except errors.UnprocessableEntity as e:
|
|
447
|
-
# handle e.data: errors.UnprocessableEntityData
|
|
448
|
-
raise(e)
|
|
449
|
-
except errors.RateLimitExceeded as e:
|
|
450
|
-
# handle e.data: errors.RateLimitExceededData
|
|
451
|
-
raise(e)
|
|
452
|
-
except errors.InternalServerError as e:
|
|
453
|
-
# handle e.data: errors.InternalServerErrorData
|
|
454
|
-
raise(e)
|
|
455
|
-
except errors.SDKError as e:
|
|
456
|
-
# handle exception
|
|
457
|
-
raise(e)
|
|
412
|
+
|
|
413
|
+
except errors.DubError as e:
|
|
414
|
+
# The base class for HTTP error responses
|
|
415
|
+
print(e.message)
|
|
416
|
+
print(e.status_code)
|
|
417
|
+
print(e.body)
|
|
418
|
+
print(e.headers)
|
|
419
|
+
print(e.raw_response)
|
|
420
|
+
|
|
421
|
+
# Depending on the method different errors may be thrown
|
|
422
|
+
if isinstance(e, errors.BadRequest):
|
|
423
|
+
print(e.data.error) # errors.Error
|
|
458
424
|
```
|
|
425
|
+
|
|
426
|
+
### Error Classes
|
|
427
|
+
**Primary errors:**
|
|
428
|
+
* [`DubError`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/duberror.py): The base class for HTTP error responses.
|
|
429
|
+
* [`BadRequest`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/badrequest.py): The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). Status code `400`.
|
|
430
|
+
* [`Unauthorized`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/unauthorized.py): Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. Status code `401`.
|
|
431
|
+
* [`Forbidden`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/forbidden.py): The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. Status code `403`.
|
|
432
|
+
* [`NotFound`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/notfound.py): The server cannot find the requested resource. Status code `404`.
|
|
433
|
+
* [`Conflict`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/conflict.py): This response is sent when a request conflicts with the current state of the server. Status code `409`.
|
|
434
|
+
* [`InviteExpired`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/inviteexpired.py): This response is sent when the requested content has been permanently deleted from server, with no forwarding address. Status code `410`.
|
|
435
|
+
* [`UnprocessableEntity`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/unprocessableentity.py): The request was well-formed but was unable to be followed due to semantic errors. Status code `422`.
|
|
436
|
+
* [`RateLimitExceeded`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/ratelimitexceeded.py): The user has sent too many requests in a given amount of time ("rate limiting"). Status code `429`.
|
|
437
|
+
* [`InternalServerError`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/internalservererror.py): The server has encountered a situation it does not know how to handle. Status code `500`.
|
|
438
|
+
|
|
439
|
+
<details><summary>Less common errors (5)</summary>
|
|
440
|
+
|
|
441
|
+
<br />
|
|
442
|
+
|
|
443
|
+
**Network errors:**
|
|
444
|
+
* [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors.
|
|
445
|
+
* [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server.
|
|
446
|
+
* [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out.
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
**Inherit from [`DubError`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/duberror.py)**:
|
|
450
|
+
* [`ResponseValidationError`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute.
|
|
451
|
+
|
|
452
|
+
</details>
|
|
459
453
|
<!-- End Error Handling [errors] -->
|
|
460
454
|
|
|
461
455
|
<!-- Start Server Selection [server] -->
|
|
@@ -345,34 +345,18 @@ asyncio.run(main())
|
|
|
345
345
|
<!-- Start Error Handling [errors] -->
|
|
346
346
|
## Error Handling
|
|
347
347
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
By default, an API error will raise a errors.SDKError exception, which has the following properties:
|
|
351
|
-
|
|
352
|
-
| Property | Type | Description |
|
|
353
|
-
|-----------------|------------------|-----------------------|
|
|
354
|
-
| `.status_code` | *int* | The HTTP status code |
|
|
355
|
-
| `.message` | *str* | The error message |
|
|
356
|
-
| `.raw_response` | *httpx.Response* | The raw HTTP response |
|
|
357
|
-
| `.body` | *str* | The response content |
|
|
358
|
-
|
|
359
|
-
When custom error responses are specified for an operation, the SDK may also raise their associated exceptions. You can refer to respective *Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the `create_async` method may raise the following exceptions:
|
|
360
|
-
|
|
361
|
-
| Error Type | Status Code | Content Type |
|
|
362
|
-
| -------------------------- | ----------- | ---------------- |
|
|
363
|
-
| errors.BadRequest | 400 | application/json |
|
|
364
|
-
| errors.Unauthorized | 401 | application/json |
|
|
365
|
-
| errors.Forbidden | 403 | application/json |
|
|
366
|
-
| errors.NotFound | 404 | application/json |
|
|
367
|
-
| errors.Conflict | 409 | application/json |
|
|
368
|
-
| errors.InviteExpired | 410 | application/json |
|
|
369
|
-
| errors.UnprocessableEntity | 422 | application/json |
|
|
370
|
-
| errors.RateLimitExceeded | 429 | application/json |
|
|
371
|
-
| errors.InternalServerError | 500 | application/json |
|
|
372
|
-
| errors.SDKError | 4XX, 5XX | \*/\* |
|
|
348
|
+
[`DubError`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/duberror.py) is the base class for all HTTP error responses. It has the following properties:
|
|
373
349
|
|
|
374
|
-
|
|
350
|
+
| Property | Type | Description |
|
|
351
|
+
| ------------------ | ---------------- | --------------------------------------------------------------------------------------- |
|
|
352
|
+
| `err.message` | `str` | Error message |
|
|
353
|
+
| `err.status_code` | `int` | HTTP response status code eg `404` |
|
|
354
|
+
| `err.headers` | `httpx.Headers` | HTTP response headers |
|
|
355
|
+
| `err.body` | `str` | HTTP body. Can be empty string if no body is returned. |
|
|
356
|
+
| `err.raw_response` | `httpx.Response` | Raw HTTP response |
|
|
357
|
+
| `err.data` | | Optional. Some errors may contain structured data. [See Error Classes](https://github.com/dubinc/dub-python/blob/master/#error-classes). |
|
|
375
358
|
|
|
359
|
+
### Example
|
|
376
360
|
```python
|
|
377
361
|
from dub import Dub
|
|
378
362
|
from dub.models import errors
|
|
@@ -407,37 +391,47 @@ with Dub(
|
|
|
407
391
|
# Handle response
|
|
408
392
|
print(res)
|
|
409
393
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
except errors.Conflict as e:
|
|
423
|
-
# handle e.data: errors.ConflictData
|
|
424
|
-
raise(e)
|
|
425
|
-
except errors.InviteExpired as e:
|
|
426
|
-
# handle e.data: errors.InviteExpiredData
|
|
427
|
-
raise(e)
|
|
428
|
-
except errors.UnprocessableEntity as e:
|
|
429
|
-
# handle e.data: errors.UnprocessableEntityData
|
|
430
|
-
raise(e)
|
|
431
|
-
except errors.RateLimitExceeded as e:
|
|
432
|
-
# handle e.data: errors.RateLimitExceededData
|
|
433
|
-
raise(e)
|
|
434
|
-
except errors.InternalServerError as e:
|
|
435
|
-
# handle e.data: errors.InternalServerErrorData
|
|
436
|
-
raise(e)
|
|
437
|
-
except errors.SDKError as e:
|
|
438
|
-
# handle exception
|
|
439
|
-
raise(e)
|
|
394
|
+
|
|
395
|
+
except errors.DubError as e:
|
|
396
|
+
# The base class for HTTP error responses
|
|
397
|
+
print(e.message)
|
|
398
|
+
print(e.status_code)
|
|
399
|
+
print(e.body)
|
|
400
|
+
print(e.headers)
|
|
401
|
+
print(e.raw_response)
|
|
402
|
+
|
|
403
|
+
# Depending on the method different errors may be thrown
|
|
404
|
+
if isinstance(e, errors.BadRequest):
|
|
405
|
+
print(e.data.error) # errors.Error
|
|
440
406
|
```
|
|
407
|
+
|
|
408
|
+
### Error Classes
|
|
409
|
+
**Primary errors:**
|
|
410
|
+
* [`DubError`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/duberror.py): The base class for HTTP error responses.
|
|
411
|
+
* [`BadRequest`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/badrequest.py): The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). Status code `400`.
|
|
412
|
+
* [`Unauthorized`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/unauthorized.py): Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. Status code `401`.
|
|
413
|
+
* [`Forbidden`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/forbidden.py): The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. Status code `403`.
|
|
414
|
+
* [`NotFound`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/notfound.py): The server cannot find the requested resource. Status code `404`.
|
|
415
|
+
* [`Conflict`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/conflict.py): This response is sent when a request conflicts with the current state of the server. Status code `409`.
|
|
416
|
+
* [`InviteExpired`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/inviteexpired.py): This response is sent when the requested content has been permanently deleted from server, with no forwarding address. Status code `410`.
|
|
417
|
+
* [`UnprocessableEntity`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/unprocessableentity.py): The request was well-formed but was unable to be followed due to semantic errors. Status code `422`.
|
|
418
|
+
* [`RateLimitExceeded`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/ratelimitexceeded.py): The user has sent too many requests in a given amount of time ("rate limiting"). Status code `429`.
|
|
419
|
+
* [`InternalServerError`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/internalservererror.py): The server has encountered a situation it does not know how to handle. Status code `500`.
|
|
420
|
+
|
|
421
|
+
<details><summary>Less common errors (5)</summary>
|
|
422
|
+
|
|
423
|
+
<br />
|
|
424
|
+
|
|
425
|
+
**Network errors:**
|
|
426
|
+
* [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors.
|
|
427
|
+
* [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server.
|
|
428
|
+
* [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out.
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
**Inherit from [`DubError`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/duberror.py)**:
|
|
432
|
+
* [`ResponseValidationError`](https://github.com/dubinc/dub-python/blob/master/./src/dub/models/errors/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute.
|
|
433
|
+
|
|
434
|
+
</details>
|
|
441
435
|
<!-- End Error Handling [errors] -->
|
|
442
436
|
|
|
443
437
|
<!-- Start Server Selection [server] -->
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import importlib.metadata
|
|
4
4
|
|
|
5
5
|
__title__: str = "dub"
|
|
6
|
-
__version__: str = "0.
|
|
6
|
+
__version__: str = "0.27.1"
|
|
7
7
|
__openapi_doc_version__: str = "0.0.1"
|
|
8
|
-
__gen_version__: str = "2.
|
|
9
|
-
__user_agent__: str = "speakeasy-sdk/python 0.
|
|
8
|
+
__gen_version__: str = "2.656.5"
|
|
9
|
+
__user_agent__: str = "speakeasy-sdk/python 0.27.1 2.656.5 0.0.1 dub"
|
|
10
10
|
|
|
11
11
|
try:
|
|
12
12
|
if __package__ is not None:
|
|
@@ -5,6 +5,7 @@ from dub import utils
|
|
|
5
5
|
from dub._hooks import HookContext
|
|
6
6
|
from dub.models import errors, operations
|
|
7
7
|
from dub.types import BaseModel, OptionalNullable, UNSET
|
|
8
|
+
from dub.utils.unmarshal_json_response import unmarshal_json_response
|
|
8
9
|
from typing import Any, Mapping, Optional, Union, cast
|
|
9
10
|
|
|
10
11
|
|
|
@@ -96,63 +97,50 @@ class Analytics(BaseSDK):
|
|
|
96
97
|
|
|
97
98
|
response_data: Any = None
|
|
98
99
|
if utils.match_response(http_res, "200", "application/json"):
|
|
99
|
-
return
|
|
100
|
-
|
|
100
|
+
return unmarshal_json_response(
|
|
101
|
+
Optional[operations.RetrieveAnalyticsResponseBody], http_res
|
|
101
102
|
)
|
|
102
103
|
if utils.match_response(http_res, "400", "application/json"):
|
|
103
|
-
response_data =
|
|
104
|
-
raise errors.BadRequest(
|
|
104
|
+
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
105
|
+
raise errors.BadRequest(response_data, http_res)
|
|
105
106
|
if utils.match_response(http_res, "401", "application/json"):
|
|
106
|
-
response_data =
|
|
107
|
-
raise errors.Unauthorized(
|
|
107
|
+
response_data = unmarshal_json_response(errors.UnauthorizedData, http_res)
|
|
108
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
108
109
|
if utils.match_response(http_res, "403", "application/json"):
|
|
109
|
-
response_data =
|
|
110
|
-
raise errors.Forbidden(
|
|
110
|
+
response_data = unmarshal_json_response(errors.ForbiddenData, http_res)
|
|
111
|
+
raise errors.Forbidden(response_data, http_res)
|
|
111
112
|
if utils.match_response(http_res, "404", "application/json"):
|
|
112
|
-
response_data =
|
|
113
|
-
raise errors.NotFound(
|
|
113
|
+
response_data = unmarshal_json_response(errors.NotFoundData, http_res)
|
|
114
|
+
raise errors.NotFound(response_data, http_res)
|
|
114
115
|
if utils.match_response(http_res, "409", "application/json"):
|
|
115
|
-
response_data =
|
|
116
|
-
raise errors.Conflict(
|
|
116
|
+
response_data = unmarshal_json_response(errors.ConflictData, http_res)
|
|
117
|
+
raise errors.Conflict(response_data, http_res)
|
|
117
118
|
if utils.match_response(http_res, "410", "application/json"):
|
|
118
|
-
response_data =
|
|
119
|
-
|
|
120
|
-
)
|
|
121
|
-
raise errors.InviteExpired(data=response_data)
|
|
119
|
+
response_data = unmarshal_json_response(errors.InviteExpiredData, http_res)
|
|
120
|
+
raise errors.InviteExpired(response_data, http_res)
|
|
122
121
|
if utils.match_response(http_res, "422", "application/json"):
|
|
123
|
-
response_data =
|
|
124
|
-
|
|
122
|
+
response_data = unmarshal_json_response(
|
|
123
|
+
errors.UnprocessableEntityData, http_res
|
|
125
124
|
)
|
|
126
|
-
raise errors.UnprocessableEntity(
|
|
125
|
+
raise errors.UnprocessableEntity(response_data, http_res)
|
|
127
126
|
if utils.match_response(http_res, "429", "application/json"):
|
|
128
|
-
response_data =
|
|
129
|
-
|
|
127
|
+
response_data = unmarshal_json_response(
|
|
128
|
+
errors.RateLimitExceededData, http_res
|
|
130
129
|
)
|
|
131
|
-
raise errors.RateLimitExceeded(
|
|
130
|
+
raise errors.RateLimitExceeded(response_data, http_res)
|
|
132
131
|
if utils.match_response(http_res, "500", "application/json"):
|
|
133
|
-
response_data =
|
|
134
|
-
|
|
132
|
+
response_data = unmarshal_json_response(
|
|
133
|
+
errors.InternalServerErrorData, http_res
|
|
135
134
|
)
|
|
136
|
-
raise errors.InternalServerError(
|
|
135
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
137
136
|
if utils.match_response(http_res, "4XX", "*"):
|
|
138
137
|
http_res_text = utils.stream_to_text(http_res)
|
|
139
|
-
raise errors.SDKError(
|
|
140
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
141
|
-
)
|
|
138
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
142
139
|
if utils.match_response(http_res, "5XX", "*"):
|
|
143
140
|
http_res_text = utils.stream_to_text(http_res)
|
|
144
|
-
raise errors.SDKError(
|
|
145
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
146
|
-
)
|
|
141
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
147
142
|
|
|
148
|
-
|
|
149
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
150
|
-
raise errors.SDKError(
|
|
151
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
152
|
-
http_res.status_code,
|
|
153
|
-
http_res_text,
|
|
154
|
-
http_res,
|
|
155
|
-
)
|
|
143
|
+
raise errors.SDKError("Unexpected response received", http_res)
|
|
156
144
|
|
|
157
145
|
async def retrieve_async(
|
|
158
146
|
self,
|
|
@@ -241,60 +229,47 @@ class Analytics(BaseSDK):
|
|
|
241
229
|
|
|
242
230
|
response_data: Any = None
|
|
243
231
|
if utils.match_response(http_res, "200", "application/json"):
|
|
244
|
-
return
|
|
245
|
-
|
|
232
|
+
return unmarshal_json_response(
|
|
233
|
+
Optional[operations.RetrieveAnalyticsResponseBody], http_res
|
|
246
234
|
)
|
|
247
235
|
if utils.match_response(http_res, "400", "application/json"):
|
|
248
|
-
response_data =
|
|
249
|
-
raise errors.BadRequest(
|
|
236
|
+
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
237
|
+
raise errors.BadRequest(response_data, http_res)
|
|
250
238
|
if utils.match_response(http_res, "401", "application/json"):
|
|
251
|
-
response_data =
|
|
252
|
-
raise errors.Unauthorized(
|
|
239
|
+
response_data = unmarshal_json_response(errors.UnauthorizedData, http_res)
|
|
240
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
253
241
|
if utils.match_response(http_res, "403", "application/json"):
|
|
254
|
-
response_data =
|
|
255
|
-
raise errors.Forbidden(
|
|
242
|
+
response_data = unmarshal_json_response(errors.ForbiddenData, http_res)
|
|
243
|
+
raise errors.Forbidden(response_data, http_res)
|
|
256
244
|
if utils.match_response(http_res, "404", "application/json"):
|
|
257
|
-
response_data =
|
|
258
|
-
raise errors.NotFound(
|
|
245
|
+
response_data = unmarshal_json_response(errors.NotFoundData, http_res)
|
|
246
|
+
raise errors.NotFound(response_data, http_res)
|
|
259
247
|
if utils.match_response(http_res, "409", "application/json"):
|
|
260
|
-
response_data =
|
|
261
|
-
raise errors.Conflict(
|
|
248
|
+
response_data = unmarshal_json_response(errors.ConflictData, http_res)
|
|
249
|
+
raise errors.Conflict(response_data, http_res)
|
|
262
250
|
if utils.match_response(http_res, "410", "application/json"):
|
|
263
|
-
response_data =
|
|
264
|
-
|
|
265
|
-
)
|
|
266
|
-
raise errors.InviteExpired(data=response_data)
|
|
251
|
+
response_data = unmarshal_json_response(errors.InviteExpiredData, http_res)
|
|
252
|
+
raise errors.InviteExpired(response_data, http_res)
|
|
267
253
|
if utils.match_response(http_res, "422", "application/json"):
|
|
268
|
-
response_data =
|
|
269
|
-
|
|
254
|
+
response_data = unmarshal_json_response(
|
|
255
|
+
errors.UnprocessableEntityData, http_res
|
|
270
256
|
)
|
|
271
|
-
raise errors.UnprocessableEntity(
|
|
257
|
+
raise errors.UnprocessableEntity(response_data, http_res)
|
|
272
258
|
if utils.match_response(http_res, "429", "application/json"):
|
|
273
|
-
response_data =
|
|
274
|
-
|
|
259
|
+
response_data = unmarshal_json_response(
|
|
260
|
+
errors.RateLimitExceededData, http_res
|
|
275
261
|
)
|
|
276
|
-
raise errors.RateLimitExceeded(
|
|
262
|
+
raise errors.RateLimitExceeded(response_data, http_res)
|
|
277
263
|
if utils.match_response(http_res, "500", "application/json"):
|
|
278
|
-
response_data =
|
|
279
|
-
|
|
264
|
+
response_data = unmarshal_json_response(
|
|
265
|
+
errors.InternalServerErrorData, http_res
|
|
280
266
|
)
|
|
281
|
-
raise errors.InternalServerError(
|
|
267
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
282
268
|
if utils.match_response(http_res, "4XX", "*"):
|
|
283
269
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
284
|
-
raise errors.SDKError(
|
|
285
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
286
|
-
)
|
|
270
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
287
271
|
if utils.match_response(http_res, "5XX", "*"):
|
|
288
272
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
289
|
-
raise errors.SDKError(
|
|
290
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
291
|
-
)
|
|
273
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
292
274
|
|
|
293
|
-
|
|
294
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
295
|
-
raise errors.SDKError(
|
|
296
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
297
|
-
http_res.status_code,
|
|
298
|
-
http_res_text,
|
|
299
|
-
http_res,
|
|
300
|
-
)
|
|
275
|
+
raise errors.SDKError("Unexpected response received", http_res)
|
|
@@ -241,7 +241,7 @@ class BaseSDK:
|
|
|
241
241
|
|
|
242
242
|
if http_res is None:
|
|
243
243
|
logger.debug("Raising no response SDK error")
|
|
244
|
-
raise errors.
|
|
244
|
+
raise errors.NoResponseError("No response received")
|
|
245
245
|
|
|
246
246
|
logger.debug(
|
|
247
247
|
"Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
|
|
@@ -262,7 +262,7 @@ class BaseSDK:
|
|
|
262
262
|
http_res = result
|
|
263
263
|
else:
|
|
264
264
|
logger.debug("Raising unexpected SDK error")
|
|
265
|
-
raise errors.SDKError("Unexpected error occurred")
|
|
265
|
+
raise errors.SDKError("Unexpected error occurred", http_res)
|
|
266
266
|
|
|
267
267
|
return http_res
|
|
268
268
|
|
|
@@ -313,7 +313,7 @@ class BaseSDK:
|
|
|
313
313
|
|
|
314
314
|
if http_res is None:
|
|
315
315
|
logger.debug("Raising no response SDK error")
|
|
316
|
-
raise errors.
|
|
316
|
+
raise errors.NoResponseError("No response received")
|
|
317
317
|
|
|
318
318
|
logger.debug(
|
|
319
319
|
"Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
|
|
@@ -334,7 +334,7 @@ class BaseSDK:
|
|
|
334
334
|
http_res = result
|
|
335
335
|
else:
|
|
336
336
|
logger.debug("Raising unexpected SDK error")
|
|
337
|
-
raise errors.SDKError("Unexpected error occurred")
|
|
337
|
+
raise errors.SDKError("Unexpected error occurred", http_res)
|
|
338
338
|
|
|
339
339
|
return http_res
|
|
340
340
|
|