🔍 Code Extractor

class ShareLinkResponse

Maturity: 48

A response class that encapsulates information about a tokenized sharing link in SharePoint, including its retrieval or creation/update status.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/links/share_response.py
Lines:
5 - 21
Complexity:
simple

Purpose

This class serves as a data transfer object (DTO) for SharePoint sharing link operations. It wraps a SharingLinkInfo object and provides a standardized response format for sharing link requests. The class inherits from ClientValue, making it compatible with the Office365 REST API client framework. It's primarily used to represent the result of sharing link operations such as creating, updating, or retrieving tokenized sharing links in SharePoint.

Source Code

class ShareLinkResponse(ClientValue):
    """
    Represents a response for a request for the retrieval or creation/update of a tokenized sharing link.
    """

    def __init__(self, sharing_link_info=SharingLinkInfo()):
        """
        :param SharingLinkInfo sharing_link_info:
        """
        self.sharingLinkInfo = sharing_link_info

    def __str__(self):
        return self.sharingLinkInfo.Url

    @property
    def entity_type_name(self):
        return "SP.Sharing.ShareLinkResponse"

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

sharing_link_info: A SharingLinkInfo object containing detailed information about the sharing link. Defaults to an empty SharingLinkInfo() instance if not provided. This parameter encapsulates all the metadata and properties of the sharing link including URL, permissions, expiration, and other link-specific settings.

Return Value

Instantiation returns a ShareLinkResponse object that contains the sharing link information. The object can be converted to a string representation which returns the URL of the sharing link. The entity_type_name property returns the SharePoint entity type identifier 'SP.Sharing.ShareLinkResponse' used for serialization and API communication.

Class Interface

Methods

__init__(self, sharing_link_info=SharingLinkInfo()) -> None

Purpose: Initializes a new ShareLinkResponse instance with sharing link information

Parameters:

  • sharing_link_info: A SharingLinkInfo object containing the sharing link details. Defaults to an empty SharingLinkInfo instance.

Returns: None - constructor method

__str__(self) -> str

Purpose: Returns the string representation of the response, which is the sharing link URL

Returns: The URL of the sharing link as a string, obtained from sharingLinkInfo.Url

@property entity_type_name(self) -> str property

Purpose: Returns the SharePoint entity type name used for API serialization and identification

Returns: The string 'SP.Sharing.ShareLinkResponse' representing the SharePoint entity type

Attributes

Name Type Description Scope
sharingLinkInfo SharingLinkInfo Stores the detailed information about the sharing link including URL, permissions, expiration date, and other link-specific properties instance

Dependencies

  • office365-runtime
  • office365-sharepoint

Required Imports

from office365.runtime.client_value import ClientValue
from office365.sharepoint.sharing.links.info import SharingLinkInfo

Usage Example

from office365.runtime.client_value import ClientValue
from office365.sharepoint.sharing.links.info import SharingLinkInfo
from office365.sharepoint.sharing.links.response import ShareLinkResponse

# Create a SharingLinkInfo object with link details
link_info = SharingLinkInfo()
link_info.Url = 'https://contoso.sharepoint.com/sites/team/Shared%20Documents/file.docx?share=xyz'

# Create a ShareLinkResponse with the link info
response = ShareLinkResponse(sharing_link_info=link_info)

# Access the sharing link URL as string
print(str(response))  # Outputs the URL
print(response.sharingLinkInfo.Url)  # Direct access to URL

# Get the entity type name for API operations
entity_type = response.entity_type_name  # Returns 'SP.Sharing.ShareLinkResponse'

# Typically used as return value from SharePoint API calls
# Example: result = ctx.web.share_object(url, link_kind, expiration)
# where result would be a ShareLinkResponse instance

Best Practices

  • Always provide a valid SharingLinkInfo object when instantiating, or use the default empty constructor if creating a placeholder
  • Use the string representation (str(response)) to quickly access the sharing link URL
  • This class is typically instantiated by the Office365 API client framework rather than manually by developers
  • The class is immutable after construction - to modify sharing link information, create a new instance
  • When using in API responses, the entity_type_name property is used internally for serialization/deserialization
  • Access the sharingLinkInfo attribute directly to retrieve detailed link properties beyond just the URL
  • This class inherits from ClientValue, so it can be serialized to/from JSON for API communication automatically

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class ShareLinkRequest 88.6% similar

    A data class representing a request for retrieving or creating a tokenized sharing link in SharePoint, encapsulating all necessary parameters for link configuration.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/links/share_request.py
  • class SharingLinkAccessRequest 78.7% similar

    A data class representing extended values required for requesting access to SharePoint objects exposed through tokenized sharing links, including password and access persistence options.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/links/access_request.py
  • class ShareLinkPartialSuccessResponse 76.6% similar

    A class representing a partial success response when creating or managing SharePoint share links, inheriting from ShareLinkResponse.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/links/partial_success_response.py
  • class SharingLinkDefaultTemplate 76.3% similar

    A data class representing a default template for sharing links in SharePoint, containing link details information.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/links/default_template.py
  • class LinkInvitation 74.2% similar

    A data class representing an invitation to a tokenized SharePoint sharing link, tracking who was invited, by whom, and when.

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