Skip to content

Commit 02176a1

Browse files
author
Vinothini Dharmaraj
committed
connect api merge changes
1 parent 55cb076 commit 02176a1

File tree

19 files changed

+891
-175
lines changed

19 files changed

+891
-175
lines changed

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

Lines changed: 168 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
RedirectCallRequest,
2424
RejectCallRequest,
2525
StartCallRecordingRequest,
26-
CallIntelligenceOptions
26+
CallIntelligenceOptions,
27+
ConnectRequest
2728
)
2829
from ._models import (
2930
CallConnectionProperties,
@@ -46,6 +47,7 @@
4647
from ._models import (
4748
ServerCallLocator,
4849
GroupCallLocator,
50+
RoomCallLocator,
4951
MediaStreamingOptions,
5052
TranscriptionOptions
5153
)
@@ -168,6 +170,118 @@ def get_call_connection( # pylint: disable=client-method-missing-tracing-decorat
168170
**kwargs
169171
)
170172

173+
@overload
174+
def connect_call(
175+
self,
176+
*,
177+
server_call_id: str,
178+
callback_url: str,
179+
cognitive_services_endpoint: Optional[str] = None,
180+
operation_context: Optional[str] = None,
181+
**kwargs
182+
) -> CallConnectionProperties:
183+
"""The request payload for creating a connection to a room CallLocator.
184+
All required parameters must be populated in order to send to server.
185+
:keyword server_call_id: The server call ID to locate ongoing call.
186+
:paramtype server_call_id: str
187+
:keyword callback_url: The call back url where callback events are sent. Required
188+
:paramtype callback_url: str
189+
:keyword cognitive_services_endpoint:
190+
The identifier of the Cognitive Service resource assigned to this call.
191+
:paramtype cognitive_services_endpoint: str or None
192+
:keyword operation_context: Value that can be used to track the call and its associated events.
193+
:paramtype operation_context: str or None
194+
:return: CallConnectionProperties
195+
:rtype: ~azure.communication.callautomation.CallConnectionProperties
196+
:raises ~azure.core.exceptions.HttpResponseError:
197+
"""
198+
199+
@overload
200+
def connect_call(
201+
self,
202+
*,
203+
group_call_id: str,
204+
callback_url: str,
205+
cognitive_services_endpoint: Optional[str] = None,
206+
operation_context: Optional[str] = None,
207+
**kwargs
208+
) -> CallConnectionProperties:
209+
"""The request payload for creating a connection to a room CallLocator.
210+
All required parameters must be populated in order to send to server.
211+
:keyword group_call_id: The group call ID to locate ongoing call.
212+
:paramtype group_call_id: str
213+
:keyword callback_url: The call back url where callback events are sent. Required
214+
:paramtype callback_url: str
215+
:keyword cognitive_services_endpoint:
216+
The identifier of the Cognitive Service resource assigned to this call.
217+
:paramtype cognitive_services_endpoint: str or None
218+
:keyword operation_context: Value that can be used to track the call and its associated events.
219+
:paramtype operation_context: str or None
220+
:return: CallConnectionProperties
221+
:rtype: ~azure.communication.callautomation.CallConnectionProperties
222+
:raises ~azure.core.exceptions.HttpResponseError:
223+
"""
224+
225+
@overload
226+
def connect_call(
227+
self,
228+
*,
229+
room_id: str,
230+
callback_url: str,
231+
cognitive_services_endpoint: Optional[str] = None,
232+
operation_context: Optional[str] = None,
233+
**kwargs
234+
) -> CallConnectionProperties:
235+
"""The request payload for creating a connection to a room CallLocator.
236+
All required parameters must be populated in order to send to server.
237+
:keyword room_id: Acs room id. Required
238+
:paramtype room_id: str
239+
:keyword callback_url: The call back url where callback events are sent. Required
240+
:paramtype callback_url: str
241+
:keyword cognitive_services_endpoint:
242+
The identifier of the Cognitive Service resource assigned to this call.
243+
:paramtype cognitive_services_endpoint: str or None
244+
:keyword operation_context: Value that can be used to track the call and its associated events.
245+
:paramtype operation_context: str or None
246+
:return: CallConnectionProperties
247+
:rtype: ~azure.communication.callautomation.CallConnectionProperties
248+
:raises ~azure.core.exceptions.HttpResponseError:
249+
"""
250+
251+
@distributed_trace
252+
def connect_call(
253+
self,
254+
*args: Union['ServerCallLocator', 'GroupCallLocator', 'RoomCallLocator'],
255+
**kwargs
256+
) -> CallConnectionProperties:
257+
258+
cognitive_services_endpoint=kwargs.pop("cognitive_services_endpoint", None)
259+
call_intelligence_options = CallIntelligenceOptions(
260+
cognitive_services_endpoint=cognitive_services_endpoint
261+
) if cognitive_services_endpoint else None
262+
263+
call_locator = build_call_locator(
264+
args,
265+
kwargs.pop("call_locator", None),
266+
kwargs.pop("server_call_id", None),
267+
kwargs.pop("group_call_id", None),
268+
kwargs.pop("room_id", None)
269+
)
270+
connect_call_request = ConnectRequest(
271+
call_locator=call_locator,
272+
callback_uri=kwargs.pop("callback_url", None),
273+
operation_context=kwargs.pop("operation_context", None),
274+
call_intelligence_options=call_intelligence_options
275+
)
276+
277+
process_repeatability_first_sent(kwargs)
278+
result = self._client.connect(
279+
connect_request=connect_call_request,
280+
**kwargs
281+
)
282+
283+
return CallConnectionProperties._from_generated(result) # pylint:disable=protected-access
284+
171285
@distributed_trace
172286
def create_call(
173287
self,
@@ -516,10 +630,60 @@ def start_recording(
516630
:raises ~azure.core.exceptions.HttpResponseError:
517631
"""
518632

633+
@overload
634+
def start_recording(
635+
self,
636+
*,
637+
room_id: str,
638+
recording_state_callback_url: Optional[str] = None,
639+
recording_content_type: Optional[Union[str, 'RecordingContent']] = None,
640+
recording_channel_type: Optional[Union[str, 'RecordingChannel']] = None,
641+
recording_format_type: Optional[Union[str, 'RecordingFormat']] = None,
642+
audio_channel_participant_ordering: Optional[List['CommunicationIdentifier']] = None,
643+
channel_affinity: Optional[List['ChannelAffinity']] = None,
644+
recording_storage: Optional[Union['AzureCommunicationsRecordingStorage',
645+
'AzureBlobContainerRecordingStorage']] = None,
646+
pause_on_start: Optional[bool] = None,
647+
**kwargs
648+
) -> RecordingProperties:
649+
"""Start recording for a ongoing call. Locate the call with call locator.
650+
:keyword str room_id: The acs room id to locate ongoing call.
651+
:keyword recording_state_callback_url: The url to send notifications to.
652+
:paramtype recording_state_callback_url: str or None
653+
:keyword recording_content_type: The content type of call recording.
654+
:paramtype recording_content_type: str or ~azure.communication.callautomation.RecordingContent or None
655+
:keyword recording_channel_type: The channel type of call recording.
656+
:paramtype recording_channel_type: str or ~azure.communication.callautomation.RecordingChannel or None
657+
:keyword recording_format_type: The format type of call recording.
658+
:paramtype recording_format_type: str or ~azure.communication.callautomation.RecordingFormat or None
659+
:keyword audio_channel_participant_ordering:
660+
The sequential order in which audio channels are assigned to participants in the unmixed recording.
661+
When 'recordingChannelType' is set to 'unmixed' and `audioChannelParticipantOrdering is not specified,
662+
the audio channel to participant mapping will be automatically assigned based on the order in
663+
which participant first audio was detected.
664+
Channel to participant mapping details can be found in the metadata of the recording.
665+
:paramtype audio_channel_participant_ordering:
666+
list[~azure.communication.callautomation.CommunicationIdentifier] or None
667+
:keyword channel_affinity: The channel affinity of call recording
668+
When 'recordingChannelType' is set to 'unmixed', if channelAffinity is not specified,
669+
'channel' will be automatically assigned.
670+
Channel-Participant mapping details can be found in the metadata of the recording.
671+
:paramtype channel_affinity: list[~azure.communication.callautomation.ChannelAffinity] or None
672+
:keyword recording_storage: Defines the kind of external storage. Known values are:
673+
``AzureCommunicationsRecordingStorage`` and ``AzureBlobContainerRecordingStorage``.
674+
If no storage option is provided, the default is Azure Communications recording storage.
675+
:paramtype recording_storage: AzureCommunicationsRecordingStorage or AzureBlobContainerRecordingStorage or None
676+
:keyword pause_on_start: The state of the pause on start option.
677+
:paramtype pause_on_start: bool or None
678+
:return: RecordingProperties
679+
:rtype: ~azure.communication.callautomation.RecordingProperties
680+
:raises ~azure.core.exceptions.HttpResponseError:
681+
"""
682+
519683
@distributed_trace
520684
def start_recording(
521685
self,
522-
*args: Union['ServerCallLocator', 'GroupCallLocator'],
686+
*args: Union['ServerCallLocator', 'GroupCallLocator', 'RoomCallLocator'],
523687
**kwargs
524688
) -> RecordingProperties:
525689
# pylint:disable=protected-access
@@ -529,7 +693,8 @@ def start_recording(
529693
args,
530694
kwargs.pop("call_locator", None),
531695
kwargs.pop("server_call_id", None),
532-
kwargs.pop("group_call_id", None)
696+
kwargs.pop("group_call_id", None),
697+
kwargs.pop("room_id", None)
533698
)
534699
external_storage = build_external_storage(kwargs.pop("recording_storage", None))
535700

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ def add_participant(
372372
add_participant_request,
373373
**kwargs
374374
)
375+
print(f"Response from add participant: {response}")
375376
return AddParticipantResult._from_generated(response) # pylint:disable=protected-access
376377

377378
@distributed_trace

sdk/communication/azure-communication-callautomation/azure/communication/callautomation/_generated/_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from copy import deepcopy
1010
from typing import Any
11+
from typing_extensions import Self
1112

1213
from azure.core import PipelineClient
1314
from azure.core.credentials import AzureKeyCredential
@@ -108,7 +109,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
108109
def close(self) -> None:
109110
self._client.close()
110111

111-
def __enter__(self) -> "AzureCommunicationCallAutomationService":
112+
def __enter__(self) -> Self:
112113
self._client.__enter__()
113114
return self
114115

sdk/communication/azure-communication-callautomation/azure/communication/callautomation/_generated/_serialization.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ def _json_attemp(data):
144144
# context otherwise.
145145
_LOGGER.critical("Wasn't XML not JSON, failing")
146146
raise DeserializationError("XML is invalid") from err
147+
elif content_type.startswith("text/"):
148+
return data_as_str
147149
raise DeserializationError("Cannot deserialize content-type: {}".format(content_type))
148150

149151
@classmethod
@@ -1441,7 +1443,7 @@ def _deserialize(self, target_obj, data):
14411443
elif isinstance(response, type) and issubclass(response, Enum):
14421444
return self.deserialize_enum(data, response)
14431445

1444-
if data is None:
1446+
if data is None or data is CoreNull:
14451447
return data
14461448
try:
14471449
attributes = response._attribute_map # type: ignore

sdk/communication/azure-communication-callautomation/azure/communication/callautomation/_generated/aio/_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from copy import deepcopy
1010
from typing import Any, Awaitable
11+
from typing_extensions import Self
1112

1213
from azure.core import AsyncPipelineClient
1314
from azure.core.credentials import AzureKeyCredential
@@ -111,7 +112,7 @@ def send_request(
111112
async def close(self) -> None:
112113
await self._client.close()
113114

114-
async def __aenter__(self) -> "AzureCommunicationCallAutomationService":
115+
async def __aenter__(self) -> Self:
115116
await self._client.__aenter__()
116117
return self
117118

0 commit comments

Comments
 (0)