class Presence
Contains information about a user's presence, including their availability and user activity.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/communications/presences/presence.py
10 - 120
moderate
Purpose
Contains information about a user's presence, including their availability and user activity.
Source Code
class Presence(Entity):
"""Contains information about a user's presence, including their availability and user activity."""
def clear_presence(self, session_id=None):
"""
Clear the application's presence session for a user. If it is the user's only presence session,
the user's presence will change to Offline/Offline.
:param str session_id: The ID of the application's presence session.
"""
payload = {"sessionId": session_id}
qry = ServiceOperationQuery(self, "clearPresence", None, payload)
self.context.add_query(qry)
return self
def clear_user_preferred_presence(self):
"""
Clear the preferred availability and activity status for a user.
"""
qry = ServiceOperationQuery(self, "clearUserPreferredPresence")
self.context.add_query(qry)
return self
def set_presence(
self, session_id, availability=None, activity=None, expiration_duration=None
):
"""
Set the state of a user's presence session as an application.
:param str session_id: The ID of the application's presence session.
:param str availability: The base presence information.
:param str activity: The supplemental information to availability.
:param str expiration_duration: The expiration of the app presence session. The value is represented in
ISO 8601 format for durations. If not provided, a default expiration of 5 minutes will be applied.
The valid duration range is 5-240 minutes (PT5M to PT4H)
"""
payload = {
"sessionId": session_id,
"availability": availability,
"activity": activity,
"expirationDuration": expiration_duration,
}
qry = ServiceOperationQuery(self, "setPresence", None, payload)
self.context.add_query(qry)
return self
def set_status_message(self, message, expiry=None):
"""
Set a presence status message for a user. An optional expiration date and time can be supplied.
:param str or ItemBody message: Status message item.
:param datetime.datetime expiry: Time in which the status message expires. If not provided, the status message
doesn't expire.
"""
if not isinstance(message, ItemBody):
message = ItemBody(message)
if expiry:
expiry = DateTimeTimeZone.parse(expiry)
payload = {
"statusMessage": PresenceStatusMessage(
message=message, expiry_datetime=expiry
)
}
qry = ServiceOperationQuery(self, "setStatusMessage", None, payload)
self.context.add_query(qry)
return self
def set_user_preferred_presence(
self, availability="Available", activity="Available", expiration_duration=None
):
"""
Set the preferred availability and activity status for a user. If the preferred presence of a user is set,
the user's presence shows as the preferred status.
Preferred presence takes effect only when at least one presence session exists for the user. Otherwise,
the user's presence shows as Offline.
A presence session is created as a result of a successful setPresence operation, or if the user is signed in
on a Microsoft Teams client.
:param str availability: The base presence information.
:param str activity: The supplemental information to availability.
:param str expiration_duration: The expiration of the app presence session. The value is represented in
ISO 8601 format for durations. If not provided, a default expiration of 5 minutes will be applied.
The valid duration range is 5-240 minutes (PT5M to PT4H)
"""
payload = {
"availability": availability,
"activity": activity,
"expirationDuration": expiration_duration,
}
qry = ServiceOperationQuery(self, "setUserPreferredPresence", None, payload)
self.context.add_query(qry)
return self
@property
def activity(self):
# type: () -> Optional[str]
"""
The supplemental information to a user's availability.
Possible values are Available, Away, BeRightBack, Busy, DoNotDisturb, InACall, InAConferenceCall, Inactive,
InAMeeting, Offline, OffWork, OutOfOffice, PresenceUnknown, Presenting, UrgentInterruptionsOnly.
"""
return self.properties.get("activity", None)
@property
def availability(self):
# type: () -> Optional[str]
"""
The base presence information for a user.
Possible values are Available, AvailableIdle, Away, BeRightBack, Busy, BusyIdle, DoNotDisturb, Offline,
PresenceUnknown
"""
return self.properties.get("availability", None)
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
Entity | - |
Parameter Details
bases: Parameter of type Entity
Return Value
Returns unspecified type
Class Interface
Methods
clear_presence(self, session_id)
Purpose: Clear the application's presence session for a user. If it is the user's only presence session, the user's presence will change to Offline/Offline. :param str session_id: The ID of the application's presence session.
Parameters:
session_id: Parameter
Returns: None
clear_user_preferred_presence(self)
Purpose: Clear the preferred availability and activity status for a user.
Returns: None
set_presence(self, session_id, availability, activity, expiration_duration)
Purpose: Set the state of a user's presence session as an application. :param str session_id: The ID of the application's presence session. :param str availability: The base presence information. :param str activity: The supplemental information to availability. :param str expiration_duration: The expiration of the app presence session. The value is represented in ISO 8601 format for durations. If not provided, a default expiration of 5 minutes will be applied. The valid duration range is 5-240 minutes (PT5M to PT4H)
Parameters:
session_id: Parameteravailability: Parameteractivity: Parameterexpiration_duration: Parameter
Returns: None
set_status_message(self, message, expiry)
Purpose: Set a presence status message for a user. An optional expiration date and time can be supplied. :param str or ItemBody message: Status message item. :param datetime.datetime expiry: Time in which the status message expires. If not provided, the status message doesn't expire.
Parameters:
message: Parameterexpiry: Parameter
Returns: None
set_user_preferred_presence(self, availability, activity, expiration_duration)
Purpose: Set the preferred availability and activity status for a user. If the preferred presence of a user is set, the user's presence shows as the preferred status. Preferred presence takes effect only when at least one presence session exists for the user. Otherwise, the user's presence shows as Offline. A presence session is created as a result of a successful setPresence operation, or if the user is signed in on a Microsoft Teams client. :param str availability: The base presence information. :param str activity: The supplemental information to availability. :param str expiration_duration: The expiration of the app presence session. The value is represented in ISO 8601 format for durations. If not provided, a default expiration of 5 minutes will be applied. The valid duration range is 5-240 minutes (PT5M to PT4H)
Parameters:
availability: Parameteractivity: Parameterexpiration_duration: Parameter
Returns: None
activity(self)
property
Purpose: The supplemental information to a user's availability. Possible values are Available, Away, BeRightBack, Busy, DoNotDisturb, InACall, InAConferenceCall, Inactive, InAMeeting, Offline, OffWork, OutOfOffice, PresenceUnknown, Presenting, UrgentInterruptionsOnly.
Returns: None
availability(self)
property
Purpose: The base presence information for a user. Possible values are Available, AvailableIdle, Away, BeRightBack, Busy, BusyIdle, DoNotDisturb, Offline, PresenceUnknown
Returns: None
Required Imports
from typing import Optional
from office365.communications.presences.status_message import PresenceStatusMessage
from office365.entity import Entity
from office365.outlook.calendar.dateTimeTimeZone import DateTimeTimeZone
from office365.outlook.mail.item_body import ItemBody
Usage Example
# Example usage:
# result = Presence(bases)
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class PresenceStatusMessage 60.5% similar
-
class OnlineMeeting 52.8% similar
-
class PrincipalInfo 49.2% similar
-
class AttendeeAvailability 48.0% similar
-
class Contact 48.0% similar