class SharingFacet
A data class representing sharing information for SharePoint activities, including recipients and sharing type.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/activities/facets/sharing.py
6 - 13
simple
Purpose
SharingFacet is a value object that encapsulates sharing-related metadata for SharePoint activities. It stores information about who an item is shared with (recipients) and the type of sharing being performed. This class inherits from ClientValue, making it suitable for serialization and transmission in SharePoint API operations. It's typically used as part of activity tracking or audit logging to record sharing events.
Source Code
class SharingFacet(ClientValue):
def __init__(self, recipients=None, sharing_type=None):
"""
:param list[ActivityIdentity] recipients:
:param str sharing_type:
"""
self.recipients = ClientValueCollection(ActivityIdentity, recipients)
self.sharingType = sharing_type
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValue | - |
Parameter Details
recipients: A list of ActivityIdentity objects representing the users or entities with whom content is being shared. Can be None if no recipients are specified. Each ActivityIdentity contains information about a user, group, or other entity involved in the sharing activity.
sharing_type: A string indicating the type of sharing operation being performed (e.g., 'direct', 'link', 'anonymous'). Can be None if the sharing type is not specified or unknown. The exact values depend on SharePoint's sharing model.
Return Value
Instantiation returns a SharingFacet object with two attributes: 'recipients' (a ClientValueCollection of ActivityIdentity objects) and 'sharingType' (a string). The object represents a complete sharing context that can be used in SharePoint activity operations.
Class Interface
Methods
__init__(recipients=None, sharing_type=None)
Purpose: Initializes a SharingFacet instance with optional recipients and sharing type information
Parameters:
recipients: Optional list of ActivityIdentity objects representing sharing recipientssharing_type: Optional string indicating the type of sharing operation
Returns: None (constructor)
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
recipients |
ClientValueCollection[ActivityIdentity] | A collection of ActivityIdentity objects representing the users or entities with whom content is shared. Managed as a ClientValueCollection for proper serialization in SharePoint API calls. | instance |
sharingType |
str | A string value indicating the type of sharing operation (e.g., 'direct', 'link', 'anonymous'). Uses camelCase to match SharePoint API naming conventions. | instance |
Dependencies
office365
Required Imports
from office365.runtime.client_value import ClientValue
from office365.runtime.client_value_collection import ClientValueCollection
from office365.sharepoint.activities.identity import ActivityIdentity
Usage Example
from office365.sharepoint.activities.identity import ActivityIdentity
from office365.sharepoint.activities.sharing_facet import SharingFacet
# Create activity identities for recipients
recipient1 = ActivityIdentity()
recipient1.id = 'user1@example.com'
recipient1.displayName = 'John Doe'
recipient2 = ActivityIdentity()
recipient2.id = 'user2@example.com'
recipient2.displayName = 'Jane Smith'
# Create a SharingFacet with recipients and sharing type
sharing_facet = SharingFacet(
recipients=[recipient1, recipient2],
sharing_type='direct'
)
# Access the sharing information
print(f'Sharing type: {sharing_facet.sharingType}')
print(f'Number of recipients: {len(sharing_facet.recipients)}')
# Iterate through recipients
for recipient in sharing_facet.recipients:
print(f'Recipient: {recipient.displayName}')
Best Practices
- Always initialize with appropriate recipients list when tracking sharing activities to maintain accurate audit trails
- Use meaningful sharing_type values that align with SharePoint's sharing model (e.g., 'direct', 'link', 'anonymous')
- The recipients parameter accepts None or a list; the ClientValueCollection will handle the conversion appropriately
- This is a value object (inherits from ClientValue), so it's immutable in concept and should represent a snapshot of sharing state
- When used in SharePoint API operations, ensure the ActivityIdentity objects in recipients are properly populated with valid user information
- This class is typically used as part of larger activity or audit objects rather than standalone
- The sharingType attribute uses camelCase to match SharePoint API conventions, while the constructor parameter uses snake_case following Python conventions
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class CreateFacet 78.1% similar
-
class GetCommentFacet 75.5% similar
-
class EditFacet 75.4% similar
-
class InDocFacet 74.4% similar
-
class RenameFacet 74.3% similar