dub 0.31.0__py3-none-any.whl → 0.33.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 +6 -6
- dub/commissions.py +12 -12
- dub/customers.py +24 -321
- dub/domains.py +34 -38
- dub/embed_tokens.py +6 -6
- dub/events.py +6 -6
- dub/folders.py +24 -28
- dub/links.py +58 -74
- dub/models/components/__init__.py +38 -6
- dub/models/components/analyticstopurls.py +2 -2
- dub/models/components/clickevent.py +10 -9
- dub/models/components/commissioncreatedevent.py +5 -2
- dub/models/components/folderschema.py +6 -1
- dub/models/components/leadcreatedevent.py +15 -11
- dub/models/components/leadevent.py +10 -9
- dub/models/components/linkclickedevent.py +10 -9
- dub/models/components/linkschema.py +9 -3
- dub/models/components/{tagschema.py → linktagschema.py} +2 -2
- dub/models/components/linkwebhookevent.py +10 -9
- dub/models/components/partnerapplicationsubmittedevent.py +269 -0
- dub/models/components/partnerenrolledevent.py +93 -29
- dub/models/components/salecreatedevent.py +15 -11
- dub/models/components/saleevent.py +10 -9
- dub/models/components/webhookevent.py +6 -0
- dub/models/components/workspaceschema.py +11 -0
- dub/models/errors/badrequest.py +1 -1
- dub/models/errors/conflict.py +1 -1
- dub/models/errors/duberror.py +1 -1
- dub/models/errors/forbidden.py +1 -1
- dub/models/errors/internalservererror.py +1 -1
- dub/models/errors/inviteexpired.py +1 -1
- dub/models/errors/no_response_error.py +1 -1
- dub/models/errors/notfound.py +1 -1
- dub/models/errors/ratelimitexceeded.py +1 -1
- dub/models/errors/responsevalidationerror.py +1 -1
- dub/models/errors/sdkerror.py +1 -1
- dub/models/errors/unauthorized.py +1 -1
- dub/models/errors/unprocessableentity.py +1 -1
- dub/models/operations/__init__.py +17 -35
- dub/models/operations/banpartner.py +83 -0
- dub/models/operations/bulkcreatelinks.py +2 -2
- dub/models/operations/createfolder.py +8 -3
- dub/models/operations/createlink.py +2 -2
- dub/models/operations/createpartner.py +93 -29
- dub/models/operations/listcommissions.py +13 -2
- dub/models/operations/listevents.py +10 -0
- dub/models/operations/listpartners.py +107 -47
- dub/models/operations/retrieveanalytics.py +16 -1
- dub/models/operations/retrievelinks.py +42 -7
- dub/models/operations/retrievepartneranalytics.py +51 -11
- dub/models/operations/tracklead.py +2 -2
- dub/models/operations/updatecommission.py +7 -2
- dub/models/operations/updatefolder.py +8 -3
- dub/models/operations/updatelink.py +2 -2
- dub/models/operations/upsertlink.py +2 -2
- dub/partners.py +310 -36
- dub/qr_codes.py +4 -4
- dub/tags.py +24 -32
- dub/track.py +12 -20
- dub/utils/retries.py +69 -5
- dub/utils/unmarshal_json_response.py +15 -1
- dub/workspaces.py +12 -20
- {dub-0.31.0.dist-info → dub-0.33.0.dist-info}/METADATA +2 -21
- {dub-0.31.0.dist-info → dub-0.33.0.dist-info}/RECORD +67 -66
- dub/models/operations/createcustomer.py +0 -382
- {dub-0.31.0.dist-info → dub-0.33.0.dist-info}/WHEEL +0 -0
- {dub-0.31.0.dist-info → dub-0.33.0.dist-info}/licenses/LICENSE +0 -0
dub/tags.py
CHANGED
|
@@ -23,7 +23,7 @@ class Tags(BaseSDK):
|
|
|
23
23
|
server_url: Optional[str] = None,
|
|
24
24
|
timeout_ms: Optional[int] = None,
|
|
25
25
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
26
|
-
) ->
|
|
26
|
+
) -> components.LinkTagSchema:
|
|
27
27
|
r"""Create a tag
|
|
28
28
|
|
|
29
29
|
Create a tag for the authenticated workspace.
|
|
@@ -82,7 +82,7 @@ class Tags(BaseSDK):
|
|
|
82
82
|
config=self.sdk_configuration,
|
|
83
83
|
base_url=base_url or "",
|
|
84
84
|
operation_id="createTag",
|
|
85
|
-
oauth2_scopes=
|
|
85
|
+
oauth2_scopes=None,
|
|
86
86
|
security_source=self.sdk_configuration.security,
|
|
87
87
|
),
|
|
88
88
|
request=req,
|
|
@@ -104,7 +104,7 @@ class Tags(BaseSDK):
|
|
|
104
104
|
|
|
105
105
|
response_data: Any = None
|
|
106
106
|
if utils.match_response(http_res, "201", "application/json"):
|
|
107
|
-
return unmarshal_json_response(
|
|
107
|
+
return unmarshal_json_response(components.LinkTagSchema, http_res)
|
|
108
108
|
if utils.match_response(http_res, "400", "application/json"):
|
|
109
109
|
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
110
110
|
raise errors.BadRequest(response_data, http_res)
|
|
@@ -160,7 +160,7 @@ class Tags(BaseSDK):
|
|
|
160
160
|
server_url: Optional[str] = None,
|
|
161
161
|
timeout_ms: Optional[int] = None,
|
|
162
162
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
163
|
-
) ->
|
|
163
|
+
) -> components.LinkTagSchema:
|
|
164
164
|
r"""Create a tag
|
|
165
165
|
|
|
166
166
|
Create a tag for the authenticated workspace.
|
|
@@ -219,7 +219,7 @@ class Tags(BaseSDK):
|
|
|
219
219
|
config=self.sdk_configuration,
|
|
220
220
|
base_url=base_url or "",
|
|
221
221
|
operation_id="createTag",
|
|
222
|
-
oauth2_scopes=
|
|
222
|
+
oauth2_scopes=None,
|
|
223
223
|
security_source=self.sdk_configuration.security,
|
|
224
224
|
),
|
|
225
225
|
request=req,
|
|
@@ -241,7 +241,7 @@ class Tags(BaseSDK):
|
|
|
241
241
|
|
|
242
242
|
response_data: Any = None
|
|
243
243
|
if utils.match_response(http_res, "201", "application/json"):
|
|
244
|
-
return unmarshal_json_response(
|
|
244
|
+
return unmarshal_json_response(components.LinkTagSchema, http_res)
|
|
245
245
|
if utils.match_response(http_res, "400", "application/json"):
|
|
246
246
|
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
247
247
|
raise errors.BadRequest(response_data, http_res)
|
|
@@ -292,7 +292,7 @@ class Tags(BaseSDK):
|
|
|
292
292
|
server_url: Optional[str] = None,
|
|
293
293
|
timeout_ms: Optional[int] = None,
|
|
294
294
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
295
|
-
) ->
|
|
295
|
+
) -> List[components.LinkTagSchema]:
|
|
296
296
|
r"""Retrieve a list of tags
|
|
297
297
|
|
|
298
298
|
Retrieve a list of tags for the authenticated workspace.
|
|
@@ -346,7 +346,7 @@ class Tags(BaseSDK):
|
|
|
346
346
|
config=self.sdk_configuration,
|
|
347
347
|
base_url=base_url or "",
|
|
348
348
|
operation_id="getTags",
|
|
349
|
-
oauth2_scopes=
|
|
349
|
+
oauth2_scopes=None,
|
|
350
350
|
security_source=self.sdk_configuration.security,
|
|
351
351
|
),
|
|
352
352
|
request=req,
|
|
@@ -368,9 +368,7 @@ class Tags(BaseSDK):
|
|
|
368
368
|
|
|
369
369
|
response_data: Any = None
|
|
370
370
|
if utils.match_response(http_res, "200", "application/json"):
|
|
371
|
-
return unmarshal_json_response(
|
|
372
|
-
Optional[List[components.TagSchema]], http_res
|
|
373
|
-
)
|
|
371
|
+
return unmarshal_json_response(List[components.LinkTagSchema], http_res)
|
|
374
372
|
if utils.match_response(http_res, "400", "application/json"):
|
|
375
373
|
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
376
374
|
raise errors.BadRequest(response_data, http_res)
|
|
@@ -421,7 +419,7 @@ class Tags(BaseSDK):
|
|
|
421
419
|
server_url: Optional[str] = None,
|
|
422
420
|
timeout_ms: Optional[int] = None,
|
|
423
421
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
424
|
-
) ->
|
|
422
|
+
) -> List[components.LinkTagSchema]:
|
|
425
423
|
r"""Retrieve a list of tags
|
|
426
424
|
|
|
427
425
|
Retrieve a list of tags for the authenticated workspace.
|
|
@@ -475,7 +473,7 @@ class Tags(BaseSDK):
|
|
|
475
473
|
config=self.sdk_configuration,
|
|
476
474
|
base_url=base_url or "",
|
|
477
475
|
operation_id="getTags",
|
|
478
|
-
oauth2_scopes=
|
|
476
|
+
oauth2_scopes=None,
|
|
479
477
|
security_source=self.sdk_configuration.security,
|
|
480
478
|
),
|
|
481
479
|
request=req,
|
|
@@ -497,9 +495,7 @@ class Tags(BaseSDK):
|
|
|
497
495
|
|
|
498
496
|
response_data: Any = None
|
|
499
497
|
if utils.match_response(http_res, "200", "application/json"):
|
|
500
|
-
return unmarshal_json_response(
|
|
501
|
-
Optional[List[components.TagSchema]], http_res
|
|
502
|
-
)
|
|
498
|
+
return unmarshal_json_response(List[components.LinkTagSchema], http_res)
|
|
503
499
|
if utils.match_response(http_res, "400", "application/json"):
|
|
504
500
|
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
505
501
|
raise errors.BadRequest(response_data, http_res)
|
|
@@ -556,7 +552,7 @@ class Tags(BaseSDK):
|
|
|
556
552
|
server_url: Optional[str] = None,
|
|
557
553
|
timeout_ms: Optional[int] = None,
|
|
558
554
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
559
|
-
) ->
|
|
555
|
+
) -> components.LinkTagSchema:
|
|
560
556
|
r"""Update a tag
|
|
561
557
|
|
|
562
558
|
Update a tag in the workspace.
|
|
@@ -621,7 +617,7 @@ class Tags(BaseSDK):
|
|
|
621
617
|
config=self.sdk_configuration,
|
|
622
618
|
base_url=base_url or "",
|
|
623
619
|
operation_id="updateTag",
|
|
624
|
-
oauth2_scopes=
|
|
620
|
+
oauth2_scopes=None,
|
|
625
621
|
security_source=self.sdk_configuration.security,
|
|
626
622
|
),
|
|
627
623
|
request=req,
|
|
@@ -643,7 +639,7 @@ class Tags(BaseSDK):
|
|
|
643
639
|
|
|
644
640
|
response_data: Any = None
|
|
645
641
|
if utils.match_response(http_res, "200", "application/json"):
|
|
646
|
-
return unmarshal_json_response(
|
|
642
|
+
return unmarshal_json_response(components.LinkTagSchema, http_res)
|
|
647
643
|
if utils.match_response(http_res, "400", "application/json"):
|
|
648
644
|
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
649
645
|
raise errors.BadRequest(response_data, http_res)
|
|
@@ -700,7 +696,7 @@ class Tags(BaseSDK):
|
|
|
700
696
|
server_url: Optional[str] = None,
|
|
701
697
|
timeout_ms: Optional[int] = None,
|
|
702
698
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
703
|
-
) ->
|
|
699
|
+
) -> components.LinkTagSchema:
|
|
704
700
|
r"""Update a tag
|
|
705
701
|
|
|
706
702
|
Update a tag in the workspace.
|
|
@@ -765,7 +761,7 @@ class Tags(BaseSDK):
|
|
|
765
761
|
config=self.sdk_configuration,
|
|
766
762
|
base_url=base_url or "",
|
|
767
763
|
operation_id="updateTag",
|
|
768
|
-
oauth2_scopes=
|
|
764
|
+
oauth2_scopes=None,
|
|
769
765
|
security_source=self.sdk_configuration.security,
|
|
770
766
|
),
|
|
771
767
|
request=req,
|
|
@@ -787,7 +783,7 @@ class Tags(BaseSDK):
|
|
|
787
783
|
|
|
788
784
|
response_data: Any = None
|
|
789
785
|
if utils.match_response(http_res, "200", "application/json"):
|
|
790
|
-
return unmarshal_json_response(
|
|
786
|
+
return unmarshal_json_response(components.LinkTagSchema, http_res)
|
|
791
787
|
if utils.match_response(http_res, "400", "application/json"):
|
|
792
788
|
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
793
789
|
raise errors.BadRequest(response_data, http_res)
|
|
@@ -838,7 +834,7 @@ class Tags(BaseSDK):
|
|
|
838
834
|
server_url: Optional[str] = None,
|
|
839
835
|
timeout_ms: Optional[int] = None,
|
|
840
836
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
841
|
-
) ->
|
|
837
|
+
) -> operations.DeleteTagResponseBody:
|
|
842
838
|
r"""Delete a tag
|
|
843
839
|
|
|
844
840
|
Delete a tag from the workspace. All existing links will still work, but they will no longer be associated with this tag.
|
|
@@ -892,7 +888,7 @@ class Tags(BaseSDK):
|
|
|
892
888
|
config=self.sdk_configuration,
|
|
893
889
|
base_url=base_url or "",
|
|
894
890
|
operation_id="deleteTag",
|
|
895
|
-
oauth2_scopes=
|
|
891
|
+
oauth2_scopes=None,
|
|
896
892
|
security_source=self.sdk_configuration.security,
|
|
897
893
|
),
|
|
898
894
|
request=req,
|
|
@@ -914,9 +910,7 @@ class Tags(BaseSDK):
|
|
|
914
910
|
|
|
915
911
|
response_data: Any = None
|
|
916
912
|
if utils.match_response(http_res, "200", "application/json"):
|
|
917
|
-
return unmarshal_json_response(
|
|
918
|
-
Optional[operations.DeleteTagResponseBody], http_res
|
|
919
|
-
)
|
|
913
|
+
return unmarshal_json_response(operations.DeleteTagResponseBody, http_res)
|
|
920
914
|
if utils.match_response(http_res, "400", "application/json"):
|
|
921
915
|
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
922
916
|
raise errors.BadRequest(response_data, http_res)
|
|
@@ -967,7 +961,7 @@ class Tags(BaseSDK):
|
|
|
967
961
|
server_url: Optional[str] = None,
|
|
968
962
|
timeout_ms: Optional[int] = None,
|
|
969
963
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
970
|
-
) ->
|
|
964
|
+
) -> operations.DeleteTagResponseBody:
|
|
971
965
|
r"""Delete a tag
|
|
972
966
|
|
|
973
967
|
Delete a tag from the workspace. All existing links will still work, but they will no longer be associated with this tag.
|
|
@@ -1021,7 +1015,7 @@ class Tags(BaseSDK):
|
|
|
1021
1015
|
config=self.sdk_configuration,
|
|
1022
1016
|
base_url=base_url or "",
|
|
1023
1017
|
operation_id="deleteTag",
|
|
1024
|
-
oauth2_scopes=
|
|
1018
|
+
oauth2_scopes=None,
|
|
1025
1019
|
security_source=self.sdk_configuration.security,
|
|
1026
1020
|
),
|
|
1027
1021
|
request=req,
|
|
@@ -1043,9 +1037,7 @@ class Tags(BaseSDK):
|
|
|
1043
1037
|
|
|
1044
1038
|
response_data: Any = None
|
|
1045
1039
|
if utils.match_response(http_res, "200", "application/json"):
|
|
1046
|
-
return unmarshal_json_response(
|
|
1047
|
-
Optional[operations.DeleteTagResponseBody], http_res
|
|
1048
|
-
)
|
|
1040
|
+
return unmarshal_json_response(operations.DeleteTagResponseBody, http_res)
|
|
1049
1041
|
if utils.match_response(http_res, "400", "application/json"):
|
|
1050
1042
|
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
1051
1043
|
raise errors.BadRequest(response_data, http_res)
|
dub/track.py
CHANGED
|
@@ -23,7 +23,7 @@ class Track(BaseSDK):
|
|
|
23
23
|
server_url: Optional[str] = None,
|
|
24
24
|
timeout_ms: Optional[int] = None,
|
|
25
25
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
26
|
-
) ->
|
|
26
|
+
) -> operations.TrackLeadResponseBody:
|
|
27
27
|
r"""Track a lead
|
|
28
28
|
|
|
29
29
|
Track a lead for a short link.
|
|
@@ -82,7 +82,7 @@ class Track(BaseSDK):
|
|
|
82
82
|
config=self.sdk_configuration,
|
|
83
83
|
base_url=base_url or "",
|
|
84
84
|
operation_id="trackLead",
|
|
85
|
-
oauth2_scopes=
|
|
85
|
+
oauth2_scopes=None,
|
|
86
86
|
security_source=self.sdk_configuration.security,
|
|
87
87
|
),
|
|
88
88
|
request=req,
|
|
@@ -104,9 +104,7 @@ class Track(BaseSDK):
|
|
|
104
104
|
|
|
105
105
|
response_data: Any = None
|
|
106
106
|
if utils.match_response(http_res, "200", "application/json"):
|
|
107
|
-
return unmarshal_json_response(
|
|
108
|
-
Optional[operations.TrackLeadResponseBody], http_res
|
|
109
|
-
)
|
|
107
|
+
return unmarshal_json_response(operations.TrackLeadResponseBody, http_res)
|
|
110
108
|
if utils.match_response(http_res, "400", "application/json"):
|
|
111
109
|
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
112
110
|
raise errors.BadRequest(response_data, http_res)
|
|
@@ -162,7 +160,7 @@ class Track(BaseSDK):
|
|
|
162
160
|
server_url: Optional[str] = None,
|
|
163
161
|
timeout_ms: Optional[int] = None,
|
|
164
162
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
165
|
-
) ->
|
|
163
|
+
) -> operations.TrackLeadResponseBody:
|
|
166
164
|
r"""Track a lead
|
|
167
165
|
|
|
168
166
|
Track a lead for a short link.
|
|
@@ -221,7 +219,7 @@ class Track(BaseSDK):
|
|
|
221
219
|
config=self.sdk_configuration,
|
|
222
220
|
base_url=base_url or "",
|
|
223
221
|
operation_id="trackLead",
|
|
224
|
-
oauth2_scopes=
|
|
222
|
+
oauth2_scopes=None,
|
|
225
223
|
security_source=self.sdk_configuration.security,
|
|
226
224
|
),
|
|
227
225
|
request=req,
|
|
@@ -243,9 +241,7 @@ class Track(BaseSDK):
|
|
|
243
241
|
|
|
244
242
|
response_data: Any = None
|
|
245
243
|
if utils.match_response(http_res, "200", "application/json"):
|
|
246
|
-
return unmarshal_json_response(
|
|
247
|
-
Optional[operations.TrackLeadResponseBody], http_res
|
|
248
|
-
)
|
|
244
|
+
return unmarshal_json_response(operations.TrackLeadResponseBody, http_res)
|
|
249
245
|
if utils.match_response(http_res, "400", "application/json"):
|
|
250
246
|
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
251
247
|
raise errors.BadRequest(response_data, http_res)
|
|
@@ -301,7 +297,7 @@ class Track(BaseSDK):
|
|
|
301
297
|
server_url: Optional[str] = None,
|
|
302
298
|
timeout_ms: Optional[int] = None,
|
|
303
299
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
304
|
-
) ->
|
|
300
|
+
) -> operations.TrackSaleResponseBody:
|
|
305
301
|
r"""Track a sale
|
|
306
302
|
|
|
307
303
|
Track a sale for a short link.
|
|
@@ -360,7 +356,7 @@ class Track(BaseSDK):
|
|
|
360
356
|
config=self.sdk_configuration,
|
|
361
357
|
base_url=base_url or "",
|
|
362
358
|
operation_id="trackSale",
|
|
363
|
-
oauth2_scopes=
|
|
359
|
+
oauth2_scopes=None,
|
|
364
360
|
security_source=self.sdk_configuration.security,
|
|
365
361
|
),
|
|
366
362
|
request=req,
|
|
@@ -382,9 +378,7 @@ class Track(BaseSDK):
|
|
|
382
378
|
|
|
383
379
|
response_data: Any = None
|
|
384
380
|
if utils.match_response(http_res, "200", "application/json"):
|
|
385
|
-
return unmarshal_json_response(
|
|
386
|
-
Optional[operations.TrackSaleResponseBody], http_res
|
|
387
|
-
)
|
|
381
|
+
return unmarshal_json_response(operations.TrackSaleResponseBody, http_res)
|
|
388
382
|
if utils.match_response(http_res, "400", "application/json"):
|
|
389
383
|
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
390
384
|
raise errors.BadRequest(response_data, http_res)
|
|
@@ -440,7 +434,7 @@ class Track(BaseSDK):
|
|
|
440
434
|
server_url: Optional[str] = None,
|
|
441
435
|
timeout_ms: Optional[int] = None,
|
|
442
436
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
443
|
-
) ->
|
|
437
|
+
) -> operations.TrackSaleResponseBody:
|
|
444
438
|
r"""Track a sale
|
|
445
439
|
|
|
446
440
|
Track a sale for a short link.
|
|
@@ -499,7 +493,7 @@ class Track(BaseSDK):
|
|
|
499
493
|
config=self.sdk_configuration,
|
|
500
494
|
base_url=base_url or "",
|
|
501
495
|
operation_id="trackSale",
|
|
502
|
-
oauth2_scopes=
|
|
496
|
+
oauth2_scopes=None,
|
|
503
497
|
security_source=self.sdk_configuration.security,
|
|
504
498
|
),
|
|
505
499
|
request=req,
|
|
@@ -521,9 +515,7 @@ class Track(BaseSDK):
|
|
|
521
515
|
|
|
522
516
|
response_data: Any = None
|
|
523
517
|
if utils.match_response(http_res, "200", "application/json"):
|
|
524
|
-
return unmarshal_json_response(
|
|
525
|
-
Optional[operations.TrackSaleResponseBody], http_res
|
|
526
|
-
)
|
|
518
|
+
return unmarshal_json_response(operations.TrackSaleResponseBody, http_res)
|
|
527
519
|
if utils.match_response(http_res, "400", "application/json"):
|
|
528
520
|
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
529
521
|
raise errors.BadRequest(response_data, http_res)
|
dub/utils/retries.py
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
import asyncio
|
|
4
4
|
import random
|
|
5
5
|
import time
|
|
6
|
-
from
|
|
6
|
+
from datetime import datetime
|
|
7
|
+
from email.utils import parsedate_to_datetime
|
|
8
|
+
from typing import List, Optional
|
|
7
9
|
|
|
8
10
|
import httpx
|
|
9
11
|
|
|
@@ -51,9 +53,11 @@ class Retries:
|
|
|
51
53
|
|
|
52
54
|
class TemporaryError(Exception):
|
|
53
55
|
response: httpx.Response
|
|
56
|
+
retry_after: Optional[int]
|
|
54
57
|
|
|
55
58
|
def __init__(self, response: httpx.Response):
|
|
56
59
|
self.response = response
|
|
60
|
+
self.retry_after = _parse_retry_after_header(response)
|
|
57
61
|
|
|
58
62
|
|
|
59
63
|
class PermanentError(Exception):
|
|
@@ -63,6 +67,62 @@ class PermanentError(Exception):
|
|
|
63
67
|
self.inner = inner
|
|
64
68
|
|
|
65
69
|
|
|
70
|
+
def _parse_retry_after_header(response: httpx.Response) -> Optional[int]:
|
|
71
|
+
"""Parse Retry-After header from response.
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
Retry interval in milliseconds, or None if header is missing or invalid.
|
|
75
|
+
"""
|
|
76
|
+
retry_after_header = response.headers.get("retry-after")
|
|
77
|
+
if not retry_after_header:
|
|
78
|
+
return None
|
|
79
|
+
|
|
80
|
+
try:
|
|
81
|
+
seconds = float(retry_after_header)
|
|
82
|
+
return round(seconds * 1000)
|
|
83
|
+
except ValueError:
|
|
84
|
+
pass
|
|
85
|
+
|
|
86
|
+
try:
|
|
87
|
+
retry_date = parsedate_to_datetime(retry_after_header)
|
|
88
|
+
delta = (retry_date - datetime.now(retry_date.tzinfo)).total_seconds()
|
|
89
|
+
return round(max(0, delta) * 1000)
|
|
90
|
+
except (ValueError, TypeError):
|
|
91
|
+
pass
|
|
92
|
+
|
|
93
|
+
return None
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def _get_sleep_interval(
|
|
97
|
+
exception: Exception,
|
|
98
|
+
initial_interval: int,
|
|
99
|
+
max_interval: int,
|
|
100
|
+
exponent: float,
|
|
101
|
+
retries: int,
|
|
102
|
+
) -> float:
|
|
103
|
+
"""Get sleep interval for retry with exponential backoff.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
exception: The exception that triggered the retry.
|
|
107
|
+
initial_interval: Initial retry interval in milliseconds.
|
|
108
|
+
max_interval: Maximum retry interval in milliseconds.
|
|
109
|
+
exponent: Base for exponential backoff calculation.
|
|
110
|
+
retries: Current retry attempt count.
|
|
111
|
+
|
|
112
|
+
Returns:
|
|
113
|
+
Sleep interval in seconds.
|
|
114
|
+
"""
|
|
115
|
+
if (
|
|
116
|
+
isinstance(exception, TemporaryError)
|
|
117
|
+
and exception.retry_after is not None
|
|
118
|
+
and exception.retry_after > 0
|
|
119
|
+
):
|
|
120
|
+
return exception.retry_after / 1000
|
|
121
|
+
|
|
122
|
+
sleep = (initial_interval / 1000) * exponent**retries + random.uniform(0, 1)
|
|
123
|
+
return min(sleep, max_interval / 1000)
|
|
124
|
+
|
|
125
|
+
|
|
66
126
|
def retry(func, retries: Retries):
|
|
67
127
|
if retries.config.strategy == "backoff":
|
|
68
128
|
|
|
@@ -183,8 +243,10 @@ def retry_with_backoff(
|
|
|
183
243
|
return exception.response
|
|
184
244
|
|
|
185
245
|
raise
|
|
186
|
-
|
|
187
|
-
sleep =
|
|
246
|
+
|
|
247
|
+
sleep = _get_sleep_interval(
|
|
248
|
+
exception, initial_interval, max_interval, exponent, retries
|
|
249
|
+
)
|
|
188
250
|
time.sleep(sleep)
|
|
189
251
|
retries += 1
|
|
190
252
|
|
|
@@ -211,7 +273,9 @@ async def retry_with_backoff_async(
|
|
|
211
273
|
return exception.response
|
|
212
274
|
|
|
213
275
|
raise
|
|
214
|
-
|
|
215
|
-
sleep =
|
|
276
|
+
|
|
277
|
+
sleep = _get_sleep_interval(
|
|
278
|
+
exception, initial_interval, max_interval, exponent, retries
|
|
279
|
+
)
|
|
216
280
|
await asyncio.sleep(sleep)
|
|
217
281
|
retries += 1
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
|
-
from typing import Any, Optional
|
|
3
|
+
from typing import Any, Optional, Type, TypeVar, overload
|
|
4
4
|
|
|
5
5
|
import httpx
|
|
6
6
|
|
|
7
7
|
from .serializers import unmarshal_json
|
|
8
8
|
from dub.models import errors
|
|
9
9
|
|
|
10
|
+
T = TypeVar("T")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@overload
|
|
14
|
+
def unmarshal_json_response(
|
|
15
|
+
typ: Type[T], http_res: httpx.Response, body: Optional[str] = None
|
|
16
|
+
) -> T: ...
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@overload
|
|
20
|
+
def unmarshal_json_response(
|
|
21
|
+
typ: Any, http_res: httpx.Response, body: Optional[str] = None
|
|
22
|
+
) -> Any: ...
|
|
23
|
+
|
|
10
24
|
|
|
11
25
|
def unmarshal_json_response(
|
|
12
26
|
typ: Any, http_res: httpx.Response, body: Optional[str] = None
|
dub/workspaces.py
CHANGED
|
@@ -20,7 +20,7 @@ class Workspaces(BaseSDK):
|
|
|
20
20
|
server_url: Optional[str] = None,
|
|
21
21
|
timeout_ms: Optional[int] = None,
|
|
22
22
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
23
|
-
) ->
|
|
23
|
+
) -> components.WorkspaceSchema:
|
|
24
24
|
r"""Retrieve a workspace
|
|
25
25
|
|
|
26
26
|
Retrieve a workspace for the authenticated user.
|
|
@@ -74,7 +74,7 @@ class Workspaces(BaseSDK):
|
|
|
74
74
|
config=self.sdk_configuration,
|
|
75
75
|
base_url=base_url or "",
|
|
76
76
|
operation_id="getWorkspace",
|
|
77
|
-
oauth2_scopes=
|
|
77
|
+
oauth2_scopes=None,
|
|
78
78
|
security_source=self.sdk_configuration.security,
|
|
79
79
|
),
|
|
80
80
|
request=req,
|
|
@@ -96,9 +96,7 @@ class Workspaces(BaseSDK):
|
|
|
96
96
|
|
|
97
97
|
response_data: Any = None
|
|
98
98
|
if utils.match_response(http_res, "200", "application/json"):
|
|
99
|
-
return unmarshal_json_response(
|
|
100
|
-
Optional[components.WorkspaceSchema], http_res
|
|
101
|
-
)
|
|
99
|
+
return unmarshal_json_response(components.WorkspaceSchema, http_res)
|
|
102
100
|
if utils.match_response(http_res, "400", "application/json"):
|
|
103
101
|
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
104
102
|
raise errors.BadRequest(response_data, http_res)
|
|
@@ -151,7 +149,7 @@ class Workspaces(BaseSDK):
|
|
|
151
149
|
server_url: Optional[str] = None,
|
|
152
150
|
timeout_ms: Optional[int] = None,
|
|
153
151
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
154
|
-
) ->
|
|
152
|
+
) -> components.WorkspaceSchema:
|
|
155
153
|
r"""Retrieve a workspace
|
|
156
154
|
|
|
157
155
|
Retrieve a workspace for the authenticated user.
|
|
@@ -205,7 +203,7 @@ class Workspaces(BaseSDK):
|
|
|
205
203
|
config=self.sdk_configuration,
|
|
206
204
|
base_url=base_url or "",
|
|
207
205
|
operation_id="getWorkspace",
|
|
208
|
-
oauth2_scopes=
|
|
206
|
+
oauth2_scopes=None,
|
|
209
207
|
security_source=self.sdk_configuration.security,
|
|
210
208
|
),
|
|
211
209
|
request=req,
|
|
@@ -227,9 +225,7 @@ class Workspaces(BaseSDK):
|
|
|
227
225
|
|
|
228
226
|
response_data: Any = None
|
|
229
227
|
if utils.match_response(http_res, "200", "application/json"):
|
|
230
|
-
return unmarshal_json_response(
|
|
231
|
-
Optional[components.WorkspaceSchema], http_res
|
|
232
|
-
)
|
|
228
|
+
return unmarshal_json_response(components.WorkspaceSchema, http_res)
|
|
233
229
|
if utils.match_response(http_res, "400", "application/json"):
|
|
234
230
|
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
235
231
|
raise errors.BadRequest(response_data, http_res)
|
|
@@ -286,7 +282,7 @@ class Workspaces(BaseSDK):
|
|
|
286
282
|
server_url: Optional[str] = None,
|
|
287
283
|
timeout_ms: Optional[int] = None,
|
|
288
284
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
289
|
-
) ->
|
|
285
|
+
) -> components.WorkspaceSchema:
|
|
290
286
|
r"""Update a workspace
|
|
291
287
|
|
|
292
288
|
Update a workspace by ID or slug.
|
|
@@ -351,7 +347,7 @@ class Workspaces(BaseSDK):
|
|
|
351
347
|
config=self.sdk_configuration,
|
|
352
348
|
base_url=base_url or "",
|
|
353
349
|
operation_id="updateWorkspace",
|
|
354
|
-
oauth2_scopes=
|
|
350
|
+
oauth2_scopes=None,
|
|
355
351
|
security_source=self.sdk_configuration.security,
|
|
356
352
|
),
|
|
357
353
|
request=req,
|
|
@@ -373,9 +369,7 @@ class Workspaces(BaseSDK):
|
|
|
373
369
|
|
|
374
370
|
response_data: Any = None
|
|
375
371
|
if utils.match_response(http_res, "200", "application/json"):
|
|
376
|
-
return unmarshal_json_response(
|
|
377
|
-
Optional[components.WorkspaceSchema], http_res
|
|
378
|
-
)
|
|
372
|
+
return unmarshal_json_response(components.WorkspaceSchema, http_res)
|
|
379
373
|
if utils.match_response(http_res, "400", "application/json"):
|
|
380
374
|
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
381
375
|
raise errors.BadRequest(response_data, http_res)
|
|
@@ -432,7 +426,7 @@ class Workspaces(BaseSDK):
|
|
|
432
426
|
server_url: Optional[str] = None,
|
|
433
427
|
timeout_ms: Optional[int] = None,
|
|
434
428
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
435
|
-
) ->
|
|
429
|
+
) -> components.WorkspaceSchema:
|
|
436
430
|
r"""Update a workspace
|
|
437
431
|
|
|
438
432
|
Update a workspace by ID or slug.
|
|
@@ -497,7 +491,7 @@ class Workspaces(BaseSDK):
|
|
|
497
491
|
config=self.sdk_configuration,
|
|
498
492
|
base_url=base_url or "",
|
|
499
493
|
operation_id="updateWorkspace",
|
|
500
|
-
oauth2_scopes=
|
|
494
|
+
oauth2_scopes=None,
|
|
501
495
|
security_source=self.sdk_configuration.security,
|
|
502
496
|
),
|
|
503
497
|
request=req,
|
|
@@ -519,9 +513,7 @@ class Workspaces(BaseSDK):
|
|
|
519
513
|
|
|
520
514
|
response_data: Any = None
|
|
521
515
|
if utils.match_response(http_res, "200", "application/json"):
|
|
522
|
-
return unmarshal_json_response(
|
|
523
|
-
Optional[components.WorkspaceSchema], http_res
|
|
524
|
-
)
|
|
516
|
+
return unmarshal_json_response(components.WorkspaceSchema, http_res)
|
|
525
517
|
if utils.match_response(http_res, "400", "application/json"):
|
|
526
518
|
response_data = unmarshal_json_response(errors.BadRequestData, http_res)
|
|
527
519
|
raise errors.BadRequest(response_data, http_res)
|