class IdentityProtectionRoot
Container class for Microsoft Graph identity protection resources, providing access to risk detections and risky users through navigation properties.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/protection/root.py
8 - 40
moderate
Purpose
This class serves as a root container for Azure AD Identity Protection resources in Microsoft Graph. It inherits from Entity and provides lazy-loaded access to two main collections: risk detections (security events and associated information) and risky users (users flagged as potentially compromised). The class implements property-based access patterns for these collections and integrates with the Microsoft Graph API resource path structure.
Source Code
class IdentityProtectionRoot(Entity):
"""Container for the navigation properties for Microsoft Graph identity protection resources."""
@property
def risk_detections(self):
"""Risk detection in Azure AD Identity Protection and the associated information about the detection."""
return self.properties.get(
"riskDetections",
EntityCollection(
self.context,
RiskDetection,
ResourcePath("riskDetections", self.resource_path),
),
)
@property
def risky_users(self):
"""Get the teams in Microsoft Teams that the user is a direct member of."""
return self.properties.get(
"riskyUsers",
RiskyUserCollection(
self.context, ResourcePath("riskyUsers", self.resource_path)
),
)
def get_property(self, name, default_value=None):
if default_value is None:
property_mapping = {
"riskDetections": self.risk_detections,
"riskyUsers": self.risky_users,
}
default_value = property_mapping.get(name, None)
return super(IdentityProtectionRoot, self).get_property(name, default_value)
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
Entity | - |
Parameter Details
context: The execution context required by the parent Entity class, typically containing authentication and connection information for Microsoft Graph API
resource_path: The ResourcePath object inherited from Entity that defines the API endpoint location for this identity protection root resource
Return Value
Instantiation returns an IdentityProtectionRoot object that provides access to identity protection collections. The risk_detections property returns an EntityCollection of RiskDetection objects. The risky_users property returns a RiskyUserCollection. The get_property method returns the requested property value or default_value if not found.
Class Interface
Methods
@property risk_detections(self) -> EntityCollection
property
Purpose: Provides access to risk detection events in Azure AD Identity Protection, including information about detected security risks
Returns: EntityCollection of RiskDetection objects representing security risk events and their associated metadata
@property risky_users(self) -> RiskyUserCollection
property
Purpose: Provides access to users flagged as risky in Azure AD Identity Protection
Returns: RiskyUserCollection containing users identified as potentially compromised or at risk
get_property(self, name: str, default_value=None) -> Any
Purpose: Retrieves a property value by name with support for default values and property mapping
Parameters:
name: The name of the property to retrieve (e.g., 'riskDetections', 'riskyUsers')default_value: Optional default value to return if the property is not found; if None, uses internal property mapping
Returns: The requested property value, mapped property object, or the default_value if not found
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
context |
ClientContext | Inherited from Entity; stores the execution context with authentication and connection information for Microsoft Graph API | instance |
resource_path |
ResourcePath | Inherited from Entity; defines the API endpoint path for this identity protection root resource | instance |
properties |
dict | Inherited from Entity; dictionary storing cached property values for lazy-loaded collections | instance |
Dependencies
office365
Required Imports
from office365.directory.protection.risk_detection import RiskDetection
from office365.directory.protection.riskyusers.collection import RiskyUserCollection
from office365.entity import Entity
from office365.entity_collection import EntityCollection
from office365.runtime.paths.resource_path import ResourcePath
Usage Example
# Assuming you have a configured Microsoft Graph context
from office365.directory.protection.identity_protection_root import IdentityProtectionRoot
from office365.runtime.paths.resource_path import ResourcePath
# Instantiate with context (context setup not shown)
identity_protection = IdentityProtectionRoot(context)
# Access risk detections
risk_detections = identity_protection.risk_detections
for detection in risk_detections:
print(f"Risk: {detection.risk_type}")
# Access risky users
risky_users = identity_protection.risky_users
for user in risky_users:
print(f"User: {user.user_principal_name}, Risk: {user.risk_level}")
# Use get_property method
detections = identity_protection.get_property('riskDetections')
users = identity_protection.get_property('riskyUsers')
Best Practices
- Ensure the context object is properly authenticated with sufficient permissions before accessing identity protection resources
- Properties are lazy-loaded, so the actual API calls occur when accessing risk_detections or risky_users for the first time
- Use get_property method for dynamic property access or when you need to provide custom default values
- The class follows the Microsoft Graph API structure, so resource paths are automatically constructed
- Collections returned are EntityCollection objects that support iteration and filtering
- Do not instantiate this class directly in most cases; it should be accessed through the Microsoft Graph client's identity protection endpoint
- Cache the property references if you need to access them multiple times to avoid redundant object creation
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class IdentityContainer 67.2% similar
-
class AuthenticationMethodsRoot 65.7% similar
-
class RiskyUser 64.5% similar
-
class RiskDetection 63.1% similar
-
class RiskyUserCollection 62.9% similar