diff --git a/.changelog-pending/2026-09-16T19-24-23-949c30cb87778129af801fadc33546518853d045.md b/.changelog-pending/2026-09-16T19-24-23-949c30cb87778129af801fadc33546518853d045.md index 744a55f6..fbb6a9e3 100644 --- a/.changelog-pending/2026-09-16T19-24-23-949c30cb87778129af801fadc33546518853d045.md +++ b/.changelog-pending/2026-09-16T19-24-23-949c30cb87778129af801fadc33546518853d045.md @@ -16,13 +16,12 @@ * Added enum `DataIntegrationInstallationConnectionRole` * Added `connection_owner` to `DataIntegrationsGetDataIntegrationAuthorizeUrlRequest` * Added enum `DataIntegrationsGetDataIntegrationAuthorizeUrlRequestConnectionOwner` + * Added the organization connected-account operations on `Pipes`: `client.pipes.get_organization_connected_account`, `create_organization_connected_account`, `update_organization_connected_account`, `delete_organization_connected_account`, `list_organization_data_providers` * **[connect](https://workos.com/docs/reference/workos-connect/standalone)**: * Added `connection_role` to `ConnectedAccount` * Added `account_identifier` to `ConnectedAccount` * Added `account_display_name` to `ConnectedAccount` * Added enum `ConnectedAccountConnectionRole` - * **[organizations](https://workos.com/docs/reference/organization)**: - * Added service `OrganizationsDataProviders` * **[webhooks](https://workos.com/docs/reference/webhooks)**: * Added `pipes.account_connection.add_failed` to `CreateWebhookEndpointEvents` * Added `pipes.account_connection.connected` to `CreateWebhookEndpointEvents` diff --git a/.changelog-pending/2026-09-17T20-59-47-bfe7aedb3cf7296ffb6ead1e287e844186479702.md b/.changelog-pending/2026-09-17T20-59-47-bfe7aedb3cf7296ffb6ead1e287e844186479702.md new file mode 100644 index 00000000..b1e228da --- /dev/null +++ b/.changelog-pending/2026-09-17T20-59-47-bfe7aedb3cf7296ffb6ead1e287e844186479702.md @@ -0,0 +1,5 @@ +* [#733](https://github.com/workos/workos-python/pull/733) fix(generated): regenerate from spec (1 change) + + **Fixes** + * **[multi_factor_auth](https://workos.com/docs/reference/authkit/mfa)**: + * Changed errors for endpoint `POST /auth/factors/{id}/challenge` diff --git a/.oagen-manifest.json b/.oagen-manifest.json index 056fa1e7..2f027a66 100644 --- a/.oagen-manifest.json +++ b/.oagen-manifest.json @@ -691,13 +691,11 @@ "src/workos/organizations/models/update_audit_logs_retention.py", "src/workos/organizations/models/update_organization.py", "src/workos/organizations_data_providers/__init__.py", - "src/workos/organizations_data_providers/_resource.py", "src/workos/organizations_data_providers/models/__init__.py", "src/workos/pipes/__init__.py", "src/workos/pipes/_resource.py", "src/workos/pipes/models/__init__.py", "src/workos/pipes/models/api_key_installation.py", - "src/workos/pipes/models/connected_account_input.py", "src/workos/pipes/models/create_data_integration.py", "src/workos/pipes/models/custom_provider_definition.py", "src/workos/pipes/models/data_integration.py", @@ -712,9 +710,6 @@ "src/workos/pipes/models/data_integration_installation.py", "src/workos/pipes/models/data_integrations_get_data_integration_authorize_url_request.py", "src/workos/pipes/models/data_integrations_get_user_token_request.py", - "src/workos/pipes/models/data_integrations_list_response.py", - "src/workos/pipes/models/data_integrations_list_response_data.py", - "src/workos/pipes/models/data_integrations_list_response_data_connected_account.py", "src/workos/pipes/models/data_integrations_upsert_api_key_request.py", "src/workos/pipes/models/data_integrations_upsert_client_credentials_request.py", "src/workos/pipes/models/data_integrations_vend_credentials_request.py", @@ -792,7 +787,6 @@ "src/workos/types/organization_domains/__init__.py", "src/workos/types/organization_membership/__init__.py", "src/workos/types/organizations/__init__.py", - "src/workos/types/organizations_data_providers/__init__.py", "src/workos/types/pipes/__init__.py", "src/workos/types/pipes_provider/__init__.py", "src/workos/types/platform_teams/__init__.py", @@ -1573,8 +1567,6 @@ "tests/test_organization_membership.py", "tests/test_organization_membership_models_round_trip.py", "tests/test_organizations.py", - "tests/test_organizations_data_providers.py", - "tests/test_organizations_data_providers_models_round_trip.py", "tests/test_organizations_models_round_trip.py", "tests/test_pipes.py", "tests/test_pipes_models_round_trip.py", @@ -1596,6 +1588,34 @@ "tests/test_widgets_models_round_trip.py" ], "operations": { + "GET /agents/blueprints": { + "sdkMethod": "list_blueprints", + "service": "agents" + }, + "POST /agents/blueprints": { + "sdkMethod": "create_blueprint", + "service": "agents" + }, + "GET /agents/blueprints/{agent_blueprint_id}": { + "sdkMethod": "get_blueprint", + "service": "agents" + }, + "PATCH /agents/blueprints/{agent_blueprint_id}": { + "sdkMethod": "update_blueprint", + "service": "agents" + }, + "DELETE /agents/blueprints/{agent_blueprint_id}": { + "sdkMethod": "delete_blueprint", + "service": "agents" + }, + "POST /agents/blueprints/{agent_blueprint_id}/tokens": { + "sdkMethod": "create_blueprint_token", + "service": "agents" + }, + "POST /agents/blueprints/{agent_blueprint_id}/tokens/validate": { + "sdkMethod": "validate_blueprint_token", + "service": "agents" + }, "PATCH /agents/claims/attempts": { "sdkMethod": "update_attempts", "service": "agents" @@ -1608,6 +1628,30 @@ "sdkMethod": "get_registration", "service": "agents" }, + "GET /agents/instances": { + "sdkMethod": "list_instances", + "service": "agents" + }, + "GET /agents/instances/{agent_instance_id}": { + "sdkMethod": "get_instance", + "service": "agents" + }, + "DELETE /agents/instances/{agent_instance_id}": { + "sdkMethod": "delete_instance", + "service": "agents" + }, + "GET /agents/sessions": { + "sdkMethod": "list_sessions", + "service": "agents" + }, + "GET /agents/sessions/{agent_instance_session_id}": { + "sdkMethod": "get_session", + "service": "agents" + }, + "POST /agents/sessions/{agent_instance_session_id}/revoke": { + "sdkMethod": "revoke_session", + "service": "agents" + }, "POST /auth/challenges/{id}/verify": { "sdkMethod": "verify_challenge", "service": "multi_factor_auth" @@ -1852,10 +1896,54 @@ "sdkMethod": "list_connections", "service": "sso" }, + "POST /connections": { + "sdkMethod": "create_connection", + "service": "sso" + }, + "GET /connections/{connectionId}/saml_idp_signing_certs": { + "sdkMethod": "list_connection_saml_idp_signing_certs", + "service": "sso" + }, + "POST /connections/{connectionId}/saml_idp_signing_certs": { + "sdkMethod": "create_connection_saml_idp_signing_cert", + "service": "sso" + }, + "DELETE /connections/{connectionId}/saml_idp_signing_certs/{certificateId}": { + "sdkMethod": "delete_connection_saml_idp_signing_cert", + "service": "sso" + }, + "GET /connections/{connectionId}/saml_sp_encryption_certs": { + "sdkMethod": "list_connection_saml_sp_encryption_certs", + "service": "sso" + }, + "POST /connections/{connectionId}/saml_sp_encryption_certs": { + "sdkMethod": "create_connection_saml_sp_encryption_cert", + "service": "sso" + }, + "DELETE /connections/{connectionId}/saml_sp_encryption_certs/{certificateId}": { + "sdkMethod": "delete_connection_saml_sp_encryption_cert", + "service": "sso" + }, + "GET /connections/{connectionId}/saml_sp_signing_cert": { + "sdkMethod": "list_connection_saml_sp_signing_cert", + "service": "sso" + }, + "POST /connections/{connectionId}/saml_sp_signing_cert": { + "sdkMethod": "create_connection_saml_sp_signing_cert", + "service": "sso" + }, + "DELETE /connections/{connectionId}/saml_sp_signing_cert/{certificateId}": { + "sdkMethod": "delete_connection_saml_sp_signing_cert", + "service": "sso" + }, "GET /connections/{id}": { "sdkMethod": "get_connection", "service": "sso" }, + "PATCH /connections/{id}": { + "sdkMethod": "update_connection", + "service": "sso" + }, "DELETE /connections/{id}": { "sdkMethod": "delete_connection", "service": "sso" @@ -1888,10 +1976,26 @@ "sdkMethod": "authorize_data_integration", "service": "pipes" }, + "PUT /data-integrations/{slug}/client-credentials": { + "sdkMethod": "update_data_integration_client_credentials", + "service": "pipes" + }, "POST /data-integrations/{slug}/credentials": { "sdkMethod": "create_data_integration_credential", "service": "pipes" }, + "GET /data-integrations/{slug}/organization": { + "sdkMethod": "list_data_integration_organization", + "service": "pipes" + }, + "PUT /data-integrations/{slug}/organization": { + "sdkMethod": "update_data_integration_organization", + "service": "pipes" + }, + "DELETE /data-integrations/{slug}/organization": { + "sdkMethod": "delete_data_integration_organization", + "service": "pipes" + }, "POST /data-integrations/{provider}/token": { "sdkMethod": "get_access_token", "service": "pipes" @@ -2060,6 +2164,54 @@ "sdkMethod": "list_authorized_applications", "service": "organizations" }, + "GET /organizations/{organization_id}/connected_accounts/{slug}": { + "sdkMethod": "get_organization_connected_account", + "service": "pipes" + }, + "POST /organizations/{organization_id}/connected_accounts/{slug}": { + "sdkMethod": "create_organization_connected_account", + "service": "pipes" + }, + "PUT /organizations/{organization_id}/connected_accounts/{slug}": { + "sdkMethod": "update_organization_connected_account", + "service": "pipes" + }, + "DELETE /organizations/{organization_id}/connected_accounts/{slug}": { + "sdkMethod": "delete_organization_connected_account", + "service": "pipes" + }, + "GET /organizations/{organization_id}/data_providers": { + "sdkMethod": "list_organization_data_providers", + "service": "pipes" + }, + "GET /organizations/{organization_id}/it_contacts": { + "sdkMethod": "list_it_contacts", + "service": "organizations" + }, + "POST /organizations/{organization_id}/it_contacts": { + "sdkMethod": "create_it_contact", + "service": "organizations" + }, + "DELETE /organizations/{organization_id}/it_contacts/{contact_id}": { + "sdkMethod": "delete_it_contact", + "service": "organizations" + }, + "POST /organizations/{organization_id}/it_contacts/{contact_id}/invite": { + "sdkMethod": "invite_it_contact", + "service": "organizations" + }, + "POST /organizations/{organization_id}/it_contacts/{contact_id}/revoke": { + "sdkMethod": "revoke_it_contact", + "service": "organizations" + }, + "POST /platform/teams": { + "sdkMethod": "create_team", + "service": "platform_teams" + }, + "GET /platform/teams/{team_id}": { + "sdkMethod": "get_team", + "service": "platform_teams" + }, "POST /portal/generate_link": { "sdkMethod": "generate_link", "service": "admin_portal" @@ -2132,6 +2284,18 @@ "sdkMethod": "revoke_session", "service": "user_management" }, + "GET /user_management/authkit_oauth_resources": { + "sdkMethod": "list_authkit_oauth_resources", + "service": "user_management" + }, + "POST /user_management/authkit_oauth_resources": { + "sdkMethod": "create_authkit_oauth_resource", + "service": "user_management" + }, + "DELETE /user_management/authkit_oauth_resources/{id}": { + "sdkMethod": "delete_authkit_oauth_resource", + "service": "user_management" + }, "GET /user_management/cors_origins": { "sdkMethod": "list_cors_origins", "service": "user_management" @@ -2332,6 +2496,34 @@ "sdkMethod": "create_user_auth_factor", "service": "multi_factor_auth" }, + "DELETE /user_management/waitlist_entries/{id}": { + "sdkMethod": "delete_waitlist_entry", + "service": "user_management" + }, + "POST /user_management/waitlist_entries/{id}/approve": { + "sdkMethod": "create_waitlist_entry_approve", + "service": "user_management" + }, + "POST /user_management/waitlist_entries/{id}/deny": { + "sdkMethod": "create_waitlist_entry_deny", + "service": "user_management" + }, + "GET /user_management/waitlists": { + "sdkMethod": "list_waitlists", + "service": "user_management" + }, + "GET /user_management/waitlists/{id}": { + "sdkMethod": "get_waitlist", + "service": "user_management" + }, + "GET /user_management/waitlists/{id}/entries": { + "sdkMethod": "list_waitlist_entries", + "service": "user_management" + }, + "POST /user_management/waitlists/{id}/entries": { + "sdkMethod": "create_waitlist_entry", + "service": "user_management" + }, "POST /vault/v1/keys/data-key": { "sdkMethod": "create_data_key", "service": "vault" @@ -2439,206 +2631,6 @@ "GET /audit_logs/exports/{auditLogExportId}": { "sdkMethod": "get_export", "service": "audit_logs" - }, - "PUT /data-integrations/{slug}/client-credentials": { - "sdkMethod": "update_data_integration_client_credentials", - "service": "pipes" - }, - "GET /agents/blueprints": { - "sdkMethod": "list_blueprints", - "service": "agents" - }, - "POST /agents/blueprints": { - "sdkMethod": "create_blueprint", - "service": "agents" - }, - "GET /agents/blueprints/{agent_blueprint_id}": { - "sdkMethod": "get_blueprint", - "service": "agents" - }, - "PATCH /agents/blueprints/{agent_blueprint_id}": { - "sdkMethod": "update_blueprint", - "service": "agents" - }, - "DELETE /agents/blueprints/{agent_blueprint_id}": { - "sdkMethod": "delete_blueprint", - "service": "agents" - }, - "POST /agents/blueprints/{agent_blueprint_id}/tokens": { - "sdkMethod": "create_blueprint_token", - "service": "agents" - }, - "GET /agents/instances": { - "sdkMethod": "list_instances", - "service": "agents" - }, - "GET /agents/instances/{agent_instance_id}": { - "sdkMethod": "get_instance", - "service": "agents" - }, - "DELETE /agents/instances/{agent_instance_id}": { - "sdkMethod": "delete_instance", - "service": "agents" - }, - "GET /agents/sessions": { - "sdkMethod": "list_sessions", - "service": "agents" - }, - "GET /agents/sessions/{agent_instance_session_id}": { - "sdkMethod": "get_session", - "service": "agents" - }, - "POST /agents/sessions/{agent_instance_session_id}/revoke": { - "sdkMethod": "revoke_session", - "service": "agents" - }, - "POST /connections": { - "sdkMethod": "create_connection", - "service": "sso" - }, - "GET /connections/{connectionId}/saml_idp_signing_certs": { - "sdkMethod": "list_connection_saml_idp_signing_certs", - "service": "sso" - }, - "POST /connections/{connectionId}/saml_idp_signing_certs": { - "sdkMethod": "create_connection_saml_idp_signing_cert", - "service": "sso" - }, - "DELETE /connections/{connectionId}/saml_idp_signing_certs/{certificateId}": { - "sdkMethod": "delete_connection_saml_idp_signing_cert", - "service": "sso" - }, - "GET /connections/{connectionId}/saml_sp_encryption_certs": { - "sdkMethod": "list_connection_saml_sp_encryption_certs", - "service": "sso" - }, - "POST /connections/{connectionId}/saml_sp_encryption_certs": { - "sdkMethod": "create_connection_saml_sp_encryption_cert", - "service": "sso" - }, - "DELETE /connections/{connectionId}/saml_sp_encryption_certs/{certificateId}": { - "sdkMethod": "delete_connection_saml_sp_encryption_cert", - "service": "sso" - }, - "GET /connections/{connectionId}/saml_sp_signing_cert": { - "sdkMethod": "list_connection_saml_sp_signing_cert", - "service": "sso" - }, - "POST /connections/{connectionId}/saml_sp_signing_cert": { - "sdkMethod": "create_connection_saml_sp_signing_cert", - "service": "sso" - }, - "DELETE /connections/{connectionId}/saml_sp_signing_cert/{certificateId}": { - "sdkMethod": "delete_connection_saml_sp_signing_cert", - "service": "sso" - }, - "PATCH /connections/{id}": { - "sdkMethod": "update_connection", - "service": "sso" - }, - "GET /organizations/{organization_id}/it_contacts": { - "sdkMethod": "list_it_contacts", - "service": "organizations" - }, - "POST /organizations/{organization_id}/it_contacts": { - "sdkMethod": "create_it_contact", - "service": "organizations" - }, - "DELETE /organizations/{organization_id}/it_contacts/{contact_id}": { - "sdkMethod": "delete_it_contact", - "service": "organizations" - }, - "POST /organizations/{organization_id}/it_contacts/{contact_id}/invite": { - "sdkMethod": "invite_it_contact", - "service": "organizations" - }, - "POST /organizations/{organization_id}/it_contacts/{contact_id}/revoke": { - "sdkMethod": "revoke_it_contact", - "service": "organizations" - }, - "POST /platform/teams": { - "sdkMethod": "create_team", - "service": "platform_teams" - }, - "GET /platform/teams/{team_id}": { - "sdkMethod": "get_team", - "service": "platform_teams" - }, - "DELETE /user_management/waitlist_entries/{id}": { - "sdkMethod": "delete_waitlist_entry", - "service": "user_management" - }, - "POST /user_management/waitlist_entries/{id}/approve": { - "sdkMethod": "create_waitlist_entry_approve", - "service": "user_management" - }, - "POST /user_management/waitlist_entries/{id}/deny": { - "sdkMethod": "create_waitlist_entry_deny", - "service": "user_management" - }, - "GET /user_management/waitlists": { - "sdkMethod": "list_waitlists", - "service": "user_management" - }, - "GET /user_management/waitlists/{id}": { - "sdkMethod": "get_waitlist", - "service": "user_management" - }, - "GET /user_management/waitlists/{id}/entries": { - "sdkMethod": "list_waitlist_entries", - "service": "user_management" - }, - "POST /user_management/waitlists/{id}/entries": { - "sdkMethod": "create_waitlist_entry", - "service": "user_management" - }, - "POST /agents/blueprints/{agent_blueprint_id}/tokens/validate": { - "sdkMethod": "validate_blueprint_token", - "service": "agents" - }, - "GET /data-integrations/{slug}/organization": { - "sdkMethod": "list_data_integration_organization", - "service": "pipes" - }, - "PUT /data-integrations/{slug}/organization": { - "sdkMethod": "update_data_integration_organization", - "service": "pipes" - }, - "DELETE /data-integrations/{slug}/organization": { - "sdkMethod": "delete_data_integration_organization", - "service": "pipes" - }, - "GET /user_management/authkit_oauth_resources": { - "sdkMethod": "list_authkit_oauth_resources", - "service": "user_management" - }, - "POST /user_management/authkit_oauth_resources": { - "sdkMethod": "create_authkit_oauth_resource", - "service": "user_management" - }, - "DELETE /user_management/authkit_oauth_resources/{id}": { - "sdkMethod": "delete_authkit_oauth_resource", - "service": "user_management" - }, - "GET /organizations/{organization_id}/connected_accounts/{slug}": { - "sdkMethod": "get_organization_connected_account", - "service": "organizations_data_providers" - }, - "POST /organizations/{organization_id}/connected_accounts/{slug}": { - "sdkMethod": "create_organization_connected_account", - "service": "organizations_data_providers" - }, - "PUT /organizations/{organization_id}/connected_accounts/{slug}": { - "sdkMethod": "update_organization_connected_account", - "service": "organizations_data_providers" - }, - "DELETE /organizations/{organization_id}/connected_accounts/{slug}": { - "sdkMethod": "delete_organization_connected_account", - "service": "organizations_data_providers" - }, - "GET /organizations/{organization_id}/data_providers": { - "sdkMethod": "list_organization_data_providers", - "service": "organizations_data_providers" } } } diff --git a/src/workos/_client.py b/src/workos/_client.py index 035d16f6..9776dd23 100644 --- a/src/workos/_client.py +++ b/src/workos/_client.py @@ -32,10 +32,6 @@ OrganizationMembershipService, ) from .organizations._resource import AsyncOrganizations, Organizations -from .organizations_data_providers._resource import ( - AsyncOrganizationsDataProviders, - OrganizationsDataProviders, -) from .passwordless import AsyncPasswordless, Passwordless from .pipes._resource import AsyncPipes, Pipes from .pipes_provider._resource import AsyncPipesProvider, PipesProvider @@ -127,11 +123,6 @@ def groups(self) -> Groups: """Groups API resources.""" return Groups(self) - @functools.cached_property - def organizations_data_providers(self) -> OrganizationsDataProviders: - """Organizations Data Providers API resources.""" - return OrganizationsDataProviders(self) - @functools.cached_property def platform_teams(self) -> PlatformTeams: """Platform Teams API resources.""" @@ -280,11 +271,6 @@ def groups(self) -> AsyncGroups: """Groups API resources.""" return AsyncGroups(self) - @functools.cached_property - def organizations_data_providers(self) -> AsyncOrganizationsDataProviders: - """Organizations Data Providers API resources.""" - return AsyncOrganizationsDataProviders(self) - @functools.cached_property def platform_teams(self) -> AsyncPlatformTeams: """Platform Teams API resources.""" diff --git a/src/workos/common/__init__.py b/src/workos/common/__init__.py index 3d04b325..a8aff35c 100644 --- a/src/workos/common/__init__.py +++ b/src/workos/common/__init__.py @@ -1,6 +1,5 @@ # This file is auto-generated by oagen. Do not edit. -from .models import * from .models import ( AccessTokenAgentRegistrationCredentialIssuedDataDetail as AccessTokenAgentRegistrationCredentialIssuedDataDetail, ) diff --git a/src/workos/common/models/__init__.py b/src/workos/common/models/__init__.py index 7aa3f369..688edaf8 100644 --- a/src/workos/common/models/__init__.py +++ b/src/workos/common/models/__init__.py @@ -54,12 +54,10 @@ from .agent_instance_created_data import ( AgentInstanceCreatedData as AgentInstanceCreatedData, ) -from .agent_instance_created_data_type import * from .agent_instance_deleted import AgentInstanceDeleted as AgentInstanceDeleted from .agent_instance_deleted_data import ( AgentInstanceDeletedData as AgentInstanceDeletedData, ) -from .agent_instance_deleted_data_type import * from .agent_instance_session_created import ( AgentInstanceSessionCreated as AgentInstanceSessionCreated, ) @@ -100,9 +98,6 @@ from .agent_registration_created_data_agent_identity import ( AgentRegistrationCreatedDataAgentIdentity as AgentRegistrationCreatedDataAgentIdentity, ) -from .agent_registration_created_data_kind import * -from .agent_registration_created_data_method import * -from .agent_registration_created_data_status import * from .agent_registration_credential_issued import ( AgentRegistrationCredentialIssued as AgentRegistrationCredentialIssued, ) @@ -299,7 +294,6 @@ from .authentication_radar_risk_detected_data import ( AuthenticationRadarRiskDetectedData as AuthenticationRadarRiskDetectedData, ) -from .authentication_radar_risk_detected_data_action import * from .authentication_reauthentication_succeeded import ( AuthenticationReauthenticationSucceeded as AuthenticationReauthenticationSucceeded, ) @@ -378,26 +372,18 @@ from .connection_activated_data import ( ConnectionActivatedData as ConnectionActivatedData, ) -from .connection_activated_data_connection_type import * from .connection_activated_data_domain import ( ConnectionActivatedDataDomain as ConnectionActivatedDataDomain, ) -from .connection_activated_data_state import * -from .connection_activated_data_status import * from .connection_deactivated import ConnectionDeactivated as ConnectionDeactivated from .connection_deactivated_data import ( ConnectionDeactivatedData as ConnectionDeactivatedData, ) -from .connection_deactivated_data_connection_type import * from .connection_deactivated_data_domain import ( ConnectionDeactivatedDataDomain as ConnectionDeactivatedDataDomain, ) -from .connection_deactivated_data_state import * -from .connection_deactivated_data_status import * from .connection_deleted import ConnectionDeleted as ConnectionDeleted from .connection_deleted_data import ConnectionDeletedData as ConnectionDeletedData -from .connection_deleted_data_connection_type import * -from .connection_deleted_data_state import * from .connection_saml_certificate_renewal_required import ( ConnectionSAMLCertificateRenewalRequired as ConnectionSAMLCertificateRenewalRequired, ) @@ -407,7 +393,6 @@ from .connection_saml_certificate_renewal_required_data_certificate import ( ConnectionSAMLCertificateRenewalRequiredDataCertificate as ConnectionSAMLCertificateRenewalRequiredDataCertificate, ) -from .connection_saml_certificate_renewal_required_data_certificate_certificate_type import * from .connection_saml_certificate_renewal_required_data_connection import ( ConnectionSAMLCertificateRenewalRequiredDataConnection as ConnectionSAMLCertificateRenewalRequiredDataConnection, ) @@ -420,7 +405,6 @@ from .connection_saml_certificate_renewed_data_certificate import ( ConnectionSAMLCertificateRenewedDataCertificate as ConnectionSAMLCertificateRenewedDataCertificate, ) -from .connection_saml_certificate_renewed_data_certificate_certificate_type import * from .connection_saml_certificate_renewed_data_connection import ( ConnectionSAMLCertificateRenewedDataConnection as ConnectionSAMLCertificateRenewedDataConnection, ) @@ -529,7 +513,6 @@ from .directory_type import DirectoryType as DirectoryType from .directory_user import DirectoryUser as DirectoryUser from .directory_user_email import DirectoryUserEmail as DirectoryUserEmail -from .directory_user_state import * from .directory_user_with_groups_state import ( DirectoryUserWithGroupsState as DirectoryUserWithGroupsState, ) @@ -538,12 +521,8 @@ from .dsync_activated_data_domain import ( DsyncActivatedDataDomain as DsyncActivatedDataDomain, ) -from .dsync_activated_data_state import * -from .dsync_activated_data_type import * from .dsync_deleted import DsyncDeleted as DsyncDeleted from .dsync_deleted_data import DsyncDeletedData as DsyncDeletedData -from .dsync_deleted_data_state import * -from .dsync_deleted_data_type import * from .dsync_group_created import DsyncGroupCreated as DsyncGroupCreated from .dsync_group_deleted import DsyncGroupDeleted as DsyncGroupDeleted from .dsync_group_updated import DsyncGroupUpdated as DsyncGroupUpdated @@ -567,7 +546,6 @@ from .dsync_user_updated_data_email import ( DsyncUserUpdatedDataEmail as DsyncUserUpdatedDataEmail, ) -from .dsync_user_updated_data_state import * from .email_verification_created import ( EmailVerificationCreated as EmailVerificationCreated, ) @@ -577,7 +555,6 @@ from .error_response import ErrorResponse as ErrorResponse from .event_context import EventContext as EventContext from .event_context_actor import EventContextActor as EventContextActor -from .event_context_actor_source import * from .event_context_google_analytics_session import ( EventContextGoogleAnalyticsSession as EventContextGoogleAnalyticsSession, ) @@ -589,7 +566,6 @@ from .flag_created_context_actor import ( FlagCreatedContextActor as FlagCreatedContextActor, ) -from .flag_created_context_actor_source import * from .flag_created_data import FlagCreatedData as FlagCreatedData from .flag_created_data_owner import FlagCreatedDataOwner as FlagCreatedDataOwner from .flag_deleted import FlagDeleted as FlagDeleted @@ -597,17 +573,14 @@ from .flag_deleted_context_actor import ( FlagDeletedContextActor as FlagDeletedContextActor, ) -from .flag_deleted_context_actor_source import * from .flag_deleted_data import FlagDeletedData as FlagDeletedData from .flag_deleted_data_owner import FlagDeletedDataOwner as FlagDeletedDataOwner from .flag_owner import FlagOwner as FlagOwner from .flag_rule_updated import FlagRuleUpdated as FlagRuleUpdated from .flag_rule_updated_context import FlagRuleUpdatedContext as FlagRuleUpdatedContext -from .flag_rule_updated_context_access_type import * from .flag_rule_updated_context_actor import ( FlagRuleUpdatedContextActor as FlagRuleUpdatedContextActor, ) -from .flag_rule_updated_context_actor_source import * from .flag_rule_updated_context_configured_target import ( FlagRuleUpdatedContextConfiguredTarget as FlagRuleUpdatedContextConfiguredTarget, ) @@ -623,7 +596,6 @@ from .flag_rule_updated_context_previous_attribute_context import ( FlagRuleUpdatedContextPreviousAttributeContext as FlagRuleUpdatedContextPreviousAttributeContext, ) -from .flag_rule_updated_context_previous_attribute_context_access_type import * from .flag_rule_updated_context_previous_attribute_context_configured_target import ( FlagRuleUpdatedContextPreviousAttributeContextConfiguredTarget as FlagRuleUpdatedContextPreviousAttributeContextConfiguredTarget, ) @@ -645,7 +617,6 @@ from .flag_updated_context_actor import ( FlagUpdatedContextActor as FlagUpdatedContextActor, ) -from .flag_updated_context_actor_source import * from .flag_updated_context_previous_attribute import ( FlagUpdatedContextPreviousAttribute as FlagUpdatedContextPreviousAttribute, ) @@ -665,16 +636,12 @@ from .group_updated import GroupUpdated as GroupUpdated from .invitation_accepted import InvitationAccepted as InvitationAccepted from .invitation_accepted_data import InvitationAcceptedData as InvitationAcceptedData -from .invitation_accepted_data_state import * from .invitation_created import InvitationCreated as InvitationCreated from .invitation_created_data import InvitationCreatedData as InvitationCreatedData -from .invitation_created_data_state import * from .invitation_resent import InvitationResent as InvitationResent from .invitation_resent_data import InvitationResentData as InvitationResentData -from .invitation_resent_data_state import * from .invitation_revoked import InvitationRevoked as InvitationRevoked from .invitation_revoked_data import InvitationRevokedData as InvitationRevokedData -from .invitation_revoked_data_state import * from .invitation_state import InvitationState as InvitationState from .invite_it_contact_intents import InviteItContactIntents as InviteItContactIntents from .list_metadata import ListMetadata as ListMetadata @@ -687,8 +654,6 @@ from .organization_created_data_domain import ( OrganizationCreatedDataDomain as OrganizationCreatedDataDomain, ) -from .organization_created_data_domain_state import * -from .organization_created_data_domain_verification_strategy import * from .organization_deleted import OrganizationDeleted as OrganizationDeleted from .organization_deleted_data import ( OrganizationDeletedData as OrganizationDeletedData, @@ -696,8 +661,6 @@ from .organization_deleted_data_domain import ( OrganizationDeletedDataDomain as OrganizationDeletedDataDomain, ) -from .organization_deleted_data_domain_state import * -from .organization_deleted_data_domain_verification_strategy import * from .organization_domain import OrganizationDomain as OrganizationDomain from .organization_domain_created import ( OrganizationDomainCreated as OrganizationDomainCreated, @@ -705,8 +668,6 @@ from .organization_domain_created_data import ( OrganizationDomainCreatedData as OrganizationDomainCreatedData, ) -from .organization_domain_created_data_state import * -from .organization_domain_created_data_verification_strategy import * from .organization_domain_data_state import ( OrganizationDomainDataState as OrganizationDomainDataState, ) @@ -716,8 +677,6 @@ from .organization_domain_deleted_data import ( OrganizationDomainDeletedData as OrganizationDomainDeletedData, ) -from .organization_domain_deleted_data_state import * -from .organization_domain_deleted_data_verification_strategy import * from .organization_domain_state import ( OrganizationDomainState as OrganizationDomainState, ) @@ -727,8 +686,6 @@ from .organization_domain_updated_data import ( OrganizationDomainUpdatedData as OrganizationDomainUpdatedData, ) -from .organization_domain_updated_data_state import * -from .organization_domain_updated_data_verification_strategy import * from .organization_domain_verification_failed import ( OrganizationDomainVerificationFailed as OrganizationDomainVerificationFailed, ) @@ -738,9 +695,6 @@ from .organization_domain_verification_failed_data_organization_domain import ( OrganizationDomainVerificationFailedDataOrganizationDomain as OrganizationDomainVerificationFailedDataOrganizationDomain, ) -from .organization_domain_verification_failed_data_organization_domain_state import * -from .organization_domain_verification_failed_data_organization_domain_verification_strategy import * -from .organization_domain_verification_failed_data_reason import * from .organization_domain_verification_strategy import ( OrganizationDomainVerificationStrategy as OrganizationDomainVerificationStrategy, ) @@ -750,22 +704,18 @@ from .organization_domain_verified_data import ( OrganizationDomainVerifiedData as OrganizationDomainVerifiedData, ) -from .organization_domain_verified_data_state import * -from .organization_domain_verified_data_verification_strategy import * from .organization_membership_created import ( OrganizationMembershipCreated as OrganizationMembershipCreated, ) from .organization_membership_created_data import ( OrganizationMembershipCreatedData as OrganizationMembershipCreatedData, ) -from .organization_membership_created_data_status import * from .organization_membership_deleted import ( OrganizationMembershipDeleted as OrganizationMembershipDeleted, ) from .organization_membership_deleted_data import ( OrganizationMembershipDeletedData as OrganizationMembershipDeletedData, ) -from .organization_membership_deleted_data_status import * from .organization_membership_status import ( OrganizationMembershipStatus as OrganizationMembershipStatus, ) @@ -775,7 +725,6 @@ from .organization_membership_updated_data import ( OrganizationMembershipUpdatedData as OrganizationMembershipUpdatedData, ) -from .organization_membership_updated_data_status import * from .organization_role_created import ( OrganizationRoleCreated as OrganizationRoleCreated, ) @@ -801,8 +750,6 @@ from .organization_updated_data_domain import ( OrganizationUpdatedDataDomain as OrganizationUpdatedDataDomain, ) -from .organization_updated_data_domain_state import * -from .organization_updated_data_domain_verification_strategy import * from .pagination_order import PaginationOrder as PaginationOrder from .password_reset_created import PasswordResetCreated as PasswordResetCreated from .password_reset_created_data import ( @@ -825,7 +772,6 @@ from .permission_updated import PermissionUpdated as PermissionUpdated from .permission_updated_data import PermissionUpdatedData as PermissionUpdatedData from .pipe_connected_account import PipeConnectedAccount as PipeConnectedAccount -from .pipe_connected_account_state import * from .pipes_account_connection_add_failed import ( PipesAccountConnectionAddFailed as PipesAccountConnectionAddFailed, ) @@ -891,24 +837,20 @@ from .resource_export_completed_data import ( ResourceExportCompletedData as ResourceExportCompletedData, ) -from .resource_export_completed_data_resource_type import * from .resource_export_created import ResourceExportCreated as ResourceExportCreated from .resource_export_created_data import ( ResourceExportCreatedData as ResourceExportCreatedData, ) -from .resource_export_created_data_resource_type import * from .resource_export_downloaded import ( ResourceExportDownloaded as ResourceExportDownloaded, ) from .resource_export_downloaded_data import ( ResourceExportDownloadedData as ResourceExportDownloadedData, ) -from .resource_export_downloaded_data_resource_type import * from .resource_export_failed import ResourceExportFailed as ResourceExportFailed from .resource_export_failed_data import ( ResourceExportFailedData as ResourceExportFailedData, ) -from .resource_export_failed_data_resource_type import * from .role_created import RoleCreated as RoleCreated from .role_created_data import RoleCreatedData as RoleCreatedData from .role_deleted import RoleDeleted as RoleDeleted @@ -918,18 +860,14 @@ from .role_updated_data import RoleUpdatedData as RoleUpdatedData from .session_created import SessionCreated as SessionCreated from .session_created_data import SessionCreatedData as SessionCreatedData -from .session_created_data_auth_method import * from .session_created_data_impersonator import ( SessionCreatedDataImpersonator as SessionCreatedDataImpersonator, ) -from .session_created_data_status import * from .session_revoked import SessionRevoked as SessionRevoked from .session_revoked_data import SessionRevokedData as SessionRevokedData -from .session_revoked_data_auth_method import * from .session_revoked_data_impersonator import ( SessionRevokedDataImpersonator as SessionRevokedDataImpersonator, ) -from .session_revoked_data_status import * from .slim_role import SlimRole as SlimRole from .team_production_state import TeamProductionState as TeamProductionState from .token_query_grant_type import TokenQueryGrantType as TokenQueryGrantType @@ -990,7 +928,6 @@ from .vault_byok_key_deleted_data import ( VaultByokKeyDeletedData as VaultByokKeyDeletedData, ) -from .vault_byok_key_provider import * from .vault_byok_key_verification_completed import ( VaultByokKeyVerificationCompleted as VaultByokKeyVerificationCompleted, ) @@ -999,40 +936,29 @@ ) from .vault_data_created import VaultDataCreated as VaultDataCreated from .vault_data_created_data import VaultDataCreatedData as VaultDataCreatedData -from .vault_data_created_data_actor_source import * from .vault_data_deleted import VaultDataDeleted as VaultDataDeleted from .vault_data_deleted_data import VaultDataDeletedData as VaultDataDeletedData -from .vault_data_deleted_data_actor_source import * from .vault_data_read import VaultDataRead as VaultDataRead from .vault_data_read_data import VaultDataReadData as VaultDataReadData -from .vault_data_read_data_actor_source import * from .vault_data_updated import VaultDataUpdated as VaultDataUpdated from .vault_data_updated_data import VaultDataUpdatedData as VaultDataUpdatedData -from .vault_data_updated_data_actor_source import * from .vault_dek_decrypted import VaultDekDecrypted as VaultDekDecrypted from .vault_dek_decrypted_data import VaultDekDecryptedData as VaultDekDecryptedData -from .vault_dek_decrypted_data_actor_source import * from .vault_dek_read import VaultDekRead as VaultDekRead from .vault_dek_read_data import VaultDekReadData as VaultDekReadData -from .vault_dek_read_data_actor_source import * from .vault_kek_created import VaultKekCreated as VaultKekCreated from .vault_kek_created_data import VaultKekCreatedData as VaultKekCreatedData -from .vault_kek_created_data_actor_source import * from .vault_kek_deleted import VaultKekDeleted as VaultKekDeleted from .vault_kek_deleted_data import VaultKekDeletedData as VaultKekDeletedData -from .vault_kek_deleted_data_actor_source import * from .vault_metadata_read import VaultMetadataRead as VaultMetadataRead from .vault_metadata_read_data import VaultMetadataReadData as VaultMetadataReadData -from .vault_metadata_read_data_actor_source import * from .vault_names_listed import VaultNamesListed as VaultNamesListed from .vault_names_listed_data import VaultNamesListedData as VaultNamesListedData -from .vault_names_listed_data_actor_source import * from .waitlist_entry_state import WaitlistEntryState as WaitlistEntryState from .waitlist_user import WaitlistUser as WaitlistUser from .waitlist_user_approved import WaitlistUserApproved as WaitlistUserApproved from .waitlist_user_created import WaitlistUserCreated as WaitlistUserCreated from .waitlist_user_denied import WaitlistUserDenied as WaitlistUserDenied -from .waitlist_user_state import * from .webhook_endpoint_status import WebhookEndpointStatus as WebhookEndpointStatus from .widget_session_token_scopes import ( WidgetSessionTokenScopes as WidgetSessionTokenScopes, diff --git a/src/workos/organizations_data_providers/__init__.py b/src/workos/organizations_data_providers/__init__.py index b773fa2d..33e9c7b7 100644 --- a/src/workos/organizations_data_providers/__init__.py +++ b/src/workos/organizations_data_providers/__init__.py @@ -1,7 +1,2 @@ # This file is auto-generated by oagen. Do not edit. -from ._resource import ( - AsyncOrganizationsDataProviders as AsyncOrganizationsDataProviders, -) -from ._resource import OrganizationsDataProviders as OrganizationsDataProviders -from .models import * diff --git a/src/workos/organizations_data_providers/_resource.py b/src/workos/organizations_data_providers/_resource.py deleted file mode 100644 index f593134d..00000000 --- a/src/workos/organizations_data_providers/_resource.py +++ /dev/null @@ -1,584 +0,0 @@ -# This file is auto-generated by oagen. Do not edit. - -from __future__ import annotations - -from typing import TYPE_CHECKING, Any - -if TYPE_CHECKING: - from .._client import AsyncWorkOSClient, WorkOSClient - -from workos.common.models.connected_account import ConnectedAccount -from workos.common.models.connected_account_input_state import ( - ConnectedAccountInputState, -) -from workos.common.models.data_integrations_list_response import ( - DataIntegrationsListResponse, -) - -from .._types import RequestOptions, enum_value - - -class OrganizationsDataProviders: - """Organizations Data Providers API resources.""" - - def __init__(self, client: WorkOSClient) -> None: - self._client = client - - def get_organization_connected_account( - self, - organization_id: str, - slug: str, - *, - supports_multiple_connections: bool | None = None, - connected_account_id: str | None = None, - request_options: RequestOptions | None = None, - ) -> ConnectedAccount: - """Get an organization connected account - - Retrieves an organization's [connected account](https://workos.com/docs/reference/pipes/connected-account) for a specific provider. - - Args: - organization_id: An [Organization](https://workos.com/docs/reference/organization) identifier. - slug: The slug identifier of the provider (e.g., `github`, `slack`, `notion`). - supports_multiple_connections: Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered. - connected_account_id: A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select a specific connection when the organization has several for this provider. - request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override. - - Returns: - ConnectedAccount - - Raises: - BadRequestError: If the request is malformed (400). - AuthenticationError: If the API key is invalid (401). - NotFoundError: If the resource is not found (404). - ConflictError: If a conflict occurs (409). - RateLimitExceededError: If rate limited (429). - ServerError: If the server returns a 5xx error. - """ - params: dict[str, Any] = { - k: v - for k, v in { - "supports_multiple_connections": supports_multiple_connections, - "connected_account_id": connected_account_id, - }.items() - if v is not None - } - return self._client.request( - method="get", - path=( - "organizations", - str(organization_id), - "connected_accounts", - str(slug), - ), - params=params, - model=ConnectedAccount, - request_options=request_options, - ) - - def create_organization_connected_account( - self, - organization_id: str, - slug: str, - *, - access_token: str | None = None, - refresh_token: str | None = None, - expires_at: str | None = None, - scopes: list[str] | None = None, - state: ConnectedAccountInputState | str | None = None, - request_options: RequestOptions | None = None, - ) -> ConnectedAccount: - """Import an organization connected account - - Imports an organization-owned [connected account](https://workos.com/docs/reference/pipes/connected-account) by providing OAuth tokens directly. Use this to migrate existing connections or set up connections without going through the OAuth flow. - - Args: - organization_id: An [Organization](https://workos.com/docs/reference/organization) identifier. - slug: The slug identifier of the provider (e.g., `github`, `slack`, `notion`). - access_token: The OAuth access token for the connected account. - refresh_token: The OAuth refresh token for the connected account. - expires_at: The ISO-8601 timestamp when the access token expires. Required when `access_token` is provided for tokens that expire. - scopes: The OAuth scopes granted for this connection. - state: Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided. - request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override. - - Returns: - ConnectedAccount - - Raises: - AuthenticationError: If the API key is invalid (401). - NotFoundError: If the resource is not found (404). - ConflictError: If a conflict occurs (409). - UnprocessableEntityError: If the request data is unprocessable (422). - RateLimitExceededError: If rate limited (429). - ServerError: If the server returns a 5xx error. - """ - body: dict[str, Any] = { - k: v - for k, v in { - "access_token": access_token, - "refresh_token": refresh_token, - "expires_at": expires_at, - "scopes": scopes, - "state": enum_value(state) if state is not None else None, - }.items() - if v is not None - } - return self._client.request( - method="post", - path=( - "organizations", - str(organization_id), - "connected_accounts", - str(slug), - ), - body=body, - model=ConnectedAccount, - request_options=request_options, - ) - - def update_organization_connected_account( - self, - organization_id: str, - slug: str, - *, - access_token: str | None = None, - refresh_token: str | None = None, - expires_at: str | None = None, - scopes: list[str] | None = None, - state: ConnectedAccountInputState | str | None = None, - supports_multiple_connections: bool | None = None, - connected_account_id: str | None = None, - request_options: RequestOptions | None = None, - ) -> ConnectedAccount: - """Update an organization connected account - - Updates an organization's [connected account](https://workos.com/docs/reference/pipes/connected-account) tokens, scopes, or state for a specific provider. - - Args: - organization_id: An [Organization](https://workos.com/docs/reference/organization) identifier. - slug: The slug identifier of the provider (e.g., `github`, `slack`, `notion`). - access_token: The OAuth access token for the connected account. - refresh_token: The OAuth refresh token for the connected account. - expires_at: The ISO-8601 timestamp when the access token expires. Required when `access_token` is provided for tokens that expire. - scopes: The OAuth scopes granted for this connection. - state: Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided. - supports_multiple_connections: Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered. - connected_account_id: A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to update. - request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override. - - Returns: - ConnectedAccount - - Raises: - BadRequestError: If the request is malformed (400). - AuthenticationError: If the API key is invalid (401). - NotFoundError: If the resource is not found (404). - ConflictError: If a conflict occurs (409). - UnprocessableEntityError: If the request data is unprocessable (422). - RateLimitExceededError: If rate limited (429). - ServerError: If the server returns a 5xx error. - """ - body: dict[str, Any] = { - k: v - for k, v in { - "access_token": access_token, - "refresh_token": refresh_token, - "expires_at": expires_at, - "scopes": scopes, - "state": enum_value(state) if state is not None else None, - }.items() - if v is not None - } - params: dict[str, Any] = { - k: v - for k, v in { - "supports_multiple_connections": supports_multiple_connections, - "connected_account_id": connected_account_id, - }.items() - if v is not None - } - return self._client.request( - method="put", - path=( - "organizations", - str(organization_id), - "connected_accounts", - str(slug), - ), - body=body, - params=params, - model=ConnectedAccount, - request_options=request_options, - ) - - def delete_organization_connected_account( - self, - organization_id: str, - slug: str, - *, - supports_multiple_connections: bool | None = None, - connected_account_id: str | None = None, - request_options: RequestOptions | None = None, - ) -> None: - """Delete an organization connected account - - Disconnects the organization's account for the provider, including removing any stored access and refresh tokens. A member will need to reauthorize if the organization wants to reconnect. This does not revoke access on the provider side. - - Args: - organization_id: An [Organization](https://workos.com/docs/reference/organization) identifier. - slug: The slug identifier of the provider (e.g., `github`, `slack`, `notion`). - supports_multiple_connections: Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered. - connected_account_id: A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to delete. - request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override. - - Raises: - BadRequestError: If the request is malformed (400). - AuthenticationError: If the API key is invalid (401). - NotFoundError: If the resource is not found (404). - ConflictError: If a conflict occurs (409). - RateLimitExceededError: If rate limited (429). - ServerError: If the server returns a 5xx error. - """ - params: dict[str, Any] = { - k: v - for k, v in { - "supports_multiple_connections": supports_multiple_connections, - "connected_account_id": connected_account_id, - }.items() - if v is not None - } - self._client.request( - method="delete", - path=( - "organizations", - str(organization_id), - "connected_accounts", - str(slug), - ), - params=params, - request_options=request_options, - ) - - def list_organization_data_providers( - self, - organization_id: str, - *, - supports_multiple_connections: bool | None = None, - request_options: RequestOptions | None = None, - ) -> DataIntegrationsListResponse: - """List providers for an organization - - Retrieves the organization-owned providers configured for your environment and the organization's [connected account](https://workos.com/docs/reference/pipes/connected-account) information for each. Providers owned by individual users are not included. - - Args: - organization_id: An [Organization](https://workos.com/docs/reference/organization) identifier to list providers and connected accounts for. - supports_multiple_connections: Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered. - request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override. - - Returns: - DataIntegrationsListResponse - - Raises: - AuthenticationError: If the API key is invalid (401). - NotFoundError: If the resource is not found (404). - RateLimitExceededError: If rate limited (429). - ServerError: If the server returns a 5xx error. - """ - params: dict[str, Any] = { - k: v - for k, v in { - "supports_multiple_connections": supports_multiple_connections, - }.items() - if v is not None - } - return self._client.request( - method="get", - path=("organizations", str(organization_id), "data_providers"), - params=params, - model=DataIntegrationsListResponse, - request_options=request_options, - ) - - -class AsyncOrganizationsDataProviders: - """Organizations Data Providers API resources (async).""" - - def __init__(self, client: AsyncWorkOSClient) -> None: - self._client = client - - async def get_organization_connected_account( - self, - organization_id: str, - slug: str, - *, - supports_multiple_connections: bool | None = None, - connected_account_id: str | None = None, - request_options: RequestOptions | None = None, - ) -> ConnectedAccount: - """Get an organization connected account - - Retrieves an organization's [connected account](https://workos.com/docs/reference/pipes/connected-account) for a specific provider. - - Args: - organization_id: An [Organization](https://workos.com/docs/reference/organization) identifier. - slug: The slug identifier of the provider (e.g., `github`, `slack`, `notion`). - supports_multiple_connections: Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered. - connected_account_id: A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select a specific connection when the organization has several for this provider. - request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override. - - Returns: - ConnectedAccount - - Raises: - BadRequestError: If the request is malformed (400). - AuthenticationError: If the API key is invalid (401). - NotFoundError: If the resource is not found (404). - ConflictError: If a conflict occurs (409). - RateLimitExceededError: If rate limited (429). - ServerError: If the server returns a 5xx error. - """ - params: dict[str, Any] = { - k: v - for k, v in { - "supports_multiple_connections": supports_multiple_connections, - "connected_account_id": connected_account_id, - }.items() - if v is not None - } - return await self._client.request( - method="get", - path=( - "organizations", - str(organization_id), - "connected_accounts", - str(slug), - ), - params=params, - model=ConnectedAccount, - request_options=request_options, - ) - - async def create_organization_connected_account( - self, - organization_id: str, - slug: str, - *, - access_token: str | None = None, - refresh_token: str | None = None, - expires_at: str | None = None, - scopes: list[str] | None = None, - state: ConnectedAccountInputState | str | None = None, - request_options: RequestOptions | None = None, - ) -> ConnectedAccount: - """Import an organization connected account - - Imports an organization-owned [connected account](https://workos.com/docs/reference/pipes/connected-account) by providing OAuth tokens directly. Use this to migrate existing connections or set up connections without going through the OAuth flow. - - Args: - organization_id: An [Organization](https://workos.com/docs/reference/organization) identifier. - slug: The slug identifier of the provider (e.g., `github`, `slack`, `notion`). - access_token: The OAuth access token for the connected account. - refresh_token: The OAuth refresh token for the connected account. - expires_at: The ISO-8601 timestamp when the access token expires. Required when `access_token` is provided for tokens that expire. - scopes: The OAuth scopes granted for this connection. - state: Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided. - request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override. - - Returns: - ConnectedAccount - - Raises: - AuthenticationError: If the API key is invalid (401). - NotFoundError: If the resource is not found (404). - ConflictError: If a conflict occurs (409). - UnprocessableEntityError: If the request data is unprocessable (422). - RateLimitExceededError: If rate limited (429). - ServerError: If the server returns a 5xx error. - """ - body: dict[str, Any] = { - k: v - for k, v in { - "access_token": access_token, - "refresh_token": refresh_token, - "expires_at": expires_at, - "scopes": scopes, - "state": enum_value(state) if state is not None else None, - }.items() - if v is not None - } - return await self._client.request( - method="post", - path=( - "organizations", - str(organization_id), - "connected_accounts", - str(slug), - ), - body=body, - model=ConnectedAccount, - request_options=request_options, - ) - - async def update_organization_connected_account( - self, - organization_id: str, - slug: str, - *, - access_token: str | None = None, - refresh_token: str | None = None, - expires_at: str | None = None, - scopes: list[str] | None = None, - state: ConnectedAccountInputState | str | None = None, - supports_multiple_connections: bool | None = None, - connected_account_id: str | None = None, - request_options: RequestOptions | None = None, - ) -> ConnectedAccount: - """Update an organization connected account - - Updates an organization's [connected account](https://workos.com/docs/reference/pipes/connected-account) tokens, scopes, or state for a specific provider. - - Args: - organization_id: An [Organization](https://workos.com/docs/reference/organization) identifier. - slug: The slug identifier of the provider (e.g., `github`, `slack`, `notion`). - access_token: The OAuth access token for the connected account. - refresh_token: The OAuth refresh token for the connected account. - expires_at: The ISO-8601 timestamp when the access token expires. Required when `access_token` is provided for tokens that expire. - scopes: The OAuth scopes granted for this connection. - state: Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided. - supports_multiple_connections: Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered. - connected_account_id: A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to update. - request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override. - - Returns: - ConnectedAccount - - Raises: - BadRequestError: If the request is malformed (400). - AuthenticationError: If the API key is invalid (401). - NotFoundError: If the resource is not found (404). - ConflictError: If a conflict occurs (409). - UnprocessableEntityError: If the request data is unprocessable (422). - RateLimitExceededError: If rate limited (429). - ServerError: If the server returns a 5xx error. - """ - body: dict[str, Any] = { - k: v - for k, v in { - "access_token": access_token, - "refresh_token": refresh_token, - "expires_at": expires_at, - "scopes": scopes, - "state": enum_value(state) if state is not None else None, - }.items() - if v is not None - } - params: dict[str, Any] = { - k: v - for k, v in { - "supports_multiple_connections": supports_multiple_connections, - "connected_account_id": connected_account_id, - }.items() - if v is not None - } - return await self._client.request( - method="put", - path=( - "organizations", - str(organization_id), - "connected_accounts", - str(slug), - ), - body=body, - params=params, - model=ConnectedAccount, - request_options=request_options, - ) - - async def delete_organization_connected_account( - self, - organization_id: str, - slug: str, - *, - supports_multiple_connections: bool | None = None, - connected_account_id: str | None = None, - request_options: RequestOptions | None = None, - ) -> None: - """Delete an organization connected account - - Disconnects the organization's account for the provider, including removing any stored access and refresh tokens. A member will need to reauthorize if the organization wants to reconnect. This does not revoke access on the provider side. - - Args: - organization_id: An [Organization](https://workos.com/docs/reference/organization) identifier. - slug: The slug identifier of the provider (e.g., `github`, `slack`, `notion`). - supports_multiple_connections: Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered. - connected_account_id: A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to delete. - request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override. - - Raises: - BadRequestError: If the request is malformed (400). - AuthenticationError: If the API key is invalid (401). - NotFoundError: If the resource is not found (404). - ConflictError: If a conflict occurs (409). - RateLimitExceededError: If rate limited (429). - ServerError: If the server returns a 5xx error. - """ - params: dict[str, Any] = { - k: v - for k, v in { - "supports_multiple_connections": supports_multiple_connections, - "connected_account_id": connected_account_id, - }.items() - if v is not None - } - await self._client.request( - method="delete", - path=( - "organizations", - str(organization_id), - "connected_accounts", - str(slug), - ), - params=params, - request_options=request_options, - ) - - async def list_organization_data_providers( - self, - organization_id: str, - *, - supports_multiple_connections: bool | None = None, - request_options: RequestOptions | None = None, - ) -> DataIntegrationsListResponse: - """List providers for an organization - - Retrieves the organization-owned providers configured for your environment and the organization's [connected account](https://workos.com/docs/reference/pipes/connected-account) information for each. Providers owned by individual users are not included. - - Args: - organization_id: An [Organization](https://workos.com/docs/reference/organization) identifier to list providers and connected accounts for. - supports_multiple_connections: Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered. - request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override. - - Returns: - DataIntegrationsListResponse - - Raises: - AuthenticationError: If the API key is invalid (401). - NotFoundError: If the resource is not found (404). - RateLimitExceededError: If rate limited (429). - ServerError: If the server returns a 5xx error. - """ - params: dict[str, Any] = { - k: v - for k, v in { - "supports_multiple_connections": supports_multiple_connections, - }.items() - if v is not None - } - return await self._client.request( - method="get", - path=("organizations", str(organization_id), "data_providers"), - params=params, - model=DataIntegrationsListResponse, - request_options=request_options, - ) diff --git a/src/workos/organizations_data_providers/models/__init__.py b/src/workos/organizations_data_providers/models/__init__.py index 5271119e..33e9c7b7 100644 --- a/src/workos/organizations_data_providers/models/__init__.py +++ b/src/workos/organizations_data_providers/models/__init__.py @@ -1,14 +1,2 @@ # This file is auto-generated by oagen. Do not edit. -from workos.common.models.connected_account_input import ( - ConnectedAccountInput as ConnectedAccountInput, -) -from workos.common.models.data_integrations_list_response import ( - DataIntegrationsListResponse as DataIntegrationsListResponse, -) -from workos.common.models.data_integrations_list_response_data import ( - DataIntegrationsListResponseData as DataIntegrationsListResponseData, -) -from workos.common.models.data_integrations_list_response_data_connected_account import ( - DataIntegrationsListResponseDataConnectedAccount as DataIntegrationsListResponseDataConnectedAccount, -) diff --git a/src/workos/pipes/_resource.py b/src/workos/pipes/_resource.py index d716edff..91a88875 100644 --- a/src/workos/pipes/_resource.py +++ b/src/workos/pipes/_resource.py @@ -731,6 +731,282 @@ def get_access_token( request_options=request_options, ) + def get_organization_connected_account( + self, + organization_id: str, + slug: str, + *, + supports_multiple_connections: bool | None = None, + connected_account_id: str | None = None, + request_options: RequestOptions | None = None, + ) -> ConnectedAccount: + """Get an organization connected account + + Retrieves an organization's [connected account](https://workos.com/docs/reference/pipes/connected-account) for a specific provider. + + Args: + organization_id: An [Organization](https://workos.com/docs/reference/organization) identifier. + slug: The slug identifier of the provider (e.g., `github`, `slack`, `notion`). + supports_multiple_connections: Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered. + connected_account_id: A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select a specific connection when the organization has several for this provider. + request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override. + + Returns: + ConnectedAccount + + Raises: + BadRequestError: If the request is malformed (400). + AuthenticationError: If the API key is invalid (401). + NotFoundError: If the resource is not found (404). + ConflictError: If a conflict occurs (409). + RateLimitExceededError: If rate limited (429). + ServerError: If the server returns a 5xx error. + """ + params: dict[str, Any] = { + k: v + for k, v in { + "supports_multiple_connections": supports_multiple_connections, + "connected_account_id": connected_account_id, + }.items() + if v is not None + } + return self._client.request( + method="get", + path=( + "organizations", + str(organization_id), + "connected_accounts", + str(slug), + ), + params=params, + model=ConnectedAccount, + request_options=request_options, + ) + + def create_organization_connected_account( + self, + organization_id: str, + slug: str, + *, + access_token: str | None = None, + refresh_token: str | None = None, + expires_at: str | None = None, + scopes: list[str] | None = None, + state: ConnectedAccountInputState | str | None = None, + request_options: RequestOptions | None = None, + ) -> ConnectedAccount: + """Import an organization connected account + + Imports an organization-owned [connected account](https://workos.com/docs/reference/pipes/connected-account) by providing OAuth tokens directly. Use this to migrate existing connections or set up connections without going through the OAuth flow. + + Args: + organization_id: An [Organization](https://workos.com/docs/reference/organization) identifier. + slug: The slug identifier of the provider (e.g., `github`, `slack`, `notion`). + access_token: The OAuth access token for the connected account. + refresh_token: The OAuth refresh token for the connected account. + expires_at: The ISO-8601 timestamp when the access token expires. Required when `access_token` is provided for tokens that expire. + scopes: The OAuth scopes granted for this connection. + state: Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided. + request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override. + + Returns: + ConnectedAccount + + Raises: + AuthenticationError: If the API key is invalid (401). + NotFoundError: If the resource is not found (404). + ConflictError: If a conflict occurs (409). + UnprocessableEntityError: If the request data is unprocessable (422). + RateLimitExceededError: If rate limited (429). + ServerError: If the server returns a 5xx error. + """ + body: dict[str, Any] = { + k: v + for k, v in { + "access_token": access_token, + "refresh_token": refresh_token, + "expires_at": expires_at, + "scopes": scopes, + "state": enum_value(state) if state is not None else None, + }.items() + if v is not None + } + return self._client.request( + method="post", + path=( + "organizations", + str(organization_id), + "connected_accounts", + str(slug), + ), + body=body, + model=ConnectedAccount, + request_options=request_options, + ) + + def update_organization_connected_account( + self, + organization_id: str, + slug: str, + *, + access_token: str | None = None, + refresh_token: str | None = None, + expires_at: str | None = None, + scopes: list[str] | None = None, + state: ConnectedAccountInputState | str | None = None, + supports_multiple_connections: bool | None = None, + connected_account_id: str | None = None, + request_options: RequestOptions | None = None, + ) -> ConnectedAccount: + """Update an organization connected account + + Updates an organization's [connected account](https://workos.com/docs/reference/pipes/connected-account) tokens, scopes, or state for a specific provider. + + Args: + organization_id: An [Organization](https://workos.com/docs/reference/organization) identifier. + slug: The slug identifier of the provider (e.g., `github`, `slack`, `notion`). + access_token: The OAuth access token for the connected account. + refresh_token: The OAuth refresh token for the connected account. + expires_at: The ISO-8601 timestamp when the access token expires. Required when `access_token` is provided for tokens that expire. + scopes: The OAuth scopes granted for this connection. + state: Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided. + supports_multiple_connections: Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered. + connected_account_id: A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to update. + request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override. + + Returns: + ConnectedAccount + + Raises: + BadRequestError: If the request is malformed (400). + AuthenticationError: If the API key is invalid (401). + NotFoundError: If the resource is not found (404). + ConflictError: If a conflict occurs (409). + UnprocessableEntityError: If the request data is unprocessable (422). + RateLimitExceededError: If rate limited (429). + ServerError: If the server returns a 5xx error. + """ + body: dict[str, Any] = { + k: v + for k, v in { + "access_token": access_token, + "refresh_token": refresh_token, + "expires_at": expires_at, + "scopes": scopes, + "state": enum_value(state) if state is not None else None, + }.items() + if v is not None + } + params: dict[str, Any] = { + k: v + for k, v in { + "supports_multiple_connections": supports_multiple_connections, + "connected_account_id": connected_account_id, + }.items() + if v is not None + } + return self._client.request( + method="put", + path=( + "organizations", + str(organization_id), + "connected_accounts", + str(slug), + ), + body=body, + params=params, + model=ConnectedAccount, + request_options=request_options, + ) + + def delete_organization_connected_account( + self, + organization_id: str, + slug: str, + *, + supports_multiple_connections: bool | None = None, + connected_account_id: str | None = None, + request_options: RequestOptions | None = None, + ) -> None: + """Delete an organization connected account + + Disconnects the organization's account for the provider, including removing any stored access and refresh tokens. A member will need to reauthorize if the organization wants to reconnect. This does not revoke access on the provider side. + + Args: + organization_id: An [Organization](https://workos.com/docs/reference/organization) identifier. + slug: The slug identifier of the provider (e.g., `github`, `slack`, `notion`). + supports_multiple_connections: Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered. + connected_account_id: A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to delete. + request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override. + + Raises: + BadRequestError: If the request is malformed (400). + AuthenticationError: If the API key is invalid (401). + NotFoundError: If the resource is not found (404). + ConflictError: If a conflict occurs (409). + RateLimitExceededError: If rate limited (429). + ServerError: If the server returns a 5xx error. + """ + params: dict[str, Any] = { + k: v + for k, v in { + "supports_multiple_connections": supports_multiple_connections, + "connected_account_id": connected_account_id, + }.items() + if v is not None + } + self._client.request( + method="delete", + path=( + "organizations", + str(organization_id), + "connected_accounts", + str(slug), + ), + params=params, + request_options=request_options, + ) + + def list_organization_data_providers( + self, + organization_id: str, + *, + supports_multiple_connections: bool | None = None, + request_options: RequestOptions | None = None, + ) -> DataIntegrationsListResponse: + """List providers for an organization + + Retrieves the organization-owned providers configured for your environment and the organization's [connected account](https://workos.com/docs/reference/pipes/connected-account) information for each. Providers owned by individual users are not included. + + Args: + organization_id: An [Organization](https://workos.com/docs/reference/organization) identifier to list providers and connected accounts for. + supports_multiple_connections: Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered. + request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override. + + Returns: + DataIntegrationsListResponse + + Raises: + AuthenticationError: If the API key is invalid (401). + NotFoundError: If the resource is not found (404). + RateLimitExceededError: If rate limited (429). + ServerError: If the server returns a 5xx error. + """ + params: dict[str, Any] = { + k: v + for k, v in { + "supports_multiple_connections": supports_multiple_connections, + }.items() + if v is not None + } + return self._client.request( + method="get", + path=("organizations", str(organization_id), "data_providers"), + params=params, + model=DataIntegrationsListResponse, + request_options=request_options, + ) + def get_user_connected_account( self, user_id: str, @@ -1713,6 +1989,282 @@ async def get_access_token( request_options=request_options, ) + async def get_organization_connected_account( + self, + organization_id: str, + slug: str, + *, + supports_multiple_connections: bool | None = None, + connected_account_id: str | None = None, + request_options: RequestOptions | None = None, + ) -> ConnectedAccount: + """Get an organization connected account + + Retrieves an organization's [connected account](https://workos.com/docs/reference/pipes/connected-account) for a specific provider. + + Args: + organization_id: An [Organization](https://workos.com/docs/reference/organization) identifier. + slug: The slug identifier of the provider (e.g., `github`, `slack`, `notion`). + supports_multiple_connections: Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered. + connected_account_id: A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select a specific connection when the organization has several for this provider. + request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override. + + Returns: + ConnectedAccount + + Raises: + BadRequestError: If the request is malformed (400). + AuthenticationError: If the API key is invalid (401). + NotFoundError: If the resource is not found (404). + ConflictError: If a conflict occurs (409). + RateLimitExceededError: If rate limited (429). + ServerError: If the server returns a 5xx error. + """ + params: dict[str, Any] = { + k: v + for k, v in { + "supports_multiple_connections": supports_multiple_connections, + "connected_account_id": connected_account_id, + }.items() + if v is not None + } + return await self._client.request( + method="get", + path=( + "organizations", + str(organization_id), + "connected_accounts", + str(slug), + ), + params=params, + model=ConnectedAccount, + request_options=request_options, + ) + + async def create_organization_connected_account( + self, + organization_id: str, + slug: str, + *, + access_token: str | None = None, + refresh_token: str | None = None, + expires_at: str | None = None, + scopes: list[str] | None = None, + state: ConnectedAccountInputState | str | None = None, + request_options: RequestOptions | None = None, + ) -> ConnectedAccount: + """Import an organization connected account + + Imports an organization-owned [connected account](https://workos.com/docs/reference/pipes/connected-account) by providing OAuth tokens directly. Use this to migrate existing connections or set up connections without going through the OAuth flow. + + Args: + organization_id: An [Organization](https://workos.com/docs/reference/organization) identifier. + slug: The slug identifier of the provider (e.g., `github`, `slack`, `notion`). + access_token: The OAuth access token for the connected account. + refresh_token: The OAuth refresh token for the connected account. + expires_at: The ISO-8601 timestamp when the access token expires. Required when `access_token` is provided for tokens that expire. + scopes: The OAuth scopes granted for this connection. + state: Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided. + request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override. + + Returns: + ConnectedAccount + + Raises: + AuthenticationError: If the API key is invalid (401). + NotFoundError: If the resource is not found (404). + ConflictError: If a conflict occurs (409). + UnprocessableEntityError: If the request data is unprocessable (422). + RateLimitExceededError: If rate limited (429). + ServerError: If the server returns a 5xx error. + """ + body: dict[str, Any] = { + k: v + for k, v in { + "access_token": access_token, + "refresh_token": refresh_token, + "expires_at": expires_at, + "scopes": scopes, + "state": enum_value(state) if state is not None else None, + }.items() + if v is not None + } + return await self._client.request( + method="post", + path=( + "organizations", + str(organization_id), + "connected_accounts", + str(slug), + ), + body=body, + model=ConnectedAccount, + request_options=request_options, + ) + + async def update_organization_connected_account( + self, + organization_id: str, + slug: str, + *, + access_token: str | None = None, + refresh_token: str | None = None, + expires_at: str | None = None, + scopes: list[str] | None = None, + state: ConnectedAccountInputState | str | None = None, + supports_multiple_connections: bool | None = None, + connected_account_id: str | None = None, + request_options: RequestOptions | None = None, + ) -> ConnectedAccount: + """Update an organization connected account + + Updates an organization's [connected account](https://workos.com/docs/reference/pipes/connected-account) tokens, scopes, or state for a specific provider. + + Args: + organization_id: An [Organization](https://workos.com/docs/reference/organization) identifier. + slug: The slug identifier of the provider (e.g., `github`, `slack`, `notion`). + access_token: The OAuth access token for the connected account. + refresh_token: The OAuth refresh token for the connected account. + expires_at: The ISO-8601 timestamp when the access token expires. Required when `access_token` is provided for tokens that expire. + scopes: The OAuth scopes granted for this connection. + state: Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided. + supports_multiple_connections: Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered. + connected_account_id: A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to update. + request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override. + + Returns: + ConnectedAccount + + Raises: + BadRequestError: If the request is malformed (400). + AuthenticationError: If the API key is invalid (401). + NotFoundError: If the resource is not found (404). + ConflictError: If a conflict occurs (409). + UnprocessableEntityError: If the request data is unprocessable (422). + RateLimitExceededError: If rate limited (429). + ServerError: If the server returns a 5xx error. + """ + body: dict[str, Any] = { + k: v + for k, v in { + "access_token": access_token, + "refresh_token": refresh_token, + "expires_at": expires_at, + "scopes": scopes, + "state": enum_value(state) if state is not None else None, + }.items() + if v is not None + } + params: dict[str, Any] = { + k: v + for k, v in { + "supports_multiple_connections": supports_multiple_connections, + "connected_account_id": connected_account_id, + }.items() + if v is not None + } + return await self._client.request( + method="put", + path=( + "organizations", + str(organization_id), + "connected_accounts", + str(slug), + ), + body=body, + params=params, + model=ConnectedAccount, + request_options=request_options, + ) + + async def delete_organization_connected_account( + self, + organization_id: str, + slug: str, + *, + supports_multiple_connections: bool | None = None, + connected_account_id: str | None = None, + request_options: RequestOptions | None = None, + ) -> None: + """Delete an organization connected account + + Disconnects the organization's account for the provider, including removing any stored access and refresh tokens. A member will need to reauthorize if the organization wants to reconnect. This does not revoke access on the provider side. + + Args: + organization_id: An [Organization](https://workos.com/docs/reference/organization) identifier. + slug: The slug identifier of the provider (e.g., `github`, `slack`, `notion`). + supports_multiple_connections: Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered. + connected_account_id: A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to delete. + request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override. + + Raises: + BadRequestError: If the request is malformed (400). + AuthenticationError: If the API key is invalid (401). + NotFoundError: If the resource is not found (404). + ConflictError: If a conflict occurs (409). + RateLimitExceededError: If rate limited (429). + ServerError: If the server returns a 5xx error. + """ + params: dict[str, Any] = { + k: v + for k, v in { + "supports_multiple_connections": supports_multiple_connections, + "connected_account_id": connected_account_id, + }.items() + if v is not None + } + await self._client.request( + method="delete", + path=( + "organizations", + str(organization_id), + "connected_accounts", + str(slug), + ), + params=params, + request_options=request_options, + ) + + async def list_organization_data_providers( + self, + organization_id: str, + *, + supports_multiple_connections: bool | None = None, + request_options: RequestOptions | None = None, + ) -> DataIntegrationsListResponse: + """List providers for an organization + + Retrieves the organization-owned providers configured for your environment and the organization's [connected account](https://workos.com/docs/reference/pipes/connected-account) information for each. Providers owned by individual users are not included. + + Args: + organization_id: An [Organization](https://workos.com/docs/reference/organization) identifier to list providers and connected accounts for. + supports_multiple_connections: Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered. + request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override. + + Returns: + DataIntegrationsListResponse + + Raises: + AuthenticationError: If the API key is invalid (401). + NotFoundError: If the resource is not found (404). + RateLimitExceededError: If rate limited (429). + ServerError: If the server returns a 5xx error. + """ + params: dict[str, Any] = { + k: v + for k, v in { + "supports_multiple_connections": supports_multiple_connections, + }.items() + if v is not None + } + return await self._client.request( + method="get", + path=("organizations", str(organization_id), "data_providers"), + params=params, + model=DataIntegrationsListResponse, + request_options=request_options, + ) + async def get_user_connected_account( self, user_id: str, diff --git a/src/workos/pipes/models/__init__.py b/src/workos/pipes/models/__init__.py index dd91230f..f27a0080 100644 --- a/src/workos/pipes/models/__init__.py +++ b/src/workos/pipes/models/__init__.py @@ -1,9 +1,20 @@ # This file is auto-generated by oagen. Do not edit. from workos.common.models.connected_account import ConnectedAccount as ConnectedAccount +from workos.common.models.connected_account_input import ( + ConnectedAccountInput as ConnectedAccountInput, +) +from workos.common.models.data_integrations_list_response import ( + DataIntegrationsListResponse as DataIntegrationsListResponse, +) +from workos.common.models.data_integrations_list_response_data import ( + DataIntegrationsListResponseData as DataIntegrationsListResponseData, +) +from workos.common.models.data_integrations_list_response_data_connected_account import ( + DataIntegrationsListResponseDataConnectedAccount as DataIntegrationsListResponseDataConnectedAccount, +) from .api_key_installation import ApiKeyInstallation as ApiKeyInstallation -from .connected_account_input import * from .create_data_integration import CreateDataIntegration as CreateDataIntegration from .custom_provider_definition import ( CustomProviderDefinition as CustomProviderDefinition, @@ -42,9 +53,6 @@ from .data_integrations_get_user_token_request import ( DataIntegrationsGetUserTokenRequest as DataIntegrationsGetUserTokenRequest, ) -from .data_integrations_list_response import * -from .data_integrations_list_response_data import * -from .data_integrations_list_response_data_connected_account import * from .data_integrations_upsert_api_key_request import ( DataIntegrationsUpsertApiKeyRequest as DataIntegrationsUpsertApiKeyRequest, ) diff --git a/src/workos/pipes/models/connected_account_input.py b/src/workos/pipes/models/connected_account_input.py deleted file mode 100644 index 2bd2eb1d..00000000 --- a/src/workos/pipes/models/connected_account_input.py +++ /dev/null @@ -1,64 +0,0 @@ -# This file is auto-generated by oagen. Do not edit. - -from __future__ import annotations - -from dataclasses import dataclass -from datetime import datetime -from enum import Enum -from typing import Any - -from workos._types import _format_datetime, _parse_datetime, _raise_deserialize_error -from workos.common.models.connected_account_input_state import ( - ConnectedAccountInputState, -) - - -@dataclass(slots=True) -class ConnectedAccountInput: - """Connected Account Input model.""" - - access_token: str | None = None - """The OAuth access token for the connected account.""" - refresh_token: str | None = None - """The OAuth refresh token for the connected account.""" - expires_at: datetime | None = None - """The ISO-8601 timestamp when the access token expires. Required when `access_token` is provided for tokens that expire.""" - scopes: list[str] | None = None - """The OAuth scopes granted for this connection.""" - state: ConnectedAccountInputState | None = None - """Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided.""" - - @classmethod - def from_dict(cls, data: dict[str, Any]) -> ConnectedAccountInput: - """Deserialize from a dictionary.""" - try: - return cls( - access_token=data.get("access_token"), - refresh_token=data.get("refresh_token"), - expires_at=_parse_datetime(_v_expires_at) - if (_v_expires_at := data.get("expires_at")) is not None - else None, - scopes=data.get("scopes"), - state=ConnectedAccountInputState(_v_state) - if (_v_state := data.get("state")) is not None - else None, - ) - except (KeyError, ValueError) as e: - _raise_deserialize_error("ConnectedAccountInput", e) - - def to_dict(self) -> dict[str, Any]: - """Serialize to a dictionary.""" - result: dict[str, Any] = {} - if self.access_token is not None: - result["access_token"] = self.access_token - if self.refresh_token is not None: - result["refresh_token"] = self.refresh_token - if self.expires_at is not None: - result["expires_at"] = _format_datetime(self.expires_at) - if self.scopes is not None: - result["scopes"] = self.scopes - if self.state is not None: - result["state"] = ( - self.state.value if isinstance(self.state, Enum) else self.state - ) - return result diff --git a/src/workos/pipes/models/data_integrations_list_response.py b/src/workos/pipes/models/data_integrations_list_response.py deleted file mode 100644 index a8482582..00000000 --- a/src/workos/pipes/models/data_integrations_list_response.py +++ /dev/null @@ -1,43 +0,0 @@ -# This file is auto-generated by oagen. Do not edit. - -from __future__ import annotations - -from dataclasses import dataclass -from typing import Any, Literal, cast - -from workos._types import _raise_deserialize_error - -from .data_integrations_list_response_data import DataIntegrationsListResponseData - - -@dataclass(slots=True) -class DataIntegrationsListResponse: - """Data Integrations List Response model.""" - - 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 the legacy `connected_account` field and the additive `connected_accounts` collection.""" - - @classmethod - def from_dict(cls, data: dict[str, Any]) -> DataIntegrationsListResponse: - """Deserialize from a dictionary.""" - try: - return cls( - object=data.get("object", "list"), - data=[ - DataIntegrationsListResponseData.from_dict( - cast(dict[str, Any], item) - ) - for item in cast(list[Any], data["data"]) - ], - ) - except (KeyError, ValueError) as e: - _raise_deserialize_error("DataIntegrationsListResponse", e) - - def to_dict(self) -> dict[str, Any]: - """Serialize to a dictionary.""" - result: dict[str, Any] = {} - result["object"] = self.object - result["data"] = [item.to_dict() for item in self.data] - return result diff --git a/src/workos/pipes/models/data_integrations_list_response_data.py b/src/workos/pipes/models/data_integrations_list_response_data.py deleted file mode 100644 index cd02d5a5..00000000 --- a/src/workos/pipes/models/data_integrations_list_response_data.py +++ /dev/null @@ -1,126 +0,0 @@ -# This file is auto-generated by oagen. Do not edit. - -from __future__ import annotations - -from dataclasses import dataclass -from enum import Enum -from typing import Any, Literal, cast - -from workos._types import _raise_deserialize_error -from workos.common.models.data_integrations_list_response_data_auth_methods import ( - DataIntegrationsListResponseDataAuthMethods, -) -from workos.common.models.data_integrations_list_response_data_ownership import ( - DataIntegrationsListResponseDataOwnership, -) - -from .data_integrations_list_response_data_connected_account import ( - DataIntegrationsListResponseDataConnectedAccount, -) - - -@dataclass(slots=True) -class DataIntegrationsListResponseData: - """Data Integrations List Response Data model.""" - - object: Literal["data_provider"] - """Distinguishes the data provider object.""" - id: str - """The unique identifier of the provider.""" - name: str - """The display name of the provider (e.g., "GitHub", "Slack").""" - description: str | None - """A description of the provider explaining how it will be used, if configured.""" - slug: str - """The slug identifier used in API calls (e.g., `github`, `slack`, `notion`).""" - integration_type: str - """The type of integration (e.g., `github`, `slack`).""" - credentials_type: str - """The type of credentials used by the provider (e.g., `oauth2`).""" - scopes: list[str] | None - """The OAuth scopes configured for this provider, or `null` if none are configured.""" - ownership: DataIntegrationsListResponseDataOwnership - """Whether the provider is owned by a user or organization.""" - created_at: str - """The timestamp when the provider was created.""" - updated_at: str - """The timestamp when the provider was last updated.""" - connected_account: DataIntegrationsListResponseDataConnectedAccount | None - """The user's compatibility [connected account](https://workos.com/docs/reference/pipes/connected-account) for this provider, or `null` when the compatibility slot is empty. This legacy field never selects a standard connection.""" - connected_accounts: list[DataIntegrationsListResponseDataConnectedAccount] - """The user's connected accounts for this provider in the requested ownership context. This contains only the compatibility connection unless `supports_multiple_connections` is `true`.""" - 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.""" - - @classmethod - def from_dict(cls, data: dict[str, Any]) -> DataIntegrationsListResponseData: - """Deserialize from a dictionary.""" - try: - return cls( - object=data.get("object", "data_provider"), - id=data["id"], - name=data["name"], - description=data["description"], - slug=data["slug"], - integration_type=data["integration_type"], - credentials_type=data["credentials_type"], - scopes=data["scopes"], - ownership=DataIntegrationsListResponseDataOwnership(data["ownership"]), - created_at=data["created_at"], - updated_at=data["updated_at"], - connected_account=DataIntegrationsListResponseDataConnectedAccount.from_dict( - cast(dict[str, Any], _v_connected_account) - ) - 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) - ] - if (_v_auth_methods := data.get("auth_methods")) is not None - else None, - ) - except (KeyError, ValueError) as e: - _raise_deserialize_error("DataIntegrationsListResponseData", e) - - def to_dict(self) -> dict[str, Any]: - """Serialize to a dictionary.""" - result: dict[str, Any] = {} - result["object"] = self.object - result["id"] = self.id - result["name"] = self.name - if self.description is not None: - result["description"] = self.description - else: - result["description"] = None - result["slug"] = self.slug - result["integration_type"] = self.integration_type - result["credentials_type"] = self.credentials_type - if self.scopes is not None: - result["scopes"] = self.scopes - else: - result["scopes"] = None - result["ownership"] = ( - self.ownership.value if isinstance(self.ownership, Enum) else self.ownership - ) - result["created_at"] = self.created_at - result["updated_at"] = self.updated_at - if self.connected_account is not None: - 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 - for item in self.auth_methods - ] - return result diff --git a/src/workos/pipes/models/data_integrations_list_response_data_connected_account.py b/src/workos/pipes/models/data_integrations_list_response_data_connected_account.py deleted file mode 100644 index 51acd981..00000000 --- a/src/workos/pipes/models/data_integrations_list_response_data_connected_account.py +++ /dev/null @@ -1,134 +0,0 @@ -# This file is auto-generated by oagen. Do not edit. - -from __future__ import annotations - -from dataclasses import dataclass -from enum import Enum -from typing import Any, Literal - -from workos._types import _raise_deserialize_error -from workos.common.models.data_integrations_list_response_data_connected_account_auth_method import ( - DataIntegrationsListResponseDataConnectedAccountAuthMethod, -) -from workos.common.models.data_integrations_list_response_data_connected_account_state import ( - DataIntegrationsListResponseDataConnectedAccountState, -) - - -@dataclass(slots=True) -class DataIntegrationsListResponseDataConnectedAccount: - """Data Integrations List Response Data Connected Account model.""" - - object: Literal["connected_account"] - """Distinguishes the connected account object.""" - id: str - """The unique identifier of the connected account.""" - user_id: str | None - """The [User](https://workos.com/docs/reference/authkit/user) identifier associated with this connection.""" - organization_id: str | None - """The [Organization](https://workos.com/docs/reference/organization) identifier associated with this connection, or `null` if not scoped to an organization.""" - scopes: list[str] - """The OAuth scopes granted for this connection.""" - state: DataIntegrationsListResponseDataConnectedAccountState - """The state of the connected account: -- `connected`: The connection is active and tokens are valid. -- `needs_reauthorization`: The user needs to reauthorize the connection, typically because required scopes have changed. -- `disconnected`: The connection has been disconnected.""" - created_at: str - """The timestamp when the connection was created.""" - updated_at: str - """The timestamp when the connection was last updated.""" - auth_method: DataIntegrationsListResponseDataConnectedAccountAuthMethod | None = ( - None - ) - """The authentication method used for this connection (`oauth`, `api_key`, or `client_credentials`). Defaults to `oauth` if absent.""" - api_key_last_4: str | None = None - """The last four characters of the API key, or `null` for OAuth connections.""" - client_id: str | None = None - """The client ID supplied for this connection. Only present when `auth_method` is `client_credentials`.""" - client_secret_last_4: str | None = None - """The last four characters of the client secret supplied for this connection, or `null` when it can't be read. Only present when `auth_method` is `client_credentials`.""" - config: dict[str, str] | None = None - """The connection-level configuration values stored for this connection — the fields the provider declares at `installation` scope, excluding any it declares as secret. Only present when `auth_method` is `client_credentials`.""" - userland_user_id: str | None = None - """Use `user_id` instead. - - .. deprecated:: This field is deprecated.""" - - @classmethod - def from_dict( - cls, data: dict[str, Any] - ) -> DataIntegrationsListResponseDataConnectedAccount: - """Deserialize from a dictionary.""" - try: - return cls( - object=data.get("object", "connected_account"), - id=data["id"], - user_id=data["user_id"], - organization_id=data["organization_id"], - scopes=data["scopes"], - state=DataIntegrationsListResponseDataConnectedAccountState( - data["state"] - ), - created_at=data["created_at"], - updated_at=data["updated_at"], - auth_method=DataIntegrationsListResponseDataConnectedAccountAuthMethod( - _v_auth_method - ) - if (_v_auth_method := data.get("auth_method")) is not None - else None, - api_key_last_4=data.get("api_key_last_4"), - client_id=data.get("client_id"), - client_secret_last_4=data.get("client_secret_last_4"), - config=data.get("config"), - userland_user_id=data.get("userlandUserId"), - ) - except (KeyError, ValueError) as e: - _raise_deserialize_error( - "DataIntegrationsListResponseDataConnectedAccount", e - ) - - def to_dict(self) -> dict[str, Any]: - """Serialize to a dictionary.""" - result: dict[str, Any] = {} - result["object"] = self.object - result["id"] = self.id - if self.user_id is not None: - result["user_id"] = self.user_id - else: - result["user_id"] = None - if self.organization_id is not None: - result["organization_id"] = self.organization_id - else: - result["organization_id"] = None - result["scopes"] = self.scopes - result["state"] = ( - self.state.value if isinstance(self.state, Enum) else self.state - ) - result["created_at"] = self.created_at - result["updated_at"] = self.updated_at - if self.auth_method is not None: - result["auth_method"] = ( - self.auth_method.value - if isinstance(self.auth_method, Enum) - else self.auth_method - ) - if self.api_key_last_4 is not None: - result["api_key_last_4"] = self.api_key_last_4 - else: - result["api_key_last_4"] = None - if self.client_id is not None: - result["client_id"] = self.client_id - else: - result["client_id"] = None - if self.client_secret_last_4 is not None: - result["client_secret_last_4"] = self.client_secret_last_4 - else: - result["client_secret_last_4"] = None - if self.config is not None: - result["config"] = self.config - if self.userland_user_id is not None: - result["userlandUserId"] = self.userland_user_id - else: - result["userlandUserId"] = None - return result diff --git a/src/workos/types/organizations_data_providers/__init__.py b/src/workos/types/organizations_data_providers/__init__.py deleted file mode 100644 index cd43f694..00000000 --- a/src/workos/types/organizations_data_providers/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# This file is auto-generated by oagen. Do not edit. - -from workos.organizations_data_providers.models import * diff --git a/tests/test_organizations_data_providers.py b/tests/test_organizations_data_providers.py deleted file mode 100644 index 062d01ef..00000000 --- a/tests/test_organizations_data_providers.py +++ /dev/null @@ -1,501 +0,0 @@ -# This file is auto-generated by oagen. Do not edit. - - -import pytest - -from tests.generated_helpers import load_fixture -from workos import AsyncWorkOSClient, WorkOSClient -from workos._errors import ( - AuthenticationError, - BadRequestError, - NotFoundError, - RateLimitExceededError, - ServerError, - UnprocessableEntityError, -) -from workos.common.models import ConnectedAccount, DataIntegrationsListResponse - - -class TestOrganizationsDataProviders: - def test_get_organization_connected_account(self, workos, httpx_mock): - httpx_mock.add_response( - json=load_fixture("connected_account.json"), - ) - result = workos.organizations_data_providers.get_organization_connected_account( - "test_organization_id", "test_slug" - ) - assert isinstance(result, ConnectedAccount) - assert result.object == "connected_account" - assert result.id == "data_installation_01EHZNVPK3SFK441A1RGBFSHRT" - request = httpx_mock.get_request() - assert request.method == "GET" - assert request.url.path.endswith( - "/organizations/test_organization_id/connected_accounts/test_slug" - ) - - def test_get_organization_connected_account_encodes_query_params( - self, workos, httpx_mock - ): - httpx_mock.add_response(json=load_fixture("connected_account.json")) - workos.organizations_data_providers.get_organization_connected_account( - "test_organization_id", - "test_slug", - supports_multiple_connections=True, - connected_account_id="value connected_account_id/test", - ) - request = httpx_mock.get_request() - assert request.url.params["supports_multiple_connections"] == "true" - assert ( - request.url.params["connected_account_id"] - == "value connected_account_id/test" - ) - - def test_create_organization_connected_account(self, workos, httpx_mock): - httpx_mock.add_response( - json=load_fixture("connected_account.json"), - ) - result = ( - workos.organizations_data_providers.create_organization_connected_account( - "test_organization_id", "test_slug" - ) - ) - assert isinstance(result, ConnectedAccount) - assert result.object == "connected_account" - assert result.id == "data_installation_01EHZNVPK3SFK441A1RGBFSHRT" - request = httpx_mock.get_request() - assert request.method == "POST" - assert request.url.path.endswith( - "/organizations/test_organization_id/connected_accounts/test_slug" - ) - - def test_update_organization_connected_account(self, workos, httpx_mock): - httpx_mock.add_response( - json=load_fixture("connected_account.json"), - ) - result = ( - workos.organizations_data_providers.update_organization_connected_account( - "test_organization_id", "test_slug" - ) - ) - assert isinstance(result, ConnectedAccount) - assert result.object == "connected_account" - assert result.id == "data_installation_01EHZNVPK3SFK441A1RGBFSHRT" - request = httpx_mock.get_request() - assert request.method == "PUT" - assert request.url.path.endswith( - "/organizations/test_organization_id/connected_accounts/test_slug" - ) - - def test_update_organization_connected_account_encodes_query_params( - self, workos, httpx_mock - ): - httpx_mock.add_response(json=load_fixture("connected_account.json")) - workos.organizations_data_providers.update_organization_connected_account( - "test_organization_id", - "test_slug", - supports_multiple_connections=True, - connected_account_id="value connected_account_id/test", - ) - request = httpx_mock.get_request() - assert request.url.params["supports_multiple_connections"] == "true" - assert ( - request.url.params["connected_account_id"] - == "value connected_account_id/test" - ) - - def test_delete_organization_connected_account(self, workos, httpx_mock): - httpx_mock.add_response(status_code=204) - result = ( - workos.organizations_data_providers.delete_organization_connected_account( - "test_organization_id", "test_slug" - ) - ) - assert result is None - request = httpx_mock.get_request() - assert request.method == "DELETE" - assert request.url.path.endswith( - "/organizations/test_organization_id/connected_accounts/test_slug" - ) - - def test_delete_organization_connected_account_encodes_query_params( - self, workos, httpx_mock - ): - httpx_mock.add_response(status_code=204) - workos.organizations_data_providers.delete_organization_connected_account( - "test_organization_id", - "test_slug", - supports_multiple_connections=True, - connected_account_id="value connected_account_id/test", - ) - request = httpx_mock.get_request() - assert request.url.params["supports_multiple_connections"] == "true" - assert ( - request.url.params["connected_account_id"] - == "value connected_account_id/test" - ) - - def test_list_organization_data_providers(self, workos, httpx_mock): - httpx_mock.add_response( - json=load_fixture("data_integrations_list_response.json"), - ) - result = workos.organizations_data_providers.list_organization_data_providers( - "test_organization_id" - ) - assert isinstance(result, DataIntegrationsListResponse) - assert result.object == "list" - request = httpx_mock.get_request() - assert request.method == "GET" - assert request.url.path.endswith( - "/organizations/test_organization_id/data_providers" - ) - - def test_list_organization_data_providers_encodes_query_params( - self, workos, httpx_mock - ): - httpx_mock.add_response( - json=load_fixture("data_integrations_list_response.json") - ) - workos.organizations_data_providers.list_organization_data_providers( - "test_organization_id", supports_multiple_connections=True - ) - request = httpx_mock.get_request() - assert request.url.params["supports_multiple_connections"] == "true" - - def test_get_organization_connected_account_with_request_options( - self, workos, httpx_mock - ): - httpx_mock.add_response(json=load_fixture("connected_account.json")) - workos.organizations_data_providers.get_organization_connected_account( - "test_organization_id", - "test_slug", - request_options={"extra_headers": {"X-Custom": "value"}}, - ) - request = httpx_mock.get_request() - assert request.headers["X-Custom"] == "value" - - def test_get_organization_connected_account_unauthorized(self, workos, httpx_mock): - httpx_mock.add_response( - status_code=401, - json={"message": "Unauthorized"}, - ) - with pytest.raises(AuthenticationError): - workos.organizations_data_providers.get_organization_connected_account( - "test_organization_id", "test_slug" - ) - - def test_get_organization_connected_account_not_found(self, httpx_mock): - workos = WorkOSClient( - api_key="sk_test_123", client_id="client_test", max_retries=0 - ) - try: - httpx_mock.add_response(status_code=404, json={"message": "Not found"}) - with pytest.raises(NotFoundError): - workos.organizations_data_providers.get_organization_connected_account( - "test_organization_id", "test_slug" - ) - finally: - workos.close() - - def test_get_organization_connected_account_rate_limited(self, httpx_mock): - workos = WorkOSClient( - api_key="sk_test_123", client_id="client_test", max_retries=0 - ) - try: - httpx_mock.add_response( - status_code=429, - headers={"Retry-After": "0"}, - json={"message": "Slow down"}, - ) - with pytest.raises(RateLimitExceededError): - workos.organizations_data_providers.get_organization_connected_account( - "test_organization_id", "test_slug" - ) - finally: - workos.close() - - def test_get_organization_connected_account_server_error(self, httpx_mock): - workos = WorkOSClient( - api_key="sk_test_123", client_id="client_test", max_retries=0 - ) - try: - httpx_mock.add_response(status_code=500, json={"message": "Server error"}) - with pytest.raises(ServerError): - workos.organizations_data_providers.get_organization_connected_account( - "test_organization_id", "test_slug" - ) - finally: - workos.close() - - def test_get_organization_connected_account_bad_request(self, httpx_mock): - workos = WorkOSClient( - api_key="sk_test_123", client_id="client_test", max_retries=0 - ) - try: - httpx_mock.add_response(status_code=400, json={"message": "Bad request"}) - with pytest.raises(BadRequestError): - workos.organizations_data_providers.get_organization_connected_account( - "test_organization_id", "test_slug" - ) - finally: - workos.close() - - def test_get_organization_connected_account_unprocessable(self, httpx_mock): - workos = WorkOSClient( - api_key="sk_test_123", client_id="client_test", max_retries=0 - ) - try: - httpx_mock.add_response(status_code=422, json={"message": "Unprocessable"}) - with pytest.raises(UnprocessableEntityError): - workos.organizations_data_providers.get_organization_connected_account( - "test_organization_id", "test_slug" - ) - finally: - workos.close() - - -class TestAsyncOrganizationsDataProviders: - @pytest.mark.asyncio - async def test_get_organization_connected_account(self, async_workos, httpx_mock): - httpx_mock.add_response(json=load_fixture("connected_account.json")) - result = await async_workos.organizations_data_providers.get_organization_connected_account( - "test_organization_id", "test_slug" - ) - assert isinstance(result, ConnectedAccount) - assert result.object == "connected_account" - assert result.id == "data_installation_01EHZNVPK3SFK441A1RGBFSHRT" - request = httpx_mock.get_request() - assert request.method == "GET" - assert request.url.path.endswith( - "/organizations/test_organization_id/connected_accounts/test_slug" - ) - - @pytest.mark.asyncio - async def test_get_organization_connected_account_encodes_query_params( - self, async_workos, httpx_mock - ): - httpx_mock.add_response(json=load_fixture("connected_account.json")) - await async_workos.organizations_data_providers.get_organization_connected_account( - "test_organization_id", - "test_slug", - supports_multiple_connections=True, - connected_account_id="value connected_account_id/test", - ) - request = httpx_mock.get_request() - assert request.url.params["supports_multiple_connections"] == "true" - assert ( - request.url.params["connected_account_id"] - == "value connected_account_id/test" - ) - - @pytest.mark.asyncio - async def test_create_organization_connected_account( - self, async_workos, httpx_mock - ): - httpx_mock.add_response(json=load_fixture("connected_account.json")) - result = await async_workos.organizations_data_providers.create_organization_connected_account( - "test_organization_id", "test_slug" - ) - assert isinstance(result, ConnectedAccount) - assert result.object == "connected_account" - assert result.id == "data_installation_01EHZNVPK3SFK441A1RGBFSHRT" - request = httpx_mock.get_request() - assert request.method == "POST" - assert request.url.path.endswith( - "/organizations/test_organization_id/connected_accounts/test_slug" - ) - - @pytest.mark.asyncio - async def test_update_organization_connected_account( - self, async_workos, httpx_mock - ): - httpx_mock.add_response(json=load_fixture("connected_account.json")) - result = await async_workos.organizations_data_providers.update_organization_connected_account( - "test_organization_id", "test_slug" - ) - assert isinstance(result, ConnectedAccount) - assert result.object == "connected_account" - assert result.id == "data_installation_01EHZNVPK3SFK441A1RGBFSHRT" - request = httpx_mock.get_request() - assert request.method == "PUT" - assert request.url.path.endswith( - "/organizations/test_organization_id/connected_accounts/test_slug" - ) - - @pytest.mark.asyncio - async def test_update_organization_connected_account_encodes_query_params( - self, async_workos, httpx_mock - ): - httpx_mock.add_response(json=load_fixture("connected_account.json")) - await async_workos.organizations_data_providers.update_organization_connected_account( - "test_organization_id", - "test_slug", - supports_multiple_connections=True, - connected_account_id="value connected_account_id/test", - ) - request = httpx_mock.get_request() - assert request.url.params["supports_multiple_connections"] == "true" - assert ( - request.url.params["connected_account_id"] - == "value connected_account_id/test" - ) - - @pytest.mark.asyncio - async def test_delete_organization_connected_account( - self, async_workos, httpx_mock - ): - httpx_mock.add_response(status_code=204) - result = await async_workos.organizations_data_providers.delete_organization_connected_account( - "test_organization_id", "test_slug" - ) - assert result is None - request = httpx_mock.get_request() - assert request.method == "DELETE" - assert request.url.path.endswith( - "/organizations/test_organization_id/connected_accounts/test_slug" - ) - - @pytest.mark.asyncio - async def test_delete_organization_connected_account_encodes_query_params( - self, async_workos, httpx_mock - ): - httpx_mock.add_response(status_code=204) - await async_workos.organizations_data_providers.delete_organization_connected_account( - "test_organization_id", - "test_slug", - supports_multiple_connections=True, - connected_account_id="value connected_account_id/test", - ) - request = httpx_mock.get_request() - assert request.url.params["supports_multiple_connections"] == "true" - assert ( - request.url.params["connected_account_id"] - == "value connected_account_id/test" - ) - - @pytest.mark.asyncio - async def test_list_organization_data_providers(self, async_workos, httpx_mock): - httpx_mock.add_response( - json=load_fixture("data_integrations_list_response.json") - ) - result = await async_workos.organizations_data_providers.list_organization_data_providers( - "test_organization_id" - ) - assert isinstance(result, DataIntegrationsListResponse) - assert result.object == "list" - request = httpx_mock.get_request() - assert request.method == "GET" - assert request.url.path.endswith( - "/organizations/test_organization_id/data_providers" - ) - - @pytest.mark.asyncio - async def test_list_organization_data_providers_encodes_query_params( - self, async_workos, httpx_mock - ): - httpx_mock.add_response( - json=load_fixture("data_integrations_list_response.json") - ) - await ( - async_workos.organizations_data_providers.list_organization_data_providers( - "test_organization_id", supports_multiple_connections=True - ) - ) - request = httpx_mock.get_request() - assert request.url.params["supports_multiple_connections"] == "true" - - @pytest.mark.asyncio - async def test_get_organization_connected_account_with_request_options( - self, async_workos, httpx_mock - ): - httpx_mock.add_response(json=load_fixture("connected_account.json")) - await async_workos.organizations_data_providers.get_organization_connected_account( - "test_organization_id", - "test_slug", - request_options={"extra_headers": {"X-Custom": "value"}}, - ) - request = httpx_mock.get_request() - assert request.headers["X-Custom"] == "value" - - @pytest.mark.asyncio - async def test_get_organization_connected_account_unauthorized( - self, async_workos, httpx_mock - ): - httpx_mock.add_response(status_code=401, json={"message": "Unauthorized"}) - with pytest.raises(AuthenticationError): - await async_workos.organizations_data_providers.get_organization_connected_account( - "test_organization_id", "test_slug" - ) - - @pytest.mark.asyncio - async def test_get_organization_connected_account_not_found(self, httpx_mock): - workos = AsyncWorkOSClient( - api_key="sk_test_123", client_id="client_test", max_retries=0 - ) - try: - httpx_mock.add_response(status_code=404, json={"message": "Not found"}) - with pytest.raises(NotFoundError): - await workos.organizations_data_providers.get_organization_connected_account( - "test_organization_id", "test_slug" - ) - finally: - await workos.close() - - @pytest.mark.asyncio - async def test_get_organization_connected_account_rate_limited(self, httpx_mock): - workos = AsyncWorkOSClient( - api_key="sk_test_123", client_id="client_test", max_retries=0 - ) - try: - httpx_mock.add_response( - status_code=429, - headers={"Retry-After": "0"}, - json={"message": "Slow down"}, - ) - with pytest.raises(RateLimitExceededError): - await workos.organizations_data_providers.get_organization_connected_account( - "test_organization_id", "test_slug" - ) - finally: - await workos.close() - - @pytest.mark.asyncio - async def test_get_organization_connected_account_server_error(self, httpx_mock): - workos = AsyncWorkOSClient( - api_key="sk_test_123", client_id="client_test", max_retries=0 - ) - try: - httpx_mock.add_response(status_code=500, json={"message": "Server error"}) - with pytest.raises(ServerError): - await workos.organizations_data_providers.get_organization_connected_account( - "test_organization_id", "test_slug" - ) - finally: - await workos.close() - - @pytest.mark.asyncio - async def test_get_organization_connected_account_bad_request(self, httpx_mock): - workos = AsyncWorkOSClient( - api_key="sk_test_123", client_id="client_test", max_retries=0 - ) - try: - httpx_mock.add_response(status_code=400, json={"message": "Bad request"}) - with pytest.raises(BadRequestError): - await workos.organizations_data_providers.get_organization_connected_account( - "test_organization_id", "test_slug" - ) - finally: - await workos.close() - - @pytest.mark.asyncio - async def test_get_organization_connected_account_unprocessable(self, httpx_mock): - workos = AsyncWorkOSClient( - api_key="sk_test_123", client_id="client_test", max_retries=0 - ) - try: - httpx_mock.add_response(status_code=422, json={"message": "Unprocessable"}) - with pytest.raises(UnprocessableEntityError): - await workos.organizations_data_providers.get_organization_connected_account( - "test_organization_id", "test_slug" - ) - finally: - await workos.close() diff --git a/tests/test_organizations_data_providers_models_round_trip.py b/tests/test_organizations_data_providers_models_round_trip.py deleted file mode 100644 index 3d6733a9..00000000 --- a/tests/test_organizations_data_providers_models_round_trip.py +++ /dev/null @@ -1,441 +0,0 @@ -# This file is auto-generated by oagen. Do not edit. - -"""Model round-trip tests: from_dict(to_dict()) preserves data.""" - -from tests.generated_helpers import load_fixture -from workos.organizations_data_providers.models import ( - DataIntegrationsListResponse, - DataIntegrationsListResponseData, - DataIntegrationsListResponseDataConnectedAccount, -) - - -class TestModelRoundTrip: - def test_data_integrations_list_response_round_trip(self): - data = load_fixture("data_integrations_list_response.json") - instance = DataIntegrationsListResponse.from_dict(data) - serialized = instance.to_dict() - assert serialized == data - restored = DataIntegrationsListResponse.from_dict(serialized) - assert restored.to_dict() == serialized - - def test_data_integrations_list_response_minimal_payload(self): - data = { - "object": "list", - "data": [ - { - "object": "data_provider", - "id": "data_integration_01EHZNVPK3SFK441A1RGBFSHRT", - "name": "GitHub", - "description": "Connect your GitHub account to access repositories.", - "slug": "github", - "integration_type": "github", - "credentials_type": "oauth2", - "scopes": ["repo", "user:email"], - "auth_methods": ["oauth"], - "connection_owner": "user", - "ownership": "userland_user", - "created_at": "2024-01-15T10:30:00.000Z", - "updated_at": "2024-01-15T10:30:00.000Z", - "connected_account": { - "object": "connected_account", - "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", - "connection_role": "compatibility", - "account_identifier": "workspace_123", - "account_display_name": "Acme production", - "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", - "organization_id": None, - "scopes": ["repo", "user:email"], - "auth_method": "oauth", - "api_key_last_4": None, - "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", - }, - "connected_accounts": [ - { - "object": "connected_account", - "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", - "connection_role": "compatibility", - "account_identifier": "workspace_123", - "account_display_name": "Acme production", - "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", - "organization_id": None, - "scopes": ["repo", "user:email"], - "auth_method": "oauth", - "api_key_last_4": None, - "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", - } - ], - } - ], - } - instance = DataIntegrationsListResponse.from_dict(data) - serialized = instance.to_dict() - assert serialized["object"] == data["object"] - assert serialized["data"] == data["data"] - - def test_data_integrations_list_response_data_round_trip(self): - data = load_fixture("data_integrations_list_response_data.json") - instance = DataIntegrationsListResponseData.from_dict(data) - serialized = instance.to_dict() - assert serialized == data - restored = DataIntegrationsListResponseData.from_dict(serialized) - assert restored.to_dict() == serialized - - def test_data_integrations_list_response_data_minimal_payload(self): - data = { - "object": "data_provider", - "id": "data_integration_01EHZNVPK3SFK441A1RGBFSHRT", - "name": "GitHub", - "description": None, - "slug": "github", - "integration_type": "github", - "credentials_type": "oauth2", - "scopes": None, - "connection_owner": "user", - "ownership": "userland_user", - "created_at": "2024-01-15T10:30:00.000Z", - "updated_at": "2024-01-15T10:30:00.000Z", - "connected_account": None, - "connected_accounts": [ - { - "object": "connected_account", - "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", - "connection_role": "compatibility", - "account_identifier": "workspace_123", - "account_display_name": "Acme production", - "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", - "organization_id": None, - "scopes": ["repo", "user:email"], - "auth_method": "oauth", - "api_key_last_4": None, - "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", - } - ], - } - instance = DataIntegrationsListResponseData.from_dict(data) - serialized = instance.to_dict() - assert serialized["object"] == data["object"] - assert serialized["id"] == data["id"] - assert serialized["name"] == data["name"] - assert serialized["description"] == data["description"] - assert serialized["slug"] == data["slug"] - assert serialized["integration_type"] == data["integration_type"] - assert serialized["credentials_type"] == data["credentials_type"] - assert serialized["scopes"] == data["scopes"] - assert serialized["connection_owner"] == data["connection_owner"] - assert serialized["ownership"] == data["ownership"] - assert serialized["created_at"] == data["created_at"] - assert serialized["updated_at"] == data["updated_at"] - assert serialized["connected_account"] == data["connected_account"] - assert serialized["connected_accounts"] == data["connected_accounts"] - - def test_data_integrations_list_response_data_omits_absent_optional_non_nullable_fields( - self, - ): - data = { - "object": "data_provider", - "id": "data_integration_01EHZNVPK3SFK441A1RGBFSHRT", - "name": "GitHub", - "description": "Connect your GitHub account to access repositories.", - "slug": "github", - "integration_type": "github", - "credentials_type": "oauth2", - "scopes": ["repo", "user:email"], - "connection_owner": "user", - "ownership": "userland_user", - "created_at": "2024-01-15T10:30:00.000Z", - "updated_at": "2024-01-15T10:30:00.000Z", - "connected_account": { - "object": "connected_account", - "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", - "connection_role": "compatibility", - "account_identifier": "workspace_123", - "account_display_name": "Acme production", - "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", - "organization_id": None, - "scopes": ["repo", "user:email"], - "auth_method": "oauth", - "api_key_last_4": None, - "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", - }, - "connected_accounts": [ - { - "object": "connected_account", - "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", - "connection_role": "compatibility", - "account_identifier": "workspace_123", - "account_display_name": "Acme production", - "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", - "organization_id": None, - "scopes": ["repo", "user:email"], - "auth_method": "oauth", - "api_key_last_4": None, - "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", - } - ], - } - instance = DataIntegrationsListResponseData.from_dict(data) - serialized = instance.to_dict() - assert "auth_methods" not in serialized - - def test_data_integrations_list_response_data_preserves_nullable_fields(self): - data = { - "object": "data_provider", - "id": "data_integration_01EHZNVPK3SFK441A1RGBFSHRT", - "name": "GitHub", - "description": None, - "slug": "github", - "integration_type": "github", - "credentials_type": "oauth2", - "scopes": None, - "auth_methods": ["oauth"], - "connection_owner": "user", - "ownership": "userland_user", - "created_at": "2024-01-15T10:30:00.000Z", - "updated_at": "2024-01-15T10:30:00.000Z", - "connected_account": None, - "connected_accounts": [ - { - "object": "connected_account", - "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", - "connection_role": "compatibility", - "account_identifier": "workspace_123", - "account_display_name": "Acme production", - "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", - "organization_id": None, - "scopes": ["repo", "user:email"], - "auth_method": "oauth", - "api_key_last_4": None, - "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", - } - ], - } - instance = DataIntegrationsListResponseData.from_dict(data) - serialized = instance.to_dict() - assert serialized["description"] is None - assert serialized["scopes"] is None - assert serialized["connected_account"] is None - - def test_data_integrations_list_response_data_round_trips_unknown_enum_values(self): - data = { - "object": "data_provider", - "id": "data_integration_01EHZNVPK3SFK441A1RGBFSHRT", - "name": "GitHub", - "description": "Connect your GitHub account to access repositories.", - "slug": "github", - "integration_type": "github", - "credentials_type": "oauth2", - "scopes": ["repo", "user:email"], - "auth_methods": ["oauth"], - "connection_owner": "unexpected_data_integrations_list_response_data_connection_owner", - "ownership": "userland_user", - "created_at": "2024-01-15T10:30:00.000Z", - "updated_at": "2024-01-15T10:30:00.000Z", - "connected_account": { - "object": "connected_account", - "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", - "connection_role": "compatibility", - "account_identifier": "workspace_123", - "account_display_name": "Acme production", - "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", - "organization_id": None, - "scopes": ["repo", "user:email"], - "auth_method": "oauth", - "api_key_last_4": None, - "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", - }, - "connected_accounts": [ - { - "object": "connected_account", - "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", - "connection_role": "compatibility", - "account_identifier": "workspace_123", - "account_display_name": "Acme production", - "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", - "organization_id": None, - "scopes": ["repo", "user:email"], - "auth_method": "oauth", - "api_key_last_4": None, - "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", - } - ], - } - instance = DataIntegrationsListResponseData.from_dict(data) - assert instance.to_dict() == data - - def test_data_integrations_list_response_data_connected_account_round_trip(self): - data = load_fixture( - "data_integrations_list_response_data_connected_account.json" - ) - instance = DataIntegrationsListResponseDataConnectedAccount.from_dict(data) - serialized = instance.to_dict() - assert serialized == data - restored = DataIntegrationsListResponseDataConnectedAccount.from_dict( - serialized - ) - assert restored.to_dict() == serialized - - def test_data_integrations_list_response_data_connected_account_minimal_payload( - self, - ): - data = { - "object": "connected_account", - "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", - "connection_role": "compatibility", - "account_identifier": None, - "account_display_name": None, - "user_id": None, - "organization_id": None, - "scopes": ["repo", "user:email"], - "state": "connected", - "created_at": "2024-01-16T14:20:00.000Z", - "updated_at": "2024-01-16T14:20:00.000Z", - "userlandUserId": None, - } - instance = DataIntegrationsListResponseDataConnectedAccount.from_dict(data) - serialized = instance.to_dict() - assert serialized["object"] == data["object"] - assert serialized["id"] == data["id"] - assert serialized["connection_role"] == data["connection_role"] - assert serialized["account_identifier"] == data["account_identifier"] - assert serialized["account_display_name"] == data["account_display_name"] - assert serialized["user_id"] == data["user_id"] - assert serialized["organization_id"] == data["organization_id"] - assert serialized["scopes"] == data["scopes"] - assert serialized["state"] == data["state"] - assert serialized["created_at"] == data["created_at"] - assert serialized["updated_at"] == data["updated_at"] - assert serialized["userlandUserId"] == data["userlandUserId"] - - def test_data_integrations_list_response_data_connected_account_omits_absent_optional_non_nullable_fields( - self, - ): - data = { - "object": "connected_account", - "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", - "connection_role": "compatibility", - "account_identifier": "workspace_123", - "account_display_name": "Acme production", - "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", - "organization_id": None, - "scopes": ["repo", "user:email"], - "api_key_last_4": None, - "client_id": "3MVG9dZJodJWxft2VoStSCVwPFsx0eDcpVc", - "client_secret_last_4": "cdef", - "state": "connected", - "created_at": "2024-01-16T14:20:00.000Z", - "updated_at": "2024-01-16T14:20:00.000Z", - "userlandUserId": "test_userlandUserId", - } - instance = DataIntegrationsListResponseDataConnectedAccount.from_dict(data) - serialized = instance.to_dict() - assert "auth_method" not in serialized - assert "config" not in serialized - - def test_data_integrations_list_response_data_connected_account_preserves_nullable_fields( - self, - ): - data = { - "object": "connected_account", - "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", - "connection_role": "compatibility", - "account_identifier": None, - "account_display_name": None, - "user_id": None, - "organization_id": None, - "scopes": ["repo", "user:email"], - "auth_method": "oauth", - "api_key_last_4": None, - "client_id": None, - "client_secret_last_4": None, - "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": None, - } - instance = DataIntegrationsListResponseDataConnectedAccount.from_dict(data) - serialized = instance.to_dict() - assert serialized["account_identifier"] is None - assert serialized["account_display_name"] is None - assert serialized["user_id"] is None - assert serialized["organization_id"] is None - assert serialized["api_key_last_4"] is None - assert serialized["client_id"] is None - assert serialized["client_secret_last_4"] is None - assert serialized["userlandUserId"] is None - - def test_data_integrations_list_response_data_connected_account_round_trips_unknown_enum_values( - self, - ): - data = { - "object": "connected_account", - "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", - "connection_role": "unexpected_data_integrations_list_response_data_connected_account_connection_role", - "account_identifier": "workspace_123", - "account_display_name": "Acme production", - "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", - "organization_id": None, - "scopes": ["repo", "user:email"], - "auth_method": "oauth", - "api_key_last_4": None, - "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", - } - instance = DataIntegrationsListResponseDataConnectedAccount.from_dict(data) - assert instance.to_dict() == data diff --git a/tests/test_pipes.py b/tests/test_pipes.py index 35f3cf8e..a4b6d3c5 100644 --- a/tests/test_pipes.py +++ b/tests/test_pipes.py @@ -227,6 +227,142 @@ def test_get_access_token(self, workos, httpx_mock): body = json.loads(request.content) assert body["user_id"] == "test_user_id" + def test_get_organization_connected_account(self, workos, httpx_mock): + httpx_mock.add_response( + json=load_fixture("connected_account.json"), + ) + result = workos.pipes.get_organization_connected_account( + "test_organization_id", "test_slug" + ) + assert isinstance(result, ConnectedAccount) + assert result.object == "connected_account" + assert result.id == "data_installation_01EHZNVPK3SFK441A1RGBFSHRT" + request = httpx_mock.get_request() + assert request.method == "GET" + assert request.url.path.endswith( + "/organizations/test_organization_id/connected_accounts/test_slug" + ) + + def test_get_organization_connected_account_encodes_query_params( + self, workos, httpx_mock + ): + httpx_mock.add_response(json=load_fixture("connected_account.json")) + workos.pipes.get_organization_connected_account( + "test_organization_id", + "test_slug", + supports_multiple_connections=True, + connected_account_id="value connected_account_id/test", + ) + request = httpx_mock.get_request() + assert request.url.params["supports_multiple_connections"] == "true" + assert ( + request.url.params["connected_account_id"] + == "value connected_account_id/test" + ) + + def test_create_organization_connected_account(self, workos, httpx_mock): + httpx_mock.add_response( + json=load_fixture("connected_account.json"), + ) + result = workos.pipes.create_organization_connected_account( + "test_organization_id", "test_slug" + ) + assert isinstance(result, ConnectedAccount) + assert result.object == "connected_account" + assert result.id == "data_installation_01EHZNVPK3SFK441A1RGBFSHRT" + request = httpx_mock.get_request() + assert request.method == "POST" + assert request.url.path.endswith( + "/organizations/test_organization_id/connected_accounts/test_slug" + ) + + def test_update_organization_connected_account(self, workos, httpx_mock): + httpx_mock.add_response( + json=load_fixture("connected_account.json"), + ) + result = workos.pipes.update_organization_connected_account( + "test_organization_id", "test_slug" + ) + assert isinstance(result, ConnectedAccount) + assert result.object == "connected_account" + assert result.id == "data_installation_01EHZNVPK3SFK441A1RGBFSHRT" + request = httpx_mock.get_request() + assert request.method == "PUT" + assert request.url.path.endswith( + "/organizations/test_organization_id/connected_accounts/test_slug" + ) + + def test_update_organization_connected_account_encodes_query_params( + self, workos, httpx_mock + ): + httpx_mock.add_response(json=load_fixture("connected_account.json")) + workos.pipes.update_organization_connected_account( + "test_organization_id", + "test_slug", + supports_multiple_connections=True, + connected_account_id="value connected_account_id/test", + ) + request = httpx_mock.get_request() + assert request.url.params["supports_multiple_connections"] == "true" + assert ( + request.url.params["connected_account_id"] + == "value connected_account_id/test" + ) + + def test_delete_organization_connected_account(self, workos, httpx_mock): + httpx_mock.add_response(status_code=204) + result = workos.pipes.delete_organization_connected_account( + "test_organization_id", "test_slug" + ) + assert result is None + request = httpx_mock.get_request() + assert request.method == "DELETE" + assert request.url.path.endswith( + "/organizations/test_organization_id/connected_accounts/test_slug" + ) + + def test_delete_organization_connected_account_encodes_query_params( + self, workos, httpx_mock + ): + httpx_mock.add_response(status_code=204) + workos.pipes.delete_organization_connected_account( + "test_organization_id", + "test_slug", + supports_multiple_connections=True, + connected_account_id="value connected_account_id/test", + ) + request = httpx_mock.get_request() + assert request.url.params["supports_multiple_connections"] == "true" + assert ( + request.url.params["connected_account_id"] + == "value connected_account_id/test" + ) + + def test_list_organization_data_providers(self, workos, httpx_mock): + httpx_mock.add_response( + json=load_fixture("data_integrations_list_response.json"), + ) + result = workos.pipes.list_organization_data_providers("test_organization_id") + assert isinstance(result, DataIntegrationsListResponse) + assert result.object == "list" + request = httpx_mock.get_request() + assert request.method == "GET" + assert request.url.path.endswith( + "/organizations/test_organization_id/data_providers" + ) + + def test_list_organization_data_providers_encodes_query_params( + self, workos, httpx_mock + ): + httpx_mock.add_response( + json=load_fixture("data_integrations_list_response.json") + ) + workos.pipes.list_organization_data_providers( + "test_organization_id", supports_multiple_connections=True + ) + request = httpx_mock.get_request() + assert request.url.params["supports_multiple_connections"] == "true" + def test_get_user_connected_account(self, workos, httpx_mock): httpx_mock.add_response( json=load_fixture("connected_account.json"), @@ -642,6 +778,153 @@ async def test_get_access_token(self, async_workos, httpx_mock): assert request.method == "POST" assert request.url.path.endswith("/data-integrations/test_provider/token") + @pytest.mark.asyncio + async def test_get_organization_connected_account(self, async_workos, httpx_mock): + httpx_mock.add_response(json=load_fixture("connected_account.json")) + result = await async_workos.pipes.get_organization_connected_account( + "test_organization_id", "test_slug" + ) + assert isinstance(result, ConnectedAccount) + assert result.object == "connected_account" + assert result.id == "data_installation_01EHZNVPK3SFK441A1RGBFSHRT" + request = httpx_mock.get_request() + assert request.method == "GET" + assert request.url.path.endswith( + "/organizations/test_organization_id/connected_accounts/test_slug" + ) + + @pytest.mark.asyncio + async def test_get_organization_connected_account_encodes_query_params( + self, async_workos, httpx_mock + ): + httpx_mock.add_response(json=load_fixture("connected_account.json")) + await async_workos.pipes.get_organization_connected_account( + "test_organization_id", + "test_slug", + supports_multiple_connections=True, + connected_account_id="value connected_account_id/test", + ) + request = httpx_mock.get_request() + assert request.url.params["supports_multiple_connections"] == "true" + assert ( + request.url.params["connected_account_id"] + == "value connected_account_id/test" + ) + + @pytest.mark.asyncio + async def test_create_organization_connected_account( + self, async_workos, httpx_mock + ): + httpx_mock.add_response(json=load_fixture("connected_account.json")) + result = await async_workos.pipes.create_organization_connected_account( + "test_organization_id", "test_slug" + ) + assert isinstance(result, ConnectedAccount) + assert result.object == "connected_account" + assert result.id == "data_installation_01EHZNVPK3SFK441A1RGBFSHRT" + request = httpx_mock.get_request() + assert request.method == "POST" + assert request.url.path.endswith( + "/organizations/test_organization_id/connected_accounts/test_slug" + ) + + @pytest.mark.asyncio + async def test_update_organization_connected_account( + self, async_workos, httpx_mock + ): + httpx_mock.add_response(json=load_fixture("connected_account.json")) + result = await async_workos.pipes.update_organization_connected_account( + "test_organization_id", "test_slug" + ) + assert isinstance(result, ConnectedAccount) + assert result.object == "connected_account" + assert result.id == "data_installation_01EHZNVPK3SFK441A1RGBFSHRT" + request = httpx_mock.get_request() + assert request.method == "PUT" + assert request.url.path.endswith( + "/organizations/test_organization_id/connected_accounts/test_slug" + ) + + @pytest.mark.asyncio + async def test_update_organization_connected_account_encodes_query_params( + self, async_workos, httpx_mock + ): + httpx_mock.add_response(json=load_fixture("connected_account.json")) + await async_workos.pipes.update_organization_connected_account( + "test_organization_id", + "test_slug", + supports_multiple_connections=True, + connected_account_id="value connected_account_id/test", + ) + request = httpx_mock.get_request() + assert request.url.params["supports_multiple_connections"] == "true" + assert ( + request.url.params["connected_account_id"] + == "value connected_account_id/test" + ) + + @pytest.mark.asyncio + async def test_delete_organization_connected_account( + self, async_workos, httpx_mock + ): + httpx_mock.add_response(status_code=204) + result = await async_workos.pipes.delete_organization_connected_account( + "test_organization_id", "test_slug" + ) + assert result is None + request = httpx_mock.get_request() + assert request.method == "DELETE" + assert request.url.path.endswith( + "/organizations/test_organization_id/connected_accounts/test_slug" + ) + + @pytest.mark.asyncio + async def test_delete_organization_connected_account_encodes_query_params( + self, async_workos, httpx_mock + ): + httpx_mock.add_response(status_code=204) + await async_workos.pipes.delete_organization_connected_account( + "test_organization_id", + "test_slug", + supports_multiple_connections=True, + connected_account_id="value connected_account_id/test", + ) + request = httpx_mock.get_request() + assert request.url.params["supports_multiple_connections"] == "true" + assert ( + request.url.params["connected_account_id"] + == "value connected_account_id/test" + ) + + @pytest.mark.asyncio + async def test_list_organization_data_providers(self, async_workos, httpx_mock): + httpx_mock.add_response( + json=load_fixture("data_integrations_list_response.json") + ) + result = await async_workos.pipes.list_organization_data_providers( + "test_organization_id" + ) + assert isinstance(result, DataIntegrationsListResponse) + assert result.object == "list" + request = httpx_mock.get_request() + assert request.method == "GET" + assert request.url.path.endswith( + "/organizations/test_organization_id/data_providers" + ) + + @pytest.mark.asyncio + async def test_list_organization_data_providers_encodes_query_params( + self, async_workos, httpx_mock + ): + httpx_mock.add_response( + json=load_fixture("data_integrations_list_response.json") + ) + await async_workos.pipes.list_organization_data_providers( + "test_organization_id", supports_multiple_connections=True + ) + request = httpx_mock.get_request() + assert request.url.params["supports_multiple_connections"] == "true" + @pytest.mark.asyncio async def test_get_user_connected_account(self, async_workos, httpx_mock): httpx_mock.add_response(json=load_fixture("connected_account.json")) diff --git a/tests/test_pipes_models_round_trip.py b/tests/test_pipes_models_round_trip.py index 2ee1f2f0..56ddf3f3 100644 --- a/tests/test_pipes_models_round_trip.py +++ b/tests/test_pipes_models_round_trip.py @@ -17,6 +17,9 @@ DataIntegrationCredentialsResponseCredential, DataIntegrationCustomProvider, DataIntegrationInstallation, + DataIntegrationsListResponse, + DataIntegrationsListResponseData, + DataIntegrationsListResponseDataConnectedAccount, UpdateCustomProviderDefinition, ) @@ -533,6 +536,308 @@ def test_connected_account_round_trips_unknown_enum_values(self): instance = ConnectedAccount.from_dict(data) assert instance.to_dict() == data + def test_data_integrations_list_response_round_trip(self): + data = load_fixture("data_integrations_list_response.json") + instance = DataIntegrationsListResponse.from_dict(data) + serialized = instance.to_dict() + assert serialized == data + restored = DataIntegrationsListResponse.from_dict(serialized) + assert restored.to_dict() == serialized + + def test_data_integrations_list_response_minimal_payload(self): + data = { + "object": "list", + "data": [ + { + "object": "data_provider", + "id": "data_integration_01EHZNVPK3SFK441A1RGBFSHRT", + "name": "GitHub", + "description": "Connect your GitHub account to access repositories.", + "slug": "github", + "integration_type": "github", + "credentials_type": "oauth2", + "scopes": ["repo", "user:email"], + "auth_methods": ["oauth"], + "connection_owner": "user", + "ownership": "userland_user", + "created_at": "2024-01-15T10:30:00.000Z", + "updated_at": "2024-01-15T10:30:00.000Z", + "connected_account": { + "object": "connected_account", + "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", + "connection_role": "compatibility", + "account_identifier": "workspace_123", + "account_display_name": "Acme production", + "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", + "organization_id": None, + "scopes": ["repo", "user:email"], + "auth_method": "oauth", + "api_key_last_4": None, + "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", + }, + "connected_accounts": [ + { + "object": "connected_account", + "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", + "connection_role": "compatibility", + "account_identifier": "workspace_123", + "account_display_name": "Acme production", + "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", + "organization_id": None, + "scopes": ["repo", "user:email"], + "auth_method": "oauth", + "api_key_last_4": None, + "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", + } + ], + } + ], + } + instance = DataIntegrationsListResponse.from_dict(data) + serialized = instance.to_dict() + assert serialized["object"] == data["object"] + assert serialized["data"] == data["data"] + + def test_data_integrations_list_response_data_round_trip(self): + data = load_fixture("data_integrations_list_response_data.json") + instance = DataIntegrationsListResponseData.from_dict(data) + serialized = instance.to_dict() + assert serialized == data + restored = DataIntegrationsListResponseData.from_dict(serialized) + assert restored.to_dict() == serialized + + def test_data_integrations_list_response_data_minimal_payload(self): + data = { + "object": "data_provider", + "id": "data_integration_01EHZNVPK3SFK441A1RGBFSHRT", + "name": "GitHub", + "description": None, + "slug": "github", + "integration_type": "github", + "credentials_type": "oauth2", + "scopes": None, + "connection_owner": "user", + "ownership": "userland_user", + "created_at": "2024-01-15T10:30:00.000Z", + "updated_at": "2024-01-15T10:30:00.000Z", + "connected_account": None, + "connected_accounts": [ + { + "object": "connected_account", + "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", + "connection_role": "compatibility", + "account_identifier": "workspace_123", + "account_display_name": "Acme production", + "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", + "organization_id": None, + "scopes": ["repo", "user:email"], + "auth_method": "oauth", + "api_key_last_4": None, + "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", + } + ], + } + instance = DataIntegrationsListResponseData.from_dict(data) + serialized = instance.to_dict() + assert serialized["object"] == data["object"] + assert serialized["id"] == data["id"] + assert serialized["name"] == data["name"] + assert serialized["description"] == data["description"] + assert serialized["slug"] == data["slug"] + assert serialized["integration_type"] == data["integration_type"] + assert serialized["credentials_type"] == data["credentials_type"] + assert serialized["scopes"] == data["scopes"] + assert serialized["connection_owner"] == data["connection_owner"] + assert serialized["ownership"] == data["ownership"] + assert serialized["created_at"] == data["created_at"] + assert serialized["updated_at"] == data["updated_at"] + assert serialized["connected_account"] == data["connected_account"] + assert serialized["connected_accounts"] == data["connected_accounts"] + + def test_data_integrations_list_response_data_omits_absent_optional_non_nullable_fields( + self, + ): + data = { + "object": "data_provider", + "id": "data_integration_01EHZNVPK3SFK441A1RGBFSHRT", + "name": "GitHub", + "description": "Connect your GitHub account to access repositories.", + "slug": "github", + "integration_type": "github", + "credentials_type": "oauth2", + "scopes": ["repo", "user:email"], + "connection_owner": "user", + "ownership": "userland_user", + "created_at": "2024-01-15T10:30:00.000Z", + "updated_at": "2024-01-15T10:30:00.000Z", + "connected_account": { + "object": "connected_account", + "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", + "connection_role": "compatibility", + "account_identifier": "workspace_123", + "account_display_name": "Acme production", + "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", + "organization_id": None, + "scopes": ["repo", "user:email"], + "auth_method": "oauth", + "api_key_last_4": None, + "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", + }, + "connected_accounts": [ + { + "object": "connected_account", + "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", + "connection_role": "compatibility", + "account_identifier": "workspace_123", + "account_display_name": "Acme production", + "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", + "organization_id": None, + "scopes": ["repo", "user:email"], + "auth_method": "oauth", + "api_key_last_4": None, + "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", + } + ], + } + instance = DataIntegrationsListResponseData.from_dict(data) + serialized = instance.to_dict() + assert "auth_methods" not in serialized + + def test_data_integrations_list_response_data_preserves_nullable_fields(self): + data = { + "object": "data_provider", + "id": "data_integration_01EHZNVPK3SFK441A1RGBFSHRT", + "name": "GitHub", + "description": None, + "slug": "github", + "integration_type": "github", + "credentials_type": "oauth2", + "scopes": None, + "auth_methods": ["oauth"], + "connection_owner": "user", + "ownership": "userland_user", + "created_at": "2024-01-15T10:30:00.000Z", + "updated_at": "2024-01-15T10:30:00.000Z", + "connected_account": None, + "connected_accounts": [ + { + "object": "connected_account", + "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", + "connection_role": "compatibility", + "account_identifier": "workspace_123", + "account_display_name": "Acme production", + "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", + "organization_id": None, + "scopes": ["repo", "user:email"], + "auth_method": "oauth", + "api_key_last_4": None, + "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", + } + ], + } + instance = DataIntegrationsListResponseData.from_dict(data) + serialized = instance.to_dict() + assert serialized["description"] is None + assert serialized["scopes"] is None + assert serialized["connected_account"] is None + + def test_data_integrations_list_response_data_round_trips_unknown_enum_values(self): + data = { + "object": "data_provider", + "id": "data_integration_01EHZNVPK3SFK441A1RGBFSHRT", + "name": "GitHub", + "description": "Connect your GitHub account to access repositories.", + "slug": "github", + "integration_type": "github", + "credentials_type": "oauth2", + "scopes": ["repo", "user:email"], + "auth_methods": ["oauth"], + "connection_owner": "unexpected_data_integrations_list_response_data_connection_owner", + "ownership": "userland_user", + "created_at": "2024-01-15T10:30:00.000Z", + "updated_at": "2024-01-15T10:30:00.000Z", + "connected_account": { + "object": "connected_account", + "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", + "connection_role": "compatibility", + "account_identifier": "workspace_123", + "account_display_name": "Acme production", + "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", + "organization_id": None, + "scopes": ["repo", "user:email"], + "auth_method": "oauth", + "api_key_last_4": None, + "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", + }, + "connected_accounts": [ + { + "object": "connected_account", + "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", + "connection_role": "compatibility", + "account_identifier": "workspace_123", + "account_display_name": "Acme production", + "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", + "organization_id": None, + "scopes": ["repo", "user:email"], + "auth_method": "oauth", + "api_key_last_4": None, + "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", + } + ], + } + instance = DataIntegrationsListResponseData.from_dict(data) + assert instance.to_dict() == data + def test_data_integration_credentials_response_credential_round_trip(self): data = load_fixture("data_integration_credentials_response_credential.json") instance = DataIntegrationCredentialsResponseCredential.from_dict(data) @@ -778,3 +1083,130 @@ def test_data_integration_custom_provider_round_trips_unknown_enum_values(self): } instance = DataIntegrationCustomProvider.from_dict(data) assert instance.to_dict() == data + + def test_data_integrations_list_response_data_connected_account_round_trip(self): + data = load_fixture( + "data_integrations_list_response_data_connected_account.json" + ) + instance = DataIntegrationsListResponseDataConnectedAccount.from_dict(data) + serialized = instance.to_dict() + assert serialized == data + restored = DataIntegrationsListResponseDataConnectedAccount.from_dict( + serialized + ) + assert restored.to_dict() == serialized + + def test_data_integrations_list_response_data_connected_account_minimal_payload( + self, + ): + data = { + "object": "connected_account", + "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", + "connection_role": "compatibility", + "account_identifier": None, + "account_display_name": None, + "user_id": None, + "organization_id": None, + "scopes": ["repo", "user:email"], + "state": "connected", + "created_at": "2024-01-16T14:20:00.000Z", + "updated_at": "2024-01-16T14:20:00.000Z", + "userlandUserId": None, + } + instance = DataIntegrationsListResponseDataConnectedAccount.from_dict(data) + serialized = instance.to_dict() + assert serialized["object"] == data["object"] + assert serialized["id"] == data["id"] + assert serialized["connection_role"] == data["connection_role"] + assert serialized["account_identifier"] == data["account_identifier"] + assert serialized["account_display_name"] == data["account_display_name"] + assert serialized["user_id"] == data["user_id"] + assert serialized["organization_id"] == data["organization_id"] + assert serialized["scopes"] == data["scopes"] + assert serialized["state"] == data["state"] + assert serialized["created_at"] == data["created_at"] + assert serialized["updated_at"] == data["updated_at"] + assert serialized["userlandUserId"] == data["userlandUserId"] + + def test_data_integrations_list_response_data_connected_account_omits_absent_optional_non_nullable_fields( + self, + ): + data = { + "object": "connected_account", + "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", + "connection_role": "compatibility", + "account_identifier": "workspace_123", + "account_display_name": "Acme production", + "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", + "organization_id": None, + "scopes": ["repo", "user:email"], + "api_key_last_4": None, + "client_id": "3MVG9dZJodJWxft2VoStSCVwPFsx0eDcpVc", + "client_secret_last_4": "cdef", + "state": "connected", + "created_at": "2024-01-16T14:20:00.000Z", + "updated_at": "2024-01-16T14:20:00.000Z", + "userlandUserId": "test_userlandUserId", + } + instance = DataIntegrationsListResponseDataConnectedAccount.from_dict(data) + serialized = instance.to_dict() + assert "auth_method" not in serialized + assert "config" not in serialized + + def test_data_integrations_list_response_data_connected_account_preserves_nullable_fields( + self, + ): + data = { + "object": "connected_account", + "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", + "connection_role": "compatibility", + "account_identifier": None, + "account_display_name": None, + "user_id": None, + "organization_id": None, + "scopes": ["repo", "user:email"], + "auth_method": "oauth", + "api_key_last_4": None, + "client_id": None, + "client_secret_last_4": None, + "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": None, + } + instance = DataIntegrationsListResponseDataConnectedAccount.from_dict(data) + serialized = instance.to_dict() + assert serialized["account_identifier"] is None + assert serialized["account_display_name"] is None + assert serialized["user_id"] is None + assert serialized["organization_id"] is None + assert serialized["api_key_last_4"] is None + assert serialized["client_id"] is None + assert serialized["client_secret_last_4"] is None + assert serialized["userlandUserId"] is None + + def test_data_integrations_list_response_data_connected_account_round_trips_unknown_enum_values( + self, + ): + data = { + "object": "connected_account", + "id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT", + "connection_role": "unexpected_data_integrations_list_response_data_connected_account_connection_role", + "account_identifier": "workspace_123", + "account_display_name": "Acme production", + "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", + "organization_id": None, + "scopes": ["repo", "user:email"], + "auth_method": "oauth", + "api_key_last_4": None, + "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", + } + instance = DataIntegrationsListResponseDataConnectedAccount.from_dict(data) + assert instance.to_dict() == data