Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
541d09d
Move audit logs types
tribble Aug 7, 2024
916ed05
Move directory sync types
tribble Aug 7, 2024
dfab603
Move event types
tribble Aug 7, 2024
0dc6747
Forgot to add some files to previous commits
tribble Aug 7, 2024
76105e5
Move mfa types
tribble Aug 7, 2024
7674cc5
Move organizations types
tribble Aug 7, 2024
2d18e24
Move passwordless session type
tribble Aug 7, 2024
64d04dd
Move portal types
tribble Aug 7, 2024
ebcbcee
Move sso provider type
tribble Aug 7, 2024
d48dc9f
Move user management types
tribble Aug 7, 2024
2b239f7
Move webhook types
tribble Aug 7, 2024
cc8c893
Move audit log resource types
tribble Aug 7, 2024
093ff05
Directory resources to types
tribble Aug 7, 2024
4ae5007
Move events resource types
tribble Aug 7, 2024
a5565d1
Move list resource
tribble Aug 7, 2024
7cc5404
Move mfa resource types
tribble Aug 7, 2024
542eabf
Move organization resource
tribble Aug 7, 2024
95f54bb
Move passwordless resource
tribble Aug 7, 2024
ad73fb2
Move workos model
tribble Aug 7, 2024
6a47490
Move portal link resource
tribble Aug 7, 2024
7426c5e
Move connection resources
tribble Aug 7, 2024
2c3cb00
Move webhooks resources
tribble Aug 7, 2024
f15594a
Move user management resource types
tribble Aug 7, 2024
7b4344b
Goodbye resources folder
tribble Aug 7, 2024
3894661
Import complex input types at the top level
tribble Aug 7, 2024
e9625de
Import NotRequired from typing_extensions
tribble Aug 8, 2024
7ea3c67
Import TypedDict from typing_extensions
tribble Aug 8, 2024
bd298a7
Sigh. Forgot to save a file
tribble Aug 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from tests.utils.list_resource import list_data_to_dicts, list_response_of
import workos
from workos.resources.list import WorkOsListResource
from workos.types.list_resource import WorkOsListResource
from workos.utils.http_client import AsyncHTTPClient, HTTPClient, SyncHTTPClient


Expand Down
2 changes: 1 addition & 1 deletion tests/test_sso.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from tests.utils.list_resource import list_data_to_dicts, list_response_of
import workos
from workos.sso import SSO, AsyncSSO, SsoProviderType
from workos.resources.sso import Profile
from workos.types.sso import Profile
from workos.utils.http_client import AsyncHTTPClient, SyncHTTPClient
from workos.utils.request_helper import RESPONSE_TYPE_CODE
from tests.utils.fixtures.mock_connection import MockConnection
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/fixtures/mock_auth_factor_totp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime

from workos.resources.mfa import AuthenticationFactorTotp, ExtendedTotpFactor
from workos.types.mfa import AuthenticationFactorTotp, ExtendedTotpFactor


class MockAuthenticationFactorTotp(AuthenticationFactorTotp):
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/fixtures/mock_connection.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import datetime
from workos.resources.sso import ConnectionDomain, ConnectionWithDomains
from workos.types.sso import ConnectionDomain, ConnectionWithDomains


class MockConnection(ConnectionWithDomains):
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/fixtures/mock_directory.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime

from workos.resources.directory_sync import Directory
from workos.types.directory_sync import Directory


class MockDirectory(Directory):
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/fixtures/mock_directory_group.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime

from workos.resources.directory_sync import DirectoryGroup
from workos.types.directory_sync import DirectoryGroup


class MockDirectoryGroup(DirectoryGroup):
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/fixtures/mock_directory_user.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime

from workos.resources.directory_sync import DirectoryUserWithGroups
from workos.types.directory_sync import DirectoryUserWithGroups
from workos.types.directory_sync.directory_user import DirectoryUserEmail, InlineRole


Expand Down
2 changes: 1 addition & 1 deletion tests/utils/fixtures/mock_email_verification.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime

from workos.resources.user_management import EmailVerification
from workos.types.user_management import EmailVerification


class MockEmailVerification(EmailVerification):
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/fixtures/mock_event.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime

from workos.resources.events import DirectoryActivatedEvent
from workos.types.events import DirectoryActivatedEvent
from workos.types.events.directory_payload_with_legacy_fields import (
DirectoryPayloadWithLegacyFields,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/fixtures/mock_invitation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime

from workos.resources.user_management import Invitation
from workos.types.user_management import Invitation


class MockInvitation(Invitation):
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/fixtures/mock_magic_auth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime

from workos.resources.user_management import MagicAuth
from workos.types.user_management import MagicAuth


class MockMagicAuth(MagicAuth):
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/fixtures/mock_organization.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime

from workos.resources.organizations import Organization
from workos.types.organizations import Organization
from workos.types.organizations.organization_domain import OrganizationDomain


Expand Down
2 changes: 1 addition & 1 deletion tests/utils/fixtures/mock_organization_membership.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime

from workos.resources.user_management import OrganizationMembership
from workos.types.user_management import OrganizationMembership


class MockOrganizationMembership(OrganizationMembership):
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/fixtures/mock_password_reset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime

from workos.resources.user_management import PasswordReset
from workos.types.user_management import PasswordReset


class MockPasswordReset(PasswordReset):
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/fixtures/mock_profile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from workos.resources.sso import Profile
from workos.types.sso import Profile


class MockProfile(Profile):
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/fixtures/mock_user.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime

from workos.resources.user_management import User
from workos.types.user_management import User


class MockUser(User):
Expand Down
41 changes: 3 additions & 38 deletions workos/audit_logs.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Dict, Optional, Protocol, Sequence
from typing_extensions import TypedDict, NotRequired
from typing import Optional, Protocol, Sequence

import workos
from workos.resources.audit_logs import AuditLogExport, AuditLogMetadata
from workos.types.audit_logs import AuditLogExport
from workos.types.audit_logs.audit_log_event import AuditLogEvent
from workos.utils.http_client import SyncHTTPClient
from workos.utils.request_helper import REQUEST_METHOD_GET, REQUEST_METHOD_POST
from workos.utils.validation import Module, validate_settings
Expand All @@ -11,41 +11,6 @@
EXPORTS_PATH = "audit_logs/exports"


class AuditLogEventTarget(TypedDict):
"""Describes the entity that was targeted by the event."""

id: str
metadata: NotRequired[AuditLogMetadata]
name: NotRequired[str]
type: str


class AuditLogEventActor(TypedDict):
"""Describes the entity that generated the event."""

id: str
metadata: NotRequired[AuditLogMetadata]
name: NotRequired[str]
type: str


class AuditLogEventContext(TypedDict):
"""Attributes of audit log event context."""

location: str
user_agent: NotRequired[str]


class AuditLogEvent(TypedDict):
action: str
version: NotRequired[int]
occurred_at: str # ISO-8601 datetime of when an event occurred
actor: AuditLogEventActor
targets: Sequence[AuditLogEventTarget]
context: AuditLogEventContext
metadata: NotRequired[AuditLogMetadata]


class AuditLogsModule(Protocol):
def create_event(
self,
Expand Down
32 changes: 11 additions & 21 deletions workos/directory_sync.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from typing import Optional, Protocol

import workos
from workos.types.directory_sync.list_filters import (
DirectoryGroupListFilters,
DirectoryListFilters,
DirectoryUserListFilters,
)
from workos.typing.sync_or_async import SyncOrAsync
from workos.utils.http_client import AsyncHTTPClient, SyncHTTPClient
from workos.utils.pagination_order import PaginationOrder
Expand All @@ -10,32 +15,17 @@
REQUEST_METHOD_GET,
)
from workos.utils.validation import Module, validate_settings
from workos.resources.directory_sync import (
from workos.types.directory_sync import (
DirectoryGroup,
Directory,
DirectoryUserWithGroups,
)
from workos.resources.list import ListArgs, ListMetadata, ListPage, WorkOsListResource


class DirectoryListFilters(ListArgs, total=False):
search: Optional[str]
organization_id: Optional[str]
domain: Optional[str]


class DirectoryUserListFilters(
from workos.types.list_resource import (
ListArgs,
total=False,
):
group: Optional[str]
directory: Optional[str]


class DirectoryGroupListFilters(ListArgs, total=False):
user: Optional[str]
directory: Optional[str]

ListMetadata,
ListPage,
WorkOsListResource,
)

DirectoryUsersListResource = WorkOsListResource[
DirectoryUserWithGroups, DirectoryUserListFilters, ListMetadata
Expand Down
13 changes: 3 additions & 10 deletions workos/events.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
from typing import Optional, Protocol, Sequence

import workos
from workos.types.events.list_filters import EventsListFilters
from workos.typing.sync_or_async import SyncOrAsync
from workos.utils.request_helper import DEFAULT_LIST_RESPONSE_LIMIT, REQUEST_METHOD_GET
from workos.resources.events import Event, EventType
from workos.types.events import Event, EventType
from workos.utils.http_client import AsyncHTTPClient, SyncHTTPClient
from workos.utils.validation import Module, validate_settings
from workos.resources.list import (
from workos.types.list_resource import (
ListAfterMetadata,
ListArgs,
ListPage,
WorkOsListResource,
)


class EventsListFilters(ListArgs, total=False):
events: Sequence[EventType]
organization_id: Optional[str]
range_start: Optional[str]
range_end: Optional[str]


EventsListResource = WorkOsListResource[Event, EventsListFilters, ListAfterMetadata]


Expand Down
14 changes: 5 additions & 9 deletions workos/mfa.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import Literal, Optional, Protocol

from typing import Optional, Protocol
import workos
from workos.types.mfa.enroll_authentication_factor_type import (
EnrollAuthenticationFactorType,
)
from workos.utils.http_client import SyncHTTPClient
from workos.utils.request_helper import (
REQUEST_METHOD_POST,
Expand All @@ -9,22 +11,16 @@
RequestHelper,
)
from workos.utils.validation import Module, validate_settings
from workos.resources.mfa import (
from workos.types.mfa import (
AuthenticationChallenge,
AuthenticationChallengeVerificationResponse,
AuthenticationFactor,
AuthenticationFactorExtended,
AuthenticationFactorSms,
AuthenticationFactorTotp,
AuthenticationFactorTotpExtended,
SmsAuthenticationFactorType,
TotpAuthenticationFactorType,
)

EnrollAuthenticationFactorType = Literal[
SmsAuthenticationFactorType, TotpAuthenticationFactorType
]


class MFAModule(Protocol):
def enroll_factor(
Expand Down
20 changes: 9 additions & 11 deletions workos/organizations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import Literal, Optional, Protocol, Sequence
from typing_extensions import TypedDict
import workos
from workos.types.organizations.domain_data_input import DomainDataInput
from workos.types.organizations.list_filters import OrganizationListFilters
from workos.utils.http_client import SyncHTTPClient
from workos.utils.pagination_order import PaginationOrder
from workos.utils.request_helper import (
Expand All @@ -11,23 +13,19 @@
REQUEST_METHOD_PUT,
)
from workos.utils.validation import Module, validate_settings
from workos.resources.organizations import (
from workos.types.organizations import (
Organization,
)
from workos.resources.list import ListMetadata, ListPage, WorkOsListResource, ListArgs
from workos.types.list_resource import (
ListMetadata,
ListPage,
WorkOsListResource,
ListArgs,
)

ORGANIZATIONS_PATH = "organizations"


class DomainDataInput(TypedDict):
domain: str
state: Literal["verified", "pending"]


class OrganizationListFilters(ListArgs, total=False):
domains: Optional[Sequence[str]]


OrganizationsListResource = WorkOsListResource[
Organization, OrganizationListFilters, ListMetadata
]
Expand Down
6 changes: 2 additions & 4 deletions workos/passwordless.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from typing import Literal, Optional, Protocol

import workos
from workos.types.passwordless.passwordless_session_type import PasswordlessSessionType
from workos.utils.http_client import SyncHTTPClient
from workos.utils.request_helper import REQUEST_METHOD_POST
from workos.resources.passwordless import PasswordlessSession
from workos.types.passwordless.passwordless_session import PasswordlessSession
from workos.utils.validation import Module, validate_settings

PasswordlessSessionType = Literal["MagicLink"]


class PasswordlessModule(Protocol):
def create_session(
Expand Down
4 changes: 2 additions & 2 deletions workos/portal.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from typing import Literal, Optional, Protocol
import workos
from workos.resources.portal import PortalLink
from workos.types.portal.portal_link import PortalLink
from workos.types.portal.portal_link_intent import PortalLinkIntent
from workos.utils.http_client import SyncHTTPClient
from workos.utils.request_helper import REQUEST_METHOD_POST
from workos.utils.validation import Module, validate_settings


PORTAL_GENERATE_PATH = "portal/generate_link"
PortalLinkIntent = Literal["audit_logs", "dsync", "log_streams", "sso"]


class PortalModule(Protocol):
Expand Down
Loading