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
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
* [#723](https://github.com/workos/workos-python/pull/723) fix(generated): regenerate from spec

**Features**
* **[pipes](https://workos.com/docs/reference/pipes)**:
* Added `connected_account_id` to `DataIntegrationsVendCredentialsRequest`
* Added `connected_account_id` to `DataIntegrationsGetUserTokenRequest`
* Added parameter `UserManagementDataProviders.getUserDataInstallation.connected_account_id`
* Changed errors for endpoint `GET /user_management/users/{user_id}/connected_accounts/{slug}`
* Added parameter `UserManagementDataProviders.updateUserDataInstallation.connected_account_id`
* Changed errors for endpoint `PUT /user_management/users/{user_id}/connected_accounts/{slug}`
* Added parameter `UserManagementDataProviders.deleteUserDataInstallation.connected_account_id`
* Changed errors for endpoint `DELETE /user_management/users/{user_id}/connected_accounts/{slug}`
* Added `connected_accounts` to `DataIntegrationsListResponseData`
* Changed errors for endpoint `PUT /data-integrations/{slug}`
* Changed errors for endpoint `PUT /data-integrations/{slug}/api-key`
* Changed errors for endpoint `PUT /data-integrations/{slug}/client-credentials`
* Changed errors for endpoint `POST /data-integrations/{slug}/credentials`
* Changed errors for endpoint `POST /data-integrations/{provider}/token`
2 changes: 1 addition & 1 deletion .last-synced-sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
edb560e2be3f54b668ea8d11fa5a060c87ab5087
6fba233c50a5b651b2df7b859b75bfe715bc825a
64 changes: 62 additions & 2 deletions src/workos/pipes/_resource.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class DataIntegrationsGetUserTokenRequest:
"""A [User](https://workos.com/docs/reference/authkit/user) identifier."""
organization_id: str | None = None
"""An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter to scope the connection to a specific organization."""
connected_account_id: str | None = None
"""A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select a specific connection when the user has several for this provider."""

@classmethod
def from_dict(cls, data: dict[str, Any]) -> DataIntegrationsGetUserTokenRequest:
Expand All @@ -24,6 +26,7 @@ def from_dict(cls, data: dict[str, Any]) -> DataIntegrationsGetUserTokenRequest:
return cls(
user_id=data["user_id"],
organization_id=data.get("organization_id"),
connected_account_id=data.get("connected_account_id"),
)
except (KeyError, ValueError) as e:
_raise_deserialize_error("DataIntegrationsGetUserTokenRequest", e)
Expand All @@ -36,4 +39,6 @@ def to_dict(self) -> dict[str, Any]:
result["organization_id"] = self.organization_id
else:
result["organization_id"] = None
if self.connected_account_id is not None:
result["connected_account_id"] = self.connected_account_id
return result
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DataIntegrationsListResponse:
object: Literal["list"]
"""Indicates this is a list response."""
data: list[DataIntegrationsListResponseData]
"""A list of [providers](https://workos.com/docs/reference/pipes/provider), each including a [`connected_account`](https://workos.com/docs/reference/pipes/connected-account) field with the user's connection status."""
"""A list of [providers](https://workos.com/docs/reference/pipes/provider), each including the legacy `connected_account` field and the additive `connected_accounts` collection."""

@classmethod
def from_dict(cls, data: dict[str, Any]) -> DataIntegrationsListResponse:
Expand Down
11 changes: 11 additions & 0 deletions src/workos/pipes/models/data_integrations_list_response_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class DataIntegrationsListResponseData:
"""The timestamp when the provider was last updated."""
connected_account: DataIntegrationsListResponseDataConnectedAccount | None
"""The user's [connected account](https://workos.com/docs/reference/pipes/connected-account) for this provider, or `null` if the user has not connected."""
connected_accounts: list[DataIntegrationsListResponseDataConnectedAccount]
"""The user's connected accounts for this provider in the requested ownership context."""
auth_methods: list[DataIntegrationsListResponseDataAuthMethods] | None = None
"""The authentication methods supported by this provider (`oauth`, `api_key`, `client_credentials`, or a combination). Defaults to `["oauth"]` if absent."""

Expand All @@ -71,6 +73,12 @@ def from_dict(cls, data: dict[str, Any]) -> DataIntegrationsListResponseData:
)
if (_v_connected_account := data["connected_account"]) is not None
else None,
connected_accounts=[
DataIntegrationsListResponseDataConnectedAccount.from_dict(
cast(dict[str, Any], item)
)
for item in cast(list[Any], data["connected_accounts"])
],
auth_methods=[
DataIntegrationsListResponseDataAuthMethods(item)
for item in cast(list[Any], _v_auth_methods)
Expand Down Expand Up @@ -107,6 +115,9 @@ def to_dict(self) -> dict[str, Any]:
result["connected_account"] = self.connected_account.to_dict()
else:
result["connected_account"] = None
result["connected_accounts"] = [
item.to_dict() for item in self.connected_accounts
]
if self.auth_methods is not None:
result["auth_methods"] = [
item.value if isinstance(item, Enum) else item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class DataIntegrationsVendCredentialsRequest:
"""A [User](https://workos.com/docs/reference/authkit/user) identifier."""
organization_id: str | None = None
"""An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter to scope the connection to a specific organization."""
connected_account_id: str | None = None
"""A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select a specific connection when the user has several for this provider."""

@classmethod
def from_dict(cls, data: dict[str, Any]) -> DataIntegrationsVendCredentialsRequest:
Expand All @@ -24,6 +26,7 @@ def from_dict(cls, data: dict[str, Any]) -> DataIntegrationsVendCredentialsReque
return cls(
user_id=data["user_id"],
organization_id=data.get("organization_id"),
connected_account_id=data.get("connected_account_id"),
)
except (KeyError, ValueError) as e:
_raise_deserialize_error("DataIntegrationsVendCredentialsRequest", e)
Expand All @@ -34,4 +37,6 @@ def to_dict(self) -> dict[str, Any]:
result["user_id"] = self.user_id
if self.organization_id is not None:
result["organization_id"] = self.organization_id
if self.connected_account_id is not None:
result["connected_account_id"] = self.connected_account_id
return result
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT",
"organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT"
"organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT",
"connected_account_id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
}
25 changes: 24 additions & 1 deletion tests/fixtures/data_integrations_list_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,30 @@
"created_at": "2024-01-16T14:20:00.000Z",
"updated_at": "2024-01-16T14:20:00.000Z",
"userlandUserId": "test_userlandUserId"
}
},
"connected_accounts": [
{
"object": "connected_account",
"id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT",
"user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT",
"organization_id": null,
"scopes": [
"repo",
"user:email"
],
"auth_method": "oauth",
"api_key_last_4": null,
"client_id": "3MVG9dZJodJWxft2VoStSCVwPFsx0eDcpVc",
"client_secret_last_4": "cdef",
"config": {
"instance_url": "https://example.my.salesforce.com"
},
"state": "connected",
"created_at": "2024-01-16T14:20:00.000Z",
"updated_at": "2024-01-16T14:20:00.000Z",
"userlandUserId": "test_userlandUserId"
}
]
}
]
}
25 changes: 24 additions & 1 deletion tests/fixtures/data_integrations_list_response_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,28 @@
"created_at": "2024-01-16T14:20:00.000Z",
"updated_at": "2024-01-16T14:20:00.000Z",
"userlandUserId": "test_userlandUserId"
}
},
"connected_accounts": [
{
"object": "connected_account",
"id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT",
"user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT",
"organization_id": null,
"scopes": [
"repo",
"user:email"
],
"auth_method": "oauth",
"api_key_last_4": null,
"client_id": "3MVG9dZJodJWxft2VoStSCVwPFsx0eDcpVc",
"client_secret_last_4": "cdef",
"config": {
"instance_url": "https://example.my.salesforce.com"
},
"state": "connected",
"created_at": "2024-01-16T14:20:00.000Z",
"updated_at": "2024-01-16T14:20:00.000Z",
"userlandUserId": "test_userlandUserId"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT",
"organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT"
"organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT",
"connected_account_id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
}
54 changes: 48 additions & 6 deletions tests/test_pipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,17 @@ def test_get_user_connected_account(self, workos, httpx_mock):
def test_get_user_connected_account_encodes_query_params(self, workos, httpx_mock):
httpx_mock.add_response(json=load_fixture("connected_account.json"))
workos.pipes.get_user_connected_account(
"test_user_id", "test_slug", organization_id="value organization_id/test"
"test_user_id",
"test_slug",
organization_id="value organization_id/test",
connected_account_id="value connected_account_id/test",
)
request = httpx_mock.get_request()
assert request.url.params["organization_id"] == "value organization_id/test"
assert (
request.url.params["connected_account_id"]
== "value connected_account_id/test"
)

def test_create_user_connected_account(self, workos, httpx_mock):
httpx_mock.add_response(
Expand Down Expand Up @@ -257,10 +264,17 @@ def test_update_user_connected_account_encodes_query_params(
):
httpx_mock.add_response(json=load_fixture("connected_account.json"))
workos.pipes.update_user_connected_account(
"test_user_id", "test_slug", organization_id="value organization_id/test"
"test_user_id",
"test_slug",
organization_id="value organization_id/test",
connected_account_id="value connected_account_id/test",
)
request = httpx_mock.get_request()
assert request.url.params["organization_id"] == "value organization_id/test"
assert (
request.url.params["connected_account_id"]
== "value connected_account_id/test"
)

def test_delete_user_connected_account(self, workos, httpx_mock):
httpx_mock.add_response(status_code=204)
Expand All @@ -277,10 +291,17 @@ def test_delete_user_connected_account_encodes_query_params(
):
httpx_mock.add_response(status_code=204)
workos.pipes.delete_user_connected_account(
"test_user_id", "test_slug", organization_id="value organization_id/test"
"test_user_id",
"test_slug",
organization_id="value organization_id/test",
connected_account_id="value connected_account_id/test",
)
request = httpx_mock.get_request()
assert request.url.params["organization_id"] == "value organization_id/test"
assert (
request.url.params["connected_account_id"]
== "value connected_account_id/test"
)

def test_list_user_data_providers(self, workos, httpx_mock):
httpx_mock.add_response(
Expand Down Expand Up @@ -559,10 +580,17 @@ async def test_get_user_connected_account_encodes_query_params(
):
httpx_mock.add_response(json=load_fixture("connected_account.json"))
await async_workos.pipes.get_user_connected_account(
"test_user_id", "test_slug", organization_id="value organization_id/test"
"test_user_id",
"test_slug",
organization_id="value organization_id/test",
connected_account_id="value connected_account_id/test",
)
request = httpx_mock.get_request()
assert request.url.params["organization_id"] == "value organization_id/test"
assert (
request.url.params["connected_account_id"]
== "value connected_account_id/test"
)

@pytest.mark.asyncio
async def test_create_user_connected_account(self, async_workos, httpx_mock):
Expand Down Expand Up @@ -611,10 +639,17 @@ async def test_update_user_connected_account_encodes_query_params(
):
httpx_mock.add_response(json=load_fixture("connected_account.json"))
await async_workos.pipes.update_user_connected_account(
"test_user_id", "test_slug", organization_id="value organization_id/test"
"test_user_id",
"test_slug",
organization_id="value organization_id/test",
connected_account_id="value connected_account_id/test",
)
request = httpx_mock.get_request()
assert request.url.params["organization_id"] == "value organization_id/test"
assert (
request.url.params["connected_account_id"]
== "value connected_account_id/test"
)

@pytest.mark.asyncio
async def test_delete_user_connected_account(self, async_workos, httpx_mock):
Expand All @@ -635,10 +670,17 @@ async def test_delete_user_connected_account_encodes_query_params(
):
httpx_mock.add_response(status_code=204)
await async_workos.pipes.delete_user_connected_account(
"test_user_id", "test_slug", organization_id="value organization_id/test"
"test_user_id",
"test_slug",
organization_id="value organization_id/test",
connected_account_id="value connected_account_id/test",
)
request = httpx_mock.get_request()
assert request.url.params["organization_id"] == "value organization_id/test"
assert (
request.url.params["connected_account_id"]
== "value connected_account_id/test"
)

@pytest.mark.asyncio
async def test_list_user_data_providers(self, async_workos, httpx_mock):
Expand Down
Loading