🔍 Code Extractor

class ShareLinkRequest

Maturity: 49

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

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/links/share_request.py
Lines:
4 - 45
Complexity:
simple

Purpose

This class serves as a data transfer object (DTO) for SharePoint sharing link operations. It encapsulates all parameters needed to request creation or retrieval of tokenized sharing links, including link type, expiration, access permissions, and settings. It inherits from ClientValue, making it compatible with SharePoint's client-side object model for serialization and transmission to SharePoint services.

Source Code

class ShareLinkRequest(ClientValue):
    """Represents a request for the retrieval or creation of a tokenized sharing link."""

    def __init__(
        self,
        link_kind=None,
        expiration=None,
        people_picker_input=None,
        settings=None,
        create_link=True,
    ):
        """
        :param int or None link_kind: The kind of the tokenized sharing link to be created/updated or retrieved.
        :param datetime or None expiration: A date/time string for which the format conforms to the ISO 8601:2004(E)
            complete representation for calendar date and time of day and which represents the time and date of expiry
            for the tokenized sharing link. Both the minutes and hour value MUST be specified for the difference
            between the local and UTC time. Midnight is represented as 00:00:00. A null value indicates no expiry.
            This value is only applicable to tokenized sharing links that are anonymous access links.
        :param str people_picker_input: A string of JSON serialized data representing users in people picker format.
            This value specifies a list of identities that will be pre-granted access through the tokenized sharing
            link and optionally sent an e-mail notification.
            If this value is null or empty, no identities will be will be pre-granted access through the tokenized
            sharing link and no notification email will be sent.
        :param office365.sharepoint.sharing.share_link_settings.ShareLinkSettings or None settings: The settings for
            the tokenized sharing link to be created/updated.
        :param bool create_link: Indicates whether the operation attempts to create the tokenized sharing link based
            on the requested settings if it does not currently exist.
            If set to true, the operation will attempt to retrieve an existing tokenized sharing link that matches
            the requested settings and failing that will attempt to create a new tokenized sharing link based on the
            requested settings. If false, the operation will attempt to retrieve an existing tokenized sharing link
            that matches the requested settings and failing that will terminate the operation.
        """
        self.linkKind = link_kind
        self.expiration = expiration
        self.peoplePickerInput = people_picker_input
        self.settings = settings
        self.createLink = create_link
        super(ShareLinkRequest, self).__init__()

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

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

link_kind: Integer value specifying the type of tokenized sharing link to create or retrieve. Determines the access level and behavior of the link (e.g., view-only, edit, anonymous). Can be None if not specified.

expiration: A datetime object representing when the sharing link should expire. Must conform to ISO 8601:2004(E) format with complete calendar date, time of day, and UTC offset. Midnight is represented as 00:00:00. A None value indicates the link never expires. Only applicable to anonymous access links.

people_picker_input: A JSON-serialized string containing user identities in SharePoint people picker format. These users will be pre-granted access through the link and optionally notified via email. If None or empty, no users are pre-granted access and no notifications are sent.

settings: A ShareLinkSettings object containing detailed configuration for the tokenized sharing link to be created or updated. Can be None if using default settings.

create_link: Boolean flag controlling operation behavior. If True, attempts to retrieve an existing link matching the settings or creates a new one if none exists. If False, only attempts retrieval and terminates if no matching link is found. Defaults to True.

Return Value

Instantiation returns a ShareLinkRequest object configured with the provided parameters. The object itself doesn't return values from methods but serves as a container for request data that will be serialized and sent to SharePoint services. The entity_type_name property returns the string 'SP.Sharing.ShareLinkRequest' for SharePoint API compatibility.

Class Interface

Methods

__init__(self, link_kind=None, expiration=None, people_picker_input=None, settings=None, create_link=True)

Purpose: Initializes a new ShareLinkRequest instance with parameters for creating or retrieving a tokenized sharing link

Parameters:

  • link_kind: Integer specifying the kind of tokenized sharing link (None allowed)
  • expiration: Datetime object for link expiration in ISO 8601 format (None for no expiry)
  • people_picker_input: JSON string with user identities for pre-granted access (None or empty for no pre-grants)
  • settings: ShareLinkSettings object with link configuration (None for defaults)
  • create_link: Boolean indicating whether to create link if it doesn't exist (default True)

Returns: None (constructor)

@property entity_type_name(self) -> str property

Purpose: Returns the SharePoint entity type name for this request object, used for API serialization and identification

Returns: String 'SP.Sharing.ShareLinkRequest' representing the SharePoint entity type

Attributes

Name Type Description Scope
linkKind int or None Stores the kind of tokenized sharing link to be created/updated or retrieved instance
expiration datetime or None Stores the expiration date/time for the tokenized sharing link in ISO 8601 format instance
peoplePickerInput str or None Stores JSON serialized data representing users who will be pre-granted access through the link instance
settings ShareLinkSettings or None Stores the settings object for configuring the tokenized sharing link instance
createLink bool Indicates whether to create the link if it doesn't exist (True) or only retrieve existing links (False) instance

Dependencies

  • office365.runtime.client_value
  • office365.sharepoint.sharing.share_link_settings

Required Imports

from office365.runtime.client_value import ClientValue
from office365.sharepoint.sharing.share_link_settings import ShareLinkSettings

Usage Example

from office365.sharepoint.sharing.share_link_request import ShareLinkRequest
from office365.sharepoint.sharing.share_link_settings import ShareLinkSettings
from datetime import datetime, timedelta

# Create a simple sharing link request
request = ShareLinkRequest(
    link_kind=1,
    create_link=True
)

# Create a more complex request with expiration and settings
expiration_date = datetime.utcnow() + timedelta(days=30)
settings = ShareLinkSettings()
request = ShareLinkRequest(
    link_kind=2,
    expiration=expiration_date,
    people_picker_input='{"users":["user@example.com"]}',
    settings=settings,
    create_link=True
)

# Access the entity type name for SharePoint API calls
entity_type = request.entity_type_name  # Returns 'SP.Sharing.ShareLinkRequest'

Best Practices

  • Always specify link_kind to ensure the correct type of sharing link is created or retrieved
  • When setting expiration dates, ensure they are in UTC and properly formatted according to ISO 8601:2004(E) standard
  • Use people_picker_input only when you need to pre-grant access to specific users; leave it None for general anonymous links
  • Set create_link=False when you only want to check for existing links without creating new ones
  • The ShareLinkRequest object is immutable after creation; create a new instance if you need different parameters
  • This class is designed to be serialized and sent to SharePoint services, not for direct manipulation of sharing links
  • Ensure proper SharePoint permissions before attempting to create or retrieve sharing links
  • The entity_type_name property should not be modified as it's required for SharePoint API compatibility

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class ShareLinkResponse 88.6% similar

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

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/links/share_response.py
  • class SharingLinkAccessRequest 86.8% 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 SharingLinkAbilities 79.4% similar

    A data class representing the set of capabilities for tokenized sharing links in SharePoint, indicating which sharing operations are enabled or disabled for the current user.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/link_abilities.py
  • class SharingLinkDefaultTemplate 76.8% 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 SharingInformationRequest 76.7% similar

    A class representing the optional Request Object for GetSharingInformation operations in SharePoint Online.

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