diff --git a/workos/event_objects/authentication.py b/workos/event_objects/authentication.py index 5fa0a954..211b6629 100644 --- a/workos/event_objects/authentication.py +++ b/workos/event_objects/authentication.py @@ -13,8 +13,8 @@ class AuthenticationType(Enum): class Error(NamedTuple): - code: str - message: str + code: str + message: str class AuthenticationFailedFields: @@ -25,7 +25,10 @@ def __init__(self, attributes: JsonDict) -> None: self.email: str = attributes["email"] self.ip_address: str = attributes["ip_address"] self.user_agent: str = attributes["user_agent"] - self.error: Error = Error(code=attributes["error"]["code"], message=attributes["error"]["message"]) + self.error: Error = Error( + code=attributes["error"]["code"], message=attributes["error"]["message"] + ) + class AuthenticationSucceededFields: def __init__(self, attributes: JsonDict) -> None: @@ -36,110 +39,124 @@ def __init__(self, attributes: JsonDict) -> None: self.ip_address: str = attributes["ip_address"] self.user_agent: str = attributes["user_agent"] + class AuthenticationEmailVerificationFailedEvent: event_name: str = "authentication.email_verification_failed" def __init__(self, attributes: JsonDict) -> None: - self.event: Literal["authentication.email_verification_failed"] = attributes['event'] + self.event: Literal["authentication.email_verification_failed"] = attributes[ + "event" + ] self.id: str = attributes["id"] self.created_at = attributes["created_at"] self.data: AuthenticationFailedFields = AuthenticationFailedFields( attributes["data"] ) + class AuthenticationEmailVerificationSucceededEvent: event_name: str = "authentication.email_verification_succeeded" def __init__(self, attributes: JsonDict) -> None: - self.event: Literal["authentication.email_verification_succeeded"] = attributes['event'] + self.event: Literal["authentication.email_verification_succeeded"] = attributes[ + "event" + ] self.id: str = attributes["id"] self.created_at = attributes["created_at"] self.data: AuthenticationSucceededFields = AuthenticationSucceededFields( attributes["data"] ) + class AuthenticationMagicAuthFailedEvent: event_name: str = "authentication.magic_auth_failed" def __init__(self, attributes: JsonDict) -> None: - self.event: Literal["authentication.magic_auth_failed"] = attributes['event'] + self.event: Literal["authentication.magic_auth_failed"] = attributes["event"] self.id: str = attributes["id"] self.created_at = attributes["created_at"] self.data: AuthenticationFailedFields = AuthenticationFailedFields( attributes["data"] ) + class AuthenticationMagicAuthSucceededEvent: event_name: str = "authentication.magic_auth_succeeded" def __init__(self, attributes: JsonDict) -> None: - self.event: Literal["authentication.magic_auth_succeeded"] = attributes['event'] + self.event: Literal["authentication.magic_auth_succeeded"] = attributes["event"] self.id: str = attributes["id"] self.created_at = attributes["created_at"] self.data: AuthenticationSucceededFields = AuthenticationSucceededFields( attributes["data"] ) + class AuthenticationMFAFailedEvent: event_name: str = "authentication.mfa_failed" def __init__(self, attributes: JsonDict) -> None: - self.event: Literal["authentication.mfa_failed"] = attributes['event'] + self.event: Literal["authentication.mfa_failed"] = attributes["event"] self.id: str = attributes["id"] self.created_at = attributes["created_at"] self.data: AuthenticationFailedFields = AuthenticationFailedFields( attributes["data"] ) + class AuthenticationMFASucceededEvent: event_name: str = "authentication.mfa_succeeded" def __init__(self, attributes: JsonDict) -> None: - self.event: Literal["authentication.mfa_succeeded"] = attributes['event'] + self.event: Literal["authentication.mfa_succeeded"] = attributes["event"] self.id: str = attributes["id"] self.created_at = attributes["created_at"] self.data: AuthenticationSucceededFields = AuthenticationSucceededFields( attributes["data"] ) + class AuthenticationOAuthFailedEvent: event_name: str = "authentication.oauth_failed" def __init__(self, attributes: JsonDict) -> None: - self.event: Literal["authentication.oauth_failed"] = attributes['event'] + self.event: Literal["authentication.oauth_failed"] = attributes["event"] self.id: str = attributes["id"] self.created_at = attributes["created_at"] self.data: AuthenticationFailedFields = AuthenticationFailedFields( attributes["data"] ) + class AuthenticationOAuthSucceededEvent: event_name: str = "authentication.oauth_succeeded" def __init__(self, attributes: JsonDict) -> None: - self.event: Literal["authentication.oauth_succeeded"] = attributes['event'] + self.event: Literal["authentication.oauth_succeeded"] = attributes["event"] self.id: str = attributes["id"] self.created_at = attributes["created_at"] self.data: AuthenticationSucceededFields = AuthenticationSucceededFields( attributes["data"] ) + class AuthenticationPasswordFailedEvent: event_name: str = "authentication.password_failed" def __init__(self, attributes: JsonDict) -> None: - self.event: Literal["authentication.password_failed"] = attributes['event'] + self.event: Literal["authentication.password_failed"] = attributes["event"] self.id: str = attributes["id"] self.created_at = attributes["created_at"] self.data: AuthenticationFailedFields = AuthenticationFailedFields( attributes["data"] ) + class AuthenticationPasswordSucceededEvent: event_name: str = "authentication.password_succeeded" def __init__(self, attributes: JsonDict) -> None: - self.event: Literal["authentication.password_succeeded"] = attributes['event'] + self.event: Literal["authentication.password_succeeded"] = attributes["event"] self.id: str = attributes["id"] self.created_at = attributes["created_at"] self.data: AuthenticationSucceededFields = AuthenticationSucceededFields( @@ -151,21 +168,21 @@ class AuthenticationSSOFailedEvent: event_name: str = "authentication.sso_failed" def __init__(self, attributes: JsonDict) -> None: - self.event: Literal["authentication.sso_failed"] = attributes['event'] + self.event: Literal["authentication.sso_failed"] = attributes["event"] self.id: str = attributes["id"] self.created_at = attributes["created_at"] self.data: AuthenticationFailedFields = AuthenticationFailedFields( attributes["data"] ) + class AuthenticationSSOSucceededEvent: event_name: str = "authentication.sso_succeeded" def __init__(self, attributes: JsonDict) -> None: - self.event: Literal["authentication.sso_succeeded"] = attributes['event'] + self.event: Literal["authentication.sso_succeeded"] = attributes["event"] self.id: str = attributes["id"] self.created_at = attributes["created_at"] self.data: AuthenticationSucceededFields = AuthenticationSucceededFields( attributes["data"] ) - diff --git a/workos/event_objects/connection.py b/workos/event_objects/connection.py index 405959c4..b20b686f 100644 --- a/workos/event_objects/connection.py +++ b/workos/event_objects/connection.py @@ -2,49 +2,52 @@ from enum import Enum from workos.utils.types import JsonDict + class ConnectionState(Enum): - INACTIVE = "inactive" - ACTIVE = "active" + INACTIVE = "inactive" + ACTIVE = "active" + class ConnectionType(Enum): - ADFS_SAML = 'ADFSSAML' - ADP_OIDC = 'AdpOidc' - AUTH0_SAML = 'Auth0SAML' - AZURE_SAML = 'AzureSAML' - CAS_SAML = 'CasSAML' - CLASS_LINK_SAML = 'ClassLinkSAML' - CLOUDFLARE_SAML = 'CloudflareSAML' - CYBER_ARK_SAML = 'CyberArkSAML' - DUO_SAML = 'DuoSAML' - GENERIC_OIDC = 'GenericOIDC' - GENERIC_SAML = 'GenericSAML' - GOOGLE_OAUTH = 'GoogleOAuth' - GOOGLE_SAML = 'GoogleSAML' - JUMP_CLOUD_SAML = 'JumpCloudSAML' - KEYCLOAK_SAML = 'KeycloakSAML' - LAST_PASS_SAML = 'LastPassSAML' - LOGIN_GOV_OIDC = 'LoginGovOidc' - MAGIC_LINK = 'MagicLink' - MICROSOFT_OAUTH = 'MicrosoftOAuth' - MINI_ORANGE_SAML = 'MiniOrangeSAML' - NET_IQ_SAML = 'NetIqSAML' - OKTA_SAML = 'OktaSAML' - ONE_LOGIN_SAML ='OneLoginSAML' - ORACLE_SAML = 'OracleSAML' - PING_FEDERATE_SAML = 'PingFederateSAML' - PING_ONE_SAML = 'PingOneSAML' - RIPPLING_SAML = 'RipplingSAML' - SALESFORCE_SAML = 'SalesforceSAML' - SHIBBOLETH_GENERIC_SAML = 'ShibbolethGenericSAML' - SHIBBOLETH_SAML = 'ShibbolethSAML' - SIMPLE_SAML_PHP_SAML = 'SimpleSamlPhpSAML' - VM_WARE_SAML = 'VMwareSAML' + ADFS_SAML = "ADFSSAML" + ADP_OIDC = "AdpOidc" + AUTH0_SAML = "Auth0SAML" + AZURE_SAML = "AzureSAML" + CAS_SAML = "CasSAML" + CLASS_LINK_SAML = "ClassLinkSAML" + CLOUDFLARE_SAML = "CloudflareSAML" + CYBER_ARK_SAML = "CyberArkSAML" + DUO_SAML = "DuoSAML" + GENERIC_OIDC = "GenericOIDC" + GENERIC_SAML = "GenericSAML" + GOOGLE_OAUTH = "GoogleOAuth" + GOOGLE_SAML = "GoogleSAML" + JUMP_CLOUD_SAML = "JumpCloudSAML" + KEYCLOAK_SAML = "KeycloakSAML" + LAST_PASS_SAML = "LastPassSAML" + LOGIN_GOV_OIDC = "LoginGovOidc" + MAGIC_LINK = "MagicLink" + MICROSOFT_OAUTH = "MicrosoftOAuth" + MINI_ORANGE_SAML = "MiniOrangeSAML" + NET_IQ_SAML = "NetIqSAML" + OKTA_SAML = "OktaSAML" + ONE_LOGIN_SAML = "OneLoginSAML" + ORACLE_SAML = "OracleSAML" + PING_FEDERATE_SAML = "PingFederateSAML" + PING_ONE_SAML = "PingOneSAML" + RIPPLING_SAML = "RipplingSAML" + SALESFORCE_SAML = "SalesforceSAML" + SHIBBOLETH_GENERIC_SAML = "ShibbolethGenericSAML" + SHIBBOLETH_SAML = "ShibbolethSAML" + SIMPLE_SAML_PHP_SAML = "SimpleSamlPhpSAML" + VM_WARE_SAML = "VMwareSAML" + class Domain: - def __init__(self, attributes: JsonDict) -> None: - self.id: str = attributes["id"] - self.object: Literal["connection_domain"] = attributes["object"] - self.domain: str = attributes["domain"] + def __init__(self, attributes: JsonDict) -> None: + self.id: str = attributes["id"] + self.object: Literal["connection_domain"] = attributes["object"] + self.domain: str = attributes["domain"] class ConnectionEvent: @@ -59,37 +62,34 @@ def __init__(self, attributes: JsonDict) -> None: self.updated_at: str = attributes["updated_at"] self.domains = [] for domain in attributes["domains"]: - self.domains.push(Domain(attributes=domain)) + self.domains.push(Domain(attributes=domain)) + class ConnectionActivatedEvent: event_name = "connection.activated" def __init__(self, attributes: JsonDict) -> None: - self.event: Literal['connection.activated'] = attributes["event"] + self.event: Literal["connection.activated"] = attributes["event"] self.id: str = attributes["id"] self.created_at = attributes["created_at"] - self.data: ConnectionEvent = ConnectionEvent( - attributes["data"] - ) + self.data: ConnectionEvent = ConnectionEvent(attributes["data"]) + class ConnectionDeactivatedEvent: event_name = "connection.deactivated" def __init__(self, attributes: JsonDict) -> None: - self.event: Literal['connection.deactivated'] = attributes["event"] + self.event: Literal["connection.deactivated"] = attributes["event"] self.id: str = attributes["id"] self.created_at = attributes["created_at"] - self.data: ConnectionEvent = ConnectionEvent( - attributes["data"] - ) + self.data: ConnectionEvent = ConnectionEvent(attributes["data"]) + class ConnectionDeactivatedEvent: event_name = "connection.deleted" def __init__(self, attributes: JsonDict) -> None: - self.event: Literal['connection.deleted'] = attributes["event"] + self.event: Literal["connection.deleted"] = attributes["event"] self.id: str = attributes["id"] self.created_at = attributes["created_at"] - self.data: ConnectionEvent = ConnectionEvent( - attributes["data"] - ) + self.data: ConnectionEvent = ConnectionEvent(attributes["data"]) diff --git a/workos/events.py b/workos/events.py index 61e7fe39..bbd70b54 100644 --- a/workos/events.py +++ b/workos/events.py @@ -69,7 +69,7 @@ def request_helper(self): def list_events( self, - events: Optional[List[EVENT_TYPES]]=None, + events: Optional[List[EVENT_TYPES]] = None, limit: Optional[int] = None, organization_id: Optional[str] = None, after: Optional[str] = None, @@ -125,7 +125,7 @@ def list_events( for list_data in response["data"]: if list_data["event"] in EVENT_TO_OBJECT.keys(): data.append(EVENT_TO_OBJECT[list_data["event"]](list_data)) - + response["data"] = data return response