🔍 Code Extractor

class SharingAbilityStatus

Maturity: 47

A data class representing the status of a specific sharing capability for the current user in SharePoint, including whether it's enabled and the reason if disabled.

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

Purpose

This class encapsulates the sharing capability status information for SharePoint users. It inherits from ClientValue, making it compatible with SharePoint's client-side object model. The class is used to represent whether a user has a particular sharing capability enabled and, if disabled, provides the reason for the restriction. This is typically used in SharePoint Online scenarios where sharing permissions and capabilities need to be checked or displayed.

Source Code

class SharingAbilityStatus(ClientValue):
    """Represents the status for a specific sharing capability for the current user."""

    def __init__(self, disabled_reason=None, enabled=None):
        """
        :param str disabled_reason:  Indicates the reason why the capability is disabled if the capability is disabled
            for any reason.
        :param bool enabled: Indicates whether capability is enabled.
        """
        self.disabledReason = disabled_reason
        self.enabled = enabled

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

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

disabled_reason: A string indicating why the sharing capability is disabled. This parameter is optional (defaults to None) and should only be populated when the capability is disabled. Common values might include policy restrictions, permission limitations, or administrative blocks.

enabled: A boolean value indicating whether the sharing capability is currently enabled for the user. True means the capability is available, False means it's disabled. This parameter is optional (defaults to None) but should typically be set to provide meaningful status information.

Return Value

Instantiation returns a SharingAbilityStatus object that contains the sharing capability status information. The object has two accessible attributes (disabledReason and enabled) and one property (entity_type_name) that returns the SharePoint entity type identifier 'SP.Sharing.SharingAbilityStatus'.

Class Interface

Methods

__init__(self, disabled_reason=None, enabled=None)

Purpose: Initializes a new SharingAbilityStatus instance with the sharing capability status information

Parameters:

  • disabled_reason: Optional string indicating why the capability is disabled (default: None)
  • enabled: Optional boolean indicating whether the capability is enabled (default: None)

Returns: None (constructor)

@property entity_type_name(self) -> str property

Purpose: Returns the SharePoint entity type name for this class, used for serialization and type identification in the SharePoint client object model

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

Attributes

Name Type Description Scope
disabledReason str or None Stores the reason why the sharing capability is disabled. None if the capability is enabled or no reason is provided. instance
enabled bool or None Stores whether the sharing capability is enabled (True) or disabled (False). None if status is unknown. instance

Dependencies

  • office365

Required Imports

from office365.runtime.client_value import ClientValue
from office365.sharepoint.sharing.ability_status import SharingAbilityStatus

Usage Example

from office365.sharepoint.sharing.ability_status import SharingAbilityStatus

# Create a status object for an enabled capability
status_enabled = SharingAbilityStatus(enabled=True)
print(f"Enabled: {status_enabled.enabled}")
print(f"Entity Type: {status_enabled.entity_type_name}")

# Create a status object for a disabled capability with reason
status_disabled = SharingAbilityStatus(
    disabled_reason="External sharing is disabled by administrator",
    enabled=False
)
print(f"Enabled: {status_disabled.enabled}")
print(f"Reason: {status_disabled.disabledReason}")

# Typically used when receiving sharing capability information from SharePoint
# The object would be populated by the SharePoint API response

Best Practices

  • Always set the 'enabled' parameter to provide clear status information
  • Only populate 'disabled_reason' when 'enabled' is False to maintain data consistency
  • This class is typically instantiated by SharePoint API responses rather than manually created
  • The class is immutable after creation - attributes should be set during initialization
  • Use the entity_type_name property when serializing to SharePoint's client object model
  • Check both 'enabled' and 'disabledReason' attributes when evaluating sharing capabilities
  • This class inherits from ClientValue, making it compatible with SharePoint's serialization mechanisms

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class DirectSharingAbilities 81.1% similar

    A data class representing the set of direct sharing capabilities available to the current user in SharePoint, including permissions to add external/internal principals and request access grants.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/direct_abilities.py
  • class SharingAbilities 79.0% similar

    Represents the matrix of possible sharing abilities for direct sharing and tokenized sharing links along with the state of each capability for the current user in SharePoint.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/abilities.py
  • class SharingLinkAbilities 77.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 SiteSharingReportStatus 72.6% similar

    SiteSharingReportStatus is a data transfer object class that represents the status of a site sharing report in Microsoft 365/SharePoint operations.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/site_sharing_report_status.py
  • class SiteSharingReportCapabilities 72.4% similar

    SiteSharingReportCapabilities is a data transfer object class that inherits from ClientValue, representing capabilities related to site sharing reports in Office 365/SharePoint.

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