🔍 Code Extractor

class SiteLinkingManager

Maturity: 36

SiteLinkingManager is a SharePoint Portal entity class that manages site linking operations, specifically retrieving linked sites information.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/portal/linkedsites/manager.py
Lines:
9 - 24
Complexity:
moderate

Purpose

This class provides functionality to interact with SharePoint's site linking features. It inherits from Entity and is designed to retrieve information about linked sites within a SharePoint portal environment. The primary use case is to fetch site links through the GetSiteLinks service operation, which returns a LinkedSitesListContract containing information about sites that are linked together in SharePoint.

Source Code

class SiteLinkingManager(Entity):
    """"""

    def __init__(self, context, resource_path=None):
        super(SiteLinkingManager, self).__init__(context, resource_path)

    def get_site_links(self):
        """ """
        result = ClientResult(self.context, LinkedSitesListContract())
        qry = ServiceOperationQuery(self, "GetSiteLinks", None, None, None, result)
        self.context.add_query(qry)
        return result

    @property
    def entity_type_name(self):
        return "Microsoft.SharePoint.Portal.SiteLinkingManager"

Parameters

Name Type Default Kind
bases Entity -

Parameter Details

context: The client context object that provides the connection and authentication information for SharePoint operations. This is required for all SharePoint API interactions and manages the request/response lifecycle.

resource_path: Optional parameter specifying the resource path for the entity in SharePoint. If not provided, defaults to None. This path identifies the specific resource location within the SharePoint site hierarchy.

Return Value

Instantiation returns a SiteLinkingManager object that can be used to query site linking information. The get_site_links() method returns a ClientResult object containing a LinkedSitesListContract, which holds the collection of linked sites and their metadata. The ClientResult is a deferred execution object that will be populated when the query is executed by the context.

Class Interface

Methods

__init__(self, context, resource_path=None)

Purpose: Initializes a new instance of SiteLinkingManager with the provided SharePoint context and optional resource path

Parameters:

  • context: The SharePoint client context object for API communication
  • resource_path: Optional resource path string identifying the entity location in SharePoint

Returns: None (constructor)

get_site_links(self) -> ClientResult

Purpose: Retrieves the list of linked sites associated with the current SharePoint portal

Returns: ClientResult object containing a LinkedSitesListContract with information about linked sites. The result is populated after calling context.execute_query()

@property entity_type_name(self) -> str property

Purpose: Returns the fully qualified entity type name used by SharePoint's internal API framework

Returns: String 'Microsoft.SharePoint.Portal.SiteLinkingManager' representing the entity type

Attributes

Name Type Description Scope
context ClientContext Inherited from Entity base class. Stores the SharePoint client context used for all API operations instance
resource_path str or None Inherited from Entity base class. Stores the resource path identifying this entity's location in SharePoint instance

Dependencies

  • office365

Required Imports

from office365.runtime.client_result import ClientResult
from office365.runtime.queries.service_operation import ServiceOperationQuery
from office365.sharepoint.entity import Entity
from office365.sharepoint.portal.linkedsites.list_contract import LinkedSitesListContract

Usage Example

from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.portal.site_linking_manager import SiteLinkingManager

# Setup SharePoint context
site_url = 'https://yourtenant.sharepoint.com/sites/yoursite'
username = 'user@yourtenant.onmicrosoft.com'
password = 'your_password'

ctx = ClientContext(site_url).with_credentials(username, password)

# Create SiteLinkingManager instance
site_linking_mgr = SiteLinkingManager(ctx)

# Get site links
linked_sites_result = site_linking_mgr.get_site_links()
ctx.execute_query()

# Access the linked sites data
linked_sites = linked_sites_result.value
for site in linked_sites.sites:
    print(f'Site URL: {site.url}, Title: {site.title}')

Best Practices

  • Always call ctx.execute_query() after calling get_site_links() to actually execute the deferred query and populate the result
  • Ensure the SharePoint context has appropriate permissions to access site linking information before instantiating this class
  • The class follows the deferred execution pattern - queries are queued and executed in batch when execute_query() is called on the context
  • Reuse the same SiteLinkingManager instance for multiple operations within the same context to optimize performance
  • Handle potential authentication and permission errors when executing queries
  • The entity_type_name property is used internally by the SharePoint API framework and should not be modified
  • This class is designed to work with SharePoint Portal features and may not be available in all SharePoint configurations

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class MySiteLinks 73.3% similar

    MySiteLinks is a SharePoint entity class that provides access to links for a user's personal site, including document libraries and followed sites.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/userprofiles/my_site_links.py
  • class LinkedSiteContract 67.8% similar

    A data contract class representing a linked site in SharePoint Portal, inheriting from ClientValue to provide serialization capabilities.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/portal/linkedsites/contract.py
  • class Link 67.3% similar

    A SharePoint Link entity class that represents a directory link object in SharePoint, inheriting from the Entity base class.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/directory/link.py
  • class LinkedSitesListContract 66.5% similar

    A client value class representing a collection of linked SharePoint sites, used for managing and transferring linked site data in SharePoint Portal operations.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/portal/linkedsites/list_contract.py
  • class VivaSiteManager 65.6% similar

    VivaSiteManager is a SharePoint entity class that manages Viva site-related operations within the Microsoft SharePoint Portal infrastructure.

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