dub 0.26.12__py3-none-any.whl → 0.27.1__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 +53 -78
- dub/basesdk.py +4 -4
- dub/commissions.py +105 -156
- dub/customers.py +261 -390
- dub/domains.py +309 -472
- dub/embed_tokens.py +53 -80
- dub/events.py +53 -78
- dub/folders.py +205 -316
- dub/links.py +511 -770
- 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/tracklead.py +2 -2
- dub/models/operations/tracksale.py +2 -2
- dub/models/operations/updatecustomer.py +3 -0
- dub/partners.py +255 -384
- dub/qr_codes.py +49 -74
- dub/tags.py +205 -308
- dub/track.py +105 -156
- dub/utils/serializers.py +3 -2
- dub/utils/unmarshal_json_response.py +24 -0
- dub/workspaces.py +105 -156
- {dub-0.26.12.dist-info → dub-0.27.1.dist-info}/METADATA +50 -56
- {dub-0.26.12.dist-info → dub-0.27.1.dist-info}/RECORD +41 -37
- {dub-0.26.12.dist-info → dub-0.27.1.dist-info}/LICENSE +0 -0
- {dub-0.26.12.dist-info → dub-0.27.1.dist-info}/WHEEL +0 -0
dub/workspaces.py
CHANGED
|
@@ -5,6 +5,7 @@ from dub import utils
|
|
|
5
5
|
from dub._hooks import HookContext
|
|
6
6
|
from dub.models import components, 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
|
|
|
@@ -95,63 +96,50 @@ class Workspaces(BaseSDK):
|
|
|
95
96
|
|
|
96
97
|
response_data: Any = None
|
|
97
98
|
if utils.match_response(http_res, "200", "application/json"):
|
|
98
|
-
return
|
|
99
|
-
|
|
99
|
+
return unmarshal_json_response(
|
|
100
|
+
Optional[components.WorkspaceSchema], http_res
|
|
100
101
|
)
|
|
101
102
|
if utils.match_response(http_res, "400", "application/json"):
|
|
102
|
-
response_data =
|
|
103
|
-
raise errors.BadRequest(
|
|
103
|
+
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
104
|
+
raise errors.BadRequest(response_data, http_res)
|
|
104
105
|
if utils.match_response(http_res, "401", "application/json"):
|
|
105
|
-
response_data =
|
|
106
|
-
raise errors.Unauthorized(
|
|
106
|
+
response_data = unmarshal_json_response(errors.UnauthorizedData, http_res)
|
|
107
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
107
108
|
if utils.match_response(http_res, "403", "application/json"):
|
|
108
|
-
response_data =
|
|
109
|
-
raise errors.Forbidden(
|
|
109
|
+
response_data = unmarshal_json_response(errors.ForbiddenData, http_res)
|
|
110
|
+
raise errors.Forbidden(response_data, http_res)
|
|
110
111
|
if utils.match_response(http_res, "404", "application/json"):
|
|
111
|
-
response_data =
|
|
112
|
-
raise errors.NotFound(
|
|
112
|
+
response_data = unmarshal_json_response(errors.NotFoundData, http_res)
|
|
113
|
+
raise errors.NotFound(response_data, http_res)
|
|
113
114
|
if utils.match_response(http_res, "409", "application/json"):
|
|
114
|
-
response_data =
|
|
115
|
-
raise errors.Conflict(
|
|
115
|
+
response_data = unmarshal_json_response(errors.ConflictData, http_res)
|
|
116
|
+
raise errors.Conflict(response_data, http_res)
|
|
116
117
|
if utils.match_response(http_res, "410", "application/json"):
|
|
117
|
-
response_data =
|
|
118
|
-
|
|
119
|
-
)
|
|
120
|
-
raise errors.InviteExpired(data=response_data)
|
|
118
|
+
response_data = unmarshal_json_response(errors.InviteExpiredData, http_res)
|
|
119
|
+
raise errors.InviteExpired(response_data, http_res)
|
|
121
120
|
if utils.match_response(http_res, "422", "application/json"):
|
|
122
|
-
response_data =
|
|
123
|
-
|
|
121
|
+
response_data = unmarshal_json_response(
|
|
122
|
+
errors.UnprocessableEntityData, http_res
|
|
124
123
|
)
|
|
125
|
-
raise errors.UnprocessableEntity(
|
|
124
|
+
raise errors.UnprocessableEntity(response_data, http_res)
|
|
126
125
|
if utils.match_response(http_res, "429", "application/json"):
|
|
127
|
-
response_data =
|
|
128
|
-
|
|
126
|
+
response_data = unmarshal_json_response(
|
|
127
|
+
errors.RateLimitExceededData, http_res
|
|
129
128
|
)
|
|
130
|
-
raise errors.RateLimitExceeded(
|
|
129
|
+
raise errors.RateLimitExceeded(response_data, http_res)
|
|
131
130
|
if utils.match_response(http_res, "500", "application/json"):
|
|
132
|
-
response_data =
|
|
133
|
-
|
|
131
|
+
response_data = unmarshal_json_response(
|
|
132
|
+
errors.InternalServerErrorData, http_res
|
|
134
133
|
)
|
|
135
|
-
raise errors.InternalServerError(
|
|
134
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
136
135
|
if utils.match_response(http_res, "4XX", "*"):
|
|
137
136
|
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
|
-
)
|
|
137
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
141
138
|
if utils.match_response(http_res, "5XX", "*"):
|
|
142
139
|
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
|
-
)
|
|
140
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
146
141
|
|
|
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
|
-
)
|
|
142
|
+
raise errors.SDKError("Unexpected response received", http_res)
|
|
155
143
|
|
|
156
144
|
async def get_async(
|
|
157
145
|
self,
|
|
@@ -239,63 +227,50 @@ class Workspaces(BaseSDK):
|
|
|
239
227
|
|
|
240
228
|
response_data: Any = None
|
|
241
229
|
if utils.match_response(http_res, "200", "application/json"):
|
|
242
|
-
return
|
|
243
|
-
|
|
230
|
+
return unmarshal_json_response(
|
|
231
|
+
Optional[components.WorkspaceSchema], http_res
|
|
244
232
|
)
|
|
245
233
|
if utils.match_response(http_res, "400", "application/json"):
|
|
246
|
-
response_data =
|
|
247
|
-
raise errors.BadRequest(
|
|
234
|
+
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
235
|
+
raise errors.BadRequest(response_data, http_res)
|
|
248
236
|
if utils.match_response(http_res, "401", "application/json"):
|
|
249
|
-
response_data =
|
|
250
|
-
raise errors.Unauthorized(
|
|
237
|
+
response_data = unmarshal_json_response(errors.UnauthorizedData, http_res)
|
|
238
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
251
239
|
if utils.match_response(http_res, "403", "application/json"):
|
|
252
|
-
response_data =
|
|
253
|
-
raise errors.Forbidden(
|
|
240
|
+
response_data = unmarshal_json_response(errors.ForbiddenData, http_res)
|
|
241
|
+
raise errors.Forbidden(response_data, http_res)
|
|
254
242
|
if utils.match_response(http_res, "404", "application/json"):
|
|
255
|
-
response_data =
|
|
256
|
-
raise errors.NotFound(
|
|
243
|
+
response_data = unmarshal_json_response(errors.NotFoundData, http_res)
|
|
244
|
+
raise errors.NotFound(response_data, http_res)
|
|
257
245
|
if utils.match_response(http_res, "409", "application/json"):
|
|
258
|
-
response_data =
|
|
259
|
-
raise errors.Conflict(
|
|
246
|
+
response_data = unmarshal_json_response(errors.ConflictData, http_res)
|
|
247
|
+
raise errors.Conflict(response_data, http_res)
|
|
260
248
|
if utils.match_response(http_res, "410", "application/json"):
|
|
261
|
-
response_data =
|
|
262
|
-
|
|
263
|
-
)
|
|
264
|
-
raise errors.InviteExpired(data=response_data)
|
|
249
|
+
response_data = unmarshal_json_response(errors.InviteExpiredData, http_res)
|
|
250
|
+
raise errors.InviteExpired(response_data, http_res)
|
|
265
251
|
if utils.match_response(http_res, "422", "application/json"):
|
|
266
|
-
response_data =
|
|
267
|
-
|
|
252
|
+
response_data = unmarshal_json_response(
|
|
253
|
+
errors.UnprocessableEntityData, http_res
|
|
268
254
|
)
|
|
269
|
-
raise errors.UnprocessableEntity(
|
|
255
|
+
raise errors.UnprocessableEntity(response_data, http_res)
|
|
270
256
|
if utils.match_response(http_res, "429", "application/json"):
|
|
271
|
-
response_data =
|
|
272
|
-
|
|
257
|
+
response_data = unmarshal_json_response(
|
|
258
|
+
errors.RateLimitExceededData, http_res
|
|
273
259
|
)
|
|
274
|
-
raise errors.RateLimitExceeded(
|
|
260
|
+
raise errors.RateLimitExceeded(response_data, http_res)
|
|
275
261
|
if utils.match_response(http_res, "500", "application/json"):
|
|
276
|
-
response_data =
|
|
277
|
-
|
|
262
|
+
response_data = unmarshal_json_response(
|
|
263
|
+
errors.InternalServerErrorData, http_res
|
|
278
264
|
)
|
|
279
|
-
raise errors.InternalServerError(
|
|
265
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
280
266
|
if utils.match_response(http_res, "4XX", "*"):
|
|
281
267
|
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
|
-
)
|
|
268
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
285
269
|
if utils.match_response(http_res, "5XX", "*"):
|
|
286
270
|
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
|
-
)
|
|
271
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
290
272
|
|
|
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
|
-
)
|
|
273
|
+
raise errors.SDKError("Unexpected response received", http_res)
|
|
299
274
|
|
|
300
275
|
def update(
|
|
301
276
|
self,
|
|
@@ -398,63 +373,50 @@ class Workspaces(BaseSDK):
|
|
|
398
373
|
|
|
399
374
|
response_data: Any = None
|
|
400
375
|
if utils.match_response(http_res, "200", "application/json"):
|
|
401
|
-
return
|
|
402
|
-
|
|
376
|
+
return unmarshal_json_response(
|
|
377
|
+
Optional[components.WorkspaceSchema], http_res
|
|
403
378
|
)
|
|
404
379
|
if utils.match_response(http_res, "400", "application/json"):
|
|
405
|
-
response_data =
|
|
406
|
-
raise errors.BadRequest(
|
|
380
|
+
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
381
|
+
raise errors.BadRequest(response_data, http_res)
|
|
407
382
|
if utils.match_response(http_res, "401", "application/json"):
|
|
408
|
-
response_data =
|
|
409
|
-
raise errors.Unauthorized(
|
|
383
|
+
response_data = unmarshal_json_response(errors.UnauthorizedData, http_res)
|
|
384
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
410
385
|
if utils.match_response(http_res, "403", "application/json"):
|
|
411
|
-
response_data =
|
|
412
|
-
raise errors.Forbidden(
|
|
386
|
+
response_data = unmarshal_json_response(errors.ForbiddenData, http_res)
|
|
387
|
+
raise errors.Forbidden(response_data, http_res)
|
|
413
388
|
if utils.match_response(http_res, "404", "application/json"):
|
|
414
|
-
response_data =
|
|
415
|
-
raise errors.NotFound(
|
|
389
|
+
response_data = unmarshal_json_response(errors.NotFoundData, http_res)
|
|
390
|
+
raise errors.NotFound(response_data, http_res)
|
|
416
391
|
if utils.match_response(http_res, "409", "application/json"):
|
|
417
|
-
response_data =
|
|
418
|
-
raise errors.Conflict(
|
|
392
|
+
response_data = unmarshal_json_response(errors.ConflictData, http_res)
|
|
393
|
+
raise errors.Conflict(response_data, http_res)
|
|
419
394
|
if utils.match_response(http_res, "410", "application/json"):
|
|
420
|
-
response_data =
|
|
421
|
-
|
|
422
|
-
)
|
|
423
|
-
raise errors.InviteExpired(data=response_data)
|
|
395
|
+
response_data = unmarshal_json_response(errors.InviteExpiredData, http_res)
|
|
396
|
+
raise errors.InviteExpired(response_data, http_res)
|
|
424
397
|
if utils.match_response(http_res, "422", "application/json"):
|
|
425
|
-
response_data =
|
|
426
|
-
|
|
398
|
+
response_data = unmarshal_json_response(
|
|
399
|
+
errors.UnprocessableEntityData, http_res
|
|
427
400
|
)
|
|
428
|
-
raise errors.UnprocessableEntity(
|
|
401
|
+
raise errors.UnprocessableEntity(response_data, http_res)
|
|
429
402
|
if utils.match_response(http_res, "429", "application/json"):
|
|
430
|
-
response_data =
|
|
431
|
-
|
|
403
|
+
response_data = unmarshal_json_response(
|
|
404
|
+
errors.RateLimitExceededData, http_res
|
|
432
405
|
)
|
|
433
|
-
raise errors.RateLimitExceeded(
|
|
406
|
+
raise errors.RateLimitExceeded(response_data, http_res)
|
|
434
407
|
if utils.match_response(http_res, "500", "application/json"):
|
|
435
|
-
response_data =
|
|
436
|
-
|
|
408
|
+
response_data = unmarshal_json_response(
|
|
409
|
+
errors.InternalServerErrorData, http_res
|
|
437
410
|
)
|
|
438
|
-
raise errors.InternalServerError(
|
|
411
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
439
412
|
if utils.match_response(http_res, "4XX", "*"):
|
|
440
413
|
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
|
-
)
|
|
414
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
444
415
|
if utils.match_response(http_res, "5XX", "*"):
|
|
445
416
|
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
|
-
)
|
|
417
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
449
418
|
|
|
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
|
-
)
|
|
419
|
+
raise errors.SDKError("Unexpected response received", http_res)
|
|
458
420
|
|
|
459
421
|
async def update_async(
|
|
460
422
|
self,
|
|
@@ -557,60 +519,47 @@ class Workspaces(BaseSDK):
|
|
|
557
519
|
|
|
558
520
|
response_data: Any = None
|
|
559
521
|
if utils.match_response(http_res, "200", "application/json"):
|
|
560
|
-
return
|
|
561
|
-
|
|
522
|
+
return unmarshal_json_response(
|
|
523
|
+
Optional[components.WorkspaceSchema], http_res
|
|
562
524
|
)
|
|
563
525
|
if utils.match_response(http_res, "400", "application/json"):
|
|
564
|
-
response_data =
|
|
565
|
-
raise errors.BadRequest(
|
|
526
|
+
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
527
|
+
raise errors.BadRequest(response_data, http_res)
|
|
566
528
|
if utils.match_response(http_res, "401", "application/json"):
|
|
567
|
-
response_data =
|
|
568
|
-
raise errors.Unauthorized(
|
|
529
|
+
response_data = unmarshal_json_response(errors.UnauthorizedData, http_res)
|
|
530
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
569
531
|
if utils.match_response(http_res, "403", "application/json"):
|
|
570
|
-
response_data =
|
|
571
|
-
raise errors.Forbidden(
|
|
532
|
+
response_data = unmarshal_json_response(errors.ForbiddenData, http_res)
|
|
533
|
+
raise errors.Forbidden(response_data, http_res)
|
|
572
534
|
if utils.match_response(http_res, "404", "application/json"):
|
|
573
|
-
response_data =
|
|
574
|
-
raise errors.NotFound(
|
|
535
|
+
response_data = unmarshal_json_response(errors.NotFoundData, http_res)
|
|
536
|
+
raise errors.NotFound(response_data, http_res)
|
|
575
537
|
if utils.match_response(http_res, "409", "application/json"):
|
|
576
|
-
response_data =
|
|
577
|
-
raise errors.Conflict(
|
|
538
|
+
response_data = unmarshal_json_response(errors.ConflictData, http_res)
|
|
539
|
+
raise errors.Conflict(response_data, http_res)
|
|
578
540
|
if utils.match_response(http_res, "410", "application/json"):
|
|
579
|
-
response_data =
|
|
580
|
-
|
|
581
|
-
)
|
|
582
|
-
raise errors.InviteExpired(data=response_data)
|
|
541
|
+
response_data = unmarshal_json_response(errors.InviteExpiredData, http_res)
|
|
542
|
+
raise errors.InviteExpired(response_data, http_res)
|
|
583
543
|
if utils.match_response(http_res, "422", "application/json"):
|
|
584
|
-
response_data =
|
|
585
|
-
|
|
544
|
+
response_data = unmarshal_json_response(
|
|
545
|
+
errors.UnprocessableEntityData, http_res
|
|
586
546
|
)
|
|
587
|
-
raise errors.UnprocessableEntity(
|
|
547
|
+
raise errors.UnprocessableEntity(response_data, http_res)
|
|
588
548
|
if utils.match_response(http_res, "429", "application/json"):
|
|
589
|
-
response_data =
|
|
590
|
-
|
|
549
|
+
response_data = unmarshal_json_response(
|
|
550
|
+
errors.RateLimitExceededData, http_res
|
|
591
551
|
)
|
|
592
|
-
raise errors.RateLimitExceeded(
|
|
552
|
+
raise errors.RateLimitExceeded(response_data, http_res)
|
|
593
553
|
if utils.match_response(http_res, "500", "application/json"):
|
|
594
|
-
response_data =
|
|
595
|
-
|
|
554
|
+
response_data = unmarshal_json_response(
|
|
555
|
+
errors.InternalServerErrorData, http_res
|
|
596
556
|
)
|
|
597
|
-
raise errors.InternalServerError(
|
|
557
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
598
558
|
if utils.match_response(http_res, "4XX", "*"):
|
|
599
559
|
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
|
-
)
|
|
560
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
603
561
|
if utils.match_response(http_res, "5XX", "*"):
|
|
604
562
|
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
|
-
)
|
|
563
|
+
raise errors.SDKError("API error occurred", http_res, http_res_text)
|
|
608
564
|
|
|
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
|
-
)
|
|
565
|
+
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.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] -->
|