Skip to content

Commit

Permalink
Onboard 2021-11-15-preview apis and UT.
Browse files Browse the repository at this point in the history
  • Loading branch information
zihzhan-msft committed Oct 13, 2021
1 parent 47fd76c commit 90abaeb
Show file tree
Hide file tree
Showing 13 changed files with 3,830 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@

from ._call_connection import CallConnection
from ._callingserver_client import CallingServerClient
from ._generated.models import (AddParticipantResult, CallConnectionProperties,
CreateCallRequest, PhoneNumberIdentifierModel,
PlayAudioRequest, PlayAudioResult,
from ._generated.models import (AudioRoutingMode, AddParticipantResult, CallConnectionProperties,
CallRejectReason, CreateCallRequest, PhoneNumberIdentifierModel,
PlayAudioRequest, PlayAudioResult, CallParticipant,
CallMediaType, CallingEventSubscriptionType,
CallingOperationStatus, CallConnectionStateChangedEvent,
ToneReceivedEvent, ToneInfo,
PlayAudioResultEvent, CommunicationIdentifierModel,
CommunicationUserIdentifierModel, AddParticipantResultEvent,
CallConnectionState, ToneValue)
CallConnectionState, ToneValue, AnswerCallResult, AudioRoutingGroupResult,
CreateAudioRoutingGroupResult)
from ._models import (
CreateCallOptions,
JoinCallOptions,
Expand All @@ -29,7 +30,10 @@
from ._shared.models import CommunicationIdentifier, CommunicationUserIdentifier, PhoneNumberIdentifier

__all__ = [
'AudioRoutingMode',
'AddParticipantResult',
'CallParticipant',
'CallRejectReason',
'CallConnectionProperties',
'CallConnection',
'CallingServerClient',
Expand Down Expand Up @@ -58,6 +62,9 @@
'AddParticipantResultEvent',
'CallConnectionState',
'ToneValue',
'CallingServerEventType'
'CallingServerEventType',
'AnswerCallResult',
'AudioRoutingGroupResult',
'CreateAudioRoutingGroupResult'
]
__version__ = VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,35 @@
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
from typing import TYPE_CHECKING, Any, Optional # pylint: disable=unused-import
# pylint: disable=too-many-public-methods
from typing import TYPE_CHECKING, List, Any, Optional # pylint: disable=unused-import
from azure.core.tracing.decorator import distributed_trace
from .utils._utils import CallingServerUtils
from ._communication_identifier_serializer import serialize_identifier
from ._converters import (
AddParticipantRequestConverter,
GetParticipantRequestConverter,
RemoveParticipantRequestConverter,
TransferCallRequestConverter,
CancelParticipantMediaOperationRequestConverter,
PlayAudioRequestConverter,
PlayAudioToParticipantRequestConverter
PlayAudioToParticipantRequestConverter,
AudioRoutingGroupRequestConverter,
MuteParticipantRequestConverter,
UnmuteParticipantRequestConverter,
HoldMeetingAudioRequestConverter,
ResumeMeetingAudioRequestConverter,
UpdateAudioRoutingGroupRequestConverter
)
from ._generated.models import (
AddParticipantResult,
CallConnectionProperties,
PhoneNumberIdentifierModel,
PlayAudioResult
PlayAudioResult,
AudioRoutingGroupResult,
CreateAudioRoutingGroupResult,
CallParticipant,
AudioRoutingMode
)
from ._shared.models import CommunicationIdentifier

Expand Down Expand Up @@ -48,6 +60,17 @@ def get_call(
**kwargs
)

@distributed_trace()
def delete_call(
self,
**kwargs # type: Any
): # type: (...) -> None

return self._call_connection_client.delete_call(
call_connection_id=self.call_connection_id,
**kwargs
)

@distributed_trace()
def hang_up(
self,
Expand All @@ -59,6 +82,17 @@ def hang_up(
**kwargs
)

@distributed_trace()
def keep_alive(
self,
**kwargs # type: Any
): # type: (...) -> None

return self._call_connection_client.keep_alive(
call_connection_id=self.call_connection_id,
**kwargs
)

@distributed_trace()
def cancel_all_media_operations(
self,
Expand Down Expand Up @@ -146,6 +180,34 @@ def remove_participant(
**kwargs
)

@distributed_trace()
def get_participants(
self,
**kwargs # type: Any
): # type: (...) -> List[CallParticipant]

return self._call_connection_client.get_participants(
call_connection_id=self.call_connection_id,
**kwargs
)

@distributed_trace()
def get_participant(
self,
participant, # type: CommunicationIdentifier
**kwargs # type: Any
): # type: (...) -> List[CallParticipant]

get_participant_request = GetParticipantRequestConverter.convert(
identifier=serialize_identifier(participant)
)

return self._call_connection_client.get_participant(
call_connection_id=self.call_connection_id,
get_participant_request=get_participant_request,
**kwargs
)

@distributed_trace()
def play_audio_to_participant(
self,
Expand Down Expand Up @@ -207,24 +269,192 @@ def cancel_participant_media_operation(
**kwargs
)

@distributed_trace()
def mute_participant(
self,
participant, # type: CommunicationIdentifier
**kwargs # type: Any
): # type: (...) -> None

if not participant:
raise ValueError("participant can not be None")

mute_participant_request = MuteParticipantRequestConverter.convert(
identifier=serialize_identifier(participant)
)

return self._call_connection_client.mute_participant(
call_connection_id=self.call_connection_id,
mute_participant_request=mute_participant_request,
**kwargs
)

@distributed_trace()
def unmute_participant(
self,
participant, # type: CommunicationIdentifier
**kwargs # type: Any
): # type: (...) -> None

if not participant:
raise ValueError("participant can not be None")

unmute_participant_request = UnmuteParticipantRequestConverter.convert(
identifier=serialize_identifier(participant)
)

return self._call_connection_client.unmute_participant(
call_connection_id=self.call_connection_id,
unmute_participant_request=unmute_participant_request,
**kwargs
)

@distributed_trace()
def hold_participant_meeting_audio(
self,
participant, # type: CommunicationIdentifier
**kwargs # type: Any
): # type: (...) -> None

if not participant:
raise ValueError("participant can not be None")

hold_meeting_audio_request = HoldMeetingAudioRequestConverter.convert(
identifier=serialize_identifier(participant)
)

return self._call_connection_client.hold_participant_meeting_audio(
call_connection_id=self.call_connection_id,
hold_meeting_audio_request=hold_meeting_audio_request,
**kwargs
)

@distributed_trace()
def resume_participant_meeting_audio(
self,
participant, # type: CommunicationIdentifier
**kwargs # type: Any
): # type: (...) -> None

if not participant:
raise ValueError("participant can not be None")

resume_participant_meeting_audio_request = ResumeMeetingAudioRequestConverter.convert(
identifier=serialize_identifier(participant)
)

return self._call_connection_client.resume_participant_meeting_audio(
call_connection_id=self.call_connection_id,
resume_meeting_audio_request=resume_participant_meeting_audio_request,
**kwargs
)

@distributed_trace()
def transfer_call(
self,
target_participant, # type: CommunicationIdentifier
target_call_connection_id, # type: str
user_to_user_information=None, # type: Optional[str]
operation_context=None, # type: str
callback_uri=None, # type: str
**kwargs # type: Any
): # type: (...) -> None

if not target_participant:
raise ValueError("target_participant can not be None")
if not target_call_connection_id:
raise ValueError("target_call_connection_id can not be None")

transfer_call_request = TransferCallRequestConverter.convert(
target_participant=serialize_identifier(target_participant),
user_to_user_information=user_to_user_information
target_call_connection_id=target_call_connection_id,
user_to_user_information=user_to_user_information,
operation_context=operation_context,
callback_uri=callback_uri
)

return self._call_connection_client.transfer(
call_connection_id=self.call_connection_id,
transfer_call_request=transfer_call_request,
**kwargs
)

@distributed_trace()
def create_audio_routing_group(
self,
audio_routing_mode, # type: AudioRoutingMode
targets, # type: List[CommunicationIdentifier]
**kwargs # type: Any
): # type: (...) -> CreateAudioRoutingGroupResult

if not audio_routing_mode:
raise ValueError("audio_routing_mode can not be None")
if not targets:
raise ValueError("targets can not be None")

audio_routing_group_request = AudioRoutingGroupRequestConverter.convert(
audio_routing_mode=audio_routing_mode,
target_identities=[serialize_identifier(m) for m in targets]
)

return self._call_connection_client.create_audio_routing_group(
call_connection_id=self.call_connection_id,
audio_routing_group_request=audio_routing_group_request,
**kwargs
)

@distributed_trace()
def get_audio_routing_groups(
self,
audio_routing_group_id, # type: str
**kwargs # type: Any
): # type: (...) -> AudioRoutingGroupResult

if not audio_routing_group_id:
raise ValueError("audio_routing_group_id can not be None")

return self._call_connection_client.get_audio_routing_groups(
call_connection_id=self.call_connection_id,
audio_routing_group_id=audio_routing_group_id,
**kwargs
)

@distributed_trace()
def delete_audio_routing_group(
self,
audio_routing_group_id, # type: str
**kwargs # type: Any
): # type: (...) -> None

if not audio_routing_group_id:
raise ValueError("audio_routing_group_id can not be None")

return self._call_connection_client.delete_audio_routing_group(
call_connection_id=self.call_connection_id,
audio_routing_group_id=audio_routing_group_id,
**kwargs
)

@distributed_trace()
def update_audio_routing_group(
self,
audio_routing_group_id, # type: str
targets, # type: List[CommunicationIdentifier]
**kwargs # type: Any
): # type: (...) -> None

if not audio_routing_group_id:
raise ValueError("audio_routing_group_id can not be None")
if not targets:
raise ValueError("targets can not be None")

update_audio_routing_group_request = UpdateAudioRoutingGroupRequestConverter.convert(
target_identities=[serialize_identifier(m) for m in targets]
)

return self._call_connection_client.update_audio_routing_group(
call_connection_id=self.call_connection_id,
audio_routing_group_id=audio_routing_group_id,
update_audio_routing_group_request=update_audio_routing_group_request,
**kwargs
)
Loading

0 comments on commit 90abaeb

Please sign in to comment.