Skip to content

Commit

Permalink
updated OPS outgoing call feature (Azure#38928)
Browse files Browse the repository at this point in the history
* updated OPS outgoing call feature

* fixed pipeline compliant
  • Loading branch information
juntuchen-msft authored Dec 18, 2024
1 parent a1a6086 commit b1291b0
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def __init__(
*,
api_version: Optional[str] = None,
source: Optional["CommunicationUserIdentifier"] = None,
ops_source: Optional["MicrosoftTeamsAppIdentifier"] = None,
**kwargs,
) -> None:
if not credential:
Expand Down Expand Up @@ -137,7 +136,6 @@ def __init__(
self._call_recording_client = self._client.call_recording
self._downloader = ContentDownloader(self._call_recording_client)
self.source = source
self.ops_source = ops_source

@classmethod
def from_connection_string(cls, conn_str: str, **kwargs) -> "CallAutomationClient":
Expand Down Expand Up @@ -324,6 +322,7 @@ def create_call(
voip_headers: Optional[Dict[str, str]] = None,
media_streaming: Optional['MediaStreamingOptions'] = None,
transcription: Optional['TranscriptionOptions'] = None,
teams_app_source: Optional['MicrosoftTeamsAppIdentifier'] = None,
**kwargs
) -> CallConnectionProperties:
"""Create a call connection request to a target identity.
Expand Down Expand Up @@ -354,6 +353,10 @@ def create_call(
:keyword transcription: Configuration of live transcription.
:paramtype transcription: ~azure.communication.callautomation.TranscriptionOptions
or None
:keyword teams_app_source: Overrides default client source by a MicrosoftTeamsAppIdentifier type source.
Required for creating call with Teams resource account ID.
This is per-operation setting and does not change the client's default source.
:paramtype teams_app_source: ~azure.communication.callautomation.MicrosoftTeamsAppIdentifier or None
:return: CallConnectionProperties
:rtype: ~azure.communication.callautomation.CallConnectionProperties
:raises ~azure.core.exceptions.HttpResponseError:
Expand Down Expand Up @@ -386,7 +389,7 @@ def create_call(
source_caller_id_number=serialize_phone_identifier(source_caller_id_number),
source_display_name=source_display_name,
source=serialize_communication_user_identifier(self.source),
ops_source=serialize_msft_teams_app_identifier(self.ops_source),
teams_app_source=serialize_msft_teams_app_identifier(teams_app_source),
operation_context=operation_context,
call_intelligence_options=call_intelligence_options,
media_streaming_options=media_config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def _create_xml_node(tag, prefix=None, ns=None):
return ET.Element(tag)


class Model(object):
class Model:
"""Mixin for all client request body/response body models to support
serialization and deserialization.
"""
Expand Down Expand Up @@ -563,7 +563,7 @@ def _decode_attribute_map_key(key):
return key.replace("\\.", ".")


class Serializer(object): # pylint: disable=too-many-public-methods
class Serializer: # pylint: disable=too-many-public-methods
"""Request object model serializer."""

basic_types = {str: "str", int: "int", bool: "bool", float: "float"}
Expand Down Expand Up @@ -1441,7 +1441,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument
return children[0]


class Deserializer(object):
class Deserializer:
"""Response object model deserializer.
:param dict classes: Class type dictionary for deserializing complex types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
HoldAudioStarted,
HoldFailed,
HoldRequest,
IncomingCall,
InterruptAudioAndAnnounceRequest,
MediaStreamingFailed,
MediaStreamingOptions,
Expand Down Expand Up @@ -235,6 +236,7 @@
"HoldAudioStarted",
"HoldFailed",
"HoldRequest",
"IncomingCall",
"InterruptAudioAndAnnounceRequest",
"MediaStreamingFailed",
"MediaStreamingOptions",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2024,8 +2024,9 @@ class CreateCallRequest(_serialization.Model):
:ivar call_intelligence_options: AI options for the call.
:vartype call_intelligence_options:
~azure.communication.callautomation.models.CallIntelligenceOptions
:ivar ops_source: The identifier of the source in an OPS call.
:vartype ops_source:
:ivar teams_app_source: The identifier of the source for creating call with Teams resource
account ID.
:vartype teams_app_source:
~azure.communication.callautomation.models.MicrosoftTeamsAppIdentifierModel
:ivar custom_calling_context: Used by customer to send custom calling context to targets.
:vartype custom_calling_context:
Expand All @@ -2050,7 +2051,7 @@ class CreateCallRequest(_serialization.Model):
"operation_context": {"key": "operationContext", "type": "str"},
"callback_uri": {"key": "callbackUri", "type": "str"},
"call_intelligence_options": {"key": "callIntelligenceOptions", "type": "CallIntelligenceOptions"},
"ops_source": {"key": "opsSource", "type": "MicrosoftTeamsAppIdentifierModel"},
"teams_app_source": {"key": "teamsAppSource", "type": "MicrosoftTeamsAppIdentifierModel"},
"custom_calling_context": {"key": "customCallingContext", "type": "CustomCallingContext"},
"media_streaming_options": {"key": "mediaStreamingOptions", "type": "MediaStreamingOptions"},
"transcription_options": {"key": "transcriptionOptions", "type": "TranscriptionOptions"},
Expand All @@ -2066,7 +2067,7 @@ def __init__(
source: Optional["_models.CommunicationUserIdentifierModel"] = None,
operation_context: Optional[str] = None,
call_intelligence_options: Optional["_models.CallIntelligenceOptions"] = None,
ops_source: Optional["_models.MicrosoftTeamsAppIdentifierModel"] = None,
teams_app_source: Optional["_models.MicrosoftTeamsAppIdentifierModel"] = None,
custom_calling_context: Optional["_models.CustomCallingContext"] = None,
media_streaming_options: Optional["_models.MediaStreamingOptions"] = None,
transcription_options: Optional["_models.TranscriptionOptions"] = None,
Expand All @@ -2092,8 +2093,9 @@ def __init__(
:keyword call_intelligence_options: AI options for the call.
:paramtype call_intelligence_options:
~azure.communication.callautomation.models.CallIntelligenceOptions
:keyword ops_source: The identifier of the source in an OPS call.
:paramtype ops_source:
:keyword teams_app_source: The identifier of the source for creating call with Teams resource
account ID.
:paramtype teams_app_source:
~azure.communication.callautomation.models.MicrosoftTeamsAppIdentifierModel
:keyword custom_calling_context: Used by customer to send custom calling context to targets.
:paramtype custom_calling_context:
Expand All @@ -2113,7 +2115,7 @@ def __init__(
self.operation_context = operation_context
self.callback_uri = callback_uri
self.call_intelligence_options = call_intelligence_options
self.ops_source = ops_source
self.teams_app_source = teams_app_source
self.custom_calling_context = custom_calling_context
self.media_streaming_options = media_streaming_options
self.transcription_options = transcription_options
Expand Down Expand Up @@ -3435,6 +3437,67 @@ def __init__(
self.operation_callback_uri = operation_callback_uri


class IncomingCall(_serialization.Model):
"""The incoming call event.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar to: The communication identifier of the target user.
:vartype to: ~azure.communication.callautomation.models.CommunicationIdentifierModel
:ivar from_property: The communication identifier of the user who initiated the call.
:vartype from_property: ~azure.communication.callautomation.models.CommunicationIdentifierModel
:ivar caller_display_name: Display name of caller.
:vartype caller_display_name: str
:ivar server_call_id: The server call id.
:vartype server_call_id: str
:ivar custom_context: Custom Context of Incoming Call.
:vartype custom_context: ~azure.communication.callautomation.models.CustomCallingContext
:ivar incoming_call_context: Incoming call context.
:vartype incoming_call_context: str
:ivar on_behalf_of_callee: The communication identifier of the user on behalf of whom the call
is made.
:vartype on_behalf_of_callee:
~azure.communication.callautomation.models.CommunicationIdentifierModel
:ivar correlation_id: Correlation ID for event to call correlation. Also called ChainId for
skype chain ID.
:vartype correlation_id: str
"""

_validation = {
"to": {"readonly": True},
"from_property": {"readonly": True},
"caller_display_name": {"readonly": True},
"server_call_id": {"readonly": True},
"custom_context": {"readonly": True},
"incoming_call_context": {"readonly": True},
"on_behalf_of_callee": {"readonly": True},
"correlation_id": {"readonly": True},
}

_attribute_map = {
"to": {"key": "to", "type": "CommunicationIdentifierModel"},
"from_property": {"key": "from", "type": "CommunicationIdentifierModel"},
"caller_display_name": {"key": "callerDisplayName", "type": "str"},
"server_call_id": {"key": "serverCallId", "type": "str"},
"custom_context": {"key": "customContext", "type": "CustomCallingContext"},
"incoming_call_context": {"key": "incomingCallContext", "type": "str"},
"on_behalf_of_callee": {"key": "onBehalfOfCallee", "type": "CommunicationIdentifierModel"},
"correlation_id": {"key": "correlationId", "type": "str"},
}

def __init__(self, **kwargs: Any) -> None:
""" """
super().__init__(**kwargs)
self.to = None
self.from_property = None
self.caller_display_name = None
self.server_call_id = None
self.custom_context = None
self.incoming_call_context = None
self.on_behalf_of_callee = None
self.correlation_id = None


class InterruptAudioAndAnnounceRequest(_serialization.Model):
"""InterruptAudioAndAnnounceRequest.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ def __init__(
*,
api_version: Optional[str] = None,
source: Optional["CommunicationUserIdentifier"] = None,
ops_source: Optional["MicrosoftTeamsAppIdentifier"] = None,
**kwargs,
) -> None:
if not credential:
Expand Down Expand Up @@ -137,7 +136,6 @@ def __init__(
self._call_recording_client = self._client.call_recording
self._downloader = ContentDownloader(self._call_recording_client)
self.source = source
self.ops_source = ops_source

@classmethod
def from_connection_string(cls, conn_str: str, **kwargs) -> "CallAutomationClient":
Expand Down Expand Up @@ -323,6 +321,7 @@ async def create_call(
voip_headers: Optional[Dict[str, str]] = None,
media_streaming: Optional['MediaStreamingOptions'] = None,
transcription: Optional['TranscriptionOptions'] = None,
teams_app_source: Optional['MicrosoftTeamsAppIdentifier'] = None,
**kwargs
) -> CallConnectionProperties:
"""Create a call connection request to a target identity.
Expand Down Expand Up @@ -353,6 +352,10 @@ async def create_call(
:keyword transcription: Configuration of live transcription.
:paramtype transcription: ~azure.communication.callautomation.TranscriptionOptions
or None
:keyword teams_app_source: Overrides default client source by a MicrosoftTeamsAppIdentifier type source.
Required for creating call with Teams resource account ID.
This is per-operation setting and does not change the client's default source.
:paramtype teams_app_source: ~azure.communication.callautomation.MicrosoftTeamsAppIdentifier or None
:return: CallConnectionProperties
:rtype: ~azure.communication.callautomation.CallConnectionProperties
:raises ~azure.core.exceptions.HttpResponseError:
Expand Down Expand Up @@ -384,7 +387,7 @@ async def create_call(
source_caller_id_number=serialize_phone_identifier(source_caller_id_number),
source_display_name=source_display_name,
source=serialize_communication_user_identifier(self.source),
ops_source=serialize_msft_teams_app_identifier(self.ops_source),
teams_app_source=serialize_msft_teams_app_identifier(teams_app_source),
operation_context=operation_context,
media_streaming_options=media_config,
transcription_options=transcription_config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ autorest SWAGGER.md

```yaml
tag: package-2024-09-01-preview
require: https://github.com/Azure/azure-rest-api-specs/blob/7347874bc2794b2770c3e7618bd1a5ccab53cb54/specification/communication/data-plane/CallAutomation/readme.md
require: https://github.com/Azure/azure-rest-api-specs/blob/691fea3efb9ff22b20904e92d5116223f452a3b1/specification/communication/data-plane/CallAutomation/readme.md
output-folder: ../azure/communication/callautomation/_generated
models-mode: msrest
namespace: azure.communication.callautomation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,16 @@ def mock_send(request, **kwargs):
call_automation_client = CallAutomationClient(
"https://endpoint",
AzureKeyCredential("fakeCredential=="),
transport=Mock(send=mock_send),
ops_source=caller,
transport=Mock(send=mock_send)
)
call_connection_properties = call_automation_client.create_call(call_invite, self.callback_url)
call_connection_properties = call_automation_client.create_call(call_invite,
self.callback_url,
teams_app_source=caller)
self.assertEqual(self.call_connection_id, call_connection_properties.call_connection_id)
self.assertEqual(self.server_callI_id, call_connection_properties.server_call_id)
self.assertEqual(self.callback_url, call_connection_properties.callback_url)
self.assertEqual(self.microsoft_teams_app_id, call_connection_properties.source.raw_id)
self.assertEqual(self.another_microsoft_teams_app_id, call_connection_properties.targets[0].raw_id)
print(call_connection_properties.targets[0])

def test_create_group_call(self):
def mock_send(_, **kwargs):
Expand Down

0 comments on commit b1291b0

Please sign in to comment.