Skip to content

Commit 1066b67

Browse files
committed
Updates to role naming.
1 parent 946786c commit 1066b67

File tree

6 files changed

+21
-23
lines changed

6 files changed

+21
-23
lines changed

tests/utils/fixtures/mock_role.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import datetime
22

3-
from workos.types.roles.role import OrganizationRole
3+
from workos.types.roles.role import Role
44

55

6-
class MockRole(OrganizationRole):
6+
class MockRole(Role):
77
def __init__(self, id):
88
now = datetime.datetime.now().isoformat()
99
super().__init__(

workos/organizations.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from workos.types.organizations.domain_data_input import DomainDataInput
44
from workos.types.organizations.list_filters import OrganizationListFilters
5-
from workos.types.roles.role import OrganizationRole, RolesList
5+
from workos.types.roles.role import RoleList
66
from workos.typing.sync_or_async import SyncOrAsync
77
from workos.utils.http_client import AsyncHTTPClient, SyncHTTPClient
88
from workos.utils.pagination_order import PaginationOrder
@@ -224,13 +224,13 @@ def delete_organization(self, organization_id: str) -> None:
224224
method=REQUEST_METHOD_DELETE,
225225
)
226226

227-
def list_organization_roles(self, organization_id: str) -> RolesList:
227+
def list_organization_roles(self, organization_id: str) -> RoleList:
228228
response = self._http_client.request(
229229
f"organizations/{organization_id}/roles",
230230
method=REQUEST_METHOD_GET,
231231
)
232232

233-
return RolesList.model_validate(response)
233+
return RoleList.model_validate(response)
234234

235235

236236
class AsyncOrganizations(OrganizationsModule):
@@ -334,10 +334,10 @@ async def delete_organization(self, organization_id: str) -> None:
334334
method=REQUEST_METHOD_DELETE,
335335
)
336336

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

343-
return RolesList.model_validate(response)
343+
return RoleList.model_validate(response)

workos/types/events/event.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
)
2828
from workos.types.events.directory_payload import DirectoryPayload
2929
from workos.types.events.directory_payload_with_legacy_fields import (
30-
DirectoryPayloadWithLegacyFields,
3130
DirectoryPayloadWithLegacyFieldsForEventsApi,
3231
)
3332
from workos.types.events.directory_user_with_previous_attributes import (
@@ -40,7 +39,7 @@
4039
from workos.types.events.session_created_payload import SessionCreatedPayload
4140
from workos.types.organizations.organization_common import OrganizationCommon
4241
from workos.types.organizations.organization_domain import OrganizationDomain
43-
from workos.types.roles.role import Role
42+
from workos.types.roles.role import EventRole
4443
from workos.types.sso.connection import Connection
4544
from workos.types.user_management.email_verification import (
4645
EmailVerificationCommon,
@@ -210,15 +209,15 @@ class PasswordResetCreatedEvent(EventModel[PasswordResetCommon]):
210209
event: Literal["password_reset.created"]
211210

212211

213-
class RoleCreatedEvent(EventModel[Role]):
212+
class RoleCreatedEvent(EventModel[EventRole]):
214213
event: Literal["role.created"]
215214

216215

217-
class RoleDeletedEvent(EventModel[Role]):
216+
class RoleDeletedEvent(EventModel[EventRole]):
218217
event: Literal["role.deleted"]
219218

220219

221-
class RoleUpdatedEvent(EventModel[Role]):
220+
class RoleUpdatedEvent(EventModel[EventRole]):
222221
event: Literal["role.updated"]
223222

224223

workos/types/events/event_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from workos.types.events.session_created_payload import SessionCreatedPayload
3939
from workos.types.organizations.organization_common import OrganizationCommon
4040
from workos.types.organizations.organization_domain import OrganizationDomain
41-
from workos.types.roles.role import Role
41+
from workos.types.roles.role import EventRole
4242
from workos.types.sso.connection import Connection
4343
from workos.types.user_management.email_verification import (
4444
EmailVerificationCommon,
@@ -72,14 +72,14 @@
7272
DirectoryUserWithPreviousAttributes,
7373
DirectoryGroupMembershipPayload,
7474
EmailVerificationCommon,
75+
EventRole,
7576
InvitationCommon,
7677
MagicAuthCommon,
7778
OrganizationCommon,
7879
OrganizationDomain,
7980
OrganizationDomainVerificationFailedPayload,
8081
OrganizationMembership,
8182
PasswordResetCommon,
82-
Role,
8383
SessionCreatedPayload,
8484
User,
8585
)

workos/types/roles/role.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ class RoleCommon(WorkOSModel):
99
slug: str
1010

1111

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

1615

17-
class OrganizationRole(RoleCommon):
16+
class Role(RoleCommon):
1817
id: str
1918
name: str
2019
description: Optional[str] = None
@@ -23,6 +22,6 @@ class OrganizationRole(RoleCommon):
2322
updated_at: str
2423

2524

26-
class RolesList(WorkOSModel):
25+
class RoleList(WorkOSModel):
2726
object: Literal["list"]
28-
data: Sequence[OrganizationRole]
27+
data: Sequence[Role]

workos/types/webhooks/webhook.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from workos.types.events.session_created_payload import SessionCreatedPayload
4040
from workos.types.organizations.organization_common import OrganizationCommon
4141
from workos.types.organizations.organization_domain import OrganizationDomain
42-
from workos.types.roles.role import Role
42+
from workos.types.roles.role import EventRole
4343
from workos.types.sso.connection import Connection
4444
from workos.types.user_management.email_verification import (
4545
EmailVerificationCommon,
@@ -213,15 +213,15 @@ class PasswordResetCreatedWebhook(WebhookModel[PasswordResetCommon]):
213213
event: Literal["password_reset.created"]
214214

215215

216-
class RoleCreatedWebhook(WebhookModel[Role]):
216+
class RoleCreatedWebhook(WebhookModel[EventRole]):
217217
event: Literal["role.created"]
218218

219219

220-
class RoleDeletedWebhook(WebhookModel[Role]):
220+
class RoleDeletedWebhook(WebhookModel[EventRole]):
221221
event: Literal["role.deleted"]
222222

223223

224-
class RoleUpdatedWebhook(WebhookModel[Role]):
224+
class RoleUpdatedWebhook(WebhookModel[EventRole]):
225225
event: Literal["role.updated"]
226226

227227

0 commit comments

Comments
 (0)