Skip to content

Commit 967e540

Browse files
lol
1 parent baf69bb commit 967e540

File tree

3 files changed

+39
-40
lines changed

3 files changed

+39
-40
lines changed

src/workos/types/authorization/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
from workos.types.authorization.authorization_resource import (
2+
AuthorizationResource,
3+
AuthorizationResourceList,
4+
)
15
from workos.types.authorization.environment_role import (
26
EnvironmentRole,
37
EnvironmentRoleList,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from typing import Literal, Optional, Sequence
2+
3+
from workos.types.workos_model import WorkOSModel
4+
5+
6+
class AuthorizationResource(WorkOSModel):
7+
object: Literal["authorization_resource"]
8+
id: str
9+
external_id: str
10+
name: str
11+
description: Optional[str] = None
12+
resource_type_slug: str
13+
organization_id: str
14+
parent_resource_id: Optional[str] = None
15+
created_at: str
16+
updated_at: str
17+
18+
19+
class AuthorizationResourceList(WorkOSModel):
20+
object: Literal["list"]
21+
data: Sequence[AuthorizationResource]
Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
1-
"""Mock fixture for AuthorizationResource used in testing new FGA APIs.
2-
3-
This fixture represents the new organization-scoped authorization resource model
4-
used in the Advanced FGA APIs, distinct from the legacy warrant-based resources.
5-
"""
6-
71
from typing import Optional
82

3+
from workos.types.authorization.authorization_resource import AuthorizationResource
94

10-
class MockAuthorizationResource:
11-
"""Mock authorization resource for testing the new FGA resource-based APIs.
12-
13-
Attributes:
14-
id: Internal WorkOS resource ID.
15-
external_id: Customer-provided external identifier for the resource.
16-
name: Human-readable name for the resource.
17-
description: Optional description of the resource.
18-
resource_type_slug: The type of resource (e.g., "document", "folder").
19-
organization_id: The organization this resource belongs to.
20-
parent_resource_id: Optional parent resource ID for hierarchical resources.
21-
"""
225

6+
class MockAuthorizationResource(AuthorizationResource):
237
def __init__(
248
self,
259
id: str = "authz_resource_01HXYZ123ABC456DEF789ABC",
@@ -30,25 +14,15 @@ def __init__(
3014
organization_id: str = "org_01HXYZ123ABC456DEF789ABC",
3115
parent_resource_id: Optional[str] = None,
3216
):
33-
self.id = id
34-
self.external_id = external_id
35-
self.name = name
36-
self.description = description
37-
self.resource_type_slug = resource_type_slug
38-
self.organization_id = organization_id
39-
self.parent_resource_id = parent_resource_id
40-
41-
def dict(self) -> dict:
42-
"""Return the resource as a dictionary matching API response format."""
43-
return {
44-
"object": "authorization_resource",
45-
"id": self.id,
46-
"external_id": self.external_id,
47-
"name": self.name,
48-
"description": self.description,
49-
"resource_type_slug": self.resource_type_slug,
50-
"organization_id": self.organization_id,
51-
"parent_resource_id": self.parent_resource_id,
52-
"created_at": "2024-01-15T09:30:00.000Z",
53-
"updated_at": "2024-01-15T09:30:00.000Z",
54-
}
17+
super().__init__(
18+
object="authorization_resource",
19+
id=id,
20+
external_id=external_id,
21+
name=name,
22+
description=description,
23+
resource_type_slug=resource_type_slug,
24+
organization_id=organization_id,
25+
parent_resource_id=parent_resource_id,
26+
created_at="2024-01-15T09:30:00.000Z",
27+
updated_at="2024-01-15T09:30:00.000Z",
28+
)

0 commit comments

Comments
 (0)