Skip to content

Commit 7a56634

Browse files
gjtorikianclaude
andcommitted
Add context field to flag.rule_updated event and webhook
The backend flag.rule_updated event includes a context object (with actor, access_type, configured_targets, and previous_attributes) as a sibling of the data field. Without this, the context was silently dropped during deserialization. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 01542a2 commit 7a56634

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

src/workos/types/events/event.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
DirectoryUserWithPreviousAttributes,
4444
)
4545
from workos.types.events.event_model import EventModel
46-
from workos.types.events.flag_payload import FlagPayload
46+
from workos.types.events.flag_payload import FlagPayload, FlagRuleUpdatedContext
4747
from workos.types.events.organization_domain_verification_failed_payload import (
4848
OrganizationDomainVerificationFailedPayload,
4949
)
@@ -235,6 +235,7 @@ class FlagDeletedEvent(EventModel[FlagPayload]):
235235

236236
class FlagRuleUpdatedEvent(EventModel[FlagPayload]):
237237
event: Literal["flag.rule_updated"]
238+
context: FlagRuleUpdatedContext
238239

239240

240241
class FlagUpdatedEvent(EventModel[FlagPayload]):

src/workos/types/events/flag_payload.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from workos.types.workos_model import WorkOSModel
44

5+
AccessType = Literal["none", "some", "all"]
6+
57

68
class FlagOwner(WorkOSModel):
79
email: str
@@ -22,3 +24,47 @@ class FlagPayload(WorkOSModel):
2224
default_value: bool
2325
created_at: str
2426
updated_at: str
27+
28+
29+
class FlagRuleActor(WorkOSModel):
30+
id: str
31+
source: Literal["api", "dashboard", "system"]
32+
name: Optional[str] = None
33+
34+
35+
class FlagRuleOrganizationTarget(WorkOSModel):
36+
id: str
37+
name: str
38+
39+
40+
class FlagRuleUserTarget(WorkOSModel):
41+
id: str
42+
email: str
43+
44+
45+
class FlagRuleConfiguredTargets(WorkOSModel):
46+
organizations: Sequence[FlagRuleOrganizationTarget]
47+
users: Sequence[FlagRuleUserTarget]
48+
49+
50+
class FlagRulePreviousDataAttributes(WorkOSModel):
51+
enabled: Optional[bool] = None
52+
default_value: Optional[bool] = None
53+
54+
55+
class FlagRulePreviousContextAttributes(WorkOSModel):
56+
access_type: Optional[AccessType] = None
57+
configured_targets: Optional[FlagRuleConfiguredTargets] = None
58+
59+
60+
class FlagRulePreviousAttributes(WorkOSModel):
61+
data: Optional[FlagRulePreviousDataAttributes] = None
62+
context: Optional[FlagRulePreviousContextAttributes] = None
63+
64+
65+
class FlagRuleUpdatedContext(WorkOSModel):
66+
client_id: str
67+
actor: FlagRuleActor
68+
access_type: AccessType
69+
configured_targets: FlagRuleConfiguredTargets
70+
previous_attributes: FlagRulePreviousAttributes

src/workos/types/webhooks/webhook.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
from workos.types.events.directory_user_with_previous_attributes import (
4444
DirectoryUserWithPreviousAttributes,
4545
)
46-
from workos.types.events.flag_payload import FlagPayload
46+
from workos.types.events.flag_payload import FlagPayload, FlagRuleUpdatedContext
4747
from workos.types.events.organization_domain_verification_failed_payload import (
4848
OrganizationDomainVerificationFailedPayload,
4949
)
@@ -243,6 +243,7 @@ class FlagDeletedWebhook(WebhookModel[FlagPayload]):
243243

244244
class FlagRuleUpdatedWebhook(WebhookModel[FlagPayload]):
245245
event: Literal["flag.rule_updated"]
246+
context: FlagRuleUpdatedContext
246247

247248

248249
class FlagUpdatedWebhook(WebhookModel[FlagPayload]):

0 commit comments

Comments
 (0)