Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"cliVersion": "3.4.3",
"generatorName": "fernapi/fern-python-sdk",
"generatorVersion": "4.37.0",
"generatorConfig": {
"client": {
"class_name": "Client",
"filename": "client.py",
"exported_class_name": "Pipedream",
"exported_filename": "pipedream.py"
}
}
}
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,30 @@ client = Pipedream(
client_id="YOUR_CLIENT_ID",
client_secret="YOUR_CLIENT_SECRET",
)
response = client.apps.list()
response = client.apps.list(
after="after",
before="before",
limit=1,
q="q",
sort_key="name",
sort_direction="asc",
)
for item in response:
yield item
# alternatively, you can paginate page-by-page
for page in response.iter_pages():
yield page
```

```python
# You can also iterate through pages and access the typed response per page
pager = client.apps.list(...)
for page in pager.iter_pages():
print(page.response) # access the typed response for each page
for item in page:
print(item)
```

## Advanced

### Access Raw Response Data
Expand All @@ -129,11 +145,11 @@ response = client.actions.with_raw_response.run(...)
print(response.headers) # access the response headers
print(response.data) # access the underlying object
pager = client.apps.list(...)
print(pager.response.headers) # access the response headers for the first page
print(pager.response) # access the typed response for the first page
for item in pager:
print(item) # access the underlying object(s)
for page in pager.iter_pages():
print(page.response.headers) # access the response headers for each page
print(page.response) # access the typed response for each page
for item in page:
print(item) # access the underlying object(s)
```
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "pipedream"

[tool.poetry]
name = "pipedream"
version = "1.0.12"
version = "1.0.13"
description = ""
readme = "README.md"
authors = []
Expand All @@ -30,7 +30,7 @@ packages = [
{ include = "pipedream", from = "src"}
]

[project.urls]
[tool.poetry.urls]
Repository = 'https://github.com/PipedreamHQ/pipedream-sdk-python'

[tool.poetry.dependencies]
Expand Down
35 changes: 29 additions & 6 deletions src/pipedream/accounts/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from ..core.pagination import AsyncPager, SyncPager
from ..core.request_options import RequestOptions
from ..types.account import Account
from ..types.list_accounts_response import ListAccountsResponse
from .raw_client import AsyncRawAccountsClient, RawAccountsClient

# this is used as the default value for optional parameters
Expand Down Expand Up @@ -38,7 +39,7 @@ def list(
app: typing.Optional[str] = None,
include_credentials: typing.Optional[bool] = None,
request_options: typing.Optional[RequestOptions] = None,
) -> SyncPager[Account]:
) -> SyncPager[Account, ListAccountsResponse]:
"""
Retrieve all connected accounts for the project with optional filtering

Expand Down Expand Up @@ -69,7 +70,7 @@ def list(

Returns
-------
SyncPager[Account]
SyncPager[Account, ListAccountsResponse]
accounts listed

Examples
Expand All @@ -82,7 +83,15 @@ def list(
client_id="YOUR_CLIENT_ID",
client_secret="YOUR_CLIENT_SECRET",
)
response = client.accounts.list()
response = client.accounts.list(
external_user_id="external_user_id",
oauth_app_id="oauth_app_id",
after="after",
before="before",
limit=1,
app="app",
include_credentials=True,
)
for item in response:
yield item
# alternatively, you can paginate page-by-page
Expand Down Expand Up @@ -152,6 +161,8 @@ def create(
client_secret="YOUR_CLIENT_SECRET",
)
client.accounts.create(
external_user_id="external_user_id",
oauth_app_id="oauth_app_id",
app_slug="app_slug",
cfmap_json="cfmap_json",
connect_token="connect_token",
Expand Down Expand Up @@ -205,6 +216,7 @@ def retrieve(
)
client.accounts.retrieve(
account_id="account_id",
include_credentials=True,
)
"""
_response = self._raw_client.retrieve(
Expand Down Expand Up @@ -303,7 +315,7 @@ async def list(
app: typing.Optional[str] = None,
include_credentials: typing.Optional[bool] = None,
request_options: typing.Optional[RequestOptions] = None,
) -> AsyncPager[Account]:
) -> AsyncPager[Account, ListAccountsResponse]:
"""
Retrieve all connected accounts for the project with optional filtering

Expand Down Expand Up @@ -334,7 +346,7 @@ async def list(

Returns
-------
AsyncPager[Account]
AsyncPager[Account, ListAccountsResponse]
accounts listed

Examples
Expand All @@ -352,7 +364,15 @@ async def list(


async def main() -> None:
response = await client.accounts.list()
response = await client.accounts.list(
external_user_id="external_user_id",
oauth_app_id="oauth_app_id",
after="after",
before="before",
limit=1,
app="app",
include_credentials=True,
)
async for item in response:
yield item

Expand Down Expand Up @@ -431,6 +451,8 @@ async def create(

async def main() -> None:
await client.accounts.create(
external_user_id="external_user_id",
oauth_app_id="oauth_app_id",
app_slug="app_slug",
cfmap_json="cfmap_json",
connect_token="connect_token",
Expand Down Expand Up @@ -492,6 +514,7 @@ async def retrieve(
async def main() -> None:
await client.accounts.retrieve(
account_id="account_id",
include_credentials=True,
)


Expand Down
58 changes: 27 additions & 31 deletions src/pipedream/accounts/raw_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.http_response import AsyncHttpResponse, HttpResponse
from ..core.jsonable_encoder import jsonable_encoder
from ..core.pagination import AsyncPager, BaseHttpResponse, SyncPager
from ..core.pagination import AsyncPager, SyncPager
from ..core.pydantic_utilities import parse_obj_as
from ..core.request_options import RequestOptions
from ..errors.too_many_requests_error import TooManyRequestsError
Expand All @@ -33,7 +33,7 @@ def list(
app: typing.Optional[str] = None,
include_credentials: typing.Optional[bool] = None,
request_options: typing.Optional[RequestOptions] = None,
) -> SyncPager[Account]:
) -> SyncPager[Account, ListAccountsResponse]:
"""
Retrieve all connected accounts for the project with optional filtering

Expand Down Expand Up @@ -64,7 +64,7 @@ def list(

Returns
-------
SyncPager[Account]
SyncPager[Account, ListAccountsResponse]
accounts listed
"""
_response = self._client_wrapper.httpx_client.request(
Expand Down Expand Up @@ -106,16 +106,14 @@ def list(
include_credentials=include_credentials,
request_options=request_options,
)
return SyncPager(
has_next=_has_next, items=_items, get_next=_get_next, response=BaseHttpResponse(response=_response)
)
return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
if _response.status_code == 429:
raise TooManyRequestsError(
headers=dict(_response.headers),
body=typing.cast(
typing.Optional[typing.Any],
typing.Any,
parse_obj_as(
type_=typing.Optional[typing.Any], # type: ignore
type_=typing.Any, # type: ignore
object_=_response.json(),
),
),
Expand Down Expand Up @@ -199,9 +197,9 @@ def create(
raise TooManyRequestsError(
headers=dict(_response.headers),
body=typing.cast(
typing.Optional[typing.Any],
typing.Any,
parse_obj_as(
type_=typing.Optional[typing.Any], # type: ignore
type_=typing.Any, # type: ignore
object_=_response.json(),
),
),
Expand Down Expand Up @@ -258,9 +256,9 @@ def retrieve(
raise TooManyRequestsError(
headers=dict(_response.headers),
body=typing.cast(
typing.Optional[typing.Any],
typing.Any,
parse_obj_as(
type_=typing.Optional[typing.Any], # type: ignore
type_=typing.Any, # type: ignore
object_=_response.json(),
),
),
Expand Down Expand Up @@ -297,9 +295,9 @@ def delete(self, account_id: str, *, request_options: typing.Optional[RequestOpt
raise TooManyRequestsError(
headers=dict(_response.headers),
body=typing.cast(
typing.Optional[typing.Any],
typing.Any,
parse_obj_as(
type_=typing.Optional[typing.Any], # type: ignore
type_=typing.Any, # type: ignore
object_=_response.json(),
),
),
Expand Down Expand Up @@ -338,9 +336,9 @@ def delete_by_app(
raise TooManyRequestsError(
headers=dict(_response.headers),
body=typing.cast(
typing.Optional[typing.Any],
typing.Any,
parse_obj_as(
type_=typing.Optional[typing.Any], # type: ignore
type_=typing.Any, # type: ignore
object_=_response.json(),
),
),
Expand All @@ -366,7 +364,7 @@ async def list(
app: typing.Optional[str] = None,
include_credentials: typing.Optional[bool] = None,
request_options: typing.Optional[RequestOptions] = None,
) -> AsyncPager[Account]:
) -> AsyncPager[Account, ListAccountsResponse]:
"""
Retrieve all connected accounts for the project with optional filtering

Expand Down Expand Up @@ -397,7 +395,7 @@ async def list(

Returns
-------
AsyncPager[Account]
AsyncPager[Account, ListAccountsResponse]
accounts listed
"""
_response = await self._client_wrapper.httpx_client.request(
Expand Down Expand Up @@ -442,16 +440,14 @@ async def _get_next():
request_options=request_options,
)

return AsyncPager(
has_next=_has_next, items=_items, get_next=_get_next, response=BaseHttpResponse(response=_response)
)
return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
if _response.status_code == 429:
raise TooManyRequestsError(
headers=dict(_response.headers),
body=typing.cast(
typing.Optional[typing.Any],
typing.Any,
parse_obj_as(
type_=typing.Optional[typing.Any], # type: ignore
type_=typing.Any, # type: ignore
object_=_response.json(),
),
),
Expand Down Expand Up @@ -535,9 +531,9 @@ async def create(
raise TooManyRequestsError(
headers=dict(_response.headers),
body=typing.cast(
typing.Optional[typing.Any],
typing.Any,
parse_obj_as(
type_=typing.Optional[typing.Any], # type: ignore
type_=typing.Any, # type: ignore
object_=_response.json(),
),
),
Expand Down Expand Up @@ -594,9 +590,9 @@ async def retrieve(
raise TooManyRequestsError(
headers=dict(_response.headers),
body=typing.cast(
typing.Optional[typing.Any],
typing.Any,
parse_obj_as(
type_=typing.Optional[typing.Any], # type: ignore
type_=typing.Any, # type: ignore
object_=_response.json(),
),
),
Expand Down Expand Up @@ -635,9 +631,9 @@ async def delete(
raise TooManyRequestsError(
headers=dict(_response.headers),
body=typing.cast(
typing.Optional[typing.Any],
typing.Any,
parse_obj_as(
type_=typing.Optional[typing.Any], # type: ignore
type_=typing.Any, # type: ignore
object_=_response.json(),
),
),
Expand Down Expand Up @@ -676,9 +672,9 @@ async def delete_by_app(
raise TooManyRequestsError(
headers=dict(_response.headers),
body=typing.cast(
typing.Optional[typing.Any],
typing.Any,
parse_obj_as(
type_=typing.Optional[typing.Any], # type: ignore
type_=typing.Any, # type: ignore
object_=_response.json(),
),
),
Expand Down
Loading
Loading