Skip to content

Commit adc51ec

Browse files
Merge pull request #252 from plivo/VT-6903
VT-6903: Python SDK changes for participant level recording
2 parents 4490120 + b5e2165 commit adc51ec

File tree

7 files changed

+87
-35
lines changed

7 files changed

+87
-35
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Change Log
2+
## [4.47.0](https://github.com/plivo/plivo-python/tree/v4.47.0) (2023-12-07)
3+
**Minor enhancements and optimizations**
4+
25
## [4.46.0](https://github.com/plivo/plivo-python/tree/v4.46.0) (2023-11-06)
36
**Introducing registration_status**
47
- Added registration_status in LIST campaign APIs

plivo/resources/multipartycall.py

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def add_participant(self,
4343
on_exit_action_url=None,
4444
on_exit_action_method='POST',
4545
record=False,
46+
record_participant_track=False,
4647
record_file_format='mp3',
4748
status_callback_events='mpc-state-changes,participant-state-changes',
4849
stay_alone=False,
@@ -84,19 +85,28 @@ def resume_recording(self):
8485
return self.client.multi_party_calls.resume_recording(uuid=self.id)
8586

8687
def start_participant_recording(self, participant_id, file_format=None, recording_callback_url=None,
87-
recording_callback_method=None):
88+
recording_callback_method=None, record_track_type='all'):
8889
return self.client.multi_party_calls.start_participant_recording(participant_id=participant_id, uuid=self.id,
89-
**to_param_dict(self.add_participant,
90+
**to_param_dict(self.start_participant_recording,
9091
locals()))
9192

92-
def stop_participant_recording(self, participant_id):
93-
return self.client.multi_party_calls.stop_participant_recording(participant_id=participant_id, uuid=self.id)
93+
def stop_participant_recording(self, participant_id, record_track_type='all'):
94+
return self.client.multi_party_calls.stop_participant_recording(participant_id=participant_id, uuid=self.id,
95+
**to_param_dict(
96+
self.stop_participant_recording,
97+
locals()))
9498

95-
def pause_participant_recording(self, participant_id):
96-
return self.client.multi_party_calls.pause_participant_recording(participant_id=participant_id, uuid=self.id)
99+
def pause_participant_recording(self, participant_id, record_track_type='all'):
100+
return self.client.multi_party_calls.pause_participant_recording(participant_id=participant_id, uuid=self.id,
101+
**to_param_dict(
102+
self.pause_participant_recording,
103+
locals()))
97104

98-
def resume_participant_recording(self, participant_id):
99-
return self.client.multi_party_calls.resume_participant_recording(participant_id=participant_id, uuid=self.id)
105+
def resume_participant_recording(self, participant_id, record_track_type='all'):
106+
return self.client.multi_party_calls.resume_participant_recording(participant_id=participant_id, uuid=self.id,
107+
**to_param_dict(
108+
self.resume_participant_recording,
109+
locals()))
100110

101111
def get(self):
102112
return self.client.multi_party_calls.get(uuid=self.id)
@@ -129,20 +139,25 @@ class MultiPartyCallParticipant(SecondaryPlivoResource):
129139
_secondary_identifier_string = 'member_id'
130140

131141
def start_participant_recording(self, file_format=None, recording_callback_url=None,
132-
recording_callback_method=None):
142+
recording_callback_method=None, record_track_type='all'):
133143
return self.client.multi_party_calls.start_participant_recording(participant_id=self.secondary_id, uuid=self.id,
134-
**to_param_dict(self.add_participant,
144+
**to_param_dict(self.start_participant_recording,
135145
locals()))
136146

137-
def stop_participant_recording(self):
138-
return self.client.multi_party_calls.stop_participant_recording(participant_id=self.secondary_id, uuid=self.id)
147+
def stop_participant_recording(self, record_track_type='all'):
148+
return self.client.multi_party_calls.stop_participant_recording(participant_id=self.secondary_id, uuid=self.id,
149+
**to_param_dict(self.stop_participant_recording,
150+
locals()))
139151

140-
def pause_participant_recording(self):
141-
return self.client.multi_party_calls.pause_participant_recording(participant_id=self.secondary_id, uuid=self.id)
152+
def pause_participant_recording(self, record_track_type='all'):
153+
return self.client.multi_party_calls.pause_participant_recording(participant_id=self.secondary_id, uuid=self.id,
154+
**to_param_dict(self.pause_participant_recording,
155+
locals()))
142156

143-
def resume_participant_recording(self):
144-
return self.client.multi_party_calls.resume_participant_recording(participant_id=self.secondary_id,
145-
uuid=self.id)
157+
def resume_participant_recording(self, record_track_type='all'):
158+
return self.client.multi_party_calls.resume_participant_recording(participant_id=self.secondary_id, uuid=self.id,
159+
**to_param_dict(self.resume_participant_recording,
160+
locals()))
146161

147162
def update(self, coach_mode=None, hold=None, mute=None):
148163
return self.client.multi_party_calls.update_participant(participant_id=self.secondary_id,
@@ -286,6 +301,7 @@ def get(self, uuid=None, friendly_name=None, callback_url=None, callback_method=
286301
on_exit_action_url=[optional(of_type_exact(str), is_url())],
287302
on_exit_action_method=[optional(of_type_exact(str), is_in(('GET', 'POST'), case_sensitive=False))],
288303
record=[optional(of_type_exact(bool))],
304+
record_participant_track=[optional(of_type_exact(bool))],
289305
record_file_format=[optional(of_type_exact(str), is_in(('mp3', 'wav'), case_sensitive=False,
290306
case_type='lower'))],
291307
status_callback_events=[optional(of_type_exact(str), multi_is_in(('mpc-state-changes',
@@ -352,6 +368,7 @@ def add_participant(self,
352368
on_exit_action_url=None,
353369
on_exit_action_method='POST',
354370
record=False,
371+
record_participant_track=False,
355372
record_file_format='mp3',
356373
status_callback_events='mpc-state-changes,participant-state-changes',
357374
stay_alone=False,
@@ -552,17 +569,18 @@ def get_participant(self, participant_id, uuid=None, friendly_name=None,
552569
uuid=[optional(of_type_exact(str))],
553570
file_format=[optional(of_type_exact(str), is_in(('mp3', 'wav'), case_sensitive=False,
554571
case_type='lower'))],
572+
record_track_type=[optional(of_type_exact(str))],
555573
recording_callback_url=[optional(of_type_exact(str), is_url())],
556574
recording_callback_method=[optional(of_type_exact(str), is_in(('GET', 'POST'), case_sensitive=False))],
557575
callback_url=[optional(is_url())],
558576
callback_method=[optional(of_type(six.text_type))],
559577
)
560578
def start_participant_recording(self, participant_id, uuid=None, friendly_name=None, file_format='mp3',
561579
recording_callback_url=None, recording_callback_method='POST',
562-
callback_url=None, callback_method=None):
580+
callback_url=None, callback_method=None, record_track_type='all'):
563581
mpc_id = self.__make_mpc_id(friendly_name, uuid)
564582
return self.client.request('POST', ('MultiPartyCall', mpc_id, 'Participant', participant_id, 'Record'),
565-
self.__clean_identifiers(to_param_dict(self.start_recording, locals())),
583+
self.__clean_identifiers(to_param_dict(self.start_participant_recording, locals())),
566584
is_voice_request=True)
567585

568586
@validate_args(
@@ -571,13 +589,15 @@ def start_participant_recording(self, participant_id, uuid=None, friendly_name=N
571589
uuid=[optional(of_type_exact(str))],
572590
callback_url=[optional(is_url())],
573591
callback_method=[optional(of_type(six.text_type))],
592+
record_track_type=[optional(of_type_exact(str))]
574593
)
575594
def stop_participant_recording(self,
576595
participant_id,
577596
uuid=None,
578597
friendly_name=None,
579598
callback_url=None,
580-
callback_method=None):
599+
callback_method=None,
600+
record_track_type='all'):
581601
mpc_id = self.__make_mpc_id(friendly_name, uuid)
582602
return self.client.request('DELETE', ('MultiPartyCall', mpc_id, 'Participant', participant_id, 'Record'),
583603
to_param_dict(self.stop_participant_recording, locals()), is_voice_request=True)
@@ -588,9 +608,10 @@ def stop_participant_recording(self,
588608
uuid=[optional(of_type_exact(str))],
589609
callback_url=[optional(is_url())],
590610
callback_method=[optional(of_type(six.text_type))],
611+
record_track_type=[optional(of_type_exact(str))]
591612
)
592613
def pause_participant_recording(self, participant_id, uuid=None, friendly_name=None,
593-
callback_url=None, callback_method=None):
614+
callback_url=None, callback_method=None, record_track_type='all'):
594615
mpc_id = self.__make_mpc_id(friendly_name, uuid)
595616
return self.client.request('POST', ('MultiPartyCall', mpc_id, 'Participant', participant_id, 'Record', 'Pause'),
596617
to_param_dict(self.pause_participant_recording, locals()), is_voice_request=True)
@@ -601,9 +622,10 @@ def pause_participant_recording(self, participant_id, uuid=None, friendly_name=N
601622
uuid=[optional(of_type_exact(str))],
602623
callback_url=[optional(is_url())],
603624
callback_method=[optional(of_type(six.text_type))],
625+
record_track_type=[optional(of_type_exact(str))]
604626
)
605627
def resume_participant_recording(self, participant_id, uuid=None, friendly_name=None,
606-
callback_url=None, callback_method=None):
628+
callback_url=None, callback_method=None, record_track_type='all'):
607629
mpc_id = self.__make_mpc_id(friendly_name, uuid)
608630
return self.client.request('POST',
609631
('MultiPartyCall', mpc_id, 'Participant', participant_id, 'Record', 'Resume'),

plivo/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# -*- coding: utf-8 -*-
2-
__version__ = '4.46.0'
2+
__version__ = '4.47.0'

plivo/xml/MultiPartyCallElement.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,19 @@ def set_record(self, record):
159159
self.record = record
160160
return self
161161

162+
@property
163+
def record_participant_track(self):
164+
return self.__record_participant_track
165+
166+
@record_participant_track.setter
167+
@validate_args(record_participant_track=[optional(of_type_exact(bool))])
168+
def record_participant_track(self, record_participant_track):
169+
self.__record_participant_track = record_participant_track
170+
171+
def set_record_participant_track(self, record_participant_track):
172+
self.record_participant_track = record_participant_track
173+
return self
174+
162175
@property
163176
def record_file_format(self):
164177
return self.__record_file_format
@@ -535,6 +548,7 @@ def __init__(
535548
customer_hold_music_url=None,
536549
customer_hold_music_method='GET',
537550
record=False,
551+
record_participant_track=False,
538552
record_file_format='mp3',
539553
recording_callback_url=None,
540554
recording_callback_method='POST',
@@ -576,6 +590,7 @@ def __init__(
576590
self.customer_hold_music_url = customer_hold_music_url
577591
self.customer_hold_music_method = customer_hold_music_method
578592
self.record = record
593+
self.record_participant_track = record_participant_track
579594
self.record_file_format = record_file_format
580595
self.recording_callback_url = recording_callback_url
581596
self.recording_callback_method = recording_callback_method
@@ -609,6 +624,7 @@ def to_dict(self):
609624
'customerHoldMusicUrl': self.customer_hold_music_url,
610625
'customerHoldMusicMethod': self.customer_hold_music_method,
611626
'record': self.record,
627+
'recordParticipantTrack': self.record_participant_track,
612628
'recordFileFormat': self.record_file_format,
613629
'recordingCallbackUrl': self.recording_callback_url,
614630
'recordingCallbackMethod': self.recording_callback_method,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setup(
1212
name='plivo',
13-
version='4.46.0',
13+
version='4.47.0',
1414
description='A Python SDK to make voice calls & send SMS using Plivo and to generate Plivo XML',
1515
long_description=long_description,
1616
url='https://github.com/plivo/plivo-python',

tests/resources/test_multipartycalls.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ def test_add_participant(self):
170170
'status_callback_events': 'mpc-state-changes,participant-state-changes',
171171
'record_file_format': 'mp3',
172172
'record': False,
173+
'record_participant_track': False,
173174
'record_min_member_count': 1,
174175
'on_exit_action_method': 'POST',
175176
'status_callback_method': 'GET',
@@ -485,7 +486,8 @@ def test_start_participant_recording(self):
485486
expected_method='POST',
486487
expected_request_body={'file_format': 'wav',
487488
'recording_callback_url': recording_callback_url,
488-
'recording_callback_method': 'POST'},
489+
'recording_callback_method': 'POST',
490+
'record_track_type': 'all'},
489491
actual_response=start_participant_recording_response)
490492

491493
def test_stop_participant_recording(self):
@@ -494,23 +496,32 @@ def test_stop_participant_recording(self):
494496
self.client.multi_party_calls.stop_participant_recording(friendly_name='Voice', participant_id=participant_id)
495497
self.__assert_requests(expected_url='https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall'
496498
'/name_{}/Participant/{}/Record/'.format('Voice', participant_id),
497-
expected_method='DELETE')
499+
expected_method='DELETE',
500+
expected_request_body={'record_track_type': 'all',
501+
'friendly_name': 'Voice',
502+
'participant_id': 10})
498503

499504
def test_pause_participant_recording(self):
500505
participant_id = 10
501506
self.client.set_expected_response(status_code=204, data_to_return=None)
502507
self.client.multi_party_calls.pause_participant_recording(friendly_name='Voice', participant_id=participant_id)
503508
self.__assert_requests(expected_url='https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall'
504509
'/name_{}/Participant/{}/Record/Pause/'.format('Voice', participant_id),
505-
expected_method='POST')
510+
expected_method='POST',
511+
expected_request_body={'record_track_type': 'all',
512+
'friendly_name': 'Voice',
513+
'participant_id': 10})
506514

507515
def test_resume_participant_recording(self):
508516
participant_id = 10
509517
self.client.set_expected_response(status_code=204, data_to_return=None)
510518
self.client.multi_party_calls.resume_participant_recording(friendly_name='Voice', participant_id=participant_id)
511519
self.__assert_requests(expected_url='https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall'
512520
'/name_{}/Participant/{}/Record/Resume/'.format('Voice', participant_id),
513-
expected_method='POST')
521+
expected_method='POST',
522+
expected_request_body={'record_track_type': 'all',
523+
'friendly_name': 'Voice',
524+
'participant_id': 10})
514525

515526
@with_response(202)
516527
def test_start_play_audio(self):

0 commit comments

Comments
 (0)