🔍 Code Extractor

class SharedWithUser

Maturity: 45

A data class representing a user with whom content has been shared, capturing their email and name for change log tracking in sharing actions.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/shared_with_user.py
Lines:
4 - 13
Complexity:
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 user
  • name: 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).

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class SharedWithMeDocumentUser 81.8% similar

    A data class representing a user associated with a document that has been shared with the current user in SharePoint/Office 365.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/userprofiles/sharedwithme/document_user.py
  • class ObjectSharingInformationUser 72.1% similar

    A class representing information about a principal (user or group) with whom a SharePoint securable object is shared, providing access to their email, SIP address, login name, and related principal/user objects.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/object_sharing_information_user.py
  • class DirectSharingAbilities 68.0% similar

    A data class representing the set of direct sharing capabilities available to the current user in SharePoint, including permissions to add external/internal principals and request access grants.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/direct_abilities.py
  • class SharingFacet 67.4% similar

    A data class representing sharing information for SharePoint activities, including recipients and sharing type.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/activities/facets/sharing.py
  • class SharingDetail 67.0% similar

    A data class representing detailed information about how a document or resource was shared in Microsoft 365, including who shared it, when, and through what method.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/insights/sharing_detail.py
← Back to Browse