Skip to content

Commit a463c33

Browse files
committed
SDK regeneration
1 parent 9f7c1f2 commit a463c33

File tree

5 files changed

+94
-61
lines changed

5 files changed

+94
-61
lines changed

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.8"
6+
version = "1.0.9"
77
description = ""
88
readme = "README.md"
99
authors = []

src/pipedream/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import typing
77

88
import httpx
9-
from .types.project_environment import ProjectEnvironment
9+
from ._.types.project_environment import ProjectEnvironment
1010
from .core.api_error import ApiError
1111
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
1212
from .core.oauth_token_provider import OAuthTokenProvider

src/pipedream/core/client_wrapper.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import typing
44

55
import httpx
6-
from ..types.project_environment import ProjectEnvironment
6+
from .._.types.project_environment import ProjectEnvironment
77
from .http_client import AsyncHttpClient, HttpClient
88

99

@@ -27,10 +27,10 @@ def __init__(
2727

2828
def get_headers(self) -> typing.Dict[str, str]:
2929
headers: typing.Dict[str, str] = {
30-
"User-Agent": "pipedream/1.0.8",
30+
"User-Agent": "pipedream/1.0.9",
3131
"X-Fern-Language": "Python",
3232
"X-Fern-SDK-Name": "pipedream",
33-
"X-Fern-SDK-Version": "1.0.8",
33+
"X-Fern-SDK-Version": "1.0.9",
3434
**(self.get_custom_headers() or {}),
3535
}
3636
if self._project_environment is not None:

src/pipedream/file_stash/client.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def with_raw_response(self) -> RawFileStashClient:
2222
"""
2323
return self._raw_client
2424

25-
def download_file(self, *, s_3_key: str, request_options: typing.Optional[RequestOptions] = None) -> None:
25+
def download_file(
26+
self, *, s_3_key: str, request_options: typing.Optional[RequestOptions] = None
27+
) -> typing.Iterator[bytes]:
2628
"""
2729
Download a file from File Stash
2830
@@ -31,11 +33,12 @@ def download_file(self, *, s_3_key: str, request_options: typing.Optional[Reques
3133
s_3_key : str
3234
3335
request_options : typing.Optional[RequestOptions]
34-
Request-specific configuration.
36+
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
3537
3638
Returns
3739
-------
38-
None
40+
typing.Iterator[bytes]
41+
file contents
3942
4043
Examples
4144
--------
@@ -51,8 +54,8 @@ def download_file(self, *, s_3_key: str, request_options: typing.Optional[Reques
5154
s_3_key="s3_key",
5255
)
5356
"""
54-
_response = self._raw_client.download_file(s_3_key=s_3_key, request_options=request_options)
55-
return _response.data
57+
with self._raw_client.download_file(s_3_key=s_3_key, request_options=request_options) as r:
58+
yield from r.data
5659

5760

5861
class AsyncFileStashClient:
@@ -70,7 +73,9 @@ def with_raw_response(self) -> AsyncRawFileStashClient:
7073
"""
7174
return self._raw_client
7275

73-
async def download_file(self, *, s_3_key: str, request_options: typing.Optional[RequestOptions] = None) -> None:
76+
async def download_file(
77+
self, *, s_3_key: str, request_options: typing.Optional[RequestOptions] = None
78+
) -> typing.AsyncIterator[bytes]:
7479
"""
7580
Download a file from File Stash
7681
@@ -79,11 +84,12 @@ async def download_file(self, *, s_3_key: str, request_options: typing.Optional[
7984
s_3_key : str
8085
8186
request_options : typing.Optional[RequestOptions]
82-
Request-specific configuration.
87+
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
8388
8489
Returns
8590
-------
86-
None
91+
typing.AsyncIterator[bytes]
92+
file contents
8793
8894
Examples
8995
--------
@@ -107,5 +113,6 @@ async def main() -> None:
107113
108114
asyncio.run(main())
109115
"""
110-
_response = await self._raw_client.download_file(s_3_key=s_3_key, request_options=request_options)
111-
return _response.data
116+
async with self._raw_client.download_file(s_3_key=s_3_key, request_options=request_options) as r:
117+
async for _chunk in r.data:
118+
yield _chunk
Lines changed: 72 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# This file was auto-generated by Fern from our API Definition.
22

3+
import contextlib
34
import typing
45
from json.decoder import JSONDecodeError
56

@@ -16,9 +17,10 @@ class RawFileStashClient:
1617
def __init__(self, *, client_wrapper: SyncClientWrapper):
1718
self._client_wrapper = client_wrapper
1819

20+
@contextlib.contextmanager
1921
def download_file(
2022
self, *, s_3_key: str, request_options: typing.Optional[RequestOptions] = None
21-
) -> HttpResponse[None]:
23+
) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]:
2224
"""
2325
Download a file from File Stash
2426
@@ -27,47 +29,59 @@ def download_file(
2729
s_3_key : str
2830
2931
request_options : typing.Optional[RequestOptions]
30-
Request-specific configuration.
32+
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
3133
3234
Returns
3335
-------
34-
HttpResponse[None]
36+
typing.Iterator[HttpResponse[typing.Iterator[bytes]]]
37+
file contents
3538
"""
36-
_response = self._client_wrapper.httpx_client.request(
39+
with self._client_wrapper.httpx_client.stream(
3740
f"v1/connect/{jsonable_encoder(self._client_wrapper._project_id)}/file_stash/download",
3841
method="GET",
3942
params={
4043
"s3_key": s_3_key,
4144
},
4245
request_options=request_options,
43-
)
44-
try:
45-
if 200 <= _response.status_code < 300:
46-
return HttpResponse(response=_response, data=None)
47-
if _response.status_code == 429:
48-
raise TooManyRequestsError(
49-
headers=dict(_response.headers),
50-
body=typing.cast(
51-
typing.Optional[typing.Any],
52-
parse_obj_as(
53-
type_=typing.Optional[typing.Any], # type: ignore
54-
object_=_response.json(),
55-
),
56-
),
57-
)
58-
_response_json = _response.json()
59-
except JSONDecodeError:
60-
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
61-
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
46+
) as _response:
47+
48+
def _stream() -> HttpResponse[typing.Iterator[bytes]]:
49+
try:
50+
if 200 <= _response.status_code < 300:
51+
_chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
52+
return HttpResponse(
53+
response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size))
54+
)
55+
_response.read()
56+
if _response.status_code == 429:
57+
raise TooManyRequestsError(
58+
headers=dict(_response.headers),
59+
body=typing.cast(
60+
typing.Optional[typing.Any],
61+
parse_obj_as(
62+
type_=typing.Optional[typing.Any], # type: ignore
63+
object_=_response.json(),
64+
),
65+
),
66+
)
67+
_response_json = _response.json()
68+
except JSONDecodeError:
69+
raise ApiError(
70+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.text
71+
)
72+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
73+
74+
yield _stream()
6275

6376

6477
class AsyncRawFileStashClient:
6578
def __init__(self, *, client_wrapper: AsyncClientWrapper):
6679
self._client_wrapper = client_wrapper
6780

81+
@contextlib.asynccontextmanager
6882
async def download_file(
6983
self, *, s_3_key: str, request_options: typing.Optional[RequestOptions] = None
70-
) -> AsyncHttpResponse[None]:
84+
) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]:
7185
"""
7286
Download a file from File Stash
7387
@@ -76,35 +90,47 @@ async def download_file(
7690
s_3_key : str
7791
7892
request_options : typing.Optional[RequestOptions]
79-
Request-specific configuration.
93+
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
8094
8195
Returns
8296
-------
83-
AsyncHttpResponse[None]
97+
typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]
98+
file contents
8499
"""
85-
_response = await self._client_wrapper.httpx_client.request(
100+
async with self._client_wrapper.httpx_client.stream(
86101
f"v1/connect/{jsonable_encoder(self._client_wrapper._project_id)}/file_stash/download",
87102
method="GET",
88103
params={
89104
"s3_key": s_3_key,
90105
},
91106
request_options=request_options,
92-
)
93-
try:
94-
if 200 <= _response.status_code < 300:
95-
return AsyncHttpResponse(response=_response, data=None)
96-
if _response.status_code == 429:
97-
raise TooManyRequestsError(
98-
headers=dict(_response.headers),
99-
body=typing.cast(
100-
typing.Optional[typing.Any],
101-
parse_obj_as(
102-
type_=typing.Optional[typing.Any], # type: ignore
103-
object_=_response.json(),
104-
),
105-
),
106-
)
107-
_response_json = _response.json()
108-
except JSONDecodeError:
109-
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
110-
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
107+
) as _response:
108+
109+
async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]:
110+
try:
111+
if 200 <= _response.status_code < 300:
112+
_chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
113+
return AsyncHttpResponse(
114+
response=_response,
115+
data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)),
116+
)
117+
await _response.aread()
118+
if _response.status_code == 429:
119+
raise TooManyRequestsError(
120+
headers=dict(_response.headers),
121+
body=typing.cast(
122+
typing.Optional[typing.Any],
123+
parse_obj_as(
124+
type_=typing.Optional[typing.Any], # type: ignore
125+
object_=_response.json(),
126+
),
127+
),
128+
)
129+
_response_json = _response.json()
130+
except JSONDecodeError:
131+
raise ApiError(
132+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.text
133+
)
134+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
135+
136+
yield await _stream()

0 commit comments

Comments
 (0)