🔍 Code Extractor

class OnlineMeetingCollection

Maturity: 38

A collection class for managing Microsoft Graph OnlineMeeting entities, providing methods to create and retrieve online meetings.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/communications/onlinemeetings/collection.py
Lines:
7 - 67
Complexity:
moderate

Purpose

OnlineMeetingCollection serves as a container and factory for OnlineMeeting objects in the Microsoft Graph API. It inherits from EntityCollection and provides specialized methods for creating new online meetings or retrieving existing ones by external ID. This class handles the communication with the Microsoft Graph API to manage online meetings on behalf of users, including scheduling meetings with specific start/end times, subjects, participants, and chat information.

Source Code

class OnlineMeetingCollection(EntityCollection[OnlineMeeting]):
    def __init__(self, context, resource_path=None):
        super(OnlineMeetingCollection, self).__init__(
            context, OnlineMeeting, resource_path
        )

    def create(self, subject, start_datetime=None, end_datetime=None):
        """
        Create an online meeting on behalf of a user by using the object ID (OID) in the user token.

        :param datetime.datetime start_datetime: The meeting start time in UTC.
        :param datetime.datetime end_datetime: The meeting end time in UTC.
        :param str subject: The subject of the online meeting.
        """
        return_type = OnlineMeeting(self.context)
        self.add_child(return_type)
        payload = {
            "startDateTime": start_datetime,
            "endDateTime": end_datetime,
            "subject": subject,
        }
        qry = CreateEntityQuery(self, payload, return_type)
        self.context.add_query(qry)
        return return_type

    def create_or_get(
        self,
        external_id=None,
        start_datetime=None,
        end_datetime=None,
        subject=None,
        participants=None,
        chat_info=None,
    ):
        """Create an onlineMeeting object with a custom specified external ID. If the external ID already exists,
        this API will return the onlineMeeting object with that external ID.

        :param str external_id: The external ID. A custom ID. (Required)
        :param datetime.datetime start_datetime: The meeting start time in UTC.
        :param datetime.datetime end_datetime: The meeting end time in UTC.
        :param str subject: The subject of the online meeting.
        :param MeetingParticipants participants: The participants associated with the online meeting.
             This includes the organizer and the attendees.

        :param ChatInfo chat_info:
        """
        return_type = OnlineMeeting(self.context)
        self.add_child(return_type)
        payload = {
            "externalId": external_id,
            "startDateTime": start_datetime,
            "endDateTime": end_datetime,
            "subject": subject,
            "chatInfo": chat_info,
            "participants": participants,
        }
        qry = ServiceOperationQuery(
            self, "createOrGet", None, payload, None, return_type
        )
        self.context.add_query(qry)
        return return_type

Parameters

Name Type Default Kind
bases EntityCollection[OnlineMeeting] -

Parameter Details

context: The client context object that manages API communication, authentication, and request execution. This is required for all API operations and is passed to child OnlineMeeting entities.

resource_path: Optional string representing the API endpoint path for this collection. If not provided, defaults to None and the parent class determines the appropriate path based on the entity type.

Return Value

Instantiation returns an OnlineMeetingCollection object that can be used to create and manage online meetings. The create() method returns an OnlineMeeting object representing a newly created meeting. The create_or_get() method returns an OnlineMeeting object that is either newly created or retrieved if it already exists with the specified external_id. Both methods return objects that are not yet populated until the query is executed by the context.

Class Interface

Methods

__init__(self, context, resource_path=None)

Purpose: Initializes the OnlineMeetingCollection with a context and optional resource path

Parameters:

  • context: The client context object for API communication
  • resource_path: Optional API endpoint path for this collection

Returns: None (constructor)

create(self, subject, start_datetime=None, end_datetime=None) -> OnlineMeeting

Purpose: Creates a new online meeting on behalf of a user using the object ID from the user token

Parameters:

  • subject: String representing the subject/title of the online meeting (required)
  • start_datetime: datetime.datetime object representing the meeting start time in UTC (optional)
  • end_datetime: datetime.datetime object representing the meeting end time in UTC (optional)

Returns: OnlineMeeting object representing the newly created meeting (not populated until execute_query is called)

create_or_get(self, external_id=None, start_datetime=None, end_datetime=None, subject=None, participants=None, chat_info=None) -> OnlineMeeting

Purpose: Creates a new online meeting with a custom external ID, or retrieves an existing meeting if the external ID already exists

Parameters:

  • external_id: String representing a custom external identifier for the meeting (required for idempotent creation)
  • start_datetime: datetime.datetime object representing the meeting start time in UTC (optional)
  • end_datetime: datetime.datetime object representing the meeting end time in UTC (optional)
  • subject: String representing the subject/title of the online meeting (optional)
  • participants: MeetingParticipants object containing organizer and attendee information (optional)
  • chat_info: ChatInfo object containing chat-related information for the meeting (optional)

Returns: OnlineMeeting object that is either newly created or retrieved based on external_id (not populated until execute_query is called)

Attributes

Name Type Description Scope
context ClientContext The client context object inherited from EntityCollection that manages API communication and authentication instance

Dependencies

  • office365
  • datetime

Required Imports

from office365.communications.onlinemeetings.online_meeting import OnlineMeeting
from office365.entity_collection import EntityCollection
from office365.runtime.queries.create_entity import CreateEntityQuery
from office365.runtime.queries.service_operation import ServiceOperationQuery

Usage Example

from office365.graph_client import GraphClient
from datetime import datetime, timedelta

# Initialize the Graph client with credentials
client = GraphClient.with_token(lambda: 'your_access_token')

# Get the online meetings collection for a user
meetings = client.users['user@example.com'].online_meetings

# Create a new online meeting
start_time = datetime.utcnow() + timedelta(hours=1)
end_time = start_time + timedelta(hours=1)
new_meeting = meetings.create(
    subject='Team Sync',
    start_datetime=start_time,
    end_datetime=end_time
)
client.execute_query()
print(f'Meeting URL: {new_meeting.join_url}')

# Create or get an existing meeting by external ID
meeting = meetings.create_or_get(
    external_id='my-custom-id-123',
    subject='Recurring Team Meeting',
    start_datetime=start_time,
    end_datetime=end_time
)
client.execute_query()
print(f'Meeting ID: {meeting.id}')

Best Practices

  • Always call context.execute_query() after creating meetings to actually execute the API request and populate the returned OnlineMeeting objects
  • Use create_or_get() with a unique external_id when you need idempotent meeting creation to avoid duplicates
  • Ensure datetime objects are in UTC timezone when passing start_datetime and end_datetime parameters
  • The returned OnlineMeeting objects are not fully populated until execute_query() is called on the context
  • Handle authentication token expiration and refresh appropriately in the context object
  • Check that the authenticated user has appropriate permissions (OnlineMeetings.ReadWrite scope) before attempting to create meetings
  • The collection automatically manages parent-child relationships by calling add_child() internally
  • Methods return immediately with placeholder objects; actual API calls are batched and executed when context.execute_query() is invoked

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class CallCollection 71.4% similar

    CallCollection is a specialized entity collection class for managing Microsoft Teams/Graph API call operations, including creating outgoing calls and logging teleconferencing device quality data.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/communications/calls/collection.py
  • class EventCollection 66.9% similar

    A collection class for managing Microsoft Outlook calendar events, providing methods to create and manage events with attendees, time zones, and other properties.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/calendar/events/collection.py
  • class PlannerPlanCollection 66.3% similar

    A collection class for managing Microsoft Planner Plan entities, providing methods to create and manage multiple PlannerPlan objects within a Microsoft Graph API context.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/planner/plans/collection.py
  • class InvitationCollection 66.1% similar

    A collection class for managing Microsoft Graph Invitation entities, providing methods to create and manage invitations for external users to join an organization.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/invitations/collection.py
  • class GroupCollection 66.0% similar

    A collection class for managing Microsoft Graph API Group resources, providing methods to create, retrieve, and manage groups including Microsoft 365 groups and Security groups.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/groups/collection.py
← Back to Browse