"""
call monitoring API
"""
from typing import Optional, Union
from pydantic import Field
from .common import PersonSettingsApiChild
from ..base import ApiModel, webex_id_to_uuid
from ..common import MonitoredMember, CallParkExtension
__all__ = ['MonitoredElementMember', 'MonitoredElement', 'Monitoring',
'MonitoringApi']
[docs]class MonitoredElementMember(MonitoredMember):
#: The location name where the call park extension is.
location_name: Optional[str] = Field(alias='location')
#: The location ID for the location.
location_id: Optional[str]
@property
def ci_location_id(self) -> Optional[str]:
return self.location_id and webex_id_to_uuid(self.location_id)
[docs]class MonitoredElement(ApiModel):
#: monitored person or place
member: Optional[MonitoredElementMember]
#: monitored call park extension
cpe: Optional[CallParkExtension] = Field(alias='callparkextension')
[docs]class Monitoring(ApiModel):
#: Call park notification is enabled or disabled.
call_park_notification_enabled: Optional[bool]
#: Settings of monitored elements which can be person, place, or call park extension.
#: for updates IDs can be used directly instead of :class:`MonitoredElement` objects
monitored_elements: Optional[list[Union[str, MonitoredElement]]]
@property
def monitored_cpes(self) -> list[CallParkExtension]:
return [me.cpe for me in self.monitored_elements or []
if me.cpe]
@property
def monitored_members(self) -> list[MonitoredElementMember]:
return [me.member for me in self.monitored_elements or []
if me.member]
[docs]class MonitoringApi(PersonSettingsApiChild):
"""
API for person's call monitoring settings
"""
feature = 'monitoring'
[docs] def read(self, person_id: str, org_id: str = None) -> Monitoring:
"""
Retrieve a Person's Monitoring Settings
Retrieves the monitoring settings of the person, which shows specified people, places or, call park
extensions under monitoring. Monitors the line status which indicates if a person or place is on a call and
if a call has been parked on that extension.
This API requires a full, user, or read-only administrator auth token with a scope of spark-admin:people_read.
:param person_id: Unique identifier for the person.
:type person_id: str
:param org_id: Person is in this organization. Only admin users of another organization (such as partners)
may use this parameter as the default is the same organization as the token used to access API.
:type org_id: str
:return: monitoring settings
:rtype: :class:`Monitoring`
"""
ep = self.f_ep(person_id=person_id)
params = org_id and {'orgId': org_id} or None
data = self.get(ep, params=params)
return Monitoring.parse_obj(data)