class CalendarPermission
Represents permissions for a user with whom an Outlook calendar has been shared or delegated, providing read-only access to permission details and role management.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/calendar/permissions/permission.py
6 - 71
moderate
Purpose
This class models calendar sharing and delegation permissions in Microsoft Outlook/Office 365. It encapsulates permission levels, user information, and organizational context for calendar access. The class is designed to work with the Microsoft Graph API for managing calendar permissions, supporting operations like retrieving permission details and updating user roles. It enforces business rules such as only allowing role updates after initial setup, and restricting certain operations to calendar owners only.
Source Code
class CalendarPermission(Entity):
"""
The permissions of a user with whom the calendar has been shared or delegated in an Outlook client.
Get, update, and delete of calendar permissions is supported on behalf of only the calendar owner.
Getting the calendar permissions of a calendar on behalf of a sharee or delegate returns
an empty calendar permissions collection.
Once a sharee or delegate has been set up for a calendar, you can update only the role property to change
the permissions of a sharee or delegate. You cannot update the allowedRoles, emailAddress, isInsideOrganization,
or isRemovable property. To change these properties, you should delete the corresponding calendarPermission
object and create another sharee or delegate in an Outlook client.
"""
@property
def allowed_roles(self):
"""
List of allowed sharing or delegating permission levels for the calendar.
Possible values are: none, freeBusyRead, limitedRead, read, write, delegateWithoutPrivateEventAccess,
delegateWithPrivateEventAccess, custom.
"""
return self.properties.get("allowedRoles", StringCollection())
@property
def email_address(self):
"""
Represents a sharee or delegate who has access to the calendar.
For the "My Organization" sharee, the address property is null. Read-only.
"""
return self.properties.get("emailAddress", EmailAddress())
@property
def is_inside_organization(self):
"""
True if the user in context (sharee or delegate) is inside the same organization as the calendar owner.
:rtype: bool or None
"""
return self.properties.get("isInsideOrganization", None)
@property
def is_removable(self):
"""
True if the user can be removed from the list of sharees or delegates for the specified calendar,
false otherwise. The "My organization" user determines the permissions other people within your organization
have to the given calendar. You cannot remove "My organization" as a sharee to a calendar.
:rtype: bool or None
"""
return self.properties.get("isRemovable", None)
@property
def role(self):
"""
Current permission level of the calendar sharee or delegate.
:rtype: str or None
"""
return self.properties.get("role", None)
def get_property(self, name, default_value=None):
if default_value is None:
property_mapping = {
"allowedRoles": self.allowed_roles,
"emailAddress": self.email_address,
}
default_value = property_mapping.get(name, None)
return super(CalendarPermission, self).get_property(name, default_value)
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
Entity | - |
Parameter Details
__init__: Inherits from Entity base class. Constructor parameters are not explicitly defined in this class but are inherited from the Entity parent class, which typically accepts properties dictionary or entity data from API responses.
Return Value
Instantiation returns a CalendarPermission object that provides access to permission properties through read-only properties. The get_property method returns property values with appropriate defaults (StringCollection for allowedRoles, EmailAddress for emailAddress, or None for other properties).
Class Interface
Methods
@property allowed_roles() -> StringCollection
property
Purpose: Returns the list of allowed sharing or delegating permission levels for the calendar
Returns: StringCollection containing possible values: none, freeBusyRead, limitedRead, read, write, delegateWithoutPrivateEventAccess, delegateWithPrivateEventAccess, custom
@property email_address() -> EmailAddress
property
Purpose: Returns the email address of the sharee or delegate who has access to the calendar
Returns: EmailAddress object representing the user; null for 'My Organization' sharee. Read-only.
@property is_inside_organization() -> bool | None
property
Purpose: Indicates whether the user is inside the same organization as the calendar owner
Returns: True if user is in same organization, False otherwise, or None if not set
@property is_removable() -> bool | None
property
Purpose: Indicates whether the user can be removed from the list of sharees or delegates
Returns: True if user can be removed, False if not (e.g., 'My Organization'), or None if not set
@property role() -> str | None
property
Purpose: Returns the current permission level of the calendar sharee or delegate
Returns: String representing the current role (e.g., 'read', 'write', 'delegateWithPrivateEventAccess') or None
get_property(name: str, default_value=None) -> Any
Purpose: Retrieves a property value by name with optional default value, providing special handling for allowedRoles and emailAddress
Parameters:
name: The name of the property to retrieve (e.g., 'role', 'allowedRoles', 'emailAddress')default_value: Optional default value to return if property not found; if None, uses internal property mapping for allowedRoles and emailAddress
Returns: The property value if found, or the default_value. For allowedRoles returns StringCollection, for emailAddress returns EmailAddress object, otherwise returns the stored value or None
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
properties |
dict | Internal dictionary storing all permission properties, inherited from Entity base class | instance |
Dependencies
office365
Required Imports
from office365.entity import Entity
from office365.outlook.calendar.email_address import EmailAddress
from office365.runtime.types.collections import StringCollection
Usage Example
# Assuming you have an authenticated Office 365 client context
from office365.outlook.calendar.permission import CalendarPermission
# Typically obtained from a calendar's permissions collection
# permission = calendar.permissions.get_by_id('permission_id')
# Access permission properties
allowed_roles = permission.allowed_roles # StringCollection of permission levels
email = permission.email_address # EmailAddress object
is_internal = permission.is_inside_organization # bool
can_remove = permission.is_removable # bool
current_role = permission.role # str like 'read', 'write', etc.
# Update only the role (other properties are read-only)
# permission.role = 'write'
# permission.update().execute()
# Get property with default
role_value = permission.get_property('role', 'none')
Best Practices
- Only calendar owners can perform get, update, and delete operations on calendar permissions
- Sharees and delegates will receive an empty permissions collection when querying
- After initial setup, only the 'role' property can be updated; other properties require deleting and recreating the permission
- The 'My Organization' sharee cannot be removed (is_removable will be False)
- Use the get_property method for safe property access with defaults
- Properties are read-only and backed by an internal properties dictionary
- This class is typically instantiated by the Office 365 SDK when retrieving calendar permissions, not directly by users
- Always check is_removable before attempting to delete a permission
- Verify is_inside_organization to understand organizational context of permissions
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class CalendarPermissionCollection 81.0% similar
-
class Calendar 71.0% similar
-
class CalendarSharingMessage 65.4% similar
-
class CalendarGroup 63.6% similar
-
class CalendarRoleType 63.3% similar