class IdentitySet
IdentitySet is a keyed collection class that represents a set of identity resources (application, device, user) associated with various events for an item, such as created by or last modified by actions.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/permissions/identity_set.py
5 - 22
simple
Purpose
This class serves as a container for tracking multiple identity types associated with an action or event in Microsoft Office 365 services. It groups together application, device, and user identities to provide comprehensive context about who or what performed an action. It inherits from ClientValue, making it suitable for serialization and transmission in API calls to Office 365 services.
Source Code
class IdentitySet(ClientValue):
"""The IdentitySet resource is a keyed collection of identity resources. It is used to represent a set of
identities associated with various events for an item, such as created by or last modified by.
"""
def __init__(self, application=Identity(), device=Identity(), user=Identity()):
"""
:param Identity application: The application associated with this action.
:param Identity device: The device associated with this action.
:param Identity user: The user associated with this action.
"""
super(IdentitySet, self).__init__()
self.application = application
self.device = device
self.user = user
def __repr__(self):
return repr({n: v.to_json() for n, v in self if v.to_json()})
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValue | - |
Parameter Details
application: An Identity object representing the application associated with the action. Defaults to an empty Identity() instance if not provided. Used to track which application performed or initiated the action.
device: An Identity object representing the device associated with the action. Defaults to an empty Identity() instance if not provided. Used to track which device was used for the action.
user: An Identity object representing the user associated with the action. Defaults to an empty Identity() instance if not provided. Used to track which user performed the action.
Return Value
Instantiation returns an IdentitySet object containing three Identity instances (application, device, user). The __repr__ method returns a dictionary representation where each identity is converted to JSON format, excluding empty identities.
Class Interface
Methods
__init__(application=Identity(), device=Identity(), user=Identity())
Purpose: Initializes an IdentitySet instance with application, device, and user identities
Parameters:
application: Identity object representing the application associated with the action (defaults to empty Identity)device: Identity object representing the device associated with the action (defaults to empty Identity)user: Identity object representing the user associated with the action (defaults to empty Identity)
Returns: None (constructor)
__repr__()
Purpose: Returns a string representation of the IdentitySet as a dictionary with JSON-serialized identities
Returns: String representation of a dictionary containing non-empty identity JSON representations
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
application |
Identity | The Identity object representing the application associated with this action | instance |
device |
Identity | The Identity object representing the device associated with this action | instance |
user |
Identity | The Identity object representing the user associated with this action | instance |
Dependencies
office365.directory.permissions.identityoffice365.runtime.client_value
Required Imports
from office365.directory.permissions.identity import Identity
from office365.runtime.client_value import ClientValue
Usage Example
from office365.directory.permissions.identity import Identity
from office365.directory.permissions.identity_set import IdentitySet
# Create individual identities
user_identity = Identity()
app_identity = Identity()
device_identity = Identity()
# Create an IdentitySet with all identities
identity_set = IdentitySet(
application=app_identity,
device=device_identity,
user=user_identity
)
# Create an IdentitySet with default empty identities
default_identity_set = IdentitySet()
# Access individual identities
user = identity_set.user
application = identity_set.application
device = identity_set.device
# Get string representation (JSON format)
print(identity_set)
Best Practices
- Always initialize with Identity objects rather than None to avoid potential AttributeErrors when accessing identity properties
- Use this class when tracking audit information or metadata about who/what performed actions in Office 365 services
- The class is iterable (inherits from ClientValue), allowing iteration over its identity attributes
- The __repr__ method automatically filters out empty identities (those that return empty JSON), making the representation cleaner
- This class is designed for serialization and should be used in contexts where data needs to be transmitted to/from Office 365 APIs
- Instantiate with specific Identity objects when you have concrete identity information; use defaults for placeholder scenarios
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class Identity 75.6% similar
-
class InsightIdentity 70.6% similar
-
class ObjectIdentity 64.3% similar
-
class ActivityIdentity 62.9% similar
-
class AppIdentity 62.0% similar