Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ameesha committed Jul 9, 2024
1 parent e8bb412 commit 7d82288
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 69 deletions.
49 changes: 33 additions & 16 deletions workos/event_objects/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class AuthenticationType(Enum):


class Error(NamedTuple):
code: str
message: str
code: str
message: str


class AuthenticationFailedFields:
Expand All @@ -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:
Expand All @@ -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(
Expand All @@ -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"]
)

102 changes: 51 additions & 51 deletions workos/event_objects/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"])
4 changes: 2 additions & 2 deletions workos/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

0 comments on commit 7d82288

Please sign in to comment.