Skip to content

Commit 557051e

Browse files
author
edle
committed
Adding agentic user enabled/disabled events
1 parent 955251c commit 557051e

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

libraries/microsoft-agents-a365-notifications/microsoft_agents_a365/notifications/agent_notification.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,52 @@ async def handle_user_manager_updated(context, state, notification):
495495
"""
496496
return self.on_lifecycle_notification(AgentLifecycleEvent.USERMANAGERUPDATED, **kwargs)
497497

498+
def on_user_enabled(
499+
self, **kwargs: Any
500+
) -> Callable[[AgentHandler], Callable[[TurnContext, TurnState], Awaitable[None]]]:
501+
"""Register a handler for user enabled lifecycle events.
502+
503+
This is a convenience decorator that registers a handler specifically for
504+
agentic user enabled events.
505+
506+
Args:
507+
**kwargs: Additional keyword arguments passed to the app's add_route method.
508+
509+
Returns:
510+
A decorator function that registers the handler with the application.
511+
512+
Example:
513+
```python
514+
@notifications.on_user_enabled()
515+
async def handle_user_enabled(context, state, notification):
516+
print("Agentic user enabled")
517+
```
518+
"""
519+
return self.on_lifecycle_notification(AgentLifecycleEvent.USERENABLED, **kwargs)
520+
521+
def on_user_disabled(
522+
self, **kwargs: Any
523+
) -> Callable[[AgentHandler], Callable[[TurnContext, TurnState], Awaitable[None]]]:
524+
"""Register a handler for user disabled lifecycle events.
525+
526+
This is a convenience decorator that registers a handler specifically for
527+
agentic user disabled events.
528+
529+
Args:
530+
**kwargs: Additional keyword arguments passed to the app's add_route method.
531+
532+
Returns:
533+
A decorator function that registers the handler with the application.
534+
535+
Example:
536+
```python
537+
@notifications.on_user_disabled()
538+
async def handle_user_disabled(context, state, notification):
539+
print("Agentic user disabled")
540+
```
541+
"""
542+
return self.on_lifecycle_notification(AgentLifecycleEvent.USERDISABLED, **kwargs)
543+
498544
@staticmethod
499545
def _normalize_subchannel(value: str | AgentSubChannel | None) -> str:
500546
"""Normalize a subchannel value to a lowercase string.

libraries/microsoft-agents-a365-notifications/microsoft_agents_a365/notifications/models/agent_lifecycle_event.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class AgentLifecycleEvent(str, Enum):
1818
USERUNDELETED: Event triggered when an agentic user identity is un-deleted.
1919
USERUPDATED: Event triggered when an agentic user identity is updated.
2020
USERMANAGERUPDATED: Event triggered when an agentic user's manager is updated.
21+
USERENABLED: Event triggered when an agentic user is enabled.
22+
USERDISABLED: Event triggered when an agentic user is disabled.
2123
"""
2224

2325
USERCREATED = "agenticuseridentitycreated"
@@ -26,3 +28,5 @@ class AgentLifecycleEvent(str, Enum):
2628
USERUNDELETED = "agenticuserundeleted"
2729
USERUPDATED = "agenticuseridentityupdated"
2830
USERMANAGERUPDATED = "agenticusermanagerupdated"
31+
USERENABLED = "agenticuserenabled"
32+
USERDISABLED = "agenticuserdisabled"

0 commit comments

Comments
 (0)