Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit81fdaa4

Browse files
Handle throttled responses (#137)
Handle responses with the `429 Too Many Requests`status code.---------Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>Co-authored-by: Jay Vercellone <jay@pipedream.com>
1 parent4166610 commit81fdaa4

File tree

19 files changed

+896
-6
lines changed

19 files changed

+896
-6
lines changed

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ from pipedream import Pipedream
175175
client= Pipedream(
176176
...,
177177
httpx_client=httpx.Client(
178-
proxies="http://my.test.proxy.example.com",
178+
proxy="http://my.test.proxy.example.com",
179179
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
180180
),
181181
)

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "pipedream"
33

44
[tool.poetry]
55
name ="pipedream"
6-
version ="1.0.6"
6+
version ="1.0.7"
77
description =""
88
readme ="README.md"
99
authors = []

‎src/pipedream/accounts/raw_client.py‎

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from ..core.paginationimportAsyncPager,BaseHttpResponse,SyncPager
1111
from ..core.pydantic_utilitiesimportparse_obj_as
1212
from ..core.request_optionsimportRequestOptions
13+
from ..errors.too_many_requests_errorimportTooManyRequestsError
1314
from ..types.accountimportAccount
1415
from ..types.list_accounts_responseimportListAccountsResponse
1516

@@ -108,6 +109,17 @@ def list(
108109
returnSyncPager(
109110
has_next=_has_next,items=_items,get_next=_get_next,response=BaseHttpResponse(response=_response)
110111
)
112+
if_response.status_code==429:
113+
raiseTooManyRequestsError(
114+
headers=dict(_response.headers),
115+
body=typing.cast(
116+
typing.Optional[typing.Any],
117+
parse_obj_as(
118+
type_=typing.Optional[typing.Any],# type: ignore
119+
object_=_response.json(),
120+
),
121+
),
122+
)
111123
_response_json=_response.json()
112124
exceptJSONDecodeError:
113125
raiseApiError(status_code=_response.status_code,headers=dict(_response.headers),body=_response.text)
@@ -188,6 +200,17 @@ def create(
188200
),
189201
)
190202
returnHttpResponse(response=_response,data=_data)
203+
if_response.status_code==429:
204+
raiseTooManyRequestsError(
205+
headers=dict(_response.headers),
206+
body=typing.cast(
207+
typing.Optional[typing.Any],
208+
parse_obj_as(
209+
type_=typing.Optional[typing.Any],# type: ignore
210+
object_=_response.json(),
211+
),
212+
),
213+
)
191214
_response_json=_response.json()
192215
exceptJSONDecodeError:
193216
raiseApiError(status_code=_response.status_code,headers=dict(_response.headers),body=_response.text)
@@ -236,6 +259,17 @@ def retrieve(
236259
),
237260
)
238261
returnHttpResponse(response=_response,data=_data)
262+
if_response.status_code==429:
263+
raiseTooManyRequestsError(
264+
headers=dict(_response.headers),
265+
body=typing.cast(
266+
typing.Optional[typing.Any],
267+
parse_obj_as(
268+
type_=typing.Optional[typing.Any],# type: ignore
269+
object_=_response.json(),
270+
),
271+
),
272+
)
239273
_response_json=_response.json()
240274
exceptJSONDecodeError:
241275
raiseApiError(status_code=_response.status_code,headers=dict(_response.headers),body=_response.text)
@@ -264,6 +298,17 @@ def delete(self, account_id: str, *, request_options: typing.Optional[RequestOpt
264298
try:
265299
if200<=_response.status_code<300:
266300
returnHttpResponse(response=_response,data=None)
301+
if_response.status_code==429:
302+
raiseTooManyRequestsError(
303+
headers=dict(_response.headers),
304+
body=typing.cast(
305+
typing.Optional[typing.Any],
306+
parse_obj_as(
307+
type_=typing.Optional[typing.Any],# type: ignore
308+
object_=_response.json(),
309+
),
310+
),
311+
)
267312
_response_json=_response.json()
268313
exceptJSONDecodeError:
269314
raiseApiError(status_code=_response.status_code,headers=dict(_response.headers),body=_response.text)
@@ -294,6 +339,17 @@ def delete_by_app(
294339
try:
295340
if200<=_response.status_code<300:
296341
returnHttpResponse(response=_response,data=None)
342+
if_response.status_code==429:
343+
raiseTooManyRequestsError(
344+
headers=dict(_response.headers),
345+
body=typing.cast(
346+
typing.Optional[typing.Any],
347+
parse_obj_as(
348+
type_=typing.Optional[typing.Any],# type: ignore
349+
object_=_response.json(),
350+
),
351+
),
352+
)
297353
_response_json=_response.json()
298354
exceptJSONDecodeError:
299355
raiseApiError(status_code=_response.status_code,headers=dict(_response.headers),body=_response.text)
@@ -394,6 +450,17 @@ async def _get_next():
394450
returnAsyncPager(
395451
has_next=_has_next,items=_items,get_next=_get_next,response=BaseHttpResponse(response=_response)
396452
)
453+
if_response.status_code==429:
454+
raiseTooManyRequestsError(
455+
headers=dict(_response.headers),
456+
body=typing.cast(
457+
typing.Optional[typing.Any],
458+
parse_obj_as(
459+
type_=typing.Optional[typing.Any],# type: ignore
460+
object_=_response.json(),
461+
),
462+
),
463+
)
397464
_response_json=_response.json()
398465
exceptJSONDecodeError:
399466
raiseApiError(status_code=_response.status_code,headers=dict(_response.headers),body=_response.text)
@@ -474,6 +541,17 @@ async def create(
474541
),
475542
)
476543
returnAsyncHttpResponse(response=_response,data=_data)
544+
if_response.status_code==429:
545+
raiseTooManyRequestsError(
546+
headers=dict(_response.headers),
547+
body=typing.cast(
548+
typing.Optional[typing.Any],
549+
parse_obj_as(
550+
type_=typing.Optional[typing.Any],# type: ignore
551+
object_=_response.json(),
552+
),
553+
),
554+
)
477555
_response_json=_response.json()
478556
exceptJSONDecodeError:
479557
raiseApiError(status_code=_response.status_code,headers=dict(_response.headers),body=_response.text)
@@ -522,6 +600,17 @@ async def retrieve(
522600
),
523601
)
524602
returnAsyncHttpResponse(response=_response,data=_data)
603+
if_response.status_code==429:
604+
raiseTooManyRequestsError(
605+
headers=dict(_response.headers),
606+
body=typing.cast(
607+
typing.Optional[typing.Any],
608+
parse_obj_as(
609+
type_=typing.Optional[typing.Any],# type: ignore
610+
object_=_response.json(),
611+
),
612+
),
613+
)
525614
_response_json=_response.json()
526615
exceptJSONDecodeError:
527616
raiseApiError(status_code=_response.status_code,headers=dict(_response.headers),body=_response.text)
@@ -552,6 +641,17 @@ async def delete(
552641
try:
553642
if200<=_response.status_code<300:
554643
returnAsyncHttpResponse(response=_response,data=None)
644+
if_response.status_code==429:
645+
raiseTooManyRequestsError(
646+
headers=dict(_response.headers),
647+
body=typing.cast(
648+
typing.Optional[typing.Any],
649+
parse_obj_as(
650+
type_=typing.Optional[typing.Any],# type: ignore
651+
object_=_response.json(),
652+
),
653+
),
654+
)
555655
_response_json=_response.json()
556656
exceptJSONDecodeError:
557657
raiseApiError(status_code=_response.status_code,headers=dict(_response.headers),body=_response.text)
@@ -582,6 +682,17 @@ async def delete_by_app(
582682
try:
583683
if200<=_response.status_code<300:
584684
returnAsyncHttpResponse(response=_response,data=None)
685+
if_response.status_code==429:
686+
raiseTooManyRequestsError(
687+
headers=dict(_response.headers),
688+
body=typing.cast(
689+
typing.Optional[typing.Any],
690+
parse_obj_as(
691+
type_=typing.Optional[typing.Any],# type: ignore
692+
object_=_response.json(),
693+
),
694+
),
695+
)
585696
_response_json=_response.json()
586697
exceptJSONDecodeError:
587698
raiseApiError(status_code=_response.status_code,headers=dict(_response.headers),body=_response.text)

‎src/pipedream/actions/raw_client.py‎

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from ..core.pydantic_utilitiesimportparse_obj_as
1212
from ..core.request_optionsimportRequestOptions
1313
from ..core.serializationimportconvert_and_respect_annotation_metadata
14+
from ..errors.too_many_requests_errorimportTooManyRequestsError
1415
from ..types.componentimportComponent
1516
from ..types.configure_prop_responseimportConfigurePropResponse
1617
from ..types.configured_propsimportConfiguredProps
@@ -104,6 +105,17 @@ def list(
104105
returnSyncPager(
105106
has_next=_has_next,items=_items,get_next=_get_next,response=BaseHttpResponse(response=_response)
106107
)
108+
if_response.status_code==429:
109+
raiseTooManyRequestsError(
110+
headers=dict(_response.headers),
111+
body=typing.cast(
112+
typing.Optional[typing.Any],
113+
parse_obj_as(
114+
type_=typing.Optional[typing.Any],# type: ignore
115+
object_=_response.json(),
116+
),
117+
),
118+
)
107119
_response_json=_response.json()
108120
exceptJSONDecodeError:
109121
raiseApiError(status_code=_response.status_code,headers=dict(_response.headers),body=_response.text)
@@ -144,6 +156,17 @@ def retrieve(
144156
)
145157
_data=_parsed_response.data
146158
returnHttpResponse(response=_response,data=_data)
159+
if_response.status_code==429:
160+
raiseTooManyRequestsError(
161+
headers=dict(_response.headers),
162+
body=typing.cast(
163+
typing.Optional[typing.Any],
164+
parse_obj_as(
165+
type_=typing.Optional[typing.Any],# type: ignore
166+
object_=_response.json(),
167+
),
168+
),
169+
)
147170
_response_json=_response.json()
148171
exceptJSONDecodeError:
149172
raiseApiError(status_code=_response.status_code,headers=dict(_response.headers),body=_response.text)
@@ -234,6 +257,17 @@ def configure_prop(
234257
),
235258
)
236259
returnHttpResponse(response=_response,data=_data)
260+
if_response.status_code==429:
261+
raiseTooManyRequestsError(
262+
headers=dict(_response.headers),
263+
body=typing.cast(
264+
typing.Optional[typing.Any],
265+
parse_obj_as(
266+
type_=typing.Optional[typing.Any],# type: ignore
267+
object_=_response.json(),
268+
),
269+
),
270+
)
237271
_response_json=_response.json()
238272
exceptJSONDecodeError:
239273
raiseApiError(status_code=_response.status_code,headers=dict(_response.headers),body=_response.text)
@@ -304,6 +338,17 @@ def reload_props(
304338
),
305339
)
306340
returnHttpResponse(response=_response,data=_data)
341+
if_response.status_code==429:
342+
raiseTooManyRequestsError(
343+
headers=dict(_response.headers),
344+
body=typing.cast(
345+
typing.Optional[typing.Any],
346+
parse_obj_as(
347+
type_=typing.Optional[typing.Any],# type: ignore
348+
object_=_response.json(),
349+
),
350+
),
351+
)
307352
_response_json=_response.json()
308353
exceptJSONDecodeError:
309354
raiseApiError(status_code=_response.status_code,headers=dict(_response.headers),body=_response.text)
@@ -375,6 +420,17 @@ def run(
375420
),
376421
)
377422
returnHttpResponse(response=_response,data=_data)
423+
if_response.status_code==429:
424+
raiseTooManyRequestsError(
425+
headers=dict(_response.headers),
426+
body=typing.cast(
427+
typing.Optional[typing.Any],
428+
parse_obj_as(
429+
type_=typing.Optional[typing.Any],# type: ignore
430+
object_=_response.json(),
431+
),
432+
),
433+
)
378434
_response_json=_response.json()
379435
exceptJSONDecodeError:
380436
raiseApiError(status_code=_response.status_code,headers=dict(_response.headers),body=_response.text)
@@ -464,6 +520,17 @@ async def _get_next():
464520
returnAsyncPager(
465521
has_next=_has_next,items=_items,get_next=_get_next,response=BaseHttpResponse(response=_response)
466522
)
523+
if_response.status_code==429:
524+
raiseTooManyRequestsError(
525+
headers=dict(_response.headers),
526+
body=typing.cast(
527+
typing.Optional[typing.Any],
528+
parse_obj_as(
529+
type_=typing.Optional[typing.Any],# type: ignore
530+
object_=_response.json(),
531+
),
532+
),
533+
)
467534
_response_json=_response.json()
468535
exceptJSONDecodeError:
469536
raiseApiError(status_code=_response.status_code,headers=dict(_response.headers),body=_response.text)
@@ -504,6 +571,17 @@ async def retrieve(
504571
)
505572
_data=_parsed_response.data
506573
returnAsyncHttpResponse(response=_response,data=_data)
574+
if_response.status_code==429:
575+
raiseTooManyRequestsError(
576+
headers=dict(_response.headers),
577+
body=typing.cast(
578+
typing.Optional[typing.Any],
579+
parse_obj_as(
580+
type_=typing.Optional[typing.Any],# type: ignore
581+
object_=_response.json(),
582+
),
583+
),
584+
)
507585
_response_json=_response.json()
508586
exceptJSONDecodeError:
509587
raiseApiError(status_code=_response.status_code,headers=dict(_response.headers),body=_response.text)
@@ -594,6 +672,17 @@ async def configure_prop(
594672
),
595673
)
596674
returnAsyncHttpResponse(response=_response,data=_data)
675+
if_response.status_code==429:
676+
raiseTooManyRequestsError(
677+
headers=dict(_response.headers),
678+
body=typing.cast(
679+
typing.Optional[typing.Any],
680+
parse_obj_as(
681+
type_=typing.Optional[typing.Any],# type: ignore
682+
object_=_response.json(),
683+
),
684+
),
685+
)
597686
_response_json=_response.json()
598687
exceptJSONDecodeError:
599688
raiseApiError(status_code=_response.status_code,headers=dict(_response.headers),body=_response.text)
@@ -664,6 +753,17 @@ async def reload_props(
664753
),
665754
)
666755
returnAsyncHttpResponse(response=_response,data=_data)
756+
if_response.status_code==429:
757+
raiseTooManyRequestsError(
758+
headers=dict(_response.headers),
759+
body=typing.cast(
760+
typing.Optional[typing.Any],
761+
parse_obj_as(
762+
type_=typing.Optional[typing.Any],# type: ignore
763+
object_=_response.json(),
764+
),
765+
),
766+
)
667767
_response_json=_response.json()
668768
exceptJSONDecodeError:
669769
raiseApiError(status_code=_response.status_code,headers=dict(_response.headers),body=_response.text)
@@ -735,6 +835,17 @@ async def run(
735835
),
736836
)
737837
returnAsyncHttpResponse(response=_response,data=_data)
838+
if_response.status_code==429:
839+
raiseTooManyRequestsError(
840+
headers=dict(_response.headers),
841+
body=typing.cast(
842+
typing.Optional[typing.Any],
843+
parse_obj_as(
844+
type_=typing.Optional[typing.Any],# type: ignore
845+
object_=_response.json(),
846+
),
847+
),
848+
)
738849
_response_json=_response.json()
739850
exceptJSONDecodeError:
740851
raiseApiError(status_code=_response.status_code,headers=dict(_response.headers),body=_response.text)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp