🔍 Code Extractor

class SharingDetail

Maturity: 47

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.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/insights/sharing_detail.py
Lines:
6 - 28
Complexity:
simple

Purpose

SharingDetail is a complex type that encapsulates properties of sharedInsight items in Microsoft 365. It stores metadata about sharing events, including the identity of the person who shared the resource, the timestamp of sharing, a reference to the shared resource, the subject/context of sharing, and the method used for sharing (link, attachment, group, or site). This class inherits from ClientValue, making it suitable for serialization and transmission in Office 365 API interactions.

Source Code

class SharingDetail(ClientValue):
    """Complex type containing properties of sharedInsight items."""

    def __init__(
        self,
        sharedBy=InsightIdentity(),
        shared_datetime=None,
        sharing_reference=ResourceReference(),
        sharing_subject=None,
        sharing_type=None,
    ):
        """
        :param datetime.datetime shared_datetime: The date and time the file was last shared.
        :param ResourceReference sharing_reference:
        :param str sharing_subject: The subject with which the document was shared.
        :param str sharing_type: Determines the way the document was shared,
            can be by a "Link", "Attachment", "Group", "Site".
        """
        self.sharedBy = sharedBy
        self.sharedDateTime = shared_datetime
        self.sharingReference = sharing_reference
        self.sharingSubject = sharing_subject
        self.sharingType = sharing_type

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

sharedBy: An InsightIdentity object representing the user who shared the resource. Defaults to an empty InsightIdentity() instance if not provided. Contains identity information about the sharer.

shared_datetime: A datetime.datetime object indicating when the file was last shared. Can be None if the sharing time is unknown or not applicable. Stored as sharedDateTime attribute.

sharing_reference: A ResourceReference object that provides a reference to the shared resource. Defaults to an empty ResourceReference() instance. Contains information to identify and locate the shared item.

sharing_subject: A string describing the subject or context with which the document was shared. Can be None if no subject was specified. Provides additional context about the sharing event.

sharing_type: A string indicating the method used to share the document. Expected values include 'Link', 'Attachment', 'Group', or 'Site'. Can be None if the sharing type is unknown.

Return Value

Instantiation returns a SharingDetail object with all sharing-related properties initialized. The object itself doesn't have methods that return values, but serves as a data container that can be serialized and used in Office 365 API operations through its ClientValue base class.

Class Interface

Methods

__init__(self, sharedBy=InsightIdentity(), shared_datetime=None, sharing_reference=ResourceReference(), sharing_subject=None, sharing_type=None)

Purpose: Initializes a new SharingDetail instance with sharing metadata properties

Parameters:

  • sharedBy: InsightIdentity object representing who shared the resource
  • shared_datetime: datetime.datetime object for when the resource was shared
  • sharing_reference: ResourceReference object pointing to the shared resource
  • sharing_subject: String describing the sharing context or subject
  • sharing_type: String indicating sharing method ('Link', 'Attachment', 'Group', 'Site')

Returns: None (constructor)

Attributes

Name Type Description Scope
sharedBy InsightIdentity Identity information of the user who shared the resource instance
sharedDateTime datetime.datetime or None Timestamp indicating when the file was last shared instance
sharingReference ResourceReference Reference object containing information about the shared resource instance
sharingSubject str or None Subject or context description for the sharing event instance
sharingType str or None Method used for sharing (Link, Attachment, Group, or Site) instance

Dependencies

  • office365.directory.insights.identity
  • office365.directory.insights.resource_reference
  • office365.runtime.client_value

Required Imports

from office365.directory.insights.identity import InsightIdentity
from office365.directory.insights.resource_reference import ResourceReference
from office365.runtime.client_value import ClientValue

Usage Example

from datetime import datetime
from office365.directory.insights.identity import InsightIdentity
from office365.directory.insights.resource_reference import ResourceReference
from office365.directory.insights.sharing_detail import SharingDetail

# Create identity for the person who shared
sharer = InsightIdentity()
sharer.displayName = 'John Doe'
sharer.id = 'user123'

# Create resource reference
resource_ref = ResourceReference()
resource_ref.id = 'doc456'
resource_ref.webUrl = 'https://example.sharepoint.com/doc456'

# Create sharing detail with all parameters
sharing_detail = SharingDetail(
    sharedBy=sharer,
    shared_datetime=datetime(2023, 10, 15, 14, 30, 0),
    sharing_reference=resource_ref,
    sharing_subject='Q4 Budget Review',
    sharing_type='Link'
)

# Access properties
print(f'Shared by: {sharing_detail.sharedBy.displayName}')
print(f'Shared on: {sharing_detail.sharedDateTime}')
print(f'Sharing type: {sharing_detail.sharingType}')
print(f'Subject: {sharing_detail.sharingSubject}')

Best Practices

  • Always provide meaningful values for sharedBy and sharing_reference when creating instances, as these are core identifiers for sharing events
  • Use proper datetime objects for shared_datetime to ensure consistent time handling across different timezones
  • Validate sharing_type against expected values ('Link', 'Attachment', 'Group', 'Site') before instantiation to maintain data consistency
  • This class is immutable after creation by design - set all properties during instantiation rather than modifying them later
  • When using with Office 365 APIs, ensure the parent ClientValue serialization methods are properly invoked for API transmission
  • Default empty objects (InsightIdentity(), ResourceReference()) are provided for convenience but should be replaced with actual data in production use
  • This class is typically instantiated by the Office 365 SDK when deserializing API responses rather than manually created by developers

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class SharingFacet 70.7% 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 SharedInsight 69.7% similar

    A class representing insights about files shared with or by a specific user in Microsoft 365, including email attachments, OneDrive for Business, and SharePoint files.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/insights/shared.py
  • class SharedDocumentInfo 68.1% similar

    A SharePoint entity class representing metadata and information about a shared document, including its activity and author details.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/shared_document_info.py
  • class OneDriveSiteSharingInsights 67.6% similar

    A data class representing sharing insights for OneDrive sites, inheriting from ClientValue to provide serialization capabilities for Microsoft 365 API interactions.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/tenant/administration/insights/onedrive_site_sharing.py
  • class ObjectSharingInformation 67.4% similar

    A class that provides comprehensive information about the sharing state of SharePoint securable objects (documents, list items, sites), including permissions, sharing links, and user access details.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/object_sharing_information.py
← Back to Browse