Skip to content

Commit

Permalink
Merge pull request #252 from plivo/VT-6903
Browse files Browse the repository at this point in the history
VT-6903: Python SDK changes for participant level recording
  • Loading branch information
eniyavan-muruganantham-plivo authored Dec 7, 2023
2 parents 4490120 + b5e2165 commit adc51ec
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 35 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Change Log
## [4.47.0](https://github.com/plivo/plivo-python/tree/v4.47.0) (2023-12-07)
**Minor enhancements and optimizations**

## [4.46.0](https://github.com/plivo/plivo-python/tree/v4.46.0) (2023-11-06)
**Introducing registration_status**
- Added registration_status in LIST campaign APIs
Expand Down
66 changes: 44 additions & 22 deletions plivo/resources/multipartycall.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def add_participant(self,
on_exit_action_url=None,
on_exit_action_method='POST',
record=False,
record_participant_track=False,
record_file_format='mp3',
status_callback_events='mpc-state-changes,participant-state-changes',
stay_alone=False,
Expand Down Expand Up @@ -84,19 +85,28 @@ def resume_recording(self):
return self.client.multi_party_calls.resume_recording(uuid=self.id)

def start_participant_recording(self, participant_id, file_format=None, recording_callback_url=None,
recording_callback_method=None):
recording_callback_method=None, record_track_type='all'):
return self.client.multi_party_calls.start_participant_recording(participant_id=participant_id, uuid=self.id,
**to_param_dict(self.add_participant,
**to_param_dict(self.start_participant_recording,
locals()))

def stop_participant_recording(self, participant_id):
return self.client.multi_party_calls.stop_participant_recording(participant_id=participant_id, uuid=self.id)
def stop_participant_recording(self, participant_id, record_track_type='all'):
return self.client.multi_party_calls.stop_participant_recording(participant_id=participant_id, uuid=self.id,
**to_param_dict(
self.stop_participant_recording,
locals()))

def pause_participant_recording(self, participant_id):
return self.client.multi_party_calls.pause_participant_recording(participant_id=participant_id, uuid=self.id)
def pause_participant_recording(self, participant_id, record_track_type='all'):
return self.client.multi_party_calls.pause_participant_recording(participant_id=participant_id, uuid=self.id,
**to_param_dict(
self.pause_participant_recording,
locals()))

def resume_participant_recording(self, participant_id):
return self.client.multi_party_calls.resume_participant_recording(participant_id=participant_id, uuid=self.id)
def resume_participant_recording(self, participant_id, record_track_type='all'):
return self.client.multi_party_calls.resume_participant_recording(participant_id=participant_id, uuid=self.id,
**to_param_dict(
self.resume_participant_recording,
locals()))

def get(self):
return self.client.multi_party_calls.get(uuid=self.id)
Expand Down Expand Up @@ -129,20 +139,25 @@ class MultiPartyCallParticipant(SecondaryPlivoResource):
_secondary_identifier_string = 'member_id'

def start_participant_recording(self, file_format=None, recording_callback_url=None,
recording_callback_method=None):
recording_callback_method=None, record_track_type='all'):
return self.client.multi_party_calls.start_participant_recording(participant_id=self.secondary_id, uuid=self.id,
**to_param_dict(self.add_participant,
**to_param_dict(self.start_participant_recording,
locals()))

def stop_participant_recording(self):
return self.client.multi_party_calls.stop_participant_recording(participant_id=self.secondary_id, uuid=self.id)
def stop_participant_recording(self, record_track_type='all'):
return self.client.multi_party_calls.stop_participant_recording(participant_id=self.secondary_id, uuid=self.id,
**to_param_dict(self.stop_participant_recording,
locals()))

def pause_participant_recording(self):
return self.client.multi_party_calls.pause_participant_recording(participant_id=self.secondary_id, uuid=self.id)
def pause_participant_recording(self, record_track_type='all'):
return self.client.multi_party_calls.pause_participant_recording(participant_id=self.secondary_id, uuid=self.id,
**to_param_dict(self.pause_participant_recording,
locals()))

def resume_participant_recording(self):
return self.client.multi_party_calls.resume_participant_recording(participant_id=self.secondary_id,
uuid=self.id)
def resume_participant_recording(self, record_track_type='all'):
return self.client.multi_party_calls.resume_participant_recording(participant_id=self.secondary_id, uuid=self.id,
**to_param_dict(self.resume_participant_recording,
locals()))

def update(self, coach_mode=None, hold=None, mute=None):
return self.client.multi_party_calls.update_participant(participant_id=self.secondary_id,
Expand Down Expand Up @@ -286,6 +301,7 @@ def get(self, uuid=None, friendly_name=None, callback_url=None, callback_method=
on_exit_action_url=[optional(of_type_exact(str), is_url())],
on_exit_action_method=[optional(of_type_exact(str), is_in(('GET', 'POST'), case_sensitive=False))],
record=[optional(of_type_exact(bool))],
record_participant_track=[optional(of_type_exact(bool))],
record_file_format=[optional(of_type_exact(str), is_in(('mp3', 'wav'), case_sensitive=False,
case_type='lower'))],
status_callback_events=[optional(of_type_exact(str), multi_is_in(('mpc-state-changes',
Expand Down Expand Up @@ -352,6 +368,7 @@ def add_participant(self,
on_exit_action_url=None,
on_exit_action_method='POST',
record=False,
record_participant_track=False,
record_file_format='mp3',
status_callback_events='mpc-state-changes,participant-state-changes',
stay_alone=False,
Expand Down Expand Up @@ -552,17 +569,18 @@ def get_participant(self, participant_id, uuid=None, friendly_name=None,
uuid=[optional(of_type_exact(str))],
file_format=[optional(of_type_exact(str), is_in(('mp3', 'wav'), case_sensitive=False,
case_type='lower'))],
record_track_type=[optional(of_type_exact(str))],
recording_callback_url=[optional(of_type_exact(str), is_url())],
recording_callback_method=[optional(of_type_exact(str), is_in(('GET', 'POST'), case_sensitive=False))],
callback_url=[optional(is_url())],
callback_method=[optional(of_type(six.text_type))],
)
def start_participant_recording(self, participant_id, uuid=None, friendly_name=None, file_format='mp3',
recording_callback_url=None, recording_callback_method='POST',
callback_url=None, callback_method=None):
callback_url=None, callback_method=None, record_track_type='all'):
mpc_id = self.__make_mpc_id(friendly_name, uuid)
return self.client.request('POST', ('MultiPartyCall', mpc_id, 'Participant', participant_id, 'Record'),
self.__clean_identifiers(to_param_dict(self.start_recording, locals())),
self.__clean_identifiers(to_param_dict(self.start_participant_recording, locals())),
is_voice_request=True)

@validate_args(
Expand All @@ -571,13 +589,15 @@ def start_participant_recording(self, participant_id, uuid=None, friendly_name=N
uuid=[optional(of_type_exact(str))],
callback_url=[optional(is_url())],
callback_method=[optional(of_type(six.text_type))],
record_track_type=[optional(of_type_exact(str))]
)
def stop_participant_recording(self,
participant_id,
uuid=None,
friendly_name=None,
callback_url=None,
callback_method=None):
callback_method=None,
record_track_type='all'):
mpc_id = self.__make_mpc_id(friendly_name, uuid)
return self.client.request('DELETE', ('MultiPartyCall', mpc_id, 'Participant', participant_id, 'Record'),
to_param_dict(self.stop_participant_recording, locals()), is_voice_request=True)
Expand All @@ -588,9 +608,10 @@ def stop_participant_recording(self,
uuid=[optional(of_type_exact(str))],
callback_url=[optional(is_url())],
callback_method=[optional(of_type(six.text_type))],
record_track_type=[optional(of_type_exact(str))]
)
def pause_participant_recording(self, participant_id, uuid=None, friendly_name=None,
callback_url=None, callback_method=None):
callback_url=None, callback_method=None, record_track_type='all'):
mpc_id = self.__make_mpc_id(friendly_name, uuid)
return self.client.request('POST', ('MultiPartyCall', mpc_id, 'Participant', participant_id, 'Record', 'Pause'),
to_param_dict(self.pause_participant_recording, locals()), is_voice_request=True)
Expand All @@ -601,9 +622,10 @@ def pause_participant_recording(self, participant_id, uuid=None, friendly_name=N
uuid=[optional(of_type_exact(str))],
callback_url=[optional(is_url())],
callback_method=[optional(of_type(six.text_type))],
record_track_type=[optional(of_type_exact(str))]
)
def resume_participant_recording(self, participant_id, uuid=None, friendly_name=None,
callback_url=None, callback_method=None):
callback_url=None, callback_method=None, record_track_type='all'):
mpc_id = self.__make_mpc_id(friendly_name, uuid)
return self.client.request('POST',
('MultiPartyCall', mpc_id, 'Participant', participant_id, 'Record', 'Resume'),
Expand Down
2 changes: 1 addition & 1 deletion plivo/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
__version__ = '4.46.0'
__version__ = '4.47.0'
16 changes: 16 additions & 0 deletions plivo/xml/MultiPartyCallElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,19 @@ def set_record(self, record):
self.record = record
return self

@property
def record_participant_track(self):
return self.__record_participant_track

@record_participant_track.setter
@validate_args(record_participant_track=[optional(of_type_exact(bool))])
def record_participant_track(self, record_participant_track):
self.__record_participant_track = record_participant_track

def set_record_participant_track(self, record_participant_track):
self.record_participant_track = record_participant_track
return self

@property
def record_file_format(self):
return self.__record_file_format
Expand Down Expand Up @@ -535,6 +548,7 @@ def __init__(
customer_hold_music_url=None,
customer_hold_music_method='GET',
record=False,
record_participant_track=False,
record_file_format='mp3',
recording_callback_url=None,
recording_callback_method='POST',
Expand Down Expand Up @@ -576,6 +590,7 @@ def __init__(
self.customer_hold_music_url = customer_hold_music_url
self.customer_hold_music_method = customer_hold_music_method
self.record = record
self.record_participant_track = record_participant_track
self.record_file_format = record_file_format
self.recording_callback_url = recording_callback_url
self.recording_callback_method = recording_callback_method
Expand Down Expand Up @@ -609,6 +624,7 @@ def to_dict(self):
'customerHoldMusicUrl': self.customer_hold_music_url,
'customerHoldMusicMethod': self.customer_hold_music_method,
'record': self.record,
'recordParticipantTrack': self.record_participant_track,
'recordFileFormat': self.record_file_format,
'recordingCallbackUrl': self.recording_callback_url,
'recordingCallbackMethod': self.recording_callback_method,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name='plivo',
version='4.46.0',
version='4.47.0',
description='A Python SDK to make voice calls & send SMS using Plivo and to generate Plivo XML',
long_description=long_description,
url='https://github.com/plivo/plivo-python',
Expand Down
19 changes: 15 additions & 4 deletions tests/resources/test_multipartycalls.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def test_add_participant(self):
'status_callback_events': 'mpc-state-changes,participant-state-changes',
'record_file_format': 'mp3',
'record': False,
'record_participant_track': False,
'record_min_member_count': 1,
'on_exit_action_method': 'POST',
'status_callback_method': 'GET',
Expand Down Expand Up @@ -485,7 +486,8 @@ def test_start_participant_recording(self):
expected_method='POST',
expected_request_body={'file_format': 'wav',
'recording_callback_url': recording_callback_url,
'recording_callback_method': 'POST'},
'recording_callback_method': 'POST',
'record_track_type': 'all'},
actual_response=start_participant_recording_response)

def test_stop_participant_recording(self):
Expand All @@ -494,23 +496,32 @@ def test_stop_participant_recording(self):
self.client.multi_party_calls.stop_participant_recording(friendly_name='Voice', participant_id=participant_id)
self.__assert_requests(expected_url='https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall'
'/name_{}/Participant/{}/Record/'.format('Voice', participant_id),
expected_method='DELETE')
expected_method='DELETE',
expected_request_body={'record_track_type': 'all',
'friendly_name': 'Voice',
'participant_id': 10})

def test_pause_participant_recording(self):
participant_id = 10
self.client.set_expected_response(status_code=204, data_to_return=None)
self.client.multi_party_calls.pause_participant_recording(friendly_name='Voice', participant_id=participant_id)
self.__assert_requests(expected_url='https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall'
'/name_{}/Participant/{}/Record/Pause/'.format('Voice', participant_id),
expected_method='POST')
expected_method='POST',
expected_request_body={'record_track_type': 'all',
'friendly_name': 'Voice',
'participant_id': 10})

def test_resume_participant_recording(self):
participant_id = 10
self.client.set_expected_response(status_code=204, data_to_return=None)
self.client.multi_party_calls.resume_participant_recording(friendly_name='Voice', participant_id=participant_id)
self.__assert_requests(expected_url='https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall'
'/name_{}/Participant/{}/Record/Resume/'.format('Voice', participant_id),
expected_method='POST')
expected_method='POST',
expected_request_body={'record_track_type': 'all',
'friendly_name': 'Voice',
'participant_id': 10})

@with_response(202)
def test_start_play_audio(self):
Expand Down
Loading

0 comments on commit adc51ec

Please sign in to comment.