"""
call monitoring API
"""
from typing import Any, Optional, Union
from pydantic import Field
from ..base import ApiModel, webex_id_to_uuid
from ..common import CallParkExtension, MonitoredMember
from .common import PersonSettingsApiChild
__all__ = ['MonitoredElementMember', 'MonitoredElement', 'Monitoring', 'MonitoringApi']
[docs]
class MonitoredElementMember(MonitoredMember):
#: The location ID for the location.
location_id: Optional[str] = None
@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] = None
#: monitored call park extension
cpe: Optional[CallParkExtension] = Field(alias='callparkextension', default=None)
[docs]
class Monitoring(ApiModel):
#: Call park notification is enabled or disabled.
call_park_notification_enabled: Optional[bool] = None
#: 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.
#: Maximum 50 elements.
monitored_elements: Optional[list[Union[str, MonitoredElement]]] = None
#: Indicates additional number of entries that can be stored (more than the number of entries listed).
available_entries_count: Optional[int] = None
@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, also used for workspaces
"""
feature = 'monitoring'
[docs]
def read(self, entity_id: str, org_id: str = None) -> Monitoring:
"""
Retrieve an entity's Monitoring Settings
Retrieves the monitoring settings of the entity, which shows specified people, places, virtual lines or call
park extensions that are being monitored.
Monitors the line status which indicates if a person, place or virtual line is on a call and if a call has been
parked on that extension.
This API requires a full, user, or read-only administrator or location administrator auth token with a scope of
`spark-admin:people_read`.
:param entity_id: Unique identifier for the entity.
:type entity_id: str
:param org_id: ID of the organization in which the entity resides. 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=entity_id)
params = org_id and {'orgId': org_id} or None
data = self.get(ep, params=params)
return Monitoring.model_validate(data)