dub 0.26.12__py3-none-any.whl → 0.27.0__py3-none-any.whl
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/_version.py +3 -3
- dub/analytics.py +66 -76
- dub/basesdk.py +4 -4
- dub/commissions.py +132 -152
- dub/customers.py +330 -380
- dub/domains.py +396 -456
- dub/embed_tokens.py +66 -78
- dub/events.py +66 -76
- dub/folders.py +264 -304
- dub/links.py +666 -750
- dub/models/errors/__init__.py +9 -0
- dub/models/errors/badrequest.py +12 -6
- dub/models/errors/conflict.py +12 -6
- dub/models/errors/duberror.py +26 -0
- dub/models/errors/forbidden.py +12 -6
- dub/models/errors/internalservererror.py +12 -6
- dub/models/errors/inviteexpired.py +12 -6
- dub/models/errors/no_response_error.py +13 -0
- dub/models/errors/notfound.py +12 -6
- dub/models/errors/ratelimitexceeded.py +12 -6
- dub/models/errors/responsevalidationerror.py +25 -0
- dub/models/errors/sdkerror.py +30 -14
- dub/models/errors/unauthorized.py +12 -6
- dub/models/errors/unprocessableentity.py +12 -6
- dub/models/operations/createcustomer.py +3 -0
- dub/models/operations/getcustomer.py +3 -0
- dub/models/operations/getcustomers.py +3 -0
- dub/models/operations/updatecustomer.py +3 -0
- dub/partners.py +336 -374
- dub/qr_codes.py +62 -72
- dub/tags.py +268 -300
- dub/track.py +132 -152
- dub/utils/__init__.py +3 -0
- dub/utils/serializers.py +21 -3
- dub/workspaces.py +132 -152
- {dub-0.26.12.dist-info → dub-0.27.0.dist-info}/METADATA +50 -56
- {dub-0.26.12.dist-info → dub-0.27.0.dist-info}/RECORD +39 -36
- {dub-0.26.12.dist-info → dub-0.27.0.dist-info}/LICENSE +0 -0
- {dub-0.26.12.dist-info → dub-0.27.0.dist-info}/WHEEL +0 -0
dub/workspaces.py
CHANGED
|
@@ -95,63 +95,58 @@ class Workspaces(BaseSDK):
|
|
|
95
95
|
|
|
96
96
|
response_data: Any = None
|
|
97
97
|
if utils.match_response(http_res, "200", "application/json"):
|
|
98
|
-
return utils.
|
|
99
|
-
|
|
98
|
+
return utils.unmarshal_json_response(
|
|
99
|
+
Optional[components.WorkspaceSchema], http_res
|
|
100
100
|
)
|
|
101
101
|
if utils.match_response(http_res, "400", "application/json"):
|
|
102
|
-
response_data = utils.
|
|
103
|
-
|
|
102
|
+
response_data = utils.unmarshal_json_response(
|
|
103
|
+
errors.BadRequestData, http_res
|
|
104
|
+
)
|
|
105
|
+
raise errors.BadRequest(response_data, http_res)
|
|
104
106
|
if utils.match_response(http_res, "401", "application/json"):
|
|
105
|
-
response_data = utils.
|
|
106
|
-
|
|
107
|
+
response_data = utils.unmarshal_json_response(
|
|
108
|
+
errors.UnauthorizedData, http_res
|
|
109
|
+
)
|
|
110
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
107
111
|
if utils.match_response(http_res, "403", "application/json"):
|
|
108
|
-
response_data = utils.
|
|
109
|
-
|
|
112
|
+
response_data = utils.unmarshal_json_response(
|
|
113
|
+
errors.ForbiddenData, http_res
|
|
114
|
+
)
|
|
115
|
+
raise errors.Forbidden(response_data, http_res)
|
|
110
116
|
if utils.match_response(http_res, "404", "application/json"):
|
|
111
|
-
response_data = utils.
|
|
112
|
-
raise errors.NotFound(
|
|
117
|
+
response_data = utils.unmarshal_json_response(errors.NotFoundData, http_res)
|
|
118
|
+
raise errors.NotFound(response_data, http_res)
|
|
113
119
|
if utils.match_response(http_res, "409", "application/json"):
|
|
114
|
-
response_data = utils.
|
|
115
|
-
raise errors.Conflict(
|
|
120
|
+
response_data = utils.unmarshal_json_response(errors.ConflictData, http_res)
|
|
121
|
+
raise errors.Conflict(response_data, http_res)
|
|
116
122
|
if utils.match_response(http_res, "410", "application/json"):
|
|
117
|
-
response_data = utils.
|
|
118
|
-
|
|
123
|
+
response_data = utils.unmarshal_json_response(
|
|
124
|
+
errors.InviteExpiredData, http_res
|
|
119
125
|
)
|
|
120
|
-
raise errors.InviteExpired(
|
|
126
|
+
raise errors.InviteExpired(response_data, http_res)
|
|
121
127
|
if utils.match_response(http_res, "422", "application/json"):
|
|
122
|
-
response_data = utils.
|
|
123
|
-
|
|
128
|
+
response_data = utils.unmarshal_json_response(
|
|
129
|
+
errors.UnprocessableEntityData, http_res
|
|
124
130
|
)
|
|
125
|
-
raise errors.UnprocessableEntity(
|
|
131
|
+
raise errors.UnprocessableEntity(response_data, http_res)
|
|
126
132
|
if utils.match_response(http_res, "429", "application/json"):
|
|
127
|
-
response_data = utils.
|
|
128
|
-
|
|
133
|
+
response_data = utils.unmarshal_json_response(
|
|
134
|
+
errors.RateLimitExceededData, http_res
|
|
129
135
|
)
|
|
130
|
-
raise errors.RateLimitExceeded(
|
|
136
|
+
raise errors.RateLimitExceeded(response_data, http_res)
|
|
131
137
|
if utils.match_response(http_res, "500", "application/json"):
|
|
132
|
-
response_data = utils.
|
|
133
|
-
|
|
138
|
+
response_data = utils.unmarshal_json_response(
|
|
139
|
+
errors.InternalServerErrorData, http_res
|
|
134
140
|
)
|
|
135
|
-
raise errors.InternalServerError(
|
|
141
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
136
142
|
if utils.match_response(http_res, "4XX", "*"):
|
|
137
143
|
http_res_text = utils.stream_to_text(http_res)
|
|
138
|
-
raise errors.SDKError(
|
|
139
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
140
|
-
)
|
|
144
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
141
145
|
if utils.match_response(http_res, "5XX", "*"):
|
|
142
146
|
http_res_text = utils.stream_to_text(http_res)
|
|
143
|
-
raise errors.SDKError(
|
|
144
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
145
|
-
)
|
|
147
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
146
148
|
|
|
147
|
-
|
|
148
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
149
|
-
raise errors.SDKError(
|
|
150
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
151
|
-
http_res.status_code,
|
|
152
|
-
http_res_text,
|
|
153
|
-
http_res,
|
|
154
|
-
)
|
|
149
|
+
raise errors.SDKError("Unexpected response received", http_res)
|
|
155
150
|
|
|
156
151
|
async def get_async(
|
|
157
152
|
self,
|
|
@@ -239,63 +234,58 @@ class Workspaces(BaseSDK):
|
|
|
239
234
|
|
|
240
235
|
response_data: Any = None
|
|
241
236
|
if utils.match_response(http_res, "200", "application/json"):
|
|
242
|
-
return utils.
|
|
243
|
-
|
|
237
|
+
return utils.unmarshal_json_response(
|
|
238
|
+
Optional[components.WorkspaceSchema], http_res
|
|
244
239
|
)
|
|
245
240
|
if utils.match_response(http_res, "400", "application/json"):
|
|
246
|
-
response_data = utils.
|
|
247
|
-
|
|
241
|
+
response_data = utils.unmarshal_json_response(
|
|
242
|
+
errors.BadRequestData, http_res
|
|
243
|
+
)
|
|
244
|
+
raise errors.BadRequest(response_data, http_res)
|
|
248
245
|
if utils.match_response(http_res, "401", "application/json"):
|
|
249
|
-
response_data = utils.
|
|
250
|
-
|
|
246
|
+
response_data = utils.unmarshal_json_response(
|
|
247
|
+
errors.UnauthorizedData, http_res
|
|
248
|
+
)
|
|
249
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
251
250
|
if utils.match_response(http_res, "403", "application/json"):
|
|
252
|
-
response_data = utils.
|
|
253
|
-
|
|
251
|
+
response_data = utils.unmarshal_json_response(
|
|
252
|
+
errors.ForbiddenData, http_res
|
|
253
|
+
)
|
|
254
|
+
raise errors.Forbidden(response_data, http_res)
|
|
254
255
|
if utils.match_response(http_res, "404", "application/json"):
|
|
255
|
-
response_data = utils.
|
|
256
|
-
raise errors.NotFound(
|
|
256
|
+
response_data = utils.unmarshal_json_response(errors.NotFoundData, http_res)
|
|
257
|
+
raise errors.NotFound(response_data, http_res)
|
|
257
258
|
if utils.match_response(http_res, "409", "application/json"):
|
|
258
|
-
response_data = utils.
|
|
259
|
-
raise errors.Conflict(
|
|
259
|
+
response_data = utils.unmarshal_json_response(errors.ConflictData, http_res)
|
|
260
|
+
raise errors.Conflict(response_data, http_res)
|
|
260
261
|
if utils.match_response(http_res, "410", "application/json"):
|
|
261
|
-
response_data = utils.
|
|
262
|
-
|
|
262
|
+
response_data = utils.unmarshal_json_response(
|
|
263
|
+
errors.InviteExpiredData, http_res
|
|
263
264
|
)
|
|
264
|
-
raise errors.InviteExpired(
|
|
265
|
+
raise errors.InviteExpired(response_data, http_res)
|
|
265
266
|
if utils.match_response(http_res, "422", "application/json"):
|
|
266
|
-
response_data = utils.
|
|
267
|
-
|
|
267
|
+
response_data = utils.unmarshal_json_response(
|
|
268
|
+
errors.UnprocessableEntityData, http_res
|
|
268
269
|
)
|
|
269
|
-
raise errors.UnprocessableEntity(
|
|
270
|
+
raise errors.UnprocessableEntity(response_data, http_res)
|
|
270
271
|
if utils.match_response(http_res, "429", "application/json"):
|
|
271
|
-
response_data = utils.
|
|
272
|
-
|
|
272
|
+
response_data = utils.unmarshal_json_response(
|
|
273
|
+
errors.RateLimitExceededData, http_res
|
|
273
274
|
)
|
|
274
|
-
raise errors.RateLimitExceeded(
|
|
275
|
+
raise errors.RateLimitExceeded(response_data, http_res)
|
|
275
276
|
if utils.match_response(http_res, "500", "application/json"):
|
|
276
|
-
response_data = utils.
|
|
277
|
-
|
|
277
|
+
response_data = utils.unmarshal_json_response(
|
|
278
|
+
errors.InternalServerErrorData, http_res
|
|
278
279
|
)
|
|
279
|
-
raise errors.InternalServerError(
|
|
280
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
280
281
|
if utils.match_response(http_res, "4XX", "*"):
|
|
281
282
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
282
|
-
raise errors.SDKError(
|
|
283
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
284
|
-
)
|
|
283
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
285
284
|
if utils.match_response(http_res, "5XX", "*"):
|
|
286
285
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
287
|
-
raise errors.SDKError(
|
|
288
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
289
|
-
)
|
|
286
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
290
287
|
|
|
291
|
-
|
|
292
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
293
|
-
raise errors.SDKError(
|
|
294
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
295
|
-
http_res.status_code,
|
|
296
|
-
http_res_text,
|
|
297
|
-
http_res,
|
|
298
|
-
)
|
|
288
|
+
raise errors.SDKError("Unexpected response received", http_res)
|
|
299
289
|
|
|
300
290
|
def update(
|
|
301
291
|
self,
|
|
@@ -398,63 +388,58 @@ class Workspaces(BaseSDK):
|
|
|
398
388
|
|
|
399
389
|
response_data: Any = None
|
|
400
390
|
if utils.match_response(http_res, "200", "application/json"):
|
|
401
|
-
return utils.
|
|
402
|
-
|
|
391
|
+
return utils.unmarshal_json_response(
|
|
392
|
+
Optional[components.WorkspaceSchema], http_res
|
|
403
393
|
)
|
|
404
394
|
if utils.match_response(http_res, "400", "application/json"):
|
|
405
|
-
response_data = utils.
|
|
406
|
-
|
|
395
|
+
response_data = utils.unmarshal_json_response(
|
|
396
|
+
errors.BadRequestData, http_res
|
|
397
|
+
)
|
|
398
|
+
raise errors.BadRequest(response_data, http_res)
|
|
407
399
|
if utils.match_response(http_res, "401", "application/json"):
|
|
408
|
-
response_data = utils.
|
|
409
|
-
|
|
400
|
+
response_data = utils.unmarshal_json_response(
|
|
401
|
+
errors.UnauthorizedData, http_res
|
|
402
|
+
)
|
|
403
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
410
404
|
if utils.match_response(http_res, "403", "application/json"):
|
|
411
|
-
response_data = utils.
|
|
412
|
-
|
|
405
|
+
response_data = utils.unmarshal_json_response(
|
|
406
|
+
errors.ForbiddenData, http_res
|
|
407
|
+
)
|
|
408
|
+
raise errors.Forbidden(response_data, http_res)
|
|
413
409
|
if utils.match_response(http_res, "404", "application/json"):
|
|
414
|
-
response_data = utils.
|
|
415
|
-
raise errors.NotFound(
|
|
410
|
+
response_data = utils.unmarshal_json_response(errors.NotFoundData, http_res)
|
|
411
|
+
raise errors.NotFound(response_data, http_res)
|
|
416
412
|
if utils.match_response(http_res, "409", "application/json"):
|
|
417
|
-
response_data = utils.
|
|
418
|
-
raise errors.Conflict(
|
|
413
|
+
response_data = utils.unmarshal_json_response(errors.ConflictData, http_res)
|
|
414
|
+
raise errors.Conflict(response_data, http_res)
|
|
419
415
|
if utils.match_response(http_res, "410", "application/json"):
|
|
420
|
-
response_data = utils.
|
|
421
|
-
|
|
416
|
+
response_data = utils.unmarshal_json_response(
|
|
417
|
+
errors.InviteExpiredData, http_res
|
|
422
418
|
)
|
|
423
|
-
raise errors.InviteExpired(
|
|
419
|
+
raise errors.InviteExpired(response_data, http_res)
|
|
424
420
|
if utils.match_response(http_res, "422", "application/json"):
|
|
425
|
-
response_data = utils.
|
|
426
|
-
|
|
421
|
+
response_data = utils.unmarshal_json_response(
|
|
422
|
+
errors.UnprocessableEntityData, http_res
|
|
427
423
|
)
|
|
428
|
-
raise errors.UnprocessableEntity(
|
|
424
|
+
raise errors.UnprocessableEntity(response_data, http_res)
|
|
429
425
|
if utils.match_response(http_res, "429", "application/json"):
|
|
430
|
-
response_data = utils.
|
|
431
|
-
|
|
426
|
+
response_data = utils.unmarshal_json_response(
|
|
427
|
+
errors.RateLimitExceededData, http_res
|
|
432
428
|
)
|
|
433
|
-
raise errors.RateLimitExceeded(
|
|
429
|
+
raise errors.RateLimitExceeded(response_data, http_res)
|
|
434
430
|
if utils.match_response(http_res, "500", "application/json"):
|
|
435
|
-
response_data = utils.
|
|
436
|
-
|
|
431
|
+
response_data = utils.unmarshal_json_response(
|
|
432
|
+
errors.InternalServerErrorData, http_res
|
|
437
433
|
)
|
|
438
|
-
raise errors.InternalServerError(
|
|
434
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
439
435
|
if utils.match_response(http_res, "4XX", "*"):
|
|
440
436
|
http_res_text = utils.stream_to_text(http_res)
|
|
441
|
-
raise errors.SDKError(
|
|
442
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
443
|
-
)
|
|
437
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
444
438
|
if utils.match_response(http_res, "5XX", "*"):
|
|
445
439
|
http_res_text = utils.stream_to_text(http_res)
|
|
446
|
-
raise errors.SDKError(
|
|
447
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
448
|
-
)
|
|
440
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
449
441
|
|
|
450
|
-
|
|
451
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
452
|
-
raise errors.SDKError(
|
|
453
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
454
|
-
http_res.status_code,
|
|
455
|
-
http_res_text,
|
|
456
|
-
http_res,
|
|
457
|
-
)
|
|
442
|
+
raise errors.SDKError("Unexpected response received", http_res)
|
|
458
443
|
|
|
459
444
|
async def update_async(
|
|
460
445
|
self,
|
|
@@ -557,60 +542,55 @@ class Workspaces(BaseSDK):
|
|
|
557
542
|
|
|
558
543
|
response_data: Any = None
|
|
559
544
|
if utils.match_response(http_res, "200", "application/json"):
|
|
560
|
-
return utils.
|
|
561
|
-
|
|
545
|
+
return utils.unmarshal_json_response(
|
|
546
|
+
Optional[components.WorkspaceSchema], http_res
|
|
562
547
|
)
|
|
563
548
|
if utils.match_response(http_res, "400", "application/json"):
|
|
564
|
-
response_data = utils.
|
|
565
|
-
|
|
549
|
+
response_data = utils.unmarshal_json_response(
|
|
550
|
+
errors.BadRequestData, http_res
|
|
551
|
+
)
|
|
552
|
+
raise errors.BadRequest(response_data, http_res)
|
|
566
553
|
if utils.match_response(http_res, "401", "application/json"):
|
|
567
|
-
response_data = utils.
|
|
568
|
-
|
|
554
|
+
response_data = utils.unmarshal_json_response(
|
|
555
|
+
errors.UnauthorizedData, http_res
|
|
556
|
+
)
|
|
557
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
569
558
|
if utils.match_response(http_res, "403", "application/json"):
|
|
570
|
-
response_data = utils.
|
|
571
|
-
|
|
559
|
+
response_data = utils.unmarshal_json_response(
|
|
560
|
+
errors.ForbiddenData, http_res
|
|
561
|
+
)
|
|
562
|
+
raise errors.Forbidden(response_data, http_res)
|
|
572
563
|
if utils.match_response(http_res, "404", "application/json"):
|
|
573
|
-
response_data = utils.
|
|
574
|
-
raise errors.NotFound(
|
|
564
|
+
response_data = utils.unmarshal_json_response(errors.NotFoundData, http_res)
|
|
565
|
+
raise errors.NotFound(response_data, http_res)
|
|
575
566
|
if utils.match_response(http_res, "409", "application/json"):
|
|
576
|
-
response_data = utils.
|
|
577
|
-
raise errors.Conflict(
|
|
567
|
+
response_data = utils.unmarshal_json_response(errors.ConflictData, http_res)
|
|
568
|
+
raise errors.Conflict(response_data, http_res)
|
|
578
569
|
if utils.match_response(http_res, "410", "application/json"):
|
|
579
|
-
response_data = utils.
|
|
580
|
-
|
|
570
|
+
response_data = utils.unmarshal_json_response(
|
|
571
|
+
errors.InviteExpiredData, http_res
|
|
581
572
|
)
|
|
582
|
-
raise errors.InviteExpired(
|
|
573
|
+
raise errors.InviteExpired(response_data, http_res)
|
|
583
574
|
if utils.match_response(http_res, "422", "application/json"):
|
|
584
|
-
response_data = utils.
|
|
585
|
-
|
|
575
|
+
response_data = utils.unmarshal_json_response(
|
|
576
|
+
errors.UnprocessableEntityData, http_res
|
|
586
577
|
)
|
|
587
|
-
raise errors.UnprocessableEntity(
|
|
578
|
+
raise errors.UnprocessableEntity(response_data, http_res)
|
|
588
579
|
if utils.match_response(http_res, "429", "application/json"):
|
|
589
|
-
response_data = utils.
|
|
590
|
-
|
|
580
|
+
response_data = utils.unmarshal_json_response(
|
|
581
|
+
errors.RateLimitExceededData, http_res
|
|
591
582
|
)
|
|
592
|
-
raise errors.RateLimitExceeded(
|
|
583
|
+
raise errors.RateLimitExceeded(response_data, http_res)
|
|
593
584
|
if utils.match_response(http_res, "500", "application/json"):
|
|
594
|
-
response_data = utils.
|
|
595
|
-
|
|
585
|
+
response_data = utils.unmarshal_json_response(
|
|
586
|
+
errors.InternalServerErrorData, http_res
|
|
596
587
|
)
|
|
597
|
-
raise errors.InternalServerError(
|
|
588
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
598
589
|
if utils.match_response(http_res, "4XX", "*"):
|
|
599
590
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
600
|
-
raise errors.SDKError(
|
|
601
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
602
|
-
)
|
|
591
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
603
592
|
if utils.match_response(http_res, "5XX", "*"):
|
|
604
593
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
605
|
-
raise errors.SDKError(
|
|
606
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
607
|
-
)
|
|
594
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
608
595
|
|
|
609
|
-
|
|
610
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
611
|
-
raise errors.SDKError(
|
|
612
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
613
|
-
http_res.status_code,
|
|
614
|
-
http_res_text,
|
|
615
|
-
http_res,
|
|
616
|
-
)
|
|
596
|
+
raise errors.SDKError("Unexpected response received", http_res)
|
|
@@ -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] -->
|