dub 0.26.12__tar.gz → 0.27.0__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.0}/PKG-INFO +50 -56
- {dub-0.26.12 → dub-0.27.0}/README-PYPI.md +50 -56
- {dub-0.26.12 → dub-0.27.0}/pyproject.toml +1 -1
- {dub-0.26.12 → dub-0.27.0}/src/dub/_version.py +3 -3
- {dub-0.26.12 → dub-0.27.0}/src/dub/analytics.py +66 -76
- {dub-0.26.12 → dub-0.27.0}/src/dub/basesdk.py +4 -4
- {dub-0.26.12 → dub-0.27.0}/src/dub/commissions.py +132 -152
- {dub-0.26.12 → dub-0.27.0}/src/dub/customers.py +330 -380
- {dub-0.26.12 → dub-0.27.0}/src/dub/domains.py +396 -456
- {dub-0.26.12 → dub-0.27.0}/src/dub/embed_tokens.py +66 -78
- {dub-0.26.12 → dub-0.27.0}/src/dub/events.py +66 -76
- {dub-0.26.12 → dub-0.27.0}/src/dub/folders.py +264 -304
- {dub-0.26.12 → dub-0.27.0}/src/dub/links.py +666 -750
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/errors/__init__.py +9 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/errors/badrequest.py +12 -6
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/errors/conflict.py +12 -6
- dub-0.27.0/src/dub/models/errors/duberror.py +26 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/errors/forbidden.py +12 -6
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/errors/internalservererror.py +12 -6
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/errors/inviteexpired.py +12 -6
- dub-0.27.0/src/dub/models/errors/no_response_error.py +13 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/errors/notfound.py +12 -6
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/errors/ratelimitexceeded.py +12 -6
- dub-0.27.0/src/dub/models/errors/responsevalidationerror.py +25 -0
- dub-0.27.0/src/dub/models/errors/sdkerror.py +38 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/errors/unauthorized.py +12 -6
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/errors/unprocessableentity.py +12 -6
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/createcustomer.py +3 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/getcustomer.py +3 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/getcustomers.py +3 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/updatecustomer.py +3 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/partners.py +336 -374
- {dub-0.26.12 → dub-0.27.0}/src/dub/qr_codes.py +62 -72
- {dub-0.26.12 → dub-0.27.0}/src/dub/tags.py +268 -300
- {dub-0.26.12 → dub-0.27.0}/src/dub/track.py +132 -152
- {dub-0.26.12 → dub-0.27.0}/src/dub/utils/__init__.py +3 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/utils/serializers.py +21 -3
- {dub-0.26.12 → dub-0.27.0}/src/dub/workspaces.py +132 -152
- dub-0.26.12/src/dub/models/errors/sdkerror.py +0 -22
- {dub-0.26.12 → dub-0.27.0}/LICENSE +0 -0
- {dub-0.26.12 → dub-0.27.0}/py.typed +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/__init__.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/_hooks/__init__.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/_hooks/registration.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/_hooks/sdkhooks.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/_hooks/types.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/httpclient.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/__init__.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/__init__.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/analyticsbrowsers.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/analyticscities.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/analyticscontinents.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/analyticscount.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/analyticscountries.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/analyticsdevices.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/analyticsos.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/analyticsreferers.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/analyticsrefererurls.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/analyticsregions.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/analyticstimeseries.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/analyticstoplinks.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/analyticstopurls.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/analyticstriggers.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/clickevent.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/continentcode.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/countrycode.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/domainschema.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/folderschema.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/leadcreatedevent.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/leadevent.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/linkclickedevent.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/linkerrorschema.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/linkgeotargeting.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/linkschema.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/linkwebhookevent.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/partneranalyticscount.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/partneranalyticstimeseries.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/partneranalyticstoplinks.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/partnerenrolledevent.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/salecreatedevent.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/saleevent.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/security.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/tagschema.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/webhookevent.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/components/workspaceschema.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/__init__.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/bulkcreatelinks.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/bulkdeletelinks.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/bulkupdatelinks.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/checkdomainstatus.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/createdomain.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/createfolder.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/createlink.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/createpartner.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/createpartnerlink.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/createreferralsembedtoken.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/createtag.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/deletecustomer.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/deletedomain.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/deletefolder.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/deletelink.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/deletetag.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/getlinkinfo.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/getlinks.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/getlinkscount.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/getqrcode.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/gettags.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/getworkspace.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/listcommissions.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/listdomains.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/listevents.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/listfolders.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/registerdomain.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/retrieveanalytics.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/retrievelinks.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/retrievepartneranalytics.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/tracklead.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/tracksale.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/updatecommission.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/updatedomain.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/updatefolder.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/updatelink.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/updatetag.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/updateworkspace.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/upsertlink.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/models/operations/upsertpartnerlink.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/py.typed +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/sdk.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/sdkconfiguration.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/types/__init__.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/types/basemodel.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/utils/annotations.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/utils/datetimes.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/utils/enums.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/utils/eventstreaming.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/utils/forms.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/utils/headers.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/utils/logger.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/utils/metadata.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/utils/queryparams.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/utils/requestbodies.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/utils/retries.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/utils/security.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/src/dub/utils/url.py +0 -0
- {dub-0.26.12 → dub-0.27.0}/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.0
|
|
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.0"
|
|
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.651.2"
|
|
9
|
+
__user_agent__: str = "speakeasy-sdk/python 0.27.0 2.651.2 0.0.1 dub"
|
|
10
10
|
|
|
11
11
|
try:
|
|
12
12
|
if __package__ is not None:
|
|
@@ -96,63 +96,58 @@ class Analytics(BaseSDK):
|
|
|
96
96
|
|
|
97
97
|
response_data: Any = None
|
|
98
98
|
if utils.match_response(http_res, "200", "application/json"):
|
|
99
|
-
return utils.
|
|
100
|
-
|
|
99
|
+
return utils.unmarshal_json_response(
|
|
100
|
+
Optional[operations.RetrieveAnalyticsResponseBody], http_res
|
|
101
101
|
)
|
|
102
102
|
if utils.match_response(http_res, "400", "application/json"):
|
|
103
|
-
response_data = utils.
|
|
104
|
-
|
|
103
|
+
response_data = utils.unmarshal_json_response(
|
|
104
|
+
errors.BadRequestData, http_res
|
|
105
|
+
)
|
|
106
|
+
raise errors.BadRequest(response_data, http_res)
|
|
105
107
|
if utils.match_response(http_res, "401", "application/json"):
|
|
106
|
-
response_data = utils.
|
|
107
|
-
|
|
108
|
+
response_data = utils.unmarshal_json_response(
|
|
109
|
+
errors.UnauthorizedData, http_res
|
|
110
|
+
)
|
|
111
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
108
112
|
if utils.match_response(http_res, "403", "application/json"):
|
|
109
|
-
response_data = utils.
|
|
110
|
-
|
|
113
|
+
response_data = utils.unmarshal_json_response(
|
|
114
|
+
errors.ForbiddenData, http_res
|
|
115
|
+
)
|
|
116
|
+
raise errors.Forbidden(response_data, http_res)
|
|
111
117
|
if utils.match_response(http_res, "404", "application/json"):
|
|
112
|
-
response_data = utils.
|
|
113
|
-
raise errors.NotFound(
|
|
118
|
+
response_data = utils.unmarshal_json_response(errors.NotFoundData, http_res)
|
|
119
|
+
raise errors.NotFound(response_data, http_res)
|
|
114
120
|
if utils.match_response(http_res, "409", "application/json"):
|
|
115
|
-
response_data = utils.
|
|
116
|
-
raise errors.Conflict(
|
|
121
|
+
response_data = utils.unmarshal_json_response(errors.ConflictData, http_res)
|
|
122
|
+
raise errors.Conflict(response_data, http_res)
|
|
117
123
|
if utils.match_response(http_res, "410", "application/json"):
|
|
118
|
-
response_data = utils.
|
|
119
|
-
|
|
124
|
+
response_data = utils.unmarshal_json_response(
|
|
125
|
+
errors.InviteExpiredData, http_res
|
|
120
126
|
)
|
|
121
|
-
raise errors.InviteExpired(
|
|
127
|
+
raise errors.InviteExpired(response_data, http_res)
|
|
122
128
|
if utils.match_response(http_res, "422", "application/json"):
|
|
123
|
-
response_data = utils.
|
|
124
|
-
|
|
129
|
+
response_data = utils.unmarshal_json_response(
|
|
130
|
+
errors.UnprocessableEntityData, http_res
|
|
125
131
|
)
|
|
126
|
-
raise errors.UnprocessableEntity(
|
|
132
|
+
raise errors.UnprocessableEntity(response_data, http_res)
|
|
127
133
|
if utils.match_response(http_res, "429", "application/json"):
|
|
128
|
-
response_data = utils.
|
|
129
|
-
|
|
134
|
+
response_data = utils.unmarshal_json_response(
|
|
135
|
+
errors.RateLimitExceededData, http_res
|
|
130
136
|
)
|
|
131
|
-
raise errors.RateLimitExceeded(
|
|
137
|
+
raise errors.RateLimitExceeded(response_data, http_res)
|
|
132
138
|
if utils.match_response(http_res, "500", "application/json"):
|
|
133
|
-
response_data = utils.
|
|
134
|
-
|
|
139
|
+
response_data = utils.unmarshal_json_response(
|
|
140
|
+
errors.InternalServerErrorData, http_res
|
|
135
141
|
)
|
|
136
|
-
raise errors.InternalServerError(
|
|
142
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
137
143
|
if utils.match_response(http_res, "4XX", "*"):
|
|
138
144
|
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
|
-
)
|
|
145
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
142
146
|
if utils.match_response(http_res, "5XX", "*"):
|
|
143
147
|
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
|
-
)
|
|
148
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
147
149
|
|
|
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
|
-
)
|
|
150
|
+
raise errors.SDKError("Unexpected response received", http_res)
|
|
156
151
|
|
|
157
152
|
async def retrieve_async(
|
|
158
153
|
self,
|
|
@@ -241,60 +236,55 @@ class Analytics(BaseSDK):
|
|
|
241
236
|
|
|
242
237
|
response_data: Any = None
|
|
243
238
|
if utils.match_response(http_res, "200", "application/json"):
|
|
244
|
-
return utils.
|
|
245
|
-
|
|
239
|
+
return utils.unmarshal_json_response(
|
|
240
|
+
Optional[operations.RetrieveAnalyticsResponseBody], http_res
|
|
246
241
|
)
|
|
247
242
|
if utils.match_response(http_res, "400", "application/json"):
|
|
248
|
-
response_data = utils.
|
|
249
|
-
|
|
243
|
+
response_data = utils.unmarshal_json_response(
|
|
244
|
+
errors.BadRequestData, http_res
|
|
245
|
+
)
|
|
246
|
+
raise errors.BadRequest(response_data, http_res)
|
|
250
247
|
if utils.match_response(http_res, "401", "application/json"):
|
|
251
|
-
response_data = utils.
|
|
252
|
-
|
|
248
|
+
response_data = utils.unmarshal_json_response(
|
|
249
|
+
errors.UnauthorizedData, http_res
|
|
250
|
+
)
|
|
251
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
253
252
|
if utils.match_response(http_res, "403", "application/json"):
|
|
254
|
-
response_data = utils.
|
|
255
|
-
|
|
253
|
+
response_data = utils.unmarshal_json_response(
|
|
254
|
+
errors.ForbiddenData, http_res
|
|
255
|
+
)
|
|
256
|
+
raise errors.Forbidden(response_data, http_res)
|
|
256
257
|
if utils.match_response(http_res, "404", "application/json"):
|
|
257
|
-
response_data = utils.
|
|
258
|
-
raise errors.NotFound(
|
|
258
|
+
response_data = utils.unmarshal_json_response(errors.NotFoundData, http_res)
|
|
259
|
+
raise errors.NotFound(response_data, http_res)
|
|
259
260
|
if utils.match_response(http_res, "409", "application/json"):
|
|
260
|
-
response_data = utils.
|
|
261
|
-
raise errors.Conflict(
|
|
261
|
+
response_data = utils.unmarshal_json_response(errors.ConflictData, http_res)
|
|
262
|
+
raise errors.Conflict(response_data, http_res)
|
|
262
263
|
if utils.match_response(http_res, "410", "application/json"):
|
|
263
|
-
response_data = utils.
|
|
264
|
-
|
|
264
|
+
response_data = utils.unmarshal_json_response(
|
|
265
|
+
errors.InviteExpiredData, http_res
|
|
265
266
|
)
|
|
266
|
-
raise errors.InviteExpired(
|
|
267
|
+
raise errors.InviteExpired(response_data, http_res)
|
|
267
268
|
if utils.match_response(http_res, "422", "application/json"):
|
|
268
|
-
response_data = utils.
|
|
269
|
-
|
|
269
|
+
response_data = utils.unmarshal_json_response(
|
|
270
|
+
errors.UnprocessableEntityData, http_res
|
|
270
271
|
)
|
|
271
|
-
raise errors.UnprocessableEntity(
|
|
272
|
+
raise errors.UnprocessableEntity(response_data, http_res)
|
|
272
273
|
if utils.match_response(http_res, "429", "application/json"):
|
|
273
|
-
response_data = utils.
|
|
274
|
-
|
|
274
|
+
response_data = utils.unmarshal_json_response(
|
|
275
|
+
errors.RateLimitExceededData, http_res
|
|
275
276
|
)
|
|
276
|
-
raise errors.RateLimitExceeded(
|
|
277
|
+
raise errors.RateLimitExceeded(response_data, http_res)
|
|
277
278
|
if utils.match_response(http_res, "500", "application/json"):
|
|
278
|
-
response_data = utils.
|
|
279
|
-
|
|
279
|
+
response_data = utils.unmarshal_json_response(
|
|
280
|
+
errors.InternalServerErrorData, http_res
|
|
280
281
|
)
|
|
281
|
-
raise errors.InternalServerError(
|
|
282
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
282
283
|
if utils.match_response(http_res, "4XX", "*"):
|
|
283
284
|
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
|
-
)
|
|
285
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
287
286
|
if utils.match_response(http_res, "5XX", "*"):
|
|
288
287
|
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
|
-
)
|
|
288
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
292
289
|
|
|
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
|
-
)
|
|
290
|
+
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
|
|