class Session
Represents a user-user communication or a user-meeting communication session, such as a conference call, in the Office 365 communications system.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/communications/callrecords/session.py
7 - 20
moderate
Purpose
This class models a communication session within Office 365 call records. It extends the Entity base class and provides access to segments that make up the session. A session can represent direct user-to-user communication or multi-party conference calls. The class serves as a container for managing and accessing the individual segments that comprise a complete communication session.
Source Code
class Session(Entity):
"""Represents a user-user communication or a user-meeting communication in the case of a conference call."""
@property
def segments(self):
"""
The list of segments involved in the session.
"""
return self.properties.get(
"segments",
EntityCollection(
self.context, Segment, ResourcePath("segments", self.resource_path)
),
)
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
Entity | - |
Parameter Details
context: The execution context required by the parent Entity class, typically containing authentication and service connection information for Office 365 API calls
resource_path: The API resource path identifying this specific session entity within the Office 365 service hierarchy
Return Value
Instantiation returns a Session object that represents a communication session. The segments property returns an EntityCollection containing Segment objects that represent the individual parts of the session.
Class Interface
Methods
@property segments(self) -> EntityCollection
property
Purpose: Provides access to the collection of segments that make up this communication session
Returns: An EntityCollection containing Segment objects representing the individual parts of the session. If not previously loaded, creates a new EntityCollection with the appropriate resource path.
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
properties |
dict | Inherited from Entity class. Stores the entity's properties including the segments collection. Used internally for property management and lazy loading. | instance |
context |
ClientContext | Inherited from Entity class. The execution context containing authentication and service connection information for API operations. | instance |
resource_path |
ResourcePath | Inherited from Entity class. The API resource path identifying this session entity within the Office 365 service hierarchy. | instance |
Dependencies
office365.communications.callrecords.segmentoffice365.entityoffice365.entity_collectionoffice365.runtime.paths.resource_path
Required Imports
from office365.communications.callrecords.session import Session
from office365.communications.callrecords.segment import Segment
from office365.entity import Entity
from office365.entity_collection import EntityCollection
from office365.runtime.paths.resource_path import ResourcePath
Usage Example
# Assuming you have an authenticated Office 365 context
from office365.communications.callrecords.session import Session
from office365.runtime.client_context import ClientContext
# Create context (authentication details omitted for brevity)
context = ClientContext(site_url)
# Session is typically retrieved from a call record, not instantiated directly
# Example: accessing session from a call record
call_record = context.call_records.get_by_id('call_record_id')
sessions = call_record.sessions
# Access segments within a session
for session in sessions:
segments = session.segments
context.load(segments)
context.execute_query()
for segment in segments:
print(f'Segment ID: {segment.id}')
print(f'Start time: {segment.start_date_time}')
Best Practices
- Session objects are typically retrieved from call records rather than instantiated directly
- Always load the segments collection using context.load() and context.execute_query() before accessing segment data
- The segments property uses lazy loading - it creates the EntityCollection only when first accessed
- Ensure proper authentication context is established before working with Session objects
- Session inherits from Entity, so all Entity methods and properties are available
- The properties dictionary is managed by the parent Entity class and should not be modified directly
- Use the segments property to access related Segment entities rather than accessing the properties dictionary directly
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class Segment 75.3% similar
-
class CallRecord 62.7% similar
-
class CloudCommunications 59.7% similar
-
class DirectorySession 56.5% similar
-
class UploadSessionQuery 55.2% similar