Skip to content

Commit b3f40f1

Browse files
committed
Update import name and fix unittest.
1 parent e95c68e commit b3f40f1

File tree

15 files changed

+137
-167
lines changed

15 files changed

+137
-167
lines changed

sdk/communication/azure-communication-callingserver/azure/communication/callingserver/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
from ._generated.models import (AddParticipantResult, CallConnectionProperties,
1212
CreateCallRequest, PhoneNumberIdentifierModel,
1313
PlayAudioRequest, PlayAudioResult,
14-
MediaType, EventSubscriptionType,
15-
OperationStatus, CallConnectionStateChangedEvent,
14+
CallMediaType, CallingEventSubscriptionType,
15+
CallingOperationStatus, CallConnectionStateChangedEvent,
1616
ToneReceivedEvent, ToneInfo,
1717
PlayAudioResultEvent, CommunicationIdentifierModel,
1818
CommunicationUserIdentifierModel, AddParticipantResultEvent,
@@ -37,10 +37,10 @@
3737
'CommunicationUserIdentifier',
3838
'CreateCallOptions',
3939
'CreateCallRequest',
40-
'EventSubscriptionType',
40+
'CallingEventSubscriptionType',
4141
'JoinCallOptions',
42-
'MediaType',
43-
'OperationStatus',
42+
'CallMediaType',
43+
'CallingOperationStatus',
4444
'PhoneNumberIdentifier',
4545
'PhoneNumberIdentifierModel',
4646
'PlayAudioOptions',

sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_callingserver_client.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
PhoneNumberIdentifierModel,
2020
PlayAudioResult,
2121
AddParticipantResult,
22-
StartCallRecordingResult,
2322
CallRecordingProperties,
24-
StartCallRecordingRequest,
25-
StartCallRecordingWithCallLocatorRequest
23+
# StartCallRecordingResult,
24+
# StartCallRecordingRequest,
25+
# StartCallRecordingWithCallLocatorRequest
2626
)
2727
from ._shared.models import CommunicationIdentifier
2828
from ._call_connection import CallConnection
@@ -391,33 +391,33 @@ def cancel_participant_media_operation(
391391
**kwargs
392392
)
393393

394-
@distributed_trace()
395-
def start_recording(
396-
self,
397-
call_locator, # type: CallLocator
398-
recording_state_callback_uri, # type: str
399-
**kwargs # type: Any
400-
): # type: (...) -> StartCallRecordingResult
401-
402-
if not call_locator:
403-
raise ValueError("call_locator cannot be None")
404-
if not CallingServerUtils.is_valid_url(recording_state_callback_uri):
405-
raise ValueError("recording_state_callback_uri is invalid")
406-
407-
start_call_recording_request = StartCallRecordingRequest(
408-
recording_state_callback_uri=recording_state_callback_uri,
409-
**kwargs
410-
)
411-
412-
start_call_recording_with_calllocator_request = StartCallRecordingWithCallLocatorRequest(
413-
call_locator=serialize_call_locator(call_locator),
414-
start_call_recording_request=start_call_recording_request
415-
)
416-
417-
return self._server_call_client.start_recording(
418-
start_call_recording_with_call_locator_request=start_call_recording_with_calllocator_request,
419-
**kwargs
420-
)
394+
# @distributed_trace()
395+
# def start_recording(
396+
# self,
397+
# call_locator, # type: CallLocator
398+
# recording_state_callback_uri, # type: str
399+
# **kwargs # type: Any
400+
# ): # type: (...) -> StartCallRecordingResult
401+
402+
# if not call_locator:
403+
# raise ValueError("call_locator cannot be None")
404+
# if not CallingServerUtils.is_valid_url(recording_state_callback_uri):
405+
# raise ValueError("recording_state_callback_uri is invalid")
406+
407+
# start_call_recording_request = StartCallRecordingRequest(
408+
# recording_state_callback_uri=recording_state_callback_uri,
409+
# **kwargs
410+
# )
411+
412+
# start_call_recording_with_calllocator_request = StartCallRecordingWithCallLocatorRequest(
413+
# call_locator=serialize_call_locator(call_locator),
414+
# start_call_recording_request=start_call_recording_request
415+
# )
416+
417+
# return self._server_call_client.start_recording(
418+
# start_call_recording_with_call_locator_request=start_call_recording_with_calllocator_request,
419+
# **kwargs
420+
# )
421421

422422
@distributed_trace()
423423
def pause_recording(

sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_converters/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
AddParticipantWithCallLocatorRequestConverter,
99
RemoveParticipantRequestConverter,
1010
RemoveParticipantWithCallLocatorRequestConverter,
11-
CancelAllMediaOperationsConverter,
12-
CancelMediaOperationRequestConverter,
1311
CancelMediaOperationWithCallLocatorRequestConverter,
1412
CancelParticipantMediaOperationRequestConverter,
1513
CancelParticipantMediaOperationWithCallLocatorRequestConverter,
@@ -26,8 +24,6 @@
2624
'AddParticipantWithCallLocatorRequestConverter',
2725
"RemoveParticipantRequestConverter",
2826
'RemoveParticipantWithCallLocatorRequestConverter',
29-
"CancelAllMediaOperationsConverter",
30-
"CancelMediaOperationRequestConverter",
3127
'CancelMediaOperationWithCallLocatorRequestConverter',
3228
'CancelParticipantMediaOperationRequestConverter',
3329
'CancelParticipantMediaOperationWithCallLocatorRequestConverter',

sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_converters/_converter.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,11 @@ def convert(
8686

8787
return PlayAudioWithCallLocatorRequest(
8888
call_locator=call_locator,
89-
play_audio_request=PlayAudioRequestConverter.convert(
90-
audio_file_uri,
91-
play_audio_options
92-
)
89+
audio_file_uri=audio_file_uri,
90+
loop=play_audio_options.loop,
91+
operation_context=play_audio_options.operation_context,
92+
audio_file_id=play_audio_options.audio_file_id,
93+
callback_uri=play_audio_options.callback_uri
9394
)
9495

9596
class PlayAudioToParticipantRequestConverter(object):
@@ -132,11 +133,12 @@ def convert(
132133

133134
return PlayAudioToParticipantWithCallLocatorRequest(
134135
call_locator=call_locator,
135-
play_audio_to_participant_request=PlayAudioToParticipantRequestConverter.convert(
136-
identifier=identifier,
137-
audio_file_uri=audio_file_uri,
138-
play_audio_options=play_audio_options
139-
)
136+
identifier=identifier,
137+
audio_file_uri=audio_file_uri,
138+
loop=play_audio_options.loop,
139+
operation_context=play_audio_options,
140+
audio_file_id=play_audio_options.audio_file_id,
141+
callback_uri=play_audio_options.callback_uri
140142
)
141143

142144
class AddParticipantRequestConverter(object):
@@ -210,7 +212,7 @@ def convert(
210212

211213
return RemoveParticipantWithCallLocatorRequest(
212214
call_locator=call_locator,
213-
remove_participant_request=RemoveParticipantRequestConverter.convert(identifier)
215+
identifier=identifier
214216
)
215217

216218
class CancelMediaOperationWithCallLocatorRequestConverter(object):
@@ -264,10 +266,8 @@ def convert(
264266

265267
return CancelParticipantMediaOperationWithCallLocatorRequest(
266268
call_locator=call_locator,
267-
cancel_participant_media_operation_request=CancelParticipantMediaOperationRequestConverter.convert(
268-
identifier=identifier,
269-
media_operation_id=media_operation_id
270-
)
269+
identifier=identifier,
270+
media_operation_id=media_operation_id
271271
)
272272

273273
class TransferCallRequestConverter(object):

sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_models.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from typing import List, Mapping, Optional, Union, Any # pylint: disable=unused-import
1010
from enum import Enum, EnumMeta
1111
from six import with_metaclass
12-
from ._generated.models import EventSubscriptionType, MediaType
12+
from ._generated.models import CallingEventSubscriptionType, CallMediaType
1313
from ._shared.models import PhoneNumberIdentifier
1414

1515
try:
@@ -94,16 +94,16 @@ class CreateCallOptions(object):
9494
:ivar callback_uri: Required. The callback URI.
9595
:type callback_uri: str
9696
:ivar requested_media_types: The requested media types.
97-
:type requested_media_types: list[str or ~azure.communication.callingserver.models.MediaType]
97+
:type requested_media_types: list[str or ~azure.communication.callingserver.models.CallMediaType]
9898
:ivar requested_call_events: The requested call events to subscribe to.
9999
:type requested_call_events: list[str or
100-
~azure.communication.callingserver.models.EventSubscriptionType]
100+
~azure.communication.callingserver.models.CallingEventSubscriptionType]
101101
"""
102102
def __init__(
103103
self,
104104
callback_uri, # type: str
105-
requested_media_types, # type: List[MediaType]
106-
requested_call_events # type: List[EventSubscriptionType]
105+
requested_media_types, # type: List[CallMediaType]
106+
requested_call_events # type: List[CallingEventSubscriptionType]
107107
): # type: (...) -> None
108108
try:
109109
if not callback_uri.lower().startswith('http'):
@@ -139,7 +139,7 @@ def requested_media_types(self):
139139

140140
@property
141141
def requested_call_events(self):
142-
# type: () -> List[EventSubscriptionType]
142+
# type: () -> List[CallingEventSubscriptionType]
143143
return self.__requested_call_events
144144

145145
@property
@@ -168,16 +168,16 @@ class JoinCallOptions(object):
168168
:ivar callback_uri: Required. The callback URI.
169169
:type callback_uri: str
170170
:ivar requested_media_types: The requested media types.
171-
:type requested_media_types: list[str or ~azure.communication.callingserver.models.MediaType]
171+
:type requested_media_types: list[str or ~azure.communication.callingserver.models.CallMediaType]
172172
:ivar requested_call_events: The requested call events to subscribe to.
173173
:type requested_call_events: list[str or
174-
~azure.communication.callingserver.models.EventSubscriptionType]
174+
~azure.communication.callingserver.models.CallingEventSubscriptionType]
175175
"""
176176
def __init__(
177177
self,
178178
callback_uri, # type: str
179-
requested_media_types, # type: List[MediaType]
180-
requested_call_events # type: List[EventSubscriptionType]
179+
requested_media_types, # type: List[CallMediaType]
180+
requested_call_events # type: List[CallingEventSubscriptionType]
181181
): # type: (...) -> None
182182
try:
183183
if not callback_uri.lower().startswith('http'):
@@ -207,12 +207,12 @@ def callback_uri(self):
207207

208208
@property
209209
def requested_media_types(self):
210-
# type: () -> List[MediaType]
210+
# type: () -> List[CallMediaType]
211211
return self.__requested_media_types
212212

213213
@property
214214
def requested_call_events(self):
215-
# type: () -> List[EventSubscriptionType]
215+
# type: () -> List[CallingEventSubscriptionType]
216216
return self.__requested_call_events
217217

218218
@property

sdk/communication/azure-communication-callingserver/azure/communication/callingserver/aio/_callingserver_client_async.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
PhoneNumberIdentifierModel,
2424
PlayAudioResult,
2525
AddParticipantResult,
26-
StartCallRecordingResult,
2726
CallRecordingProperties,
28-
StartCallRecordingWithCallLocatorRequest,
29-
StartCallRecordingRequest
27+
# StartCallRecordingResult,
28+
# StartCallRecordingRequest,
29+
# StartCallRecordingWithCallLocatorRequest
3030
)
3131
from .._shared.models import CommunicationIdentifier
3232
from ._content_downloader_async import ContentDownloader
@@ -396,33 +396,33 @@ async def cancel_participant_media_operation(
396396
**kwargs
397397
)
398398

399-
@distributed_trace_async()
400-
async def start_recording(
401-
self,
402-
call_locator: CallLocator,
403-
recording_state_callback_uri: str,
404-
**kwargs: Any
405-
) -> StartCallRecordingResult:
406-
407-
if not call_locator:
408-
raise ValueError("call_locator cannot be None")
409-
if not CallingServerUtils.is_valid_url(recording_state_callback_uri):
410-
raise ValueError("recording_state_callback_uri is invalid")
411-
412-
start_call_recording_request = StartCallRecordingRequest(
413-
recording_state_callback_uri=recording_state_callback_uri,
414-
**kwargs
415-
)
416-
417-
start_call_recording_with_calllocator_request = StartCallRecordingWithCallLocatorRequest(
418-
call_locator=serialize_call_locator(call_locator),
419-
start_call_recording_request=start_call_recording_request
420-
)
421-
422-
return await self._server_call_client.start_recording(
423-
start_call_recording_with_calllocator_request,
424-
**kwargs
425-
)
399+
# @distributed_trace_async()
400+
# async def start_recording(
401+
# self,
402+
# call_locator: CallLocator,
403+
# recording_state_callback_uri: str,
404+
# **kwargs: Any
405+
# ) -> StartCallRecordingResult:
406+
407+
# if not call_locator:
408+
# raise ValueError("call_locator cannot be None")
409+
# if not CallingServerUtils.is_valid_url(recording_state_callback_uri):
410+
# raise ValueError("recording_state_callback_uri is invalid")
411+
412+
# start_call_recording_request = StartCallRecordingRequest(
413+
# recording_state_callback_uri=recording_state_callback_uri,
414+
# **kwargs
415+
# )
416+
417+
# start_call_recording_with_calllocator_request = StartCallRecordingWithCallLocatorRequest(
418+
# call_locator=serialize_call_locator(call_locator),
419+
# start_call_recording_request=start_call_recording_request
420+
# )
421+
422+
# return await self._server_call_client.start_recording(
423+
# start_call_recording_with_calllocator_request,
424+
# **kwargs
425+
# )
426426

427427
@distributed_trace_async()
428428
async def pause_recording(

sdk/communication/azure-communication-callingserver/samples/callingserver_samples.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ def create_call_connection(self):
5050
endpoint = self.endpoint
5151
from_user = self.user
5252
# [START create_call_connection]
53-
from azure.communication.callingserver import PhoneNumberIdentifier, CreateCallOptions, MediaType, EventSubscriptionType
53+
from azure.communication.callingserver import PhoneNumberIdentifier, CreateCallOptions, CallMediaType, CallingEventSubscriptionType
5454
from azure.communication.callingserver import CallingServerClient
5555
from azure.identity import DefaultAzureCredential
56-
to_user = PhoneNumberIdentifier(self.to_phone_number)
56+
to_user = PhoneNumberIdentifier("<your-phone-number>")
5757
options = CreateCallOptions(
5858
callback_uri="<your-callback-uri>",
59-
requested_media_types=[MediaType.AUDIO],
60-
requested_call_events=[EventSubscriptionType.PARTICIPANTS_UPDATED, EventSubscriptionType.DTMF_RECEIVED]
59+
requested_media_types=[CallMediaType.AUDIO],
60+
requested_call_events=[CallingEventSubscriptionType.PARTICIPANTS_UPDATED, CallingEventSubscriptionType.TONE_RECEIVED]
6161
)
6262
# set `endpoint` to an existing ACS endpoint
6363
calling_server_client = CallingServerClient(endpoint, DefaultAzureCredential())
@@ -76,14 +76,14 @@ def create_server_call_with_calllocator(self):
7676
from_user = self.user
7777
# [START create_server_call_with_calllocator]
7878
# set `endpoint` to an existing ACS endpoint
79-
from azure.communication.callingserver import ServerCallLocator, CommunicationUserIdentifier, MediaType, EventSubscriptionType, JoinCallOptions
79+
from azure.communication.callingserver import ServerCallLocator, CommunicationUserIdentifier, CallMediaType, CallingEventSubscriptionType, JoinCallOptions
8080
from azure.communication.callingserver import CallingServerClient
8181
from azure.identity import DefaultAzureCredential
8282

8383
join_options = JoinCallOptions(
8484
callback_uri="<your-callback-uri>",
85-
requested_media_types=[MediaType.AUDIO],
86-
requested_call_events=[EventSubscriptionType.PARTICIPANTS_UPDATED]
85+
requested_media_types=[CallMediaType.AUDIO],
86+
requested_call_events=[CallingEventSubscriptionType.PARTICIPANTS_UPDATED]
8787
)
8888
# set `endpoint` to an existing ACS endpoint
8989
calling_server_client = CallingServerClient(endpoint, DefaultAzureCredential())

sdk/communication/azure-communication-callingserver/tests/test_call_connection.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ def test_cancel_all_media_operations_succeed(
103103
self,
104104
test_name, # type: str
105105
call_connection_id, # type: str
106-
operation_context = None, # type: str
107106
use_managed_identity = False # type: bool
108107
):
109108

@@ -114,8 +113,8 @@ def test_cancel_all_media_operations_succeed(
114113
use_managed_identity=use_managed_identity
115114
)
116115

117-
result = call_connection.cancel_all_media_operations(operation_context)
118-
CallConnectionUnitTestUtils.verify_cancel_all_media_operations_result(result)
116+
call_connection.cancel_all_media_operations()
117+
assert call_connection.call_connection_id == _test_constants.CALL_ID
119118

120119
@parameterized.expand(CallConnectionUnitTestUtils.data_source_test_cancel_all_media_operations())
121120
def test_cancel_all_media_operations_failed(

sdk/communication/azure-communication-callingserver/tests/test_call_connection_async.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ async def test_hang_up_failed(
101101
async def test_cancel_all_media_operations_succeed(
102102
test_name, # type: str
103103
call_connection_id, # type: str
104-
operation_context = None, # type: str
105104
use_managed_identity = False # type: bool
106105
):
107106

@@ -112,8 +111,8 @@ async def test_cancel_all_media_operations_succeed(
112111
use_managed_identity=use_managed_identity
113112
)
114113

115-
result = await call_connection.cancel_all_media_operations(operation_context)
116-
CallConnectionUnitTestUtils.verify_cancel_all_media_operations_result(result)
114+
await call_connection.cancel_all_media_operations()
115+
assert call_connection.call_connection_id == _test_constants.CALL_ID
117116

118117
@parameterized.expand(CallConnectionUnitTestUtils.data_source_test_cancel_all_media_operations())
119118
@pytest.mark.asyncio

0 commit comments

Comments
 (0)