Skip to content

Commit ed99826

Browse files
authored
adding interrupt call media operation flag (#34315)
* adding interrupt call media operation flag * adding interrupt call media flag to play all * adding tests for interrupt call media flag * fixing the test issue * addressing PR comments * missed to change the default value in play all for interrupt media flag * setting the type for interrupt flag to set bool or none * setting default to interrupt media operation call flag * fixing tests * running live tests and updating the test events json * updating the asset json change to fix the test
1 parent c66e236 commit ed99826

8 files changed

+135
-11
lines changed

sdk/communication/azure-communication-callautomation/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/communication/azure-communication-callautomation",
5-
"Tag": "python/communication/azure-communication-callautomation_3124e163ae"
5+
"Tag": "python/communication/azure-communication-callautomation_93668e001d"
66
}

sdk/communication/azure-communication-callautomation/azure/communication/callautomation/_call_connection_client.py

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,52 @@ def play_media(
436436
:rtype: None
437437
:raises ~azure.core.exceptions.HttpResponseError:
438438
"""
439+
self._play_media(
440+
play_source=play_source,
441+
play_to=play_to,
442+
loop=loop,
443+
operation_context=operation_context,
444+
operation_callback_url=operation_callback_url,
445+
**kwargs
446+
)
447+
448+
@distributed_trace
449+
def _play_media(
450+
self,
451+
play_source: Union['FileSource', 'TextSource', 'SsmlSource'],
452+
play_to: Union[Literal["all"], List['CommunicationIdentifier']] = 'all',
453+
*,
454+
loop: bool = False,
455+
operation_context: Optional[str] = None,
456+
operation_callback_url: Optional[str] = None,
457+
interrupt_call_media_operation: Optional[bool] = None,
458+
**kwargs
459+
) -> None:
460+
"""Play media to specific participant(s) in this call.
461+
462+
:param play_source: A PlaySource representing the source to play.
463+
:type play_source: ~azure.communication.callautomation.FileSource or
464+
~azure.communication.callautomation.TextSource or
465+
~azure.communication.callautomation.SsmlSource
466+
:param play_to: The targets to play media to. Default value is 'all', to play media
467+
to all participants in the call.
468+
:type play_to: list[~azure.communication.callautomation.CommunicationIdentifier]
469+
:keyword loop: Whether the media should be repeated until cancelled.
470+
:paramtype loop: bool
471+
:keyword operation_context: Value that can be used to track this call and its associated events.
472+
:paramtype operation_context: str or None
473+
:keyword operation_callback_url: Set a callback URL that overrides the default callback URL set
474+
by CreateCall/AnswerCall for this operation.
475+
This setup is per-action. If this is not set, the default callback URL set by
476+
CreateCall/AnswerCall will be used.
477+
:paramtype operation_callback_url: str or None
478+
:keyword interrupt_call_media_operation: If set play can barge into other existing
479+
queued-up/currently-processing requests.
480+
:paramtype interrupt_call_media_operation: bool
481+
:return: None
482+
:rtype: None
483+
:raises ~azure.core.exceptions.HttpResponseError:
484+
"""
439485
play_source_single: Optional[Union['FileSource', 'TextSource', 'SsmlSource']] = None
440486
if isinstance(play_source, list):
441487
warnings.warn("Currently only single play source per request is supported.")
@@ -448,7 +494,7 @@ def play_media(
448494
play_request = PlayRequest(
449495
play_sources=[play_source_single._to_generated()], # pylint:disable=protected-access
450496
play_to=audience,
451-
play_options=PlayOptions(loop=loop),
497+
play_options=PlayOptions(loop=loop, interrupt_call_media_operation=interrupt_call_media_operation),
452498
operation_context=operation_context,
453499
operation_callback_uri=operation_callback_url,
454500
**kwargs
@@ -463,6 +509,7 @@ def play_media_to_all(
463509
loop: bool = False,
464510
operation_context: Optional[str] = None,
465511
operation_callback_url: Optional[str] = None,
512+
interrupt_call_media_operation: bool = False,
466513
**kwargs
467514
) -> None:
468515
"""Play media to all participants in this call.
@@ -480,6 +527,9 @@ def play_media_to_all(
480527
This setup is per-action. If this is not set, the default callback URL set by
481528
CreateCall/AnswerCall will be used.
482529
:paramtype operation_callback_url: str or None
530+
:keyword interrupt_call_media_operation: If set play can barge into other existing
531+
queued-up/currently-processing requests.
532+
:paramtype interrupt_call_media_operation: bool
483533
:return: None
484534
:rtype: None
485535
:raises ~azure.core.exceptions.HttpResponseError:
@@ -488,11 +538,12 @@ def play_media_to_all(
488538
"The method 'play_media_to_all' is deprecated. Please use 'play_media' instead.",
489539
DeprecationWarning
490540
)
491-
self.play_media(
541+
self._play_media(
492542
play_source=play_source,
493543
loop=loop,
494544
operation_context=operation_context,
495545
operation_callback_url=operation_callback_url,
546+
interrupt_call_media_operation=interrupt_call_media_operation,
496547
**kwargs
497548
)
498549

sdk/communication/azure-communication-callautomation/azure/communication/callautomation/aio/_call_connection_client_async.py

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pylint: disable=too-many-lines
12
# -------------------------------------------------------------------------
23
# Copyright (c) Microsoft Corporation. All rights reserved.
34
# Licensed under the MIT License. See License.txt in the project root for
@@ -442,6 +443,52 @@ async def play_media(
442443
:rtype: None
443444
:raises ~azure.core.exceptions.HttpResponseError:
444445
"""
446+
await self._play_media(
447+
play_source=play_source,
448+
play_to=play_to,
449+
loop=loop,
450+
operation_context=operation_context,
451+
operation_callback_url=operation_callback_url,
452+
**kwargs
453+
)
454+
455+
@distributed_trace_async
456+
async def _play_media(
457+
self,
458+
play_source: Union['FileSource', 'TextSource', 'SsmlSource'],
459+
play_to: Union[Literal["all"], List['CommunicationIdentifier']] = 'all',
460+
*,
461+
loop: bool = False,
462+
operation_context: Optional[str] = None,
463+
operation_callback_url: Optional[str] = None,
464+
interrupt_call_media_operation: Optional[bool] = None,
465+
**kwargs
466+
) -> None:
467+
"""Play media to specific participant(s) in this call.
468+
469+
:param play_source: A PlaySource representing the source to play.
470+
:type play_source: ~azure.communication.callautomation.FileSource or
471+
~azure.communication.callautomation.TextSource or
472+
~azure.communication.callautomation.SsmlSource
473+
:param play_to: The targets to play media to. Default value is 'all', to play media
474+
to all participants in the call.
475+
:type play_to: list[~azure.communication.callautomation.CommunicationIdentifier]
476+
:keyword loop: Whether the media should be repeated until cancelled.
477+
:paramtype loop: bool
478+
:keyword operation_context: Value that can be used to track this call and its associated events.
479+
:paramtype operation_context: str or None
480+
:keyword operation_callback_url: Set a callback URL that overrides the default callback URL set
481+
by CreateCall/AnswerCall for this operation.
482+
This setup is per-action. If this is not set, the default callback URL set by
483+
CreateCall/AnswerCall will be used.
484+
:paramtype operation_callback_url: str or None
485+
:keyword interrupt_call_media_operation: If set play can barge into other existing
486+
queued-up/currently-processing requests.
487+
:paramtype interrupt_call_media_operation: bool
488+
:return: None
489+
:rtype: None
490+
:raises ~azure.core.exceptions.HttpResponseError:
491+
"""
445492
play_source_single: Optional[Union['FileSource', 'TextSource', 'SsmlSource']] = None
446493
if isinstance(play_source, list):
447494
warnings.warn("Currently only single play source per request is supported.")
@@ -454,7 +501,7 @@ async def play_media(
454501
play_request = PlayRequest(
455502
play_sources=[play_source_single._to_generated()], # pylint:disable=protected-access
456503
play_to=audience,
457-
play_options=PlayOptions(loop=loop),
504+
play_options=PlayOptions(loop=loop, interrupt_call_media_operation=interrupt_call_media_operation),
458505
operation_context=operation_context,
459506
operation_callback_uri=operation_callback_url,
460507
**kwargs
@@ -469,6 +516,7 @@ async def play_media_to_all(
469516
loop: bool = False,
470517
operation_context: Optional[str] = None,
471518
operation_callback_url: Optional[str] = None,
519+
interrupt_call_media_operation: bool = False,
472520
**kwargs
473521
) -> None:
474522
"""Play media to all participants in this call.
@@ -486,6 +534,9 @@ async def play_media_to_all(
486534
This setup is per-action. If this is not set, the default callback URL set by
487535
CreateCall/AnswerCall will be used.
488536
:paramtype operation_callback_url: str or None
537+
:keyword interrupt_call_media_operation: If set play can barge into other existing
538+
queued-up/currently-processing requests.
539+
:paramtype interrupt_call_media_operation: bool
489540
:return: None
490541
:rtype: None
491542
:raises ~azure.core.exceptions.HttpResponseError:
@@ -494,11 +545,12 @@ async def play_media_to_all(
494545
"The method 'play_media_to_all' is deprecated. Please use 'play_media' instead.",
495546
DeprecationWarning
496547
)
497-
await self.play_media(
548+
await self._play_media(
498549
play_source=play_source,
499550
loop=loop,
500551
operation_context=operation_context,
501552
operation_callback_url=operation_callback_url,
553+
interrupt_call_media_operation=interrupt_call_media_operation,
502554
**kwargs
503555
)
504556

0 commit comments

Comments
 (0)