Skip to content

Commit

Permalink
Updates to role naming.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgd committed Dec 30, 2024
1 parent 946786c commit 1066b67
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 23 deletions.
4 changes: 2 additions & 2 deletions tests/utils/fixtures/mock_role.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import datetime

from workos.types.roles.role import OrganizationRole
from workos.types.roles.role import Role


class MockRole(OrganizationRole):
class MockRole(Role):
def __init__(self, id):
now = datetime.datetime.now().isoformat()
super().__init__(
Expand Down
10 changes: 5 additions & 5 deletions workos/organizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from workos.types.organizations.domain_data_input import DomainDataInput
from workos.types.organizations.list_filters import OrganizationListFilters
from workos.types.roles.role import OrganizationRole, RolesList
from workos.types.roles.role import RoleList
from workos.typing.sync_or_async import SyncOrAsync
from workos.utils.http_client import AsyncHTTPClient, SyncHTTPClient
from workos.utils.pagination_order import PaginationOrder
Expand Down Expand Up @@ -224,13 +224,13 @@ def delete_organization(self, organization_id: str) -> None:
method=REQUEST_METHOD_DELETE,
)

def list_organization_roles(self, organization_id: str) -> RolesList:
def list_organization_roles(self, organization_id: str) -> RoleList:
response = self._http_client.request(
f"organizations/{organization_id}/roles",
method=REQUEST_METHOD_GET,
)

return RolesList.model_validate(response)
return RoleList.model_validate(response)


class AsyncOrganizations(OrganizationsModule):
Expand Down Expand Up @@ -334,10 +334,10 @@ async def delete_organization(self, organization_id: str) -> None:
method=REQUEST_METHOD_DELETE,
)

async def list_organization_roles(self, organization_id: str) -> RolesList:
async def list_organization_roles(self, organization_id: str) -> RoleList:
response = await self._http_client.request(
f"organizations/{organization_id}/roles",
method=REQUEST_METHOD_GET,
)

return RolesList.model_validate(response)
return RoleList.model_validate(response)
9 changes: 4 additions & 5 deletions workos/types/events/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
)
from workos.types.events.directory_payload import DirectoryPayload
from workos.types.events.directory_payload_with_legacy_fields import (
DirectoryPayloadWithLegacyFields,
DirectoryPayloadWithLegacyFieldsForEventsApi,
)
from workos.types.events.directory_user_with_previous_attributes import (
Expand All @@ -40,7 +39,7 @@
from workos.types.events.session_created_payload import SessionCreatedPayload
from workos.types.organizations.organization_common import OrganizationCommon
from workos.types.organizations.organization_domain import OrganizationDomain
from workos.types.roles.role import Role
from workos.types.roles.role import EventRole
from workos.types.sso.connection import Connection
from workos.types.user_management.email_verification import (
EmailVerificationCommon,
Expand Down Expand Up @@ -210,15 +209,15 @@ class PasswordResetCreatedEvent(EventModel[PasswordResetCommon]):
event: Literal["password_reset.created"]


class RoleCreatedEvent(EventModel[Role]):
class RoleCreatedEvent(EventModel[EventRole]):
event: Literal["role.created"]


class RoleDeletedEvent(EventModel[Role]):
class RoleDeletedEvent(EventModel[EventRole]):
event: Literal["role.deleted"]


class RoleUpdatedEvent(EventModel[Role]):
class RoleUpdatedEvent(EventModel[EventRole]):
event: Literal["role.updated"]


Expand Down
4 changes: 2 additions & 2 deletions workos/types/events/event_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from workos.types.events.session_created_payload import SessionCreatedPayload
from workos.types.organizations.organization_common import OrganizationCommon
from workos.types.organizations.organization_domain import OrganizationDomain
from workos.types.roles.role import Role
from workos.types.roles.role import EventRole
from workos.types.sso.connection import Connection
from workos.types.user_management.email_verification import (
EmailVerificationCommon,
Expand Down Expand Up @@ -72,14 +72,14 @@
DirectoryUserWithPreviousAttributes,
DirectoryGroupMembershipPayload,
EmailVerificationCommon,
EventRole,
InvitationCommon,
MagicAuthCommon,
OrganizationCommon,
OrganizationDomain,
OrganizationDomainVerificationFailedPayload,
OrganizationMembership,
PasswordResetCommon,
Role,
SessionCreatedPayload,
User,
)
Expand Down
9 changes: 4 additions & 5 deletions workos/types/roles/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ class RoleCommon(WorkOSModel):
slug: str


# TODO: This is used for events/webhooks only. Rename to EventRole or something similar.
class Role(RoleCommon):
class EventRole(RoleCommon):
permissions: Optional[Sequence[str]] = None


class OrganizationRole(RoleCommon):
class Role(RoleCommon):
id: str
name: str
description: Optional[str] = None
Expand All @@ -23,6 +22,6 @@ class OrganizationRole(RoleCommon):
updated_at: str


class RolesList(WorkOSModel):
class RoleList(WorkOSModel):
object: Literal["list"]
data: Sequence[OrganizationRole]
data: Sequence[Role]
8 changes: 4 additions & 4 deletions workos/types/webhooks/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from workos.types.events.session_created_payload import SessionCreatedPayload
from workos.types.organizations.organization_common import OrganizationCommon
from workos.types.organizations.organization_domain import OrganizationDomain
from workos.types.roles.role import Role
from workos.types.roles.role import EventRole
from workos.types.sso.connection import Connection
from workos.types.user_management.email_verification import (
EmailVerificationCommon,
Expand Down Expand Up @@ -213,15 +213,15 @@ class PasswordResetCreatedWebhook(WebhookModel[PasswordResetCommon]):
event: Literal["password_reset.created"]


class RoleCreatedWebhook(WebhookModel[Role]):
class RoleCreatedWebhook(WebhookModel[EventRole]):
event: Literal["role.created"]


class RoleDeletedWebhook(WebhookModel[Role]):
class RoleDeletedWebhook(WebhookModel[EventRole]):
event: Literal["role.deleted"]


class RoleUpdatedWebhook(WebhookModel[Role]):
class RoleUpdatedWebhook(WebhookModel[EventRole]):
event: Literal["role.updated"]


Expand Down

0 comments on commit 1066b67

Please sign in to comment.