class AuditActivityInitiator
A data class representing the identity of a resource (user, app, or system) that initiates an audit activity in Microsoft 365/Office 365 services.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/audit/activity_initiator.py
5 - 19
simple
Purpose
This class serves as a container for identifying the initiator of an audit activity. It can represent either an application (including system-level operations) or a user, or both. It inherits from ClientValue, making it suitable for serialization and transmission in API requests/responses. This is typically used in audit logging and activity tracking scenarios within Office 365 services to record who or what triggered a particular action.
Source Code
class AuditActivityInitiator(ClientValue):
"""
Identity the resource object that initiates the activity.
The initiator can be a user, an app, or a system (which is considered an app).
"""
def __init__(self, app=AppIdentity(), user=AppIdentity()):
"""
:param AppIdentity app: If the resource initiating the activity is an app, this property indicates all the app
related information like appId, Name, servicePrincipalId, Name.
:param AppIdentity user: If the resource initiating the activity is a user, this property Indicates
all the user related information like userId, Name, UserPrinicpalName.
"""
self.app = app
self.user = user
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValue | - |
Parameter Details
app: An AppIdentity instance representing the application that initiated the activity. Defaults to an empty AppIdentity(). Contains app-related information such as appId, Name, servicePrincipalId, and Name. Used when the initiator is an application or system service.
user: An AppIdentity instance representing the user that initiated the activity. Defaults to an empty AppIdentity(). Contains user-related information such as userId, Name, and UserPrincipalName. Used when the initiator is a human user.
Return Value
Instantiation returns an AuditActivityInitiator object with app and user attributes set to the provided AppIdentity instances or default empty AppIdentity objects. The class itself does not define any methods that return values beyond the constructor.
Class Interface
Methods
__init__(app=AppIdentity(), user=AppIdentity())
Purpose: Initializes an AuditActivityInitiator instance with optional app and user identities
Parameters:
app: AppIdentity instance representing the application initiator, defaults to empty AppIdentity()user: AppIdentity instance representing the user initiator, defaults to empty AppIdentity()
Returns: None (constructor)
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
app |
AppIdentity | Stores the application identity that initiated the activity, including appId, Name, servicePrincipalId, and Name properties | instance |
user |
AppIdentity | Stores the user identity that initiated the activity, including userId, Name, and UserPrincipalName properties | instance |
Dependencies
office365
Required Imports
from office365.directory.applications.app_identity import AppIdentity
from office365.runtime.client_value import ClientValue
Usage Example
from office365.directory.applications.app_identity import AppIdentity
from office365.directory.audit.activity_initiator import AuditActivityInitiator
# Create an initiator with default empty identities
initiator = AuditActivityInitiator()
# Create an initiator with specific app identity
app_identity = AppIdentity()
app_identity.appId = 'app-123-456'
app_identity.displayName = 'MyApplication'
initiator_with_app = AuditActivityInitiator(app=app_identity)
# Create an initiator with specific user identity
user_identity = AppIdentity()
user_identity.id = 'user-789-012'
user_identity.displayName = 'John Doe'
initiator_with_user = AuditActivityInitiator(user=user_identity)
# Create an initiator with both app and user
initiator_full = AuditActivityInitiator(app=app_identity, user=user_identity)
# Access the attributes
print(initiator_full.app.displayName)
print(initiator_full.user.displayName)
Best Practices
- Always provide at least one identity (app or user) when creating an AuditActivityInitiator for meaningful audit trails
- Use the app parameter for service-to-service calls or system-initiated activities
- Use the user parameter for user-initiated activities
- Both app and user can be populated simultaneously when a user action is performed through an application
- This class is immutable after construction - set all required properties on the AppIdentity objects before passing them to the constructor
- This class inherits from ClientValue, which means it's designed for serialization and should be used as a data transfer object
- Do not modify the app or user attributes directly after instantiation; create a new instance if changes are needed
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class AppIdentity 66.7% similar
-
class UserIdentity 65.4% similar
-
class ActivityIdentity 62.8% similar
-
class Identity 60.6% similar
-
class ActivityIdentityItem 60.4% similar