class CalendarGroup
A class representing a group of user calendars in Microsoft Office 365, providing access to calendar group properties and associated calendars.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/calendar/group.py
9 - 35
moderate
Purpose
CalendarGroup is an entity class that represents a collection of calendars grouped together in Office 365. It extends the Entity base class and provides read-only access to the group's name, class identifier, and the collection of calendars within the group. This class is typically used when working with Office 365 calendar APIs to organize and manage multiple calendars as a logical unit.
Source Code
class CalendarGroup(Entity):
"""
A group of user calendars.
"""
@property
def name(self):
# type: () -> Optional[str]
"""The group name"""
return self.properties.get("name", None)
@property
def class_id(self):
# type: () -> Optional[str]
"""The class identifier"""
return self.properties.get("classId", None)
@property
def calendars(self):
# type: () -> EntityCollection[Calendar]
"""The calendars in the calendar group. Navigation property. Read-only. Nullable."""
return self.properties.get(
"calendars",
EntityCollection(
self.context, Calendar, ResourcePath("calendars", self.resource_path)
),
)
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
Entity | - |
Parameter Details
Entity_base_class: Inherits from Entity base class which provides core functionality for Office 365 entities including context management, properties storage, and resource path handling. The constructor parameters are inherited from Entity and typically include context and resource_path.
Return Value
Instantiation returns a CalendarGroup object that provides access to calendar group properties through read-only properties. The 'name' property returns an optional string, 'class_id' returns an optional string identifier, and 'calendars' returns an EntityCollection of Calendar objects representing all calendars in the group.
Class Interface
Methods
@property name(self) -> Optional[str]
property
Purpose: Returns the name of the calendar group
Returns: Optional string containing the calendar group name, or None if not set
@property class_id(self) -> Optional[str]
property
Purpose: Returns the class identifier for the calendar group
Returns: Optional string containing the class identifier, or None if not set
@property calendars(self) -> EntityCollection[Calendar]
property
Purpose: Returns the collection of calendars contained within this calendar group as a navigation property
Returns: EntityCollection of Calendar objects representing all calendars in the group. This is a read-only, nullable navigation property that may require additional API calls to populate
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
properties |
dict | Inherited from Entity base class. Stores the raw property data retrieved from the Office 365 API including name, classId, and calendars | instance |
context |
ClientContext | Inherited from Entity base class. The Office 365 client context used for API communication and authentication | instance |
resource_path |
ResourcePath | Inherited from Entity base class. The API resource path for this calendar group entity | instance |
Dependencies
typingoffice365
Required Imports
from office365.entity import Entity
from office365.entity_collection import EntityCollection
from office365.outlook.calendar.calendar import Calendar
from office365.runtime.paths.resource_path import ResourcePath
from typing import Optional
Usage Example
# Assuming you have an authenticated Office 365 context
from office365.outlook.calendar.calendar_group import CalendarGroup
from office365.graph_client import GraphClient
# Initialize client with credentials
client = GraphClient.with_credentials(tenant_id, client_id, client_secret)
# Get a calendar group
calendar_group = client.me.calendar_groups.get_by_id('group_id').get().execute_query()
# Access properties
group_name = calendar_group.name
class_id = calendar_group.class_id
# Access calendars in the group
calendars_collection = calendar_group.calendars
for calendar in calendars_collection:
print(f'Calendar: {calendar.name}')
# Note: All properties are read-only
Best Practices
- CalendarGroup is a read-only entity - properties cannot be modified directly through this class
- Always ensure the Office 365 context is properly authenticated before accessing calendar group properties
- The calendars property returns an EntityCollection which may require additional API calls to fully populate
- Use execute_query() on the parent context after accessing navigation properties to ensure data is loaded
- Handle Optional return types appropriately as name and class_id may be None
- The calendars collection is lazily loaded - it will only fetch data when accessed or iterated
- This class is typically instantiated by the Office 365 SDK framework, not directly by user code
- Calendar groups are part of the Microsoft Graph API hierarchy under user resources
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class Calendar 78.4% similar
-
class PlannerGroup 70.3% similar
-
class CalendarPermissionCollection 68.9% similar
-
class UnifiedGroup 66.1% similar
-
class GroupCollection 66.0% similar