class SharedWithUser
A data class representing a user with whom content has been shared, capturing their email and name for change log tracking in sharing actions.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/shared_with_user.py
4 - 13
simple
Purpose
This class serves as a data transfer object (DTO) that encapsulates information about users involved in sharing operations within the Office 365 API context. It inherits from ClientValue, which is part of the office365 runtime framework, making it suitable for serialization and transmission in API requests/responses. The class is primarily used to track and represent principals (users) in sharing activity logs.
Source Code
class SharedWithUser(ClientValue):
"""Returns the array of users that have been shared in sharing action for the change log."""
def __init__(self, email=None, name=None):
"""
:param str email: Gets the email of the principal.
:param str name: Gets the name of the principal.
"""
self.Email = email
self.Name = name
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValue | - |
Parameter Details
email: Optional string parameter representing the email address of the principal (user) who has been granted sharing access. Can be None if email information is not available or not provided. This is typically a valid email address format (e.g., 'user@example.com').
name: Optional string parameter representing the display name or full name of the principal (user) who has been granted sharing access. Can be None if name information is not available or not provided. This is typically a human-readable name (e.g., 'John Doe').
Return Value
Instantiation returns a SharedWithUser object with Email and Name attributes set to the provided values (or None if not provided). The object inherits from ClientValue, which likely provides serialization capabilities for use with Office 365 API operations.
Class Interface
Methods
__init__(self, email=None, name=None)
Purpose: Constructor that initializes a SharedWithUser instance with optional email and name parameters
Parameters:
email: Optional string representing the email address of the principal username: Optional string representing the display name of the principal user
Returns: None (constructor initializes the instance)
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
Email |
str or None | Stores the email address of the principal user who has been granted sharing access. Uses PascalCase naming convention for Office 365 API compatibility. | instance |
Name |
str or None | Stores the display name or full name of the principal user who has been granted sharing access. Uses PascalCase naming convention for Office 365 API compatibility. | instance |
Dependencies
office365
Required Imports
from office365.runtime.client_value import ClientValue
Usage Example
from office365.runtime.client_value import ClientValue
# Create a SharedWithUser instance with both email and name
shared_user = SharedWithUser(
email='john.doe@example.com',
name='John Doe'
)
# Access the attributes
print(shared_user.Email) # Output: john.doe@example.com
print(shared_user.Name) # Output: John Doe
# Create instance with only email
shared_user_partial = SharedWithUser(email='jane@example.com')
print(shared_user_partial.Email) # Output: jane@example.com
print(shared_user_partial.Name) # Output: None
# Create empty instance
empty_user = SharedWithUser()
print(empty_user.Email) # Output: None
print(empty_user.Name) # Output: None
Best Practices
- This is a simple data container class with no complex logic or state management. Instantiate it with appropriate email and name values when tracking sharing operations.
- Both constructor parameters are optional, allowing flexible instantiation based on available data. However, for meaningful usage, at least one identifier (email or name) should typically be provided.
- The class inherits from ClientValue, which suggests it's designed for serialization in Office 365 API contexts. Do not modify the inheritance chain unless you understand the serialization implications.
- Attribute names use PascalCase (Email, Name) following the Office 365 API naming conventions, which differs from Python's typical snake_case convention. This is intentional for API compatibility.
- This class is immutable by convention - once instantiated, attributes can be modified but typically shouldn't be in normal usage patterns to maintain data integrity in change logs.
- When used in arrays or collections for change log operations, ensure consistent data quality across all instances (e.g., all have emails, or all have names).
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class SharedWithMeDocumentUser 81.8% similar
-
class ObjectSharingInformationUser 72.1% similar
-
class DirectSharingAbilities 68.0% similar
-
class SharingFacet 67.4% similar
-
class SharingDetail 67.0% similar