class SharingAbilityStatus
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.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/ability_status.py
4 - 18
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
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class DirectSharingAbilities 81.1% similar
-
class SharingAbilities 79.0% similar
-
class SharingLinkAbilities 77.4% similar
-
class SiteSharingReportStatus 72.6% similar
-
class SiteSharingReportCapabilities 72.4% similar