Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"exported_filename": "pipedream.py"
}
},
"originGitCommit": "b399bbbdcc0ed7ed414d0fcc795c5c6b6dea46eb",
"originGitCommit": "267ec323a4305eba2c41bd93e26686a26e329107",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
"ciProvider": "github",
"sdkVersion": "2.0.1"
"sdkVersion": "2.0.2"
}
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dynamic = ["version"]

[tool.poetry]
name = "pipedream"
version = "2.0.1"
version = "2.0.2"
description = ""
readme = "README.md"
authors = []
Expand Down
102 changes: 102 additions & 0 deletions src/pipedream/accounts/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,53 @@ def delete_by_app(self, app_id: str, *, request_options: typing.Optional[Request
_response = self._raw_client.delete_by_app(app_id, request_options=request_options)
return _response.data

def list_by_external_user(
self,
external_user_id: str,
*,
include_credentials: typing.Optional[bool] = None,
app: typing.Optional[str] = None,
request_options: typing.Optional[RequestOptions] = None,
) -> typing.List[Account]:
"""
List all connected accounts for a specific external user. Equivalent to GET /accounts with external_user_id filter but uses path-based routing.

Parameters
----------
external_user_id : str

include_credentials : typing.Optional[bool]

app : typing.Optional[str]

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Returns
-------
typing.List[Account]
accounts listed

Examples
--------
from pipedream import Pipedream

client = Pipedream(
project_id="YOUR_PROJECT_ID",
client_id="YOUR_CLIENT_ID",
client_secret="YOUR_CLIENT_SECRET",
)
client.accounts.list_by_external_user(
external_user_id="external_user_id",
include_credentials=True,
app="app",
)
"""
_response = self._raw_client.list_by_external_user(
external_user_id, include_credentials=include_credentials, app=app, request_options=request_options
)
return _response.data


class AsyncAccountsClient:
def __init__(self, *, client_wrapper: AsyncClientWrapper):
Expand Down Expand Up @@ -604,3 +651,58 @@ async def main() -> None:
"""
_response = await self._raw_client.delete_by_app(app_id, request_options=request_options)
return _response.data

async def list_by_external_user(
self,
external_user_id: str,
*,
include_credentials: typing.Optional[bool] = None,
app: typing.Optional[str] = None,
request_options: typing.Optional[RequestOptions] = None,
) -> typing.List[Account]:
"""
List all connected accounts for a specific external user. Equivalent to GET /accounts with external_user_id filter but uses path-based routing.

Parameters
----------
external_user_id : str

include_credentials : typing.Optional[bool]

app : typing.Optional[str]

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Returns
-------
typing.List[Account]
accounts listed

Examples
--------
import asyncio

from pipedream import AsyncPipedream

client = AsyncPipedream(
project_id="YOUR_PROJECT_ID",
client_id="YOUR_CLIENT_ID",
client_secret="YOUR_CLIENT_SECRET",
)


async def main() -> None:
await client.accounts.list_by_external_user(
external_user_id="external_user_id",
include_credentials=True,
app="app",
)


asyncio.run(main())
"""
_response = await self._raw_client.list_by_external_user(
external_user_id, include_credentials=include_credentials, app=app, request_options=request_options
)
return _response.data
132 changes: 132 additions & 0 deletions src/pipedream/accounts/raw_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,72 @@ def delete_by_app(
)
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

def list_by_external_user(
self,
external_user_id: str,
*,
include_credentials: typing.Optional[bool] = None,
app: typing.Optional[str] = None,
request_options: typing.Optional[RequestOptions] = None,
) -> HttpResponse[typing.List[Account]]:
"""
List all connected accounts for a specific external user. Equivalent to GET /accounts with external_user_id filter but uses path-based routing.

Parameters
----------
external_user_id : str

include_credentials : typing.Optional[bool]

app : typing.Optional[str]

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Returns
-------
HttpResponse[typing.List[Account]]
accounts listed
"""
_response = self._client_wrapper.httpx_client.request(
f"v1/connect/{encode_path_param(self._client_wrapper._project_id)}/users/{encode_path_param(external_user_id)}/accounts",
method="GET",
params={
"include_credentials": include_credentials,
"app": app,
},
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
_data = typing.cast(
typing.List[Account],
parse_obj_as(
type_=typing.List[Account], # type: ignore
object_=_response.json(),
),
)
return HttpResponse(response=_response, data=_data)
if _response.status_code == 429:
raise TooManyRequestsError(
headers=dict(_response.headers),
body=typing.cast(
typing.Any,
parse_obj_as(
type_=typing.Any, # type: ignore
object_=_response.json(),
),
),
)
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
except ValidationError as e:
raise ParsingError(
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
)
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)


class AsyncRawAccountsClient:
def __init__(self, *, client_wrapper: AsyncClientWrapper):
Expand Down Expand Up @@ -735,3 +801,69 @@ async def delete_by_app(
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
)
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

async def list_by_external_user(
self,
external_user_id: str,
*,
include_credentials: typing.Optional[bool] = None,
app: typing.Optional[str] = None,
request_options: typing.Optional[RequestOptions] = None,
) -> AsyncHttpResponse[typing.List[Account]]:
"""
List all connected accounts for a specific external user. Equivalent to GET /accounts with external_user_id filter but uses path-based routing.

Parameters
----------
external_user_id : str

include_credentials : typing.Optional[bool]

app : typing.Optional[str]

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Returns
-------
AsyncHttpResponse[typing.List[Account]]
accounts listed
"""
_response = await self._client_wrapper.httpx_client.request(
f"v1/connect/{encode_path_param(self._client_wrapper._project_id)}/users/{encode_path_param(external_user_id)}/accounts",
method="GET",
params={
"include_credentials": include_credentials,
"app": app,
},
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
_data = typing.cast(
typing.List[Account],
parse_obj_as(
type_=typing.List[Account], # type: ignore
object_=_response.json(),
),
)
return AsyncHttpResponse(response=_response, data=_data)
if _response.status_code == 429:
raise TooManyRequestsError(
headers=dict(_response.headers),
body=typing.cast(
typing.Any,
parse_obj_as(
type_=typing.Any, # type: ignore
object_=_response.json(),
),
),
)
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
except ValidationError as e:
raise ParsingError(
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
)
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
4 changes: 2 additions & 2 deletions src/pipedream/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ def get_headers(self) -> typing.Dict[str, str]:
import platform

headers: typing.Dict[str, str] = {
"User-Agent": "pipedream/2.0.1",
"User-Agent": "pipedream/2.0.2",
"X-Fern-Language": "Python",
"X-Fern-Runtime": f"python/{platform.python_version()}",
"X-Fern-Platform": f"{platform.system().lower()}/{platform.release()}",
"X-Fern-SDK-Name": "pipedream",
"X-Fern-SDK-Version": "2.0.1",
"X-Fern-SDK-Version": "2.0.2",
**(self.get_custom_headers() or {}),
}
if self._project_environment is not None:
Expand Down
Loading