class RiskyUserHistoryItem
Represents the risk history of an Azure Active Directory (Azure AD) user as determined by Azure AD Identity Protection, extending the RiskyUser class with historical activity tracking.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/protection/riskyusers/history_item.py
5 - 19
simple
Purpose
This class provides access to historical risk information for Azure AD users, including the activities that led to risk level changes and the actors who initiated those changes. It extends the RiskyUser base class to add historical context to user risk assessments, allowing applications to track and audit risk-related events over time.
Source Code
class RiskyUserHistoryItem(RiskyUser):
"""Represents the risk history of an Azure Active Directory (Azure AD) user as determined
by Azure AD Identity Protection."""
@property
def activity(self):
"""The activity related to user risk level change."""
return self.properties.get("activity", RiskUserActivity())
@property
def initiated_by(self):
"""The ID of actor that does the operation.
:rtype: str
"""
return self.properties.get("initiatedBy", None)
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
RiskyUser | - |
Parameter Details
inherited_from_RiskyUser: This class inherits from RiskyUser and does not define its own __init__ method. Constructor parameters are inherited from the RiskyUser parent class, which likely includes user identification and risk-related properties stored in a 'properties' dictionary.
Return Value
Instantiation returns a RiskyUserHistoryItem object that provides access to historical risk data through properties. The 'activity' property returns a RiskUserActivity object containing details about risk-related activities. The 'initiated_by' property returns a string representing the ID of the actor who performed the risk-related operation, or None if not available.
Class Interface
Methods
@property activity(self) -> RiskUserActivity
property
Purpose: Retrieves the activity related to user risk level change from the properties dictionary
Returns: A RiskUserActivity object representing the activity that caused or is related to the user's risk level change. Returns an empty RiskUserActivity object if the 'activity' key is not present in properties.
@property initiated_by(self) -> str | None
property
Purpose: Retrieves the ID of the actor that performed the risk-related operation
Returns: A string containing the ID of the actor who initiated the operation, or None if this information is not available in the properties dictionary
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
properties |
dict | Inherited from RiskyUser. Dictionary containing the raw data for the risky user history item, including 'activity' and 'initiatedBy' keys | instance |
Dependencies
office365.directory.protection.riskyusers.activityoffice365.directory.protection.riskyusers.risky_user
Required Imports
from office365.directory.protection.riskyusers.activity import RiskUserActivity
from office365.directory.protection.riskyusers.risky_user import RiskyUser
from office365.directory.protection.riskyusers.history_item import RiskyUserHistoryItem
Usage Example
# Assuming you have an authenticated Office365 context
from office365.directory.protection.riskyusers.history_item import RiskyUserHistoryItem
# Typically obtained from Azure AD Identity Protection API
history_item = RiskyUserHistoryItem()
# Access the activity related to user risk level change
activity = history_item.activity
print(f"Activity type: {activity}")
# Get the ID of the actor who initiated the operation
initiator_id = history_item.initiated_by
if initiator_id:
print(f"Operation initiated by: {initiator_id}")
else:
print("Initiator information not available")
# Access inherited RiskyUser properties
# (exact properties depend on RiskyUser implementation)
Best Practices
- This class is typically instantiated by the Office365 SDK when retrieving risky user history data, not directly by application code
- Always check if 'initiated_by' is None before using it, as this information may not always be available
- The 'activity' property returns a RiskUserActivity object by default if not present in properties, ensuring safe access
- This class relies on a 'properties' dictionary inherited from RiskyUser for data storage
- Use this class in conjunction with Azure AD Identity Protection APIs to track historical risk events
- Ensure proper error handling when accessing properties as the underlying data may be incomplete or unavailable
- Consider the temporal nature of this data - history items represent point-in-time snapshots of risk status
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class RiskyUser 82.3% similar
-
class RiskUserActivity 74.1% similar
-
class RiskyUserCollection 67.3% similar
-
class RiskDetection 64.0% similar
-
class ActivityHistoryItem 61.2% similar