🔍 Code Extractor

class SharingPermissionInformation

Maturity: 47

A class representing sharing permission information for SharePoint entities such as groups or roles, providing access to permission metadata and default permission status.

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

Purpose

This class encapsulates information about SharePoint sharing permissions, including whether a permission is a default group/role and its unique identifier. It is used to query and understand permission entities associated with SharePoint sites, webs, files, and other objects. The class helps identify default permission groups (site owners, members, visitors) and default roles (view, edit) for various SharePoint objects.

Source Code

class SharingPermissionInformation(Entity):
    """
    Contains information about a sharing permission entity such as group or role.
    """

    @property
    def is_default_permission(self):
        """
        Identifies whether or not the permission entity is a default SP.Group or role (meaning it is recommended
        for granting permissions).

        A value of true specifies the current permission is a default SP.Group for granting permissions to a site
        (site owner, member, or visitor SP.Group) or a default role for granting permission to a file or other
        non-site object (edit or view). A value of false specifies otherwise.

        For SPSites & SPWebs, there can be three default permission entities: owners, members, or visitors SPGroups.
        For granting permissions to a file or other non-site object, there can be two default permission entities:
        a role for view permissions (StandardViewerRoleDefinitionID) and a role for edit permissions
        (StandardEditorRoleDefinitionID).

        :rtype: bool or None
        """
        return self.properties.get("IsDefaultPermission", None)

    @property
    def permission_id(self):
        """Gets the ID of this permission in the following formats: group:x, role: xxxxxx.
        :rtype: str or None
        """
        return self.properties.get("PermissionId", None)

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

Parameters

Name Type Default Kind
bases Entity -

Parameter Details

bases: Inherits from Entity class, which provides base functionality for SharePoint entity objects including property management and entity type handling

Return Value

Instantiation returns a SharingPermissionInformation object that provides read-only access to permission metadata through properties. The is_default_permission property returns a boolean (or None) indicating default permission status, and permission_id returns a string (or None) with the permission identifier in format 'group:x' or 'role:xxxxxx'.

Class Interface

Methods

@property is_default_permission() -> bool | None property

Purpose: Identifies whether the permission entity is a default SharePoint group or role recommended for granting permissions

Returns: True if this is a default permission entity (site owner/member/visitor group, or standard view/edit role), False otherwise, or None if not available. For sites/webs: identifies default owner, member, or visitor groups. For files/objects: identifies standard viewer or editor roles.

@property permission_id() -> str | None property

Purpose: Gets the unique identifier of this permission entity in a formatted string

Returns: String containing the permission ID in format 'group:x' for groups or 'role:xxxxxx' for roles, or None if not available

@property entity_type_name() -> str property

Purpose: Returns the SharePoint entity type name for this class, used for serialization and API communication

Returns: String 'SP.SharingPermissionInformation' representing the SharePoint entity type

Attributes

Name Type Description Scope
properties dict Inherited from Entity base class. Dictionary containing the raw property data for this permission information object, including 'IsDefaultPermission' and 'PermissionId' keys instance

Dependencies

  • office365

Required Imports

from office365.sharepoint.entity import Entity
from office365.sharepoint.sharing.permission_information import SharingPermissionInformation

Usage Example

# Assuming you have a SharePoint context and permission information object
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.sharing.permission_information import SharingPermissionInformation

# Typically obtained from SharePoint API responses
# permission_info would be instantiated by the Office365 library internally
permission_info = SharingPermissionInformation()

# Check if this is a default permission (e.g., site owners, members, visitors)
is_default = permission_info.is_default_permission
if is_default:
    print("This is a default SharePoint permission group or role")

# Get the permission ID
perm_id = permission_info.permission_id
if perm_id:
    if perm_id.startswith('group:'):
        print(f"Group permission ID: {perm_id}")
    elif perm_id.startswith('role:'):
        print(f"Role permission ID: {perm_id}")

# Get entity type name
entity_type = permission_info.entity_type_name
print(f"Entity type: {entity_type}")

Best Practices

  • This class is typically instantiated by the Office365 library internally when querying SharePoint permission information, not directly by user code
  • Properties return None when the corresponding data is not available, so always check for None before using values
  • The class is read-only; it provides access to permission metadata but does not modify permissions
  • Use is_default_permission to identify recommended default groups (owners, members, visitors) or roles (view, edit) when setting up permissions
  • The permission_id format differs between groups ('group:x') and roles ('role:xxxxxx'), parse accordingly
  • This class inherits from Entity, so it has access to the properties dictionary and entity type management from the base class
  • The entity_type_name property returns 'SP.SharingPermissionInformation' which is used internally by the Office365 library for serialization

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class ObjectSharingInformation 81.5% 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
  • class SharingInformation 75.8% similar

    Represents sharing information for a SharePoint securable object, providing access to sharing settings, picker configurations, sharing abilities, and link templates.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/information.py
  • class ObjectSharingInformationUser 74.3% 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 PermissionCollection 73.6% similar

    A SharePoint client value class representing a collection of permissions for a securable object, containing LinkInfo and PrincipalInfo objects for users/groups with access.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/permission_collection.py
  • class Role 69.6% similar

    An enumeration class representing abstract roles for SharePoint sharing permissions on securable objects in document libraries.

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