Source code for twilio.rest.insights.v1.conference.conference_participant

# coding=utf-8
r"""
This code was generated by
\ / _    _  _|   _  _
 | (_)\/(_)(_|\/| |(/_  v1.0.0
      /       /
"""

from twilio.base import deserialize
from twilio.base import values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.page import Page


[docs]class ConferenceParticipantList(ListResource): def __init__(self, version, conference_sid): """ Initialize the ConferenceParticipantList :param Version version: Version that contains the resource :param conference_sid: The conference_sid :returns: twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantList :rtype: twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantList """ super(ConferenceParticipantList, self).__init__(version) # Path Solution self._solution = {'conference_sid': conference_sid, } self._uri = '/Conferences/{conference_sid}/Participants'.format(**self._solution)
[docs] def stream(self, participant_sid=values.unset, label=values.unset, events=values.unset, limit=None, page_size=None): """ Streams ConferenceParticipantInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode participant_sid: The participant_sid :param unicode label: The label :param unicode events: The events :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( participant_sid=participant_sid, label=label, events=events, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'])
[docs] def list(self, participant_sid=values.unset, label=values.unset, events=values.unset, limit=None, page_size=None): """ Lists ConferenceParticipantInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode participant_sid: The participant_sid :param unicode label: The label :param unicode events: The events :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantInstance] """ return list(self.stream( participant_sid=participant_sid, label=label, events=events, limit=limit, page_size=page_size, ))
[docs] def page(self, participant_sid=values.unset, label=values.unset, events=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ConferenceParticipantInstance records from the API. Request is executed immediately :param unicode participant_sid: The participant_sid :param unicode label: The label :param unicode events: The events :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ConferenceParticipantInstance :rtype: twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantPage """ data = values.of({ 'ParticipantSid': participant_sid, 'Label': label, 'Events': events, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page(method='GET', uri=self._uri, params=data, ) return ConferenceParticipantPage(self._version, response, self._solution)
[docs] def get_page(self, target_url): """ Retrieve a specific page of ConferenceParticipantInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ConferenceParticipantInstance :rtype: twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ConferenceParticipantPage(self._version, response, self._solution)
[docs] def get(self, participant_sid): """ Constructs a ConferenceParticipantContext :param participant_sid: The participant_sid :returns: twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantContext :rtype: twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantContext """ return ConferenceParticipantContext( self._version, conference_sid=self._solution['conference_sid'], participant_sid=participant_sid, )
def __call__(self, participant_sid): """ Constructs a ConferenceParticipantContext :param participant_sid: The participant_sid :returns: twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantContext :rtype: twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantContext """ return ConferenceParticipantContext( self._version, conference_sid=self._solution['conference_sid'], participant_sid=participant_sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Insights.V1.ConferenceParticipantList>'
[docs]class ConferenceParticipantPage(Page): def __init__(self, version, response, solution): """ Initialize the ConferenceParticipantPage :param Version version: Version that contains the resource :param Response response: Response from the API :param conference_sid: The conference_sid :returns: twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantPage :rtype: twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantPage """ super(ConferenceParticipantPage, self).__init__(version, response) # Path Solution self._solution = solution
[docs] def get_instance(self, payload): """ Build an instance of ConferenceParticipantInstance :param dict payload: Payload response from the API :returns: twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantInstance :rtype: twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantInstance """ return ConferenceParticipantInstance( self._version, payload, conference_sid=self._solution['conference_sid'], )
def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Insights.V1.ConferenceParticipantPage>'
[docs]class ConferenceParticipantContext(InstanceContext): def __init__(self, version, conference_sid, participant_sid): """ Initialize the ConferenceParticipantContext :param Version version: Version that contains the resource :param conference_sid: The conference_sid :param participant_sid: The participant_sid :returns: twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantContext :rtype: twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantContext """ super(ConferenceParticipantContext, self).__init__(version) # Path Solution self._solution = {'conference_sid': conference_sid, 'participant_sid': participant_sid, } self._uri = '/Conferences/{conference_sid}/Participants/{participant_sid}'.format(**self._solution)
[docs] def fetch(self, events=values.unset, metrics=values.unset): """ Fetch the ConferenceParticipantInstance :param unicode events: The events :param unicode metrics: The metrics :returns: The fetched ConferenceParticipantInstance :rtype: twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantInstance """ data = values.of({'Events': events, 'Metrics': metrics, }) payload = self._version.fetch(method='GET', uri=self._uri, params=data, ) return ConferenceParticipantInstance( self._version, payload, conference_sid=self._solution['conference_sid'], participant_sid=self._solution['participant_sid'], )
def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return '<Twilio.Insights.V1.ConferenceParticipantContext {}>'.format(context)
[docs]class ConferenceParticipantInstance(InstanceResource):
[docs] class CallDirection(object): INBOUND = "inbound" OUTBOUND = "outbound"
[docs] class CallState(object): ANSWERED = "answered" COMPLETED = "completed" BUSY = "busy" FAIL = "fail" NOANSWER = "noanswer" RINGING = "ringing" CANCELED = "canceled"
[docs] class JitterBufferSize(object): LARGE = "large" SMALL = "small" MEDIUM = "medium" OFF = "off"
[docs] class Region(object): US1 = "us1" US2 = "us2" AU1 = "au1" BR1 = "br1" IE1 = "ie1" JP1 = "jp1" SG1 = "sg1" DE1 = "de1"
[docs] class CallType(object): CARRIER = "carrier" CLIENT = "client" SIP = "sip"
def __init__(self, version, payload, conference_sid, participant_sid=None): """ Initialize the ConferenceParticipantInstance :returns: twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantInstance :rtype: twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantInstance """ super(ConferenceParticipantInstance, self).__init__(version) # Marshaled Properties self._properties = { 'participant_sid': payload.get('participant_sid'), 'label': payload.get('label'), 'conference_sid': payload.get('conference_sid'), 'call_sid': payload.get('call_sid'), 'account_sid': payload.get('account_sid'), 'call_direction': payload.get('call_direction'), 'from_': payload.get('from'), 'to': payload.get('to'), 'call_state': payload.get('call_state'), 'country_code': payload.get('country_code'), 'is_moderator': payload.get('is_moderator'), 'join_time': deserialize.iso8601_datetime(payload.get('join_time')), 'leave_time': deserialize.iso8601_datetime(payload.get('leave_time')), 'duration_seconds': deserialize.integer(payload.get('duration_seconds')), 'whisper': payload.get('whisper'), 'agent_audio': payload.get('agent_audio'), 'outbound_queue_length': deserialize.integer(payload.get('outbound_queue_length')), 'outbound_time_in_queue': deserialize.integer(payload.get('outbound_time_in_queue')), 'jitter_buffer_size': payload.get('jitter_buffer_size'), 'is_coach': payload.get('is_coach'), 'coached_participants': payload.get('coached_participants'), 'participant_region': payload.get('participant_region'), 'conference_region': payload.get('conference_region'), 'call_type': payload.get('call_type'), 'quality_issues': deserialize.integer(payload.get('quality_issues')), 'properties': payload.get('properties'), 'events': payload.get('events'), 'metrics': payload.get('metrics'), 'url': payload.get('url'), } # Context self._context = None self._solution = { 'conference_sid': conference_sid, 'participant_sid': participant_sid or self._properties['participant_sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: ConferenceParticipantContext for this ConferenceParticipantInstance :rtype: twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantContext """ if self._context is None: self._context = ConferenceParticipantContext( self._version, conference_sid=self._solution['conference_sid'], participant_sid=self._solution['participant_sid'], ) return self._context @property def participant_sid(self): """ :returns: The participant_sid :rtype: unicode """ return self._properties['participant_sid'] @property def label(self): """ :returns: The label :rtype: unicode """ return self._properties['label'] @property def conference_sid(self): """ :returns: The conference_sid :rtype: unicode """ return self._properties['conference_sid'] @property def call_sid(self): """ :returns: The call_sid :rtype: unicode """ return self._properties['call_sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def call_direction(self): """ :returns: The call_direction :rtype: ConferenceParticipantInstance.CallDirection """ return self._properties['call_direction'] @property def from_(self): """ :returns: The from :rtype: unicode """ return self._properties['from_'] @property def to(self): """ :returns: The to :rtype: unicode """ return self._properties['to'] @property def call_state(self): """ :returns: The call_state :rtype: ConferenceParticipantInstance.CallState """ return self._properties['call_state'] @property def country_code(self): """ :returns: The country_code :rtype: unicode """ return self._properties['country_code'] @property def is_moderator(self): """ :returns: The is_moderator :rtype: bool """ return self._properties['is_moderator'] @property def join_time(self): """ :returns: The join_time :rtype: datetime """ return self._properties['join_time'] @property def leave_time(self): """ :returns: The leave_time :rtype: datetime """ return self._properties['leave_time'] @property def duration_seconds(self): """ :returns: The duration_seconds :rtype: unicode """ return self._properties['duration_seconds'] @property def whisper(self): """ :returns: The whisper :rtype: unicode """ return self._properties['whisper'] @property def agent_audio(self): """ :returns: The agent_audio :rtype: bool """ return self._properties['agent_audio'] @property def outbound_queue_length(self): """ :returns: The outbound_queue_length :rtype: unicode """ return self._properties['outbound_queue_length'] @property def outbound_time_in_queue(self): """ :returns: The outbound_time_in_queue :rtype: unicode """ return self._properties['outbound_time_in_queue'] @property def jitter_buffer_size(self): """ :returns: The jitter_buffer_size :rtype: ConferenceParticipantInstance.JitterBufferSize """ return self._properties['jitter_buffer_size'] @property def is_coach(self): """ :returns: The is_coach :rtype: bool """ return self._properties['is_coach'] @property def coached_participants(self): """ :returns: The coached_participants :rtype: list[unicode] """ return self._properties['coached_participants'] @property def participant_region(self): """ :returns: The participant_region :rtype: ConferenceParticipantInstance.Region """ return self._properties['participant_region'] @property def conference_region(self): """ :returns: The conference_region :rtype: ConferenceParticipantInstance.Region """ return self._properties['conference_region'] @property def call_type(self): """ :returns: The call_type :rtype: ConferenceParticipantInstance.CallType """ return self._properties['call_type'] @property def quality_issues(self): """ :returns: The quality_issues :rtype: unicode """ return self._properties['quality_issues'] @property def properties(self): """ :returns: The properties :rtype: dict """ return self._properties['properties'] @property def events(self): """ :returns: The events :rtype: dict """ return self._properties['events'] @property def metrics(self): """ :returns: The metrics :rtype: dict """ return self._properties['metrics'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url']
[docs] def fetch(self, events=values.unset, metrics=values.unset): """ Fetch the ConferenceParticipantInstance :param unicode events: The events :param unicode metrics: The metrics :returns: The fetched ConferenceParticipantInstance :rtype: twilio.rest.insights.v1.conference.conference_participant.ConferenceParticipantInstance """ return self._proxy.fetch(events=events, metrics=metrics, )
def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return '<Twilio.Insights.V1.ConferenceParticipantInstance {}>'.format(context)