Skip to content

Commit

Permalink
Juntuchen/callback media (Azure#31705)
Browse files Browse the repository at this point in the history
* updated swagger

* added media API support
  • Loading branch information
juntuchen-msft authored Aug 18, 2023
1 parent 2c4c367 commit 1c8ab17
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ def play_media(
*,
loop: bool = False,
operation_context: Optional[str] = None,
callback_url: Optional[str] = None,
**kwargs
) -> None:
"""Play media to specific participant(s) in this call.
Expand All @@ -418,6 +419,8 @@ def play_media(
:paramtype loop: bool
:keyword operation_context: Value that can be used to track this call and its associated events.
:paramtype operation_context: str or None
:keyword callback_url: Url that overrides original callback URI for this request.
:paramtype callback_url: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
Expand All @@ -435,6 +438,7 @@ def play_media(
play_to=audience,
play_options=PlayOptions(loop=loop),
operation_context=operation_context,
callback_uri=callback_url,
**kwargs
)
self._call_media_client.play(self._call_connection_id, play_request)
Expand All @@ -446,6 +450,7 @@ def play_media_to_all(
*,
loop: bool = False,
operation_context: Optional[str] = None,
callback_url: Optional[str] = None,
**kwargs
) -> None:
"""Play media to all participants in this call.
Expand All @@ -457,6 +462,8 @@ def play_media_to_all(
:paramtype loop: bool
:keyword operation_context: Value that can be used to track this call and its associated events.
:paramtype operation_context: str or None
:keyword callback_url: Url that overrides original callback URI for this request.
:paramtype callback_url: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
Expand All @@ -469,6 +476,7 @@ def play_media_to_all(
play_source=play_source,
loop=loop,
operation_context=operation_context,
callback_url=callback_url,
**kwargs
)

Expand All @@ -489,6 +497,7 @@ def start_recognizing_media(
choices: Optional[List["Choice"]] = None,
end_silence_timeout_in_ms: Optional[int] = None,
speech_recognition_model_endpoint_id: Optional[str] = None,
callback_url: Optional[str] = None,
**kwargs
) -> None:
"""Recognize tones from specific participant in this call.
Expand Down Expand Up @@ -522,6 +531,8 @@ def start_recognizing_media(
:keyword speech_recognition_model_endpoint_id:
Endpoint id where the custom speech recognition model was deployed.
:paramtype speech_recognition_model_endpoint_id:
:keyword callback_url: Url that overrides original callback URI for this request.
:paramtype callback_url: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
Expand Down Expand Up @@ -570,6 +581,7 @@ def start_recognizing_media(
interrupt_call_media_operation=interrupt_call_media_operation,
operation_context=operation_context,
recognize_options=options,
callback_uri=callback_url
)
self._call_media_client.recognize(
self._call_connection_id,
Expand Down Expand Up @@ -621,6 +633,7 @@ def stop_continuous_dtmf_recognition(
target_participant: 'CommunicationIdentifier',
*,
operation_context: Optional[str] = None,
callback_url: Optional[str] = None,
**kwargs
) -> None:
"""Stop continuous Dtmf recognition by unsubscribing to tones.
Expand All @@ -629,13 +642,16 @@ def stop_continuous_dtmf_recognition(
:type target_participant: ~azure.communication.callautomation.CommunicationIdentifier
:keyword operation_context: The value to identify context of the operation.
:paramtype operation_context: str
:keyword callback_url: Url that overrides original callback URI for this request.
:paramtype callback_url: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
continuous_dtmf_recognition_request = ContinuousDtmfRecognitionRequest(
target_participant=serialize_identifier(target_participant),
operation_context=operation_context
operation_context=operation_context,
callback_uri=callback_url
)
self._call_media_client.stop_continuous_dtmf_recognition(
self._call_connection_id,
Expand All @@ -650,6 +666,7 @@ def send_dtmf(
target_participant: 'CommunicationIdentifier',
*,
operation_context: Optional[str] = None,
callback_url: Optional[str] = None,
**kwargs
) -> None:
"""Send Dtmf tones to this call.
Expand All @@ -660,14 +677,17 @@ def send_dtmf(
:type target_participant: ~azure.communication.callautomation.CommunicationIdentifier
:keyword operation_context: The value to identify context of the operation.
:paramtype operation_context: str
:keyword callback_url: Url that overrides original callback URI for this request.
:paramtype callback_url: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
send_dtmf_request = SendDtmfRequest(
tones=tones,
target_participant=serialize_identifier(target_participant),
operation_context=operation_context
operation_context=operation_context,
callback_uri=callback_url
)
self._call_media_client.send_dtmf(
self._call_connection_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,8 @@ class ContinuousDtmfRecognitionRequest(_serialization.Model):
~azure.communication.callautomation.models.CommunicationIdentifierModel
:ivar operation_context: The value to identify context of the operation.
:vartype operation_context: str
:ivar callback_uri: The callback URI to override the main callback URI.
:vartype callback_uri: str
"""

_validation = {
Expand All @@ -1125,13 +1127,15 @@ class ContinuousDtmfRecognitionRequest(_serialization.Model):
_attribute_map = {
"target_participant": {"key": "targetParticipant", "type": "CommunicationIdentifierModel"},
"operation_context": {"key": "operationContext", "type": "str"},
"callback_uri": {"key": "callbackUri", "type": "str"},
}

def __init__(
self,
*,
target_participant: "_models.CommunicationIdentifierModel",
operation_context: Optional[str] = None,
callback_uri: Optional[str] = None,
**kwargs: Any
) -> None:
"""
Expand All @@ -1140,10 +1144,13 @@ def __init__(
~azure.communication.callautomation.models.CommunicationIdentifierModel
:keyword operation_context: The value to identify context of the operation.
:paramtype operation_context: str
:keyword callback_uri: The callback URI to override the main callback URI.
:paramtype callback_uri: str
"""
super().__init__(**kwargs)
self.target_participant = target_participant
self.operation_context = operation_context
self.callback_uri = callback_uri


class ContinuousDtmfRecognitionStopped(_serialization.Model):
Expand Down Expand Up @@ -2740,6 +2747,8 @@ class PlayRequest(_serialization.Model):
:vartype play_options: ~azure.communication.callautomation.models.PlayOptions
:ivar operation_context: The value to identify context of the operation.
:vartype operation_context: str
:ivar callback_uri: The callback URI to override the main callback URI.
:vartype callback_uri: str
"""

_validation = {
Expand All @@ -2751,6 +2760,7 @@ class PlayRequest(_serialization.Model):
"play_to": {"key": "playTo", "type": "[CommunicationIdentifierModel]"},
"play_options": {"key": "playOptions", "type": "PlayOptions"},
"operation_context": {"key": "operationContext", "type": "str"},
"callback_uri": {"key": "callbackUri", "type": "str"},
}

def __init__(
Expand All @@ -2760,6 +2770,7 @@ def __init__(
play_to: Optional[List["_models.CommunicationIdentifierModel"]] = None,
play_options: Optional["_models.PlayOptions"] = None,
operation_context: Optional[str] = None,
callback_uri: Optional[str] = None,
**kwargs: Any
) -> None:
"""
Expand All @@ -2773,12 +2784,15 @@ def __init__(
:paramtype play_options: ~azure.communication.callautomation.models.PlayOptions
:keyword operation_context: The value to identify context of the operation.
:paramtype operation_context: str
:keyword callback_uri: The callback URI to override the main callback URI.
:paramtype callback_uri: str
"""
super().__init__(**kwargs)
self.play_source_info = play_source_info
self.play_to = play_to
self.play_options = play_options
self.operation_context = operation_context
self.callback_uri = callback_uri


class PlaySource(_serialization.Model):
Expand Down Expand Up @@ -3148,6 +3162,8 @@ class RecognizeRequest(_serialization.Model):
:vartype recognize_options: ~azure.communication.callautomation.models.RecognizeOptions
:ivar operation_context: The value to identify context of the operation.
:vartype operation_context: str
:ivar callback_uri: The callback URI to override the main callback URI.
:vartype callback_uri: str
"""

_validation = {
Expand All @@ -3161,6 +3177,7 @@ class RecognizeRequest(_serialization.Model):
"interrupt_call_media_operation": {"key": "interruptCallMediaOperation", "type": "bool"},
"recognize_options": {"key": "recognizeOptions", "type": "RecognizeOptions"},
"operation_context": {"key": "operationContext", "type": "str"},
"callback_uri": {"key": "callbackUri", "type": "str"},
}

def __init__(
Expand All @@ -3171,6 +3188,7 @@ def __init__(
play_prompt: Optional["_models.PlaySource"] = None,
interrupt_call_media_operation: Optional[bool] = None,
operation_context: Optional[str] = None,
callback_uri: Optional[str] = None,
**kwargs: Any
) -> None:
"""
Expand All @@ -3187,13 +3205,16 @@ def __init__(
:paramtype recognize_options: ~azure.communication.callautomation.models.RecognizeOptions
:keyword operation_context: The value to identify context of the operation.
:paramtype operation_context: str
:keyword callback_uri: The callback URI to override the main callback URI.
:paramtype callback_uri: str
"""
super().__init__(**kwargs)
self.recognize_input_type = recognize_input_type
self.play_prompt = play_prompt
self.interrupt_call_media_operation = interrupt_call_media_operation
self.recognize_options = recognize_options
self.operation_context = operation_context
self.callback_uri = callback_uri


class RecordingStateChanged(_serialization.Model):
Expand Down Expand Up @@ -3742,6 +3763,8 @@ class SendDtmfRequest(_serialization.Model):
~azure.communication.callautomation.models.CommunicationIdentifierModel
:ivar operation_context: The value to identify context of the operation.
:vartype operation_context: str
:ivar callback_uri: The callback URI to override the main callback URI.
:vartype callback_uri: str
"""

_validation = {
Expand All @@ -3753,6 +3776,7 @@ class SendDtmfRequest(_serialization.Model):
"tones": {"key": "tones", "type": "[str]"},
"target_participant": {"key": "targetParticipant", "type": "CommunicationIdentifierModel"},
"operation_context": {"key": "operationContext", "type": "str"},
"callback_uri": {"key": "callbackUri", "type": "str"},
}

def __init__(
Expand All @@ -3761,6 +3785,7 @@ def __init__(
tones: List[Union[str, "_models.DtmfTone"]],
target_participant: "_models.CommunicationIdentifierModel",
operation_context: Optional[str] = None,
callback_uri: Optional[str] = None,
**kwargs: Any
) -> None:
"""
Expand All @@ -3771,11 +3796,14 @@ def __init__(
~azure.communication.callautomation.models.CommunicationIdentifierModel
:keyword operation_context: The value to identify context of the operation.
:paramtype operation_context: str
:keyword callback_uri: The callback URI to override the main callback URI.
:paramtype callback_uri: str
"""
super().__init__(**kwargs)
self.tones = tones
self.target_participant = target_participant
self.operation_context = operation_context
self.callback_uri = callback_uri


class SpeechOptions(_serialization.Model):
Expand Down
Loading

0 comments on commit 1c8ab17

Please sign in to comment.