class ScheduleInformation
Represents the availability of a user, distribution list, or resource (room or equipment) for a specified time period in Microsoft Outlook/Office 365.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/calendar/schedule/information.py
7 - 37
moderate
Purpose
This class encapsulates schedule and availability information for calendar resources in Office 365. It provides a structured way to represent availability data including schedule items, working hours, availability views (free/busy status), and error information. The class is used when querying calendar availability through the Office 365 API, allowing applications to determine when users or resources are available for meetings or bookings.
Source Code
class ScheduleInformation(ClientValue):
"""Represents the availability of a user, distribution list, or resource (room or equipment)
for a specified time period."""
def __init__(
self,
schedule_id=None,
schedule_items=None,
availability_view=None,
error=None,
working_hours=WorkingHours(),
):
"""
:param WorkingHours working_hours: The days of the week and hours in a specific time zone that the user works.
These are set as part of the user's mailboxSettings.
:param str error: Error information from attempting to get the availability of the user, distribution list,
or resource.
:param str availability_view: Represents a merged view of availability of all the items in scheduleItems.
The view consists of time slots. Availability during each time slot is indicated with:
0= free, 1= tentative, 2= busy, 3= out of office, 4= working elsewhere.
:param list[ScheduleItem] schedule_items: Contains the items that describe the availability
of the user or resource.
:param str schedule_id: An SMTP address of the user, distribution list, or resource, identifying an instance
of scheduleInformation.
"""
super(ScheduleInformation, self).__init__()
self.scheduleItems = ClientValueCollection(ScheduleItem, schedule_items)
self.scheduleId = schedule_id
self.availabilityView = availability_view
self.error = error
self.workingHours = working_hours
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValue | - |
Parameter Details
schedule_id: An SMTP address (email) of the user, distribution list, or resource. This uniquely identifies the entity whose schedule information is being represented. Expected format is a valid email address string (e.g., 'user@domain.com').
schedule_items: A list of ScheduleItem objects that describe the availability of the user or resource. Each item represents a time slot with specific availability status. Can be None or an empty list if no schedule items are available.
availability_view: A string representing a merged view of availability across all schedule items. Each character represents a time slot with values: '0'=free, '1'=tentative, '2'=busy, '3'=out of office, '4'=working elsewhere. For example, '00022' indicates two free slots followed by two busy slots.
error: A string containing error information if there was a problem retrieving the availability data for the user, distribution list, or resource. None if no errors occurred.
working_hours: A WorkingHours object that defines the days of the week and hours in a specific time zone that the user works. These settings come from the user's mailboxSettings. Defaults to an empty WorkingHours() instance if not provided.
Return Value
Instantiation returns a ScheduleInformation object that inherits from ClientValue. The object contains all schedule and availability data for the specified resource. This object is typically used as a data transfer object (DTO) when working with Office 365 calendar APIs and does not return values from method calls as it has no public methods beyond inherited ones.
Class Interface
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
scheduleId |
str | An SMTP address (email) identifying the user, distribution list, or resource whose schedule this represents | instance |
scheduleItems |
ClientValueCollection[ScheduleItem] | A collection of ScheduleItem objects describing individual availability time slots for the resource | instance |
availabilityView |
str | A string where each character represents availability status for a time slot (0=free, 1=tentative, 2=busy, 3=out of office, 4=working elsewhere) | instance |
error |
str | Error message if availability retrieval failed, None if successful | instance |
workingHours |
WorkingHours | Defines the working days and hours in a specific timezone for the user, sourced from mailboxSettings | instance |
Dependencies
office365
Required Imports
from office365.outlook.calendar.schedule.information import ScheduleInformation
from office365.outlook.calendar.schedule.item import ScheduleItem
from office365.outlook.calendar.working_hours import WorkingHours
Usage Example
from office365.outlook.calendar.schedule.information import ScheduleInformation
from office365.outlook.calendar.schedule.item import ScheduleItem
from office365.outlook.calendar.working_hours import WorkingHours
from datetime import datetime
# Create working hours configuration
working_hours = WorkingHours()
# Create schedule items
schedule_item = ScheduleItem()
schedule_item.start = datetime(2024, 1, 15, 9, 0)
schedule_item.end = datetime(2024, 1, 15, 10, 0)
schedule_item.status = 'busy'
# Instantiate ScheduleInformation
schedule_info = ScheduleInformation(
schedule_id='user@contoso.com',
schedule_items=[schedule_item],
availability_view='0022200',
error=None,
working_hours=working_hours
)
# Access attributes
print(f"Schedule ID: {schedule_info.scheduleId}")
print(f"Availability: {schedule_info.availabilityView}")
print(f"Number of items: {len(schedule_info.scheduleItems)}")
for item in schedule_info.scheduleItems:
print(f"Item status: {item.status}")
Best Practices
- Always provide a valid SMTP address for schedule_id to properly identify the resource
- The availability_view string should match the time slots covered by schedule_items for consistency
- Handle the error attribute to detect and respond to availability retrieval failures
- Use WorkingHours to properly represent timezone-aware working schedules
- This class is primarily a data container (DTO) and should be populated by Office 365 API responses rather than manually constructed in most cases
- The scheduleItems attribute is a ClientValueCollection which provides collection-like behavior for ScheduleItem objects
- When manually creating instances for testing, ensure schedule_items list contains valid ScheduleItem objects
- The availability_view encoding (0-4) should be interpreted according to Microsoft's free/busy status definitions
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class ScheduleItem 78.0% similar
-
class AttendeeAvailability 71.8% similar
-
class StaffAvailabilityItem 71.0% similar
-
class Calendar 64.0% similar
-
class WorkingHours 63.6% similar