diff --git a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_call_connection.py b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_call_connection.py index a746e49dc104..8cff0b999d0b 100644 --- a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_call_connection.py +++ b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_call_connection.py @@ -9,9 +9,13 @@ from azure.core.tracing.decorator import distributed_trace from ._communication_identifier_serializer import serialize_identifier -from ._converters import (AddParticipantRequestConverter, - PlayAudioRequestConverter, - CancelAllMediaOperationsConverter) +from ._converters import ( + AddParticipantRequestConverter, + CancelAllMediaOperationsConverter, + TransferCallRequestConverter, + CancelMediaOperationRequestConverter, + PlayAudioRequestConverter + ) from ._generated.models import (AddParticipantResult, CancelAllMediaOperationsResult, PhoneNumberIdentifierModel, @@ -120,3 +124,50 @@ def remove_participant( participant_id=participant_id, **kwargs ) + + @distributed_trace() + def cancel_participant_media_operation( + self, + participant_id, # type: str + media_operation_id, # type: str + **kwargs # type: Any + ): # type: (...) -> None + + if not participant_id: + raise ValueError("participant_id can not be None") + + if not media_operation_id: + raise ValueError("media_operation_id can not be None") + + cancel_media_operation_request = CancelMediaOperationRequestConverter.convert( + media_operation_id=media_operation_id + ) + + return self._call_connection_client.cancel_participant_media_operation( + call_connection_id=self.call_connection_id, + participant_id=participant_id, + cancel_media_operation_request=cancel_media_operation_request, + **kwargs + ) + + @distributed_trace() + def transfer_call( + self, + target_participant, # type: CommunicationIdentifier + user_to_user_information, # type: str + **kwargs # type: Any + ): # type: (...) -> None + + if not target_participant: + raise ValueError("target_participant can not be None") + + transfer_call_request = TransferCallRequestConverter.convert( + target_participant=serialize_identifier(target_participant), + user_to_user_information=user_to_user_information + ) + + return self._call_connection_client.transfer( + call_connection_id=self.call_connection_id, + transfer_call_request=transfer_call_request, + **kwargs + ) diff --git a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_converters/__init__.py b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_converters/__init__.py index fcf0f4dd06ea..bc2c17cc7019 100644 --- a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_converters/__init__.py +++ b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_converters/__init__.py @@ -2,12 +2,16 @@ JoinCallRequestConverter, PlayAudioRequestConverter, AddParticipantRequestConverter, - CancelAllMediaOperationsConverter + CancelAllMediaOperationsConverter, + CancelMediaOperationRequestConverter, + TransferCallRequestConverter ) __all__ = [ 'JoinCallRequestConverter', 'PlayAudioRequestConverter', "AddParticipantRequestConverter", - "CancelAllMediaOperationsConverter" + "CancelAllMediaOperationsConverter", + "CancelMediaOperationRequestConverter", + "TransferCallRequestConverter" ] diff --git a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_converters/_converter.py b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_converters/_converter.py index 0ead69d6c7b2..32155add8a58 100644 --- a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_converters/_converter.py +++ b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_converters/_converter.py @@ -8,10 +8,12 @@ from .._generated.models import ( JoinCallRequest, PlayAudioRequest, + TransferCallRequest, CommunicationIdentifierModel, AddParticipantRequest, - PhoneNumberIdentifierModel, - CancelAllMediaOperationsRequest + CancelAllMediaOperationsRequest, + CancelMediaOperationRequest, + PhoneNumberIdentifierModel ) class JoinCallRequestConverter(object): @@ -77,9 +79,37 @@ def convert( class CancelAllMediaOperationsConverter(object): @staticmethod def convert( - operation_context=None, # type: str + operation_context=None # type: str ): # type: (...) -> CancelAllMediaOperationsRequest return CancelAllMediaOperationsRequest( operation_context=operation_context ) + +class CancelMediaOperationRequestConverter(object): + @staticmethod + def convert( + media_operation_id # type: str + ): # type: (...) -> CancelMediaOperationRequest + + if not media_operation_id: + raise ValueError("media_operation_id can not be None") + + return CancelMediaOperationRequest( + media_operation_id=media_operation_id + ) + +class TransferCallRequestConverter(object): + @staticmethod + def convert( + target_participant, # type: CommunicationIdentifierModel + user_to_user_information=None # type: str + ): # type: (...) -> TransferCallRequest + + if not target_participant: + raise ValueError("target_participant can not be None") + + return TransferCallRequest( + target_participant=target_participant, + user_to_user_information=user_to_user_information + ) diff --git a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/_configuration.py b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/_configuration.py index b81e3dcc74c8..f439864705e5 100644 --- a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/_configuration.py +++ b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/_configuration.py @@ -38,7 +38,7 @@ def __init__( super(AzureCommunicationCallingServerServiceConfiguration, self).__init__(**kwargs) self.endpoint = endpoint - self.api_version = "2021-06-15-preview" + self.api_version = "2021-09-15-preview" kwargs.setdefault('sdk_moniker', 'azurecommunicationcallingserverservice/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/aio/_configuration.py b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/aio/_configuration.py index 2f7026473195..dbc7daea5462 100644 --- a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/aio/_configuration.py +++ b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/aio/_configuration.py @@ -33,7 +33,7 @@ def __init__( super(AzureCommunicationCallingServerServiceConfiguration, self).__init__(**kwargs) self.endpoint = endpoint - self.api_version = "2021-06-15-preview" + self.api_version = "2021-09-15-preview" kwargs.setdefault('sdk_moniker', 'azurecommunicationcallingserverservice/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/aio/operations/_call_connections_operations.py b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/aio/operations/_call_connections_operations.py index e9a0932047df..cc4adf1de98c 100644 --- a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/aio/operations/_call_connections_operations.py +++ b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/aio/operations/_call_connections_operations.py @@ -5,7 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -65,7 +65,7 @@ async def create_call( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -104,6 +104,125 @@ async def create_call( return deserialized create_call.metadata = {'url': '/calling/callConnections'} # type: ignore + async def get_call( + self, + call_connection_id: str, + **kwargs: Any + ) -> "_models.CallConnectionProperties": + """Get call connection. + + Get call connection. + + :param call_connection_id: The call connection id. + :type call_connection_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CallConnectionProperties, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.CallConnectionProperties + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CallConnectionProperties"] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get_call.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('CallConnectionProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_call.metadata = {'url': '/calling/callConnections/{callConnectionId}'} # type: ignore + + async def delete_call( + self, + call_connection_id: str, + **kwargs: Any + ) -> None: + """Delete the call. + + Delete the call. + + :param call_connection_id: The call connection id. + :type call_connection_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.delete_call.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + delete_call.metadata = {'url': '/calling/callConnections/{callConnectionId}'} # type: ignore + async def hangup_call( self, call_connection_id: str, @@ -130,7 +249,7 @@ async def hangup_call( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" accept = "application/json" # Construct URL @@ -191,7 +310,7 @@ async def play_audio( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -260,7 +379,7 @@ async def cancel_all_media_operations( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -300,26 +419,84 @@ async def cancel_all_media_operations( return deserialized cancel_all_media_operations.metadata = {'url': '/calling/callConnections/{callConnectionId}/:cancelAllMediaOperations'} # type: ignore - async def add_participant( + async def keep_alive( self, call_connection_id: str, - add_participant_request: "_models.AddParticipantRequest", **kwargs: Any - ) -> "_models.AddParticipantResult": - """Add a participant to the call. + ) -> None: + """Keep the call alive. - Add a participant to the call. + Keep the call alive. :param call_connection_id: The call connection id. :type call_connection_id: str - :param add_participant_request: Add participant request. - :type add_participant_request: ~azure.communication.callingserver.models.AddParticipantRequest :keyword callable cls: A custom type or function that will be passed the direct response - :return: AddParticipantResult, or the result of cls(response) - :rtype: ~azure.communication.callingserver.models.AddParticipantResult + :return: None, or the result of cls(response) + :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AddParticipantResult"] + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.keep_alive.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + keep_alive.metadata = {'url': '/calling/callConnections/{callConnectionId}/:keepAlive'} # type: ignore + + async def transfer( + self, + call_connection_id: str, + transfer_call_request: "_models.TransferCallRequest", + **kwargs: Any + ) -> None: + """Transfer the call to a participant or to another call. + + Transfer the call to a participant or to another call. + + :param call_connection_id: The call connection id. + :type call_connection_id: str + :param transfer_call_request: The transfer call request. + :type transfer_call_request: ~azure.communication.callingserver.models.TransferCallRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 409: ResourceExistsError, 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), @@ -329,12 +506,12 @@ async def add_participant( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL - url = self.add_participant.metadata['url'] # type: ignore + url = self.transfer.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), @@ -351,7 +528,7 @@ async def add_participant( header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(add_participant_request, 'AddParticipantRequest') + body_content = self._serialize.body(transfer_call_request, 'TransferCallRequest') body_content_kwargs['content'] = body_content request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) @@ -361,34 +538,92 @@ async def add_participant( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = self._deserialize('AddParticipantResult', pipeline_response) + if cls: + return cls(pipeline_response, None, {}) + + transfer.metadata = {'url': '/calling/callConnections/{callConnectionId}/:transfer'} # type: ignore + + async def get_participants( + self, + call_connection_id: str, + **kwargs: Any + ) -> List["_models.CallParticipant"]: + """Get participants from a call. + + Get participants from a call. + + :param call_connection_id: The call connection id. + :type call_connection_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of CallParticipant, or the result of cls(response) + :rtype: list[~azure.communication.callingserver.models.CallParticipant] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[List["_models.CallParticipant"]] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get_participants.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('[CallParticipant]', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - add_participant.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants'} # type: ignore + get_participants.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants'} # type: ignore - async def remove_participant( + async def add_participant( self, call_connection_id: str, - participant_id: str, + add_participant_request: "_models.AddParticipantRequest", **kwargs: Any - ) -> None: - """Remove a participant from the call. + ) -> "_models.AddParticipantResult": + """Add a participant to the call. - Remove a participant from the call. + Add a participant to the call. :param call_connection_id: The call connection id. :type call_connection_id: str - :param participant_id: The participant id. - :type participant_id: str + :param add_participant_request: Add participant request. + :type add_participant_request: ~azure.communication.callingserver.models.AddParticipantRequest :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None + :return: AddParticipantResult, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.AddParticipantResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AddParticipantResult"] error_map = { 409: ResourceExistsError, 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), @@ -398,15 +633,15 @@ async def remove_participant( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL - url = self.remove_participant.metadata['url'] # type: ignore + url = self.add_participant.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), - 'participantId': self._serialize.url("participant_id", participant_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -416,9 +651,13 @@ async def remove_participant( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.delete(url, query_parameters, header_parameters) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(add_participant_request, 'AddParticipantRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -426,7 +665,554 @@ async def remove_participant( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + deserialized = self._deserialize('AddParticipantResult', pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) - remove_participant.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants/{participantId}'} # type: ignore + return deserialized + add_participant.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants'} # type: ignore + + async def remove_participant_by_id( + self, + call_connection_id: str, + remove_participant_by_id_request: "_models.RemoveParticipantByIdRequest", + **kwargs: Any + ) -> None: + """Remove participant from the call using identifier. + + Remove participant from the call using identifier. + + :param call_connection_id: The call connection id. + :type call_connection_id: str + :param remove_participant_by_id_request: The identifier of the participant to be removed from + the call. + :type remove_participant_by_id_request: ~azure.communication.callingserver.models.RemoveParticipantByIdRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.remove_participant_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(remove_participant_by_id_request, 'RemoveParticipantByIdRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + remove_participant_by_id.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants/:removeUser'} # type: ignore + + async def get_participant_by_id( + self, + call_connection_id: str, + get_participant_by_id_request: "_models.GetParticipantByIdRequest", + **kwargs: Any + ) -> List["_models.CallParticipant"]: + """Get participant from the call using identifier. + + Get participant from the call using identifier. + + :param call_connection_id: The call connection id. + :type call_connection_id: str + :param get_participant_by_id_request: The identifier of the participant to get from the call. + :type get_participant_by_id_request: ~azure.communication.callingserver.models.GetParticipantByIdRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of CallParticipant, or the result of cls(response) + :rtype: list[~azure.communication.callingserver.models.CallParticipant] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[List["_models.CallParticipant"]] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.get_participant_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(get_participant_by_id_request, 'GetParticipantByIdRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('[CallParticipant]', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_participant_by_id.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants/:getUser'} # type: ignore + + async def get_participant( + self, + call_connection_id: str, + participant_id: str, + **kwargs: Any + ) -> "_models.CallParticipant": + """Get participant by participant id from the call. + + Get participant by participant id from the call. + + :param call_connection_id: The call connection id. + :type call_connection_id: str + :param participant_id: The participant id. + :type participant_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CallParticipant, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.CallParticipant + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CallParticipant"] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get_participant.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('CallParticipant', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_participant.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants/{participantId}'} # type: ignore + + async def remove_participant( + self, + call_connection_id: str, + participant_id: str, + **kwargs: Any + ) -> None: + """Remove a participant from the call. + + Remove a participant from the call. + + :param call_connection_id: The call connection id. + :type call_connection_id: str + :param participant_id: The participant id. + :type participant_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.remove_participant.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + remove_participant.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants/{participantId}'} # type: ignore + + async def start_hold_music( + self, + call_connection_id: str, + participant_id: str, + request: "_models.StartHoldMusicRequest", + **kwargs: Any + ) -> "_models.StartHoldMusicResult": + """Play hold music to a participant. + + Play hold music to a participant. + + :param call_connection_id: The callConnectionId. + :type call_connection_id: str + :param participant_id: The participant id. + :type participant_id: str + :param request: The start hold music request. + :type request: ~azure.communication.callingserver.models.StartHoldMusicRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StartHoldMusicResult, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.StartHoldMusicResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.StartHoldMusicResult"] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.start_hold_music.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(request, 'StartHoldMusicRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('StartHoldMusicResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + start_hold_music.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants/{participantId}/:startHoldMusic'} # type: ignore + + async def stop_hold_music( + self, + call_connection_id: str, + participant_id: str, + **kwargs: Any + ) -> "_models.StopHoldMusicResult": + """Stop hold music to a participant. + + Stop hold music to a participant. + + :param call_connection_id: The callConnectionId. + :type call_connection_id: str + :param participant_id: The participant id. + :type participant_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StopHoldMusicResult, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.StopHoldMusicResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.StopHoldMusicResult"] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.stop_hold_music.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('StopHoldMusicResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + stop_hold_music.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants/{participantId}/:stopHoldMusic'} # type: ignore + + async def participant_play_audio( + self, + call_connection_id: str, + participant_id: str, + play_audio_request: "_models.PlayAudioRequest", + **kwargs: Any + ) -> "_models.PlayAudioResult": + """Play audio to a participant. + + Play audio to a participant. + + :param call_connection_id: The callConnectionId. + :type call_connection_id: str + :param participant_id: Participant id. + :type participant_id: str + :param play_audio_request: PlayAudioRequest body. + :type play_audio_request: ~azure.communication.callingserver.models.PlayAudioRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PlayAudioResult, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.PlayAudioResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PlayAudioResult"] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.participant_play_audio.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(play_audio_request, 'PlayAudioRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('PlayAudioResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + participant_play_audio.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants/{participantId}/:playAudio'} # type: ignore + + async def cancel_participant_media_operation( + self, + call_connection_id: str, + participant_id: str, + cancel_media_operation_request: "_models.CancelMediaOperationRequest", + **kwargs: Any + ) -> None: + """cancel media operation for a participant. + + cancel media operation for a participant. + + :param call_connection_id: The callConnectionId. + :type call_connection_id: str + :param participant_id: The participant id. + :type participant_id: str + :param cancel_media_operation_request: The cancel media operation request. + :type cancel_media_operation_request: ~azure.communication.callingserver.models.CancelMediaOperationRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.cancel_participant_media_operation.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(cancel_media_operation_request, 'CancelMediaOperationRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_participant_media_operation.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants/{participantId}/:cancelMediaOperation'} # type: ignore diff --git a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/aio/operations/_server_calls_operations.py b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/aio/operations/_server_calls_operations.py index 92f4af168af3..d3e6186bf7a1 100644 --- a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/aio/operations/_server_calls_operations.py +++ b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/aio/operations/_server_calls_operations.py @@ -5,7 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -39,6 +39,67 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + async def get_participants( + self, + server_call_id: str, + **kwargs: Any + ) -> List["_models.CallParticipant"]: + """Get participants from a server call. + + Get participants from a server call. + + :param server_call_id: The server call id. + :type server_call_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of CallParticipant, or the result of cls(response) + :rtype: list[~azure.communication.callingserver.models.CallParticipant] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[List["_models.CallParticipant"]] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get_participants.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'serverCallId': self._serialize.url("server_call_id", server_call_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('[CallParticipant]', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_participants.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants'} # type: ignore + async def add_participant( self, server_call_id: str, @@ -68,7 +129,7 @@ async def add_participant( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -108,6 +169,207 @@ async def add_participant( return deserialized add_participant.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants'} # type: ignore + async def remove_participant_by_id( + self, + server_call_id: str, + remove_participant_by_id_request: "_models.RemoveParticipantByIdRequest", + **kwargs: Any + ) -> None: + """Remove participant from the call using identifier. + + Remove participant from the call using identifier. + + :param server_call_id: The server call id. + :type server_call_id: str + :param remove_participant_by_id_request: The identifier of the participant to be removed from + the call. + :type remove_participant_by_id_request: ~azure.communication.callingserver.models.RemoveParticipantByIdRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.remove_participant_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'serverCallId': self._serialize.url("server_call_id", server_call_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(remove_participant_by_id_request, 'RemoveParticipantByIdRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + remove_participant_by_id.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants/:removeUser'} # type: ignore + + async def get_participant_by_id( + self, + server_call_id: str, + get_participant_by_id_request: "_models.GetParticipantByIdRequest", + **kwargs: Any + ) -> List["_models.CallParticipant"]: + """Get participant from the call using identifier. + + Get participant from the call using identifier. + + :param server_call_id: The server call id. + :type server_call_id: str + :param get_participant_by_id_request: The identifier of the participant to get from the call. + :type get_participant_by_id_request: ~azure.communication.callingserver.models.GetParticipantByIdRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of CallParticipant, or the result of cls(response) + :rtype: list[~azure.communication.callingserver.models.CallParticipant] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[List["_models.CallParticipant"]] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.get_participant_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'serverCallId': self._serialize.url("server_call_id", server_call_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(get_participant_by_id_request, 'GetParticipantByIdRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('[CallParticipant]', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_participant_by_id.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants/:getUser'} # type: ignore + + async def get_participant( + self, + server_call_id: str, + participant_id: str, + **kwargs: Any + ) -> "_models.CallParticipant": + """Get participant by participant id from a call. + + Get participant by participant id from a call. + + :param server_call_id: The server call id. + :type server_call_id: str + :param participant_id: The participant id. + :type participant_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CallParticipant, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.CallParticipant + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CallParticipant"] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get_participant.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'serverCallId': self._serialize.url("server_call_id", server_call_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('CallParticipant', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_participant.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants/{participantId}'} # type: ignore + async def remove_participant( self, server_call_id: str, @@ -118,9 +380,9 @@ async def remove_participant( Remove participant from the call. - :param server_call_id: Server call id. + :param server_call_id: The server call id. :type server_call_id: str - :param participant_id: Participant id. + :param participant_id: The participant id. :type participant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) @@ -137,7 +399,7 @@ async def remove_participant( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" accept = "application/json" # Construct URL @@ -170,15 +432,304 @@ async def remove_participant( remove_participant.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants/{participantId}'} # type: ignore + async def start_hold_music( + self, + server_call_id: str, + participant_id: str, + request: "_models.StartHoldMusicRequest", + **kwargs: Any + ) -> "_models.StartHoldMusicResult": + """Play hold music to a participant. + + Play hold music to a participant. + + :param server_call_id: The server call id. + :type server_call_id: str + :param participant_id: The participant id. + :type participant_id: str + :param request: The start hold music request. + :type request: ~azure.communication.callingserver.models.StartHoldMusicRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StartHoldMusicResult, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.StartHoldMusicResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.StartHoldMusicResult"] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.start_hold_music.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'serverCallId': self._serialize.url("server_call_id", server_call_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(request, 'StartHoldMusicRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('StartHoldMusicResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + start_hold_music.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants/{participantId}/:startHoldMusic'} # type: ignore + + async def stop_hold_music( + self, + server_call_id: str, + participant_id: str, + stop_hold_music_request: "_models.StopHoldMusicRequest", + **kwargs: Any + ) -> "_models.StopHoldMusicResult": + """Stop hold music to a participant. + + Stop hold music to a participant. + + :param server_call_id: The server call id. + :type server_call_id: str + :param participant_id: The participant id. + :type participant_id: str + :param stop_hold_music_request: The stop hold music request. + :type stop_hold_music_request: ~azure.communication.callingserver.models.StopHoldMusicRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StopHoldMusicResult, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.StopHoldMusicResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.StopHoldMusicResult"] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.stop_hold_music.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'serverCallId': self._serialize.url("server_call_id", server_call_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(stop_hold_music_request, 'StopHoldMusicRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('StopHoldMusicResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + stop_hold_music.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants/{participantId}/:stopHoldMusic'} # type: ignore + + async def participant_play_audio( + self, + server_call_id: str, + participant_id: str, + play_audio_request: "_models.PlayAudioRequest", + **kwargs: Any + ) -> "_models.PlayAudioResult": + """Play audio to a participant. + + Play audio to a participant. + + :param server_call_id: Server call id. + :type server_call_id: str + :param participant_id: Participant id. + :type participant_id: str + :param play_audio_request: PlayAudioRequest body. + :type play_audio_request: ~azure.communication.callingserver.models.PlayAudioRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PlayAudioResult, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.PlayAudioResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PlayAudioResult"] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.participant_play_audio.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'serverCallId': self._serialize.url("server_call_id", server_call_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(play_audio_request, 'PlayAudioRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('PlayAudioResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + participant_play_audio.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants/{participantId}/:playAudio'} # type: ignore + + async def cancel_participant_media_operation( + self, + server_call_id: str, + participant_id: str, + cancel_media_operation_request: "_models.CancelMediaOperationRequest", + **kwargs: Any + ) -> None: + """cancel media operation for a participant. + + cancel media operation for a participant. + + :param server_call_id: The server call id. + :type server_call_id: str + :param participant_id: The participant id. + :type participant_id: str + :param cancel_media_operation_request: The cancel media operation request. + :type cancel_media_operation_request: ~azure.communication.callingserver.models.CancelMediaOperationRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.cancel_participant_media_operation.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'serverCallId': self._serialize.url("server_call_id", server_call_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(cancel_media_operation_request, 'CancelMediaOperationRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_participant_media_operation.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants/{participantId}/:cancelMediaOperation'} # type: ignore + async def start_recording( self, server_call_id: str, request: "_models.StartCallRecordingRequest", **kwargs: Any ) -> "_models.StartCallRecordingResult": - """Start recording of the call. + """Start recording the call. - Start recording of the call. + Start recording the call. :param server_call_id: The server call id. :type server_call_id: str @@ -199,7 +750,7 @@ async def start_recording( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -268,7 +819,7 @@ async def get_recording_properties( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" accept = "application/json" # Construct URL @@ -333,7 +884,7 @@ async def stop_recording( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" accept = "application/json" # Construct URL @@ -395,7 +946,7 @@ async def pause_recording( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" accept = "application/json" # Construct URL @@ -457,7 +1008,7 @@ async def resume_recording( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" accept = "application/json" # Construct URL @@ -519,7 +1070,7 @@ async def join_call( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -588,7 +1139,7 @@ async def play_audio( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -627,3 +1178,69 @@ async def play_audio( return deserialized play_audio.metadata = {'url': '/calling/serverCalls/{serverCallId}/:playAudio'} # type: ignore + + async def cancel_media_operation( + self, + server_call_id: str, + cancel_media_operation_request: "_models.CancelMediaOperationRequest", + **kwargs: Any + ) -> None: + """cancel media operation. + + cancel media operation. + + :param server_call_id: The server call id. + :type server_call_id: str + :param cancel_media_operation_request: The cancel media operation request. + :type cancel_media_operation_request: ~azure.communication.callingserver.models.CancelMediaOperationRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.cancel_media_operation.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'serverCallId': self._serialize.url("server_call_id", server_call_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(cancel_media_operation_request, 'CancelMediaOperationRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_media_operation.metadata = {'url': '/calling/serverCalls/{serverCallId}/:cancelMediaOperation'} # type: ignore diff --git a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/models/__init__.py b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/models/__init__.py index 6ff7c8ae6cd6..a54265444702 100644 --- a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/models/__init__.py +++ b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/models/__init__.py @@ -10,18 +10,21 @@ from ._models_py3 import AddParticipantRequest from ._models_py3 import AddParticipantResult from ._models_py3 import AddParticipantResultEvent + from ._models_py3 import CallConnectionProperties from ._models_py3 import CallConnectionStateChangedEvent from ._models_py3 import CallParticipant from ._models_py3 import CallRecordingProperties from ._models_py3 import CallRecordingStateChangeEvent from ._models_py3 import CancelAllMediaOperationsRequest from ._models_py3 import CancelAllMediaOperationsResult + from ._models_py3 import CancelMediaOperationRequest from ._models_py3 import CommunicationError from ._models_py3 import CommunicationErrorResponse from ._models_py3 import CommunicationIdentifierModel from ._models_py3 import CommunicationUserIdentifierModel from ._models_py3 import CreateCallRequest from ._models_py3 import CreateCallResult + from ._models_py3 import GetParticipantByIdRequest from ._models_py3 import JoinCallRequest from ._models_py3 import JoinCallResult from ._models_py3 import MicrosoftTeamsUserIdentifierModel @@ -30,27 +33,36 @@ from ._models_py3 import PlayAudioRequest from ._models_py3 import PlayAudioResult from ._models_py3 import PlayAudioResultEvent + from ._models_py3 import RemoveParticipantByIdRequest from ._models_py3 import ResultInfo from ._models_py3 import StartCallRecordingRequest from ._models_py3 import StartCallRecordingResult + from ._models_py3 import StartHoldMusicRequest + from ._models_py3 import StartHoldMusicResult + from ._models_py3 import StopHoldMusicRequest + from ._models_py3 import StopHoldMusicResult from ._models_py3 import ToneInfo from ._models_py3 import ToneReceivedEvent + from ._models_py3 import TransferCallRequest except (SyntaxError, ImportError): from ._models import AddParticipantRequest # type: ignore from ._models import AddParticipantResult # type: ignore from ._models import AddParticipantResultEvent # type: ignore + from ._models import CallConnectionProperties # type: ignore from ._models import CallConnectionStateChangedEvent # type: ignore from ._models import CallParticipant # type: ignore from ._models import CallRecordingProperties # type: ignore from ._models import CallRecordingStateChangeEvent # type: ignore from ._models import CancelAllMediaOperationsRequest # type: ignore from ._models import CancelAllMediaOperationsResult # type: ignore + from ._models import CancelMediaOperationRequest # type: ignore from ._models import CommunicationError # type: ignore from ._models import CommunicationErrorResponse # type: ignore from ._models import CommunicationIdentifierModel # type: ignore from ._models import CommunicationUserIdentifierModel # type: ignore from ._models import CreateCallRequest # type: ignore from ._models import CreateCallResult # type: ignore + from ._models import GetParticipantByIdRequest # type: ignore from ._models import JoinCallRequest # type: ignore from ._models import JoinCallResult # type: ignore from ._models import MicrosoftTeamsUserIdentifierModel # type: ignore @@ -59,11 +71,17 @@ from ._models import PlayAudioRequest # type: ignore from ._models import PlayAudioResult # type: ignore from ._models import PlayAudioResultEvent # type: ignore + from ._models import RemoveParticipantByIdRequest # type: ignore from ._models import ResultInfo # type: ignore from ._models import StartCallRecordingRequest # type: ignore from ._models import StartCallRecordingResult # type: ignore + from ._models import StartHoldMusicRequest # type: ignore + from ._models import StartHoldMusicResult # type: ignore + from ._models import StopHoldMusicRequest # type: ignore + from ._models import StopHoldMusicResult # type: ignore from ._models import ToneInfo # type: ignore from ._models import ToneReceivedEvent # type: ignore + from ._models import TransferCallRequest # type: ignore from ._azure_communication_calling_server_service_enums import ( CallConnectionState, @@ -72,6 +90,9 @@ EventSubscriptionType, MediaType, OperationStatus, + RecordingChannelType, + RecordingContentType, + RecordingFormatType, ToneValue, ) @@ -79,18 +100,21 @@ 'AddParticipantRequest', 'AddParticipantResult', 'AddParticipantResultEvent', + 'CallConnectionProperties', 'CallConnectionStateChangedEvent', 'CallParticipant', 'CallRecordingProperties', 'CallRecordingStateChangeEvent', 'CancelAllMediaOperationsRequest', 'CancelAllMediaOperationsResult', + 'CancelMediaOperationRequest', 'CommunicationError', 'CommunicationErrorResponse', 'CommunicationIdentifierModel', 'CommunicationUserIdentifierModel', 'CreateCallRequest', 'CreateCallResult', + 'GetParticipantByIdRequest', 'JoinCallRequest', 'JoinCallResult', 'MicrosoftTeamsUserIdentifierModel', @@ -99,16 +123,25 @@ 'PlayAudioRequest', 'PlayAudioResult', 'PlayAudioResultEvent', + 'RemoveParticipantByIdRequest', 'ResultInfo', 'StartCallRecordingRequest', 'StartCallRecordingResult', + 'StartHoldMusicRequest', + 'StartHoldMusicResult', + 'StopHoldMusicRequest', + 'StopHoldMusicResult', 'ToneInfo', 'ToneReceivedEvent', + 'TransferCallRequest', 'CallConnectionState', 'CallRecordingState', 'CommunicationCloudEnvironmentModel', 'EventSubscriptionType', 'MediaType', 'OperationStatus', + 'RecordingChannelType', + 'RecordingContentType', + 'RecordingFormatType', 'ToneValue', ] diff --git a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/models/_azure_communication_calling_server_service_enums.py b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/models/_azure_communication_calling_server_service_enums.py index 069b5fb58a9b..6355d85b1e32 100644 --- a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/models/_azure_communication_calling_server_service_enums.py +++ b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/models/_azure_communication_calling_server_service_enums.py @@ -27,12 +27,13 @@ def __getattr__(cls, name): class CallConnectionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The call connection state. + """The state of the call connection. """ - INCOMING = "incoming" CONNECTING = "connecting" CONNECTED = "connected" + TRANSFERRING = "transferring" + TRANSFER_ACCEPTED = "transferAccepted" DISCONNECTING = "disconnecting" DISCONNECTED = "disconnected" @@ -70,6 +71,28 @@ class OperationStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "completed" FAILED = "failed" +class RecordingChannelType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Channel type of call recording. + """ + + MIXED = "mixed" + UNMIXED = "unmixed" + +class RecordingContentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Content type of call recording. + """ + + AUDIO = "audio" + AUDIO_VIDEO = "audioVideo" + +class RecordingFormatType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Format type of call recording. + """ + + WAV = "wav" + MP3 = "mp3" + MP4 = "mp4" + class ToneValue(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """The tone value. """ diff --git a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/models/_models.py b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/models/_models.py index 389240e276d7..612bad5d6334 100644 --- a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/models/_models.py +++ b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/models/_models.py @@ -94,6 +94,65 @@ def __init__( self.status = kwargs['status'] +class CallConnectionProperties(msrest.serialization.Model): + """CallConnectionProperties. + + :param call_connection_id: The call connection id. + :type call_connection_id: str + :param source: The source of the call. + :type source: ~azure.communication.callingserver.models.CommunicationIdentifierModel + :param alternate_caller_id: The alternate identity of the source of the call if dialing out to + a pstn number. + :type alternate_caller_id: ~azure.communication.callingserver.models.PhoneNumberIdentifierModel + :param targets: The targets of the call. + :type targets: list[~azure.communication.callingserver.models.CommunicationIdentifierModel] + :param call_connection_state: The state of the call connection. Possible values include: + "connecting", "connected", "transferring", "transferAccepted", "disconnecting", "disconnected". + :type call_connection_state: str or + ~azure.communication.callingserver.models.CallConnectionState + :param subject: The subject. + :type subject: str + :param callback_uri: The callback URI. + :type callback_uri: str + :param requested_media_types: The requested modalities. + :type requested_media_types: list[str or ~azure.communication.callingserver.models.MediaType] + :param requested_call_events: The requested call events to subscribe to. + :type requested_call_events: list[str or + ~azure.communication.callingserver.models.EventSubscriptionType] + :param server_call_id: The server call id. + :type server_call_id: str + """ + + _attribute_map = { + 'call_connection_id': {'key': 'callConnectionId', 'type': 'str'}, + 'source': {'key': 'source', 'type': 'CommunicationIdentifierModel'}, + 'alternate_caller_id': {'key': 'alternateCallerId', 'type': 'PhoneNumberIdentifierModel'}, + 'targets': {'key': 'targets', 'type': '[CommunicationIdentifierModel]'}, + 'call_connection_state': {'key': 'callConnectionState', 'type': 'str'}, + 'subject': {'key': 'subject', 'type': 'str'}, + 'callback_uri': {'key': 'callbackUri', 'type': 'str'}, + 'requested_media_types': {'key': 'requestedMediaTypes', 'type': '[str]'}, + 'requested_call_events': {'key': 'requestedCallEvents', 'type': '[str]'}, + 'server_call_id': {'key': 'serverCallId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CallConnectionProperties, self).__init__(**kwargs) + self.call_connection_id = kwargs.get('call_connection_id', None) + self.source = kwargs.get('source', None) + self.alternate_caller_id = kwargs.get('alternate_caller_id', None) + self.targets = kwargs.get('targets', None) + self.call_connection_state = kwargs.get('call_connection_state', None) + self.subject = kwargs.get('subject', None) + self.callback_uri = kwargs.get('callback_uri', None) + self.requested_media_types = kwargs.get('requested_media_types', None) + self.requested_call_events = kwargs.get('requested_call_events', None) + self.server_call_id = kwargs.get('server_call_id', None) + + class CallConnectionStateChangedEvent(msrest.serialization.Model): """The call connection state changed event. @@ -103,8 +162,9 @@ class CallConnectionStateChangedEvent(msrest.serialization.Model): :type server_call_id: str :param call_connection_id: The call connection id. :type call_connection_id: str - :param call_connection_state: Required. The call connection state. Possible values include: - "incoming", "connecting", "connected", "disconnecting", "disconnected". + :param call_connection_state: Required. The state of the call connection. Possible values + include: "connecting", "connected", "transferring", "transferAccepted", "disconnecting", + "disconnected". :type call_connection_state: str or ~azure.communication.callingserver.models.CallConnectionState """ @@ -134,7 +194,7 @@ class CallParticipant(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param identifier: Communication identifier of the participant. + :param identifier: Required. Communication identifier of the participant. :type identifier: ~azure.communication.callingserver.models.CommunicationIdentifierModel :param participant_id: Participant id. :type participant_id: str @@ -143,6 +203,7 @@ class CallParticipant(msrest.serialization.Model): """ _validation = { + 'identifier': {'required': True}, 'is_muted': {'required': True}, } @@ -157,7 +218,7 @@ def __init__( **kwargs ): super(CallParticipant, self).__init__(**kwargs) - self.identifier = kwargs.get('identifier', None) + self.identifier = kwargs['identifier'] self.participant_id = kwargs.get('participant_id', None) self.is_muted = kwargs['is_muted'] @@ -284,6 +345,31 @@ def __init__( self.result_info = kwargs.get('result_info', None) +class CancelMediaOperationRequest(msrest.serialization.Model): + """The request payload for stopping a media operation for a participant. + + All required parameters must be populated in order to send to Azure. + + :param media_operation_id: Required. The operationId of the media operation to cancel. + :type media_operation_id: str + """ + + _validation = { + 'media_operation_id': {'required': True}, + } + + _attribute_map = { + 'media_operation_id': {'key': 'mediaOperationId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CancelMediaOperationRequest, self).__init__(**kwargs) + self.media_operation_id = kwargs['media_operation_id'] + + class CommunicationError(msrest.serialization.Model): """The Communication Services error. @@ -486,6 +572,31 @@ def __init__( self.call_connection_id = kwargs.get('call_connection_id', None) +class GetParticipantByIdRequest(msrest.serialization.Model): + """The get participant by identifier request. + + All required parameters must be populated in order to send to Azure. + + :param identifier: Required. The identifier of the participant. + :type identifier: ~azure.communication.callingserver.models.CommunicationIdentifierModel + """ + + _validation = { + 'identifier': {'required': True}, + } + + _attribute_map = { + 'identifier': {'key': 'identifier', 'type': 'CommunicationIdentifierModel'}, + } + + def __init__( + self, + **kwargs + ): + super(GetParticipantByIdRequest, self).__init__(**kwargs) + self.identifier = kwargs['identifier'] + + class JoinCallRequest(msrest.serialization.Model): """The request payload for join call. @@ -636,12 +747,15 @@ def __init__( class PlayAudioRequest(msrest.serialization.Model): """The request payload for playing audio. + All required parameters must be populated in order to send to Azure. + :param audio_file_uri: The media resource uri of the play audio request. Currently only Wave file (.wav) format audio prompts are supported. More specifically, the audio content in the wave file must be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate. :type audio_file_uri: str - :param loop: The flag indicating whether audio file needs to be played in loop or not. + :param loop: Required. The flag indicating whether audio file needs to be played in loop or + not. :type loop: bool :param operation_context: The value to identify context of the operation. :type operation_context: str @@ -652,6 +766,10 @@ class PlayAudioRequest(msrest.serialization.Model): :type callback_uri: str """ + _validation = { + 'loop': {'required': True}, + } + _attribute_map = { 'audio_file_uri': {'key': 'audioFileUri', 'type': 'str'}, 'loop': {'key': 'loop', 'type': 'bool'}, @@ -666,7 +784,7 @@ def __init__( ): super(PlayAudioRequest, self).__init__(**kwargs) self.audio_file_uri = kwargs.get('audio_file_uri', None) - self.loop = kwargs.get('loop', None) + self.loop = kwargs['loop'] self.operation_context = kwargs.get('operation_context', None) self.audio_file_id = kwargs.get('audio_file_id', None) self.callback_uri = kwargs.get('callback_uri', None) @@ -744,6 +862,31 @@ def __init__( self.status = kwargs['status'] +class RemoveParticipantByIdRequest(msrest.serialization.Model): + """The remove participant by identifier request. + + All required parameters must be populated in order to send to Azure. + + :param identifier: Required. The identifier of the participant to be removed from the call. + :type identifier: ~azure.communication.callingserver.models.CommunicationIdentifierModel + """ + + _validation = { + 'identifier': {'required': True}, + } + + _attribute_map = { + 'identifier': {'key': 'identifier', 'type': 'CommunicationIdentifierModel'}, + } + + def __init__( + self, + **kwargs + ): + super(RemoveParticipantByIdRequest, self).__init__(**kwargs) + self.identifier = kwargs['identifier'] + + class ResultInfo(msrest.serialization.Model): """Result info class to be used to report result status for actions/operations. @@ -752,6 +895,7 @@ class ResultInfo(msrest.serialization.Model): :param code: Required. The result code associated with the operation. :type code: int :param subcode: Required. The subcode that further classifies the result. + The subcode further classifies a failure. For example. :type subcode: int :param message: The message is a detail explanation of subcode. :type message: str @@ -783,10 +927,25 @@ class StartCallRecordingRequest(msrest.serialization.Model): :param recording_state_callback_uri: The uri to send notifications to. :type recording_state_callback_uri: str + :param recording_content_type: Content type of call recording. Possible values include: + "audio", "audioVideo". + :type recording_content_type: str or + ~azure.communication.callingserver.models.RecordingContentType + :param recording_channel_type: Channel type of call recording. Possible values include: + "mixed", "unmixed". + :type recording_channel_type: str or + ~azure.communication.callingserver.models.RecordingChannelType + :param recording_format_type: Format type of call recording. Possible values include: "wav", + "mp3", "mp4". + :type recording_format_type: str or + ~azure.communication.callingserver.models.RecordingFormatType """ _attribute_map = { 'recording_state_callback_uri': {'key': 'recordingStateCallbackUri', 'type': 'str'}, + 'recording_content_type': {'key': 'recordingContentType', 'type': 'str'}, + 'recording_channel_type': {'key': 'recordingChannelType', 'type': 'str'}, + 'recording_format_type': {'key': 'recordingFormatType', 'type': 'str'}, } def __init__( @@ -795,6 +954,9 @@ def __init__( ): super(StartCallRecordingRequest, self).__init__(**kwargs) self.recording_state_callback_uri = kwargs.get('recording_state_callback_uri', None) + self.recording_content_type = kwargs.get('recording_content_type', None) + self.recording_channel_type = kwargs.get('recording_channel_type', None) + self.recording_format_type = kwargs.get('recording_format_type', None) class StartCallRecordingResult(msrest.serialization.Model): @@ -816,6 +978,139 @@ def __init__( self.recording_id = kwargs.get('recording_id', None) +class StartHoldMusicRequest(msrest.serialization.Model): + """The request payload for playing hold music for a participant. + + :param audio_file_uri: The media resource uri of the hold music request. + Currently only Wave file (.wav) format audio prompts are supported. + More specifically, the audio content in the wave file must be mono (single-channel), + 16-bit samples with a 16,000 (16KHz) sampling rate. + :type audio_file_uri: str + :param audio_file_id: An id for the media in the AudioFileUri, using which we cache the media + resource. + :type audio_file_id: str + :param callback_uri: The callback URI. + :type callback_uri: str + """ + + _attribute_map = { + 'audio_file_uri': {'key': 'audioFileUri', 'type': 'str'}, + 'audio_file_id': {'key': 'audioFileId', 'type': 'str'}, + 'callback_uri': {'key': 'callbackUri', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(StartHoldMusicRequest, self).__init__(**kwargs) + self.audio_file_uri = kwargs.get('audio_file_uri', None) + self.audio_file_id = kwargs.get('audio_file_id', None) + self.callback_uri = kwargs.get('callback_uri', None) + + +class StartHoldMusicResult(msrest.serialization.Model): + """The response payload for start hold music operation. + + All required parameters must be populated in order to send to Azure. + + :param operation_id: The operation id. + :type operation_id: str + :param status: Required. The status of the operation. Possible values include: "notStarted", + "running", "completed", "failed". + :type status: str or ~azure.communication.callingserver.models.OperationStatus + :param operation_context: The operation context provided by client. + :type operation_context: str + :param result_info: The result info for the operation. + :type result_info: ~azure.communication.callingserver.models.ResultInfo + """ + + _validation = { + 'status': {'required': True}, + } + + _attribute_map = { + 'operation_id': {'key': 'operationId', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'operation_context': {'key': 'operationContext', 'type': 'str'}, + 'result_info': {'key': 'resultInfo', 'type': 'ResultInfo'}, + } + + def __init__( + self, + **kwargs + ): + super(StartHoldMusicResult, self).__init__(**kwargs) + self.operation_id = kwargs.get('operation_id', None) + self.status = kwargs['status'] + self.operation_context = kwargs.get('operation_context', None) + self.result_info = kwargs.get('result_info', None) + + +class StopHoldMusicRequest(msrest.serialization.Model): + """The request payload for playing hold music for a participant. + + All required parameters must be populated in order to send to Azure. + + :param start_hold_music_operation_id: Required. The operationId of the StartHoldMusicOperation + to stop. + :type start_hold_music_operation_id: str + """ + + _validation = { + 'start_hold_music_operation_id': {'required': True}, + } + + _attribute_map = { + 'start_hold_music_operation_id': {'key': 'startHoldMusicOperationId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(StopHoldMusicRequest, self).__init__(**kwargs) + self.start_hold_music_operation_id = kwargs['start_hold_music_operation_id'] + + +class StopHoldMusicResult(msrest.serialization.Model): + """The response payload for start hold music operation. + + All required parameters must be populated in order to send to Azure. + + :param operation_id: The operation id. + :type operation_id: str + :param status: Required. The status of the operation. Possible values include: "notStarted", + "running", "completed", "failed". + :type status: str or ~azure.communication.callingserver.models.OperationStatus + :param operation_context: The operation context provided by client. + :type operation_context: str + :param result_info: The result info for the operation. + :type result_info: ~azure.communication.callingserver.models.ResultInfo + """ + + _validation = { + 'status': {'required': True}, + } + + _attribute_map = { + 'operation_id': {'key': 'operationId', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'operation_context': {'key': 'operationContext', 'type': 'str'}, + 'result_info': {'key': 'resultInfo', 'type': 'ResultInfo'}, + } + + def __init__( + self, + **kwargs + ): + super(StopHoldMusicResult, self).__init__(**kwargs) + self.operation_id = kwargs.get('operation_id', None) + self.status = kwargs['status'] + self.operation_context = kwargs.get('operation_context', None) + self.result_info = kwargs.get('result_info', None) + + class ToneInfo(msrest.serialization.Model): """The information about the tone. @@ -876,3 +1171,34 @@ def __init__( super(ToneReceivedEvent, self).__init__(**kwargs) self.tone_info = kwargs['tone_info'] self.call_connection_id = kwargs.get('call_connection_id', None) + + +class TransferCallRequest(msrest.serialization.Model): + """The transfer call request. + + All required parameters must be populated in order to send to Azure. + + :param target_participant: Required. The identity of the target where call should be transfer + to. + :type target_participant: + ~azure.communication.callingserver.models.CommunicationIdentifierModel + :param user_to_user_information: The user to user information. + :type user_to_user_information: str + """ + + _validation = { + 'target_participant': {'required': True}, + } + + _attribute_map = { + 'target_participant': {'key': 'targetParticipant', 'type': 'CommunicationIdentifierModel'}, + 'user_to_user_information': {'key': 'userToUserInformation', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TransferCallRequest, self).__init__(**kwargs) + self.target_participant = kwargs['target_participant'] + self.user_to_user_information = kwargs.get('user_to_user_information', None) diff --git a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/models/_models_py3.py b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/models/_models_py3.py index 647d330b9c4a..fc487ab9d206 100644 --- a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/models/_models_py3.py +++ b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/models/_models_py3.py @@ -110,6 +110,76 @@ def __init__( self.status = status +class CallConnectionProperties(msrest.serialization.Model): + """CallConnectionProperties. + + :param call_connection_id: The call connection id. + :type call_connection_id: str + :param source: The source of the call. + :type source: ~azure.communication.callingserver.models.CommunicationIdentifierModel + :param alternate_caller_id: The alternate identity of the source of the call if dialing out to + a pstn number. + :type alternate_caller_id: ~azure.communication.callingserver.models.PhoneNumberIdentifierModel + :param targets: The targets of the call. + :type targets: list[~azure.communication.callingserver.models.CommunicationIdentifierModel] + :param call_connection_state: The state of the call connection. Possible values include: + "connecting", "connected", "transferring", "transferAccepted", "disconnecting", "disconnected". + :type call_connection_state: str or + ~azure.communication.callingserver.models.CallConnectionState + :param subject: The subject. + :type subject: str + :param callback_uri: The callback URI. + :type callback_uri: str + :param requested_media_types: The requested modalities. + :type requested_media_types: list[str or ~azure.communication.callingserver.models.MediaType] + :param requested_call_events: The requested call events to subscribe to. + :type requested_call_events: list[str or + ~azure.communication.callingserver.models.EventSubscriptionType] + :param server_call_id: The server call id. + :type server_call_id: str + """ + + _attribute_map = { + 'call_connection_id': {'key': 'callConnectionId', 'type': 'str'}, + 'source': {'key': 'source', 'type': 'CommunicationIdentifierModel'}, + 'alternate_caller_id': {'key': 'alternateCallerId', 'type': 'PhoneNumberIdentifierModel'}, + 'targets': {'key': 'targets', 'type': '[CommunicationIdentifierModel]'}, + 'call_connection_state': {'key': 'callConnectionState', 'type': 'str'}, + 'subject': {'key': 'subject', 'type': 'str'}, + 'callback_uri': {'key': 'callbackUri', 'type': 'str'}, + 'requested_media_types': {'key': 'requestedMediaTypes', 'type': '[str]'}, + 'requested_call_events': {'key': 'requestedCallEvents', 'type': '[str]'}, + 'server_call_id': {'key': 'serverCallId', 'type': 'str'}, + } + + def __init__( + self, + *, + call_connection_id: Optional[str] = None, + source: Optional["CommunicationIdentifierModel"] = None, + alternate_caller_id: Optional["PhoneNumberIdentifierModel"] = None, + targets: Optional[List["CommunicationIdentifierModel"]] = None, + call_connection_state: Optional[Union[str, "CallConnectionState"]] = None, + subject: Optional[str] = None, + callback_uri: Optional[str] = None, + requested_media_types: Optional[List[Union[str, "MediaType"]]] = None, + requested_call_events: Optional[List[Union[str, "EventSubscriptionType"]]] = None, + server_call_id: Optional[str] = None, + **kwargs + ): + super(CallConnectionProperties, self).__init__(**kwargs) + self.call_connection_id = call_connection_id + self.source = source + self.alternate_caller_id = alternate_caller_id + self.targets = targets + self.call_connection_state = call_connection_state + self.subject = subject + self.callback_uri = callback_uri + self.requested_media_types = requested_media_types + self.requested_call_events = requested_call_events + self.server_call_id = server_call_id + + class CallConnectionStateChangedEvent(msrest.serialization.Model): """The call connection state changed event. @@ -119,8 +189,9 @@ class CallConnectionStateChangedEvent(msrest.serialization.Model): :type server_call_id: str :param call_connection_id: The call connection id. :type call_connection_id: str - :param call_connection_state: Required. The call connection state. Possible values include: - "incoming", "connecting", "connected", "disconnecting", "disconnected". + :param call_connection_state: Required. The state of the call connection. Possible values + include: "connecting", "connected", "transferring", "transferAccepted", "disconnecting", + "disconnected". :type call_connection_state: str or ~azure.communication.callingserver.models.CallConnectionState """ @@ -154,7 +225,7 @@ class CallParticipant(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param identifier: Communication identifier of the participant. + :param identifier: Required. Communication identifier of the participant. :type identifier: ~azure.communication.callingserver.models.CommunicationIdentifierModel :param participant_id: Participant id. :type participant_id: str @@ -163,6 +234,7 @@ class CallParticipant(msrest.serialization.Model): """ _validation = { + 'identifier': {'required': True}, 'is_muted': {'required': True}, } @@ -175,8 +247,8 @@ class CallParticipant(msrest.serialization.Model): def __init__( self, *, + identifier: "CommunicationIdentifierModel", is_muted: bool, - identifier: Optional["CommunicationIdentifierModel"] = None, participant_id: Optional[str] = None, **kwargs ): @@ -322,6 +394,33 @@ def __init__( self.result_info = result_info +class CancelMediaOperationRequest(msrest.serialization.Model): + """The request payload for stopping a media operation for a participant. + + All required parameters must be populated in order to send to Azure. + + :param media_operation_id: Required. The operationId of the media operation to cancel. + :type media_operation_id: str + """ + + _validation = { + 'media_operation_id': {'required': True}, + } + + _attribute_map = { + 'media_operation_id': {'key': 'mediaOperationId', 'type': 'str'}, + } + + def __init__( + self, + *, + media_operation_id: str, + **kwargs + ): + super(CancelMediaOperationRequest, self).__init__(**kwargs) + self.media_operation_id = media_operation_id + + class CommunicationError(msrest.serialization.Model): """The Communication Services error. @@ -546,6 +645,33 @@ def __init__( self.call_connection_id = call_connection_id +class GetParticipantByIdRequest(msrest.serialization.Model): + """The get participant by identifier request. + + All required parameters must be populated in order to send to Azure. + + :param identifier: Required. The identifier of the participant. + :type identifier: ~azure.communication.callingserver.models.CommunicationIdentifierModel + """ + + _validation = { + 'identifier': {'required': True}, + } + + _attribute_map = { + 'identifier': {'key': 'identifier', 'type': 'CommunicationIdentifierModel'}, + } + + def __init__( + self, + *, + identifier: "CommunicationIdentifierModel", + **kwargs + ): + super(GetParticipantByIdRequest, self).__init__(**kwargs) + self.identifier = identifier + + class JoinCallRequest(msrest.serialization.Model): """The request payload for join call. @@ -713,12 +839,15 @@ def __init__( class PlayAudioRequest(msrest.serialization.Model): """The request payload for playing audio. + All required parameters must be populated in order to send to Azure. + :param audio_file_uri: The media resource uri of the play audio request. Currently only Wave file (.wav) format audio prompts are supported. More specifically, the audio content in the wave file must be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate. :type audio_file_uri: str - :param loop: The flag indicating whether audio file needs to be played in loop or not. + :param loop: Required. The flag indicating whether audio file needs to be played in loop or + not. :type loop: bool :param operation_context: The value to identify context of the operation. :type operation_context: str @@ -729,6 +858,10 @@ class PlayAudioRequest(msrest.serialization.Model): :type callback_uri: str """ + _validation = { + 'loop': {'required': True}, + } + _attribute_map = { 'audio_file_uri': {'key': 'audioFileUri', 'type': 'str'}, 'loop': {'key': 'loop', 'type': 'bool'}, @@ -740,8 +873,8 @@ class PlayAudioRequest(msrest.serialization.Model): def __init__( self, *, + loop: bool, audio_file_uri: Optional[str] = None, - loop: Optional[bool] = None, operation_context: Optional[str] = None, audio_file_id: Optional[str] = None, callback_uri: Optional[str] = None, @@ -836,6 +969,33 @@ def __init__( self.status = status +class RemoveParticipantByIdRequest(msrest.serialization.Model): + """The remove participant by identifier request. + + All required parameters must be populated in order to send to Azure. + + :param identifier: Required. The identifier of the participant to be removed from the call. + :type identifier: ~azure.communication.callingserver.models.CommunicationIdentifierModel + """ + + _validation = { + 'identifier': {'required': True}, + } + + _attribute_map = { + 'identifier': {'key': 'identifier', 'type': 'CommunicationIdentifierModel'}, + } + + def __init__( + self, + *, + identifier: "CommunicationIdentifierModel", + **kwargs + ): + super(RemoveParticipantByIdRequest, self).__init__(**kwargs) + self.identifier = identifier + + class ResultInfo(msrest.serialization.Model): """Result info class to be used to report result status for actions/operations. @@ -844,6 +1004,7 @@ class ResultInfo(msrest.serialization.Model): :param code: Required. The result code associated with the operation. :type code: int :param subcode: Required. The subcode that further classifies the result. + The subcode further classifies a failure. For example. :type subcode: int :param message: The message is a detail explanation of subcode. :type message: str @@ -879,20 +1040,41 @@ class StartCallRecordingRequest(msrest.serialization.Model): :param recording_state_callback_uri: The uri to send notifications to. :type recording_state_callback_uri: str + :param recording_content_type: Content type of call recording. Possible values include: + "audio", "audioVideo". + :type recording_content_type: str or + ~azure.communication.callingserver.models.RecordingContentType + :param recording_channel_type: Channel type of call recording. Possible values include: + "mixed", "unmixed". + :type recording_channel_type: str or + ~azure.communication.callingserver.models.RecordingChannelType + :param recording_format_type: Format type of call recording. Possible values include: "wav", + "mp3", "mp4". + :type recording_format_type: str or + ~azure.communication.callingserver.models.RecordingFormatType """ _attribute_map = { 'recording_state_callback_uri': {'key': 'recordingStateCallbackUri', 'type': 'str'}, + 'recording_content_type': {'key': 'recordingContentType', 'type': 'str'}, + 'recording_channel_type': {'key': 'recordingChannelType', 'type': 'str'}, + 'recording_format_type': {'key': 'recordingFormatType', 'type': 'str'}, } def __init__( self, *, recording_state_callback_uri: Optional[str] = None, + recording_content_type: Optional[Union[str, "RecordingContentType"]] = None, + recording_channel_type: Optional[Union[str, "RecordingChannelType"]] = None, + recording_format_type: Optional[Union[str, "RecordingFormatType"]] = None, **kwargs ): super(StartCallRecordingRequest, self).__init__(**kwargs) self.recording_state_callback_uri = recording_state_callback_uri + self.recording_content_type = recording_content_type + self.recording_channel_type = recording_channel_type + self.recording_format_type = recording_format_type class StartCallRecordingResult(msrest.serialization.Model): @@ -916,6 +1098,155 @@ def __init__( self.recording_id = recording_id +class StartHoldMusicRequest(msrest.serialization.Model): + """The request payload for playing hold music for a participant. + + :param audio_file_uri: The media resource uri of the hold music request. + Currently only Wave file (.wav) format audio prompts are supported. + More specifically, the audio content in the wave file must be mono (single-channel), + 16-bit samples with a 16,000 (16KHz) sampling rate. + :type audio_file_uri: str + :param audio_file_id: An id for the media in the AudioFileUri, using which we cache the media + resource. + :type audio_file_id: str + :param callback_uri: The callback URI. + :type callback_uri: str + """ + + _attribute_map = { + 'audio_file_uri': {'key': 'audioFileUri', 'type': 'str'}, + 'audio_file_id': {'key': 'audioFileId', 'type': 'str'}, + 'callback_uri': {'key': 'callbackUri', 'type': 'str'}, + } + + def __init__( + self, + *, + audio_file_uri: Optional[str] = None, + audio_file_id: Optional[str] = None, + callback_uri: Optional[str] = None, + **kwargs + ): + super(StartHoldMusicRequest, self).__init__(**kwargs) + self.audio_file_uri = audio_file_uri + self.audio_file_id = audio_file_id + self.callback_uri = callback_uri + + +class StartHoldMusicResult(msrest.serialization.Model): + """The response payload for start hold music operation. + + All required parameters must be populated in order to send to Azure. + + :param operation_id: The operation id. + :type operation_id: str + :param status: Required. The status of the operation. Possible values include: "notStarted", + "running", "completed", "failed". + :type status: str or ~azure.communication.callingserver.models.OperationStatus + :param operation_context: The operation context provided by client. + :type operation_context: str + :param result_info: The result info for the operation. + :type result_info: ~azure.communication.callingserver.models.ResultInfo + """ + + _validation = { + 'status': {'required': True}, + } + + _attribute_map = { + 'operation_id': {'key': 'operationId', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'operation_context': {'key': 'operationContext', 'type': 'str'}, + 'result_info': {'key': 'resultInfo', 'type': 'ResultInfo'}, + } + + def __init__( + self, + *, + status: Union[str, "OperationStatus"], + operation_id: Optional[str] = None, + operation_context: Optional[str] = None, + result_info: Optional["ResultInfo"] = None, + **kwargs + ): + super(StartHoldMusicResult, self).__init__(**kwargs) + self.operation_id = operation_id + self.status = status + self.operation_context = operation_context + self.result_info = result_info + + +class StopHoldMusicRequest(msrest.serialization.Model): + """The request payload for playing hold music for a participant. + + All required parameters must be populated in order to send to Azure. + + :param start_hold_music_operation_id: Required. The operationId of the StartHoldMusicOperation + to stop. + :type start_hold_music_operation_id: str + """ + + _validation = { + 'start_hold_music_operation_id': {'required': True}, + } + + _attribute_map = { + 'start_hold_music_operation_id': {'key': 'startHoldMusicOperationId', 'type': 'str'}, + } + + def __init__( + self, + *, + start_hold_music_operation_id: str, + **kwargs + ): + super(StopHoldMusicRequest, self).__init__(**kwargs) + self.start_hold_music_operation_id = start_hold_music_operation_id + + +class StopHoldMusicResult(msrest.serialization.Model): + """The response payload for start hold music operation. + + All required parameters must be populated in order to send to Azure. + + :param operation_id: The operation id. + :type operation_id: str + :param status: Required. The status of the operation. Possible values include: "notStarted", + "running", "completed", "failed". + :type status: str or ~azure.communication.callingserver.models.OperationStatus + :param operation_context: The operation context provided by client. + :type operation_context: str + :param result_info: The result info for the operation. + :type result_info: ~azure.communication.callingserver.models.ResultInfo + """ + + _validation = { + 'status': {'required': True}, + } + + _attribute_map = { + 'operation_id': {'key': 'operationId', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'operation_context': {'key': 'operationContext', 'type': 'str'}, + 'result_info': {'key': 'resultInfo', 'type': 'ResultInfo'}, + } + + def __init__( + self, + *, + status: Union[str, "OperationStatus"], + operation_id: Optional[str] = None, + operation_context: Optional[str] = None, + result_info: Optional["ResultInfo"] = None, + **kwargs + ): + super(StopHoldMusicResult, self).__init__(**kwargs) + self.operation_id = operation_id + self.status = status + self.operation_context = operation_context + self.result_info = result_info + + class ToneInfo(msrest.serialization.Model): """The information about the tone. @@ -982,3 +1313,37 @@ def __init__( super(ToneReceivedEvent, self).__init__(**kwargs) self.tone_info = tone_info self.call_connection_id = call_connection_id + + +class TransferCallRequest(msrest.serialization.Model): + """The transfer call request. + + All required parameters must be populated in order to send to Azure. + + :param target_participant: Required. The identity of the target where call should be transfer + to. + :type target_participant: + ~azure.communication.callingserver.models.CommunicationIdentifierModel + :param user_to_user_information: The user to user information. + :type user_to_user_information: str + """ + + _validation = { + 'target_participant': {'required': True}, + } + + _attribute_map = { + 'target_participant': {'key': 'targetParticipant', 'type': 'CommunicationIdentifierModel'}, + 'user_to_user_information': {'key': 'userToUserInformation', 'type': 'str'}, + } + + def __init__( + self, + *, + target_participant: "CommunicationIdentifierModel", + user_to_user_information: Optional[str] = None, + **kwargs + ): + super(TransferCallRequest, self).__init__(**kwargs) + self.target_participant = target_participant + self.user_to_user_information = user_to_user_information diff --git a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/operations/_call_connections_operations.py b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/operations/_call_connections_operations.py index f70c372d4bcc..443046e93f30 100644 --- a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/operations/_call_connections_operations.py +++ b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/operations/_call_connections_operations.py @@ -16,7 +16,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -70,7 +70,7 @@ def create_call( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -109,6 +109,127 @@ def create_call( return deserialized create_call.metadata = {'url': '/calling/callConnections'} # type: ignore + def get_call( + self, + call_connection_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.CallConnectionProperties" + """Get call connection. + + Get call connection. + + :param call_connection_id: The call connection id. + :type call_connection_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CallConnectionProperties, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.CallConnectionProperties + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CallConnectionProperties"] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get_call.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('CallConnectionProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_call.metadata = {'url': '/calling/callConnections/{callConnectionId}'} # type: ignore + + def delete_call( + self, + call_connection_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Delete the call. + + Delete the call. + + :param call_connection_id: The call connection id. + :type call_connection_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.delete_call.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + delete_call.metadata = {'url': '/calling/callConnections/{callConnectionId}'} # type: ignore + def hangup_call( self, call_connection_id, # type: str @@ -136,7 +257,7 @@ def hangup_call( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" accept = "application/json" # Construct URL @@ -198,7 +319,7 @@ def play_audio( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -268,7 +389,7 @@ def cancel_all_media_operations( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -308,27 +429,86 @@ def cancel_all_media_operations( return deserialized cancel_all_media_operations.metadata = {'url': '/calling/callConnections/{callConnectionId}/:cancelAllMediaOperations'} # type: ignore - def add_participant( + def keep_alive( self, call_connection_id, # type: str - add_participant_request, # type: "_models.AddParticipantRequest" **kwargs # type: Any ): - # type: (...) -> "_models.AddParticipantResult" - """Add a participant to the call. + # type: (...) -> None + """Keep the call alive. - Add a participant to the call. + Keep the call alive. :param call_connection_id: The call connection id. :type call_connection_id: str - :param add_participant_request: Add participant request. - :type add_participant_request: ~azure.communication.callingserver.models.AddParticipantRequest :keyword callable cls: A custom type or function that will be passed the direct response - :return: AddParticipantResult, or the result of cls(response) - :rtype: ~azure.communication.callingserver.models.AddParticipantResult + :return: None, or the result of cls(response) + :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AddParticipantResult"] + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.keep_alive.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + keep_alive.metadata = {'url': '/calling/callConnections/{callConnectionId}/:keepAlive'} # type: ignore + + def transfer( + self, + call_connection_id, # type: str + transfer_call_request, # type: "_models.TransferCallRequest" + **kwargs # type: Any + ): + # type: (...) -> None + """Transfer the call to a participant or to another call. + + Transfer the call to a participant or to another call. + + :param call_connection_id: The call connection id. + :type call_connection_id: str + :param transfer_call_request: The transfer call request. + :type transfer_call_request: ~azure.communication.callingserver.models.TransferCallRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 409: ResourceExistsError, 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), @@ -338,12 +518,12 @@ def add_participant( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL - url = self.add_participant.metadata['url'] # type: ignore + url = self.transfer.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), @@ -360,7 +540,7 @@ def add_participant( header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(add_participant_request, 'AddParticipantRequest') + body_content = self._serialize.body(transfer_call_request, 'TransferCallRequest') body_content_kwargs['content'] = body_content request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) @@ -370,35 +550,94 @@ def add_participant( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = self._deserialize('AddParticipantResult', pipeline_response) + if cls: + return cls(pipeline_response, None, {}) + + transfer.metadata = {'url': '/calling/callConnections/{callConnectionId}/:transfer'} # type: ignore + + def get_participants( + self, + call_connection_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> List["_models.CallParticipant"] + """Get participants from a call. + + Get participants from a call. + + :param call_connection_id: The call connection id. + :type call_connection_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of CallParticipant, or the result of cls(response) + :rtype: list[~azure.communication.callingserver.models.CallParticipant] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[List["_models.CallParticipant"]] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get_participants.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('[CallParticipant]', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - add_participant.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants'} # type: ignore + get_participants.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants'} # type: ignore - def remove_participant( + def add_participant( self, call_connection_id, # type: str - participant_id, # type: str + add_participant_request, # type: "_models.AddParticipantRequest" **kwargs # type: Any ): - # type: (...) -> None - """Remove a participant from the call. + # type: (...) -> "_models.AddParticipantResult" + """Add a participant to the call. - Remove a participant from the call. + Add a participant to the call. :param call_connection_id: The call connection id. :type call_connection_id: str - :param participant_id: The participant id. - :type participant_id: str + :param add_participant_request: Add participant request. + :type add_participant_request: ~azure.communication.callingserver.models.AddParticipantRequest :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None + :return: AddParticipantResult, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.AddParticipantResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AddParticipantResult"] error_map = { 409: ResourceExistsError, 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), @@ -408,15 +647,15 @@ def remove_participant( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL - url = self.remove_participant.metadata['url'] # type: ignore + url = self.add_participant.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), - 'participantId': self._serialize.url("participant_id", participant_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -426,9 +665,13 @@ def remove_participant( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.delete(url, query_parameters, header_parameters) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(add_participant_request, 'AddParticipantRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -436,7 +679,562 @@ def remove_participant( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + deserialized = self._deserialize('AddParticipantResult', pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + + return deserialized + add_participant.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants'} # type: ignore + + def remove_participant_by_id( + self, + call_connection_id, # type: str + remove_participant_by_id_request, # type: "_models.RemoveParticipantByIdRequest" + **kwargs # type: Any + ): + # type: (...) -> None + """Remove participant from the call using identifier. + + Remove participant from the call using identifier. + + :param call_connection_id: The call connection id. + :type call_connection_id: str + :param remove_participant_by_id_request: The identifier of the participant to be removed from + the call. + :type remove_participant_by_id_request: ~azure.communication.callingserver.models.RemoveParticipantByIdRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.remove_participant_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(remove_participant_by_id_request, 'RemoveParticipantByIdRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + remove_participant_by_id.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants/:removeUser'} # type: ignore + + def get_participant_by_id( + self, + call_connection_id, # type: str + get_participant_by_id_request, # type: "_models.GetParticipantByIdRequest" + **kwargs # type: Any + ): + # type: (...) -> List["_models.CallParticipant"] + """Get participant from the call using identifier. + + Get participant from the call using identifier. + + :param call_connection_id: The call connection id. + :type call_connection_id: str + :param get_participant_by_id_request: The identifier of the participant to get from the call. + :type get_participant_by_id_request: ~azure.communication.callingserver.models.GetParticipantByIdRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of CallParticipant, or the result of cls(response) + :rtype: list[~azure.communication.callingserver.models.CallParticipant] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[List["_models.CallParticipant"]] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.get_participant_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(get_participant_by_id_request, 'GetParticipantByIdRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('[CallParticipant]', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_participant_by_id.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants/:getUser'} # type: ignore + + def get_participant( + self, + call_connection_id, # type: str + participant_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.CallParticipant" + """Get participant by participant id from the call. + + Get participant by participant id from the call. + + :param call_connection_id: The call connection id. + :type call_connection_id: str + :param participant_id: The participant id. + :type participant_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CallParticipant, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.CallParticipant + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CallParticipant"] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get_participant.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('CallParticipant', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_participant.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants/{participantId}'} # type: ignore + + def remove_participant( + self, + call_connection_id, # type: str + participant_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Remove a participant from the call. + + Remove a participant from the call. + + :param call_connection_id: The call connection id. + :type call_connection_id: str + :param participant_id: The participant id. + :type participant_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.remove_participant.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) remove_participant.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants/{participantId}'} # type: ignore + + def start_hold_music( + self, + call_connection_id, # type: str + participant_id, # type: str + request, # type: "_models.StartHoldMusicRequest" + **kwargs # type: Any + ): + # type: (...) -> "_models.StartHoldMusicResult" + """Play hold music to a participant. + + Play hold music to a participant. + + :param call_connection_id: The callConnectionId. + :type call_connection_id: str + :param participant_id: The participant id. + :type participant_id: str + :param request: The start hold music request. + :type request: ~azure.communication.callingserver.models.StartHoldMusicRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StartHoldMusicResult, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.StartHoldMusicResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.StartHoldMusicResult"] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.start_hold_music.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(request, 'StartHoldMusicRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('StartHoldMusicResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + start_hold_music.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants/{participantId}/:startHoldMusic'} # type: ignore + + def stop_hold_music( + self, + call_connection_id, # type: str + participant_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.StopHoldMusicResult" + """Stop hold music to a participant. + + Stop hold music to a participant. + + :param call_connection_id: The callConnectionId. + :type call_connection_id: str + :param participant_id: The participant id. + :type participant_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StopHoldMusicResult, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.StopHoldMusicResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.StopHoldMusicResult"] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.stop_hold_music.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('StopHoldMusicResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + stop_hold_music.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants/{participantId}/:stopHoldMusic'} # type: ignore + + def participant_play_audio( + self, + call_connection_id, # type: str + participant_id, # type: str + play_audio_request, # type: "_models.PlayAudioRequest" + **kwargs # type: Any + ): + # type: (...) -> "_models.PlayAudioResult" + """Play audio to a participant. + + Play audio to a participant. + + :param call_connection_id: The callConnectionId. + :type call_connection_id: str + :param participant_id: Participant id. + :type participant_id: str + :param play_audio_request: PlayAudioRequest body. + :type play_audio_request: ~azure.communication.callingserver.models.PlayAudioRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PlayAudioResult, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.PlayAudioResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PlayAudioResult"] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.participant_play_audio.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(play_audio_request, 'PlayAudioRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('PlayAudioResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + participant_play_audio.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants/{participantId}/:playAudio'} # type: ignore + + def cancel_participant_media_operation( + self, + call_connection_id, # type: str + participant_id, # type: str + cancel_media_operation_request, # type: "_models.CancelMediaOperationRequest" + **kwargs # type: Any + ): + # type: (...) -> None + """cancel media operation for a participant. + + cancel media operation for a participant. + + :param call_connection_id: The callConnectionId. + :type call_connection_id: str + :param participant_id: The participant id. + :type participant_id: str + :param cancel_media_operation_request: The cancel media operation request. + :type cancel_media_operation_request: ~azure.communication.callingserver.models.CancelMediaOperationRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.cancel_participant_media_operation.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'callConnectionId': self._serialize.url("call_connection_id", call_connection_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(cancel_media_operation_request, 'CancelMediaOperationRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_participant_media_operation.metadata = {'url': '/calling/callConnections/{callConnectionId}/participants/{participantId}/:cancelMediaOperation'} # type: ignore diff --git a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/operations/_server_calls_operations.py b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/operations/_server_calls_operations.py index 3f30d5121437..a0aceb4bea4b 100644 --- a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/operations/_server_calls_operations.py +++ b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/operations/_server_calls_operations.py @@ -16,7 +16,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,27 +43,429 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + def get_participants( + self, + server_call_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> List["_models.CallParticipant"] + """Get participants from a server call. + + Get participants from a server call. + + :param server_call_id: The server call id. + :type server_call_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of CallParticipant, or the result of cls(response) + :rtype: list[~azure.communication.callingserver.models.CallParticipant] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[List["_models.CallParticipant"]] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get_participants.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'serverCallId': self._serialize.url("server_call_id", server_call_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('[CallParticipant]', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_participants.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants'} # type: ignore + def add_participant( self, server_call_id, # type: str - add_participant_request, # type: "_models.AddParticipantRequest" + add_participant_request, # type: "_models.AddParticipantRequest" + **kwargs # type: Any + ): + # type: (...) -> "_models.AddParticipantResult" + """Add a participant to the call. + + Add a participant to the call. + + :param server_call_id: The server call id. + :type server_call_id: str + :param add_participant_request: The add participant request. + :type add_participant_request: ~azure.communication.callingserver.models.AddParticipantRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AddParticipantResult, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.AddParticipantResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AddParticipantResult"] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.add_participant.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'serverCallId': self._serialize.url("server_call_id", server_call_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(add_participant_request, 'AddParticipantRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('AddParticipantResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + add_participant.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants'} # type: ignore + + def remove_participant_by_id( + self, + server_call_id, # type: str + remove_participant_by_id_request, # type: "_models.RemoveParticipantByIdRequest" + **kwargs # type: Any + ): + # type: (...) -> None + """Remove participant from the call using identifier. + + Remove participant from the call using identifier. + + :param server_call_id: The server call id. + :type server_call_id: str + :param remove_participant_by_id_request: The identifier of the participant to be removed from + the call. + :type remove_participant_by_id_request: ~azure.communication.callingserver.models.RemoveParticipantByIdRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.remove_participant_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'serverCallId': self._serialize.url("server_call_id", server_call_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(remove_participant_by_id_request, 'RemoveParticipantByIdRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + remove_participant_by_id.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants/:removeUser'} # type: ignore + + def get_participant_by_id( + self, + server_call_id, # type: str + get_participant_by_id_request, # type: "_models.GetParticipantByIdRequest" + **kwargs # type: Any + ): + # type: (...) -> List["_models.CallParticipant"] + """Get participant from the call using identifier. + + Get participant from the call using identifier. + + :param server_call_id: The server call id. + :type server_call_id: str + :param get_participant_by_id_request: The identifier of the participant to get from the call. + :type get_participant_by_id_request: ~azure.communication.callingserver.models.GetParticipantByIdRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of CallParticipant, or the result of cls(response) + :rtype: list[~azure.communication.callingserver.models.CallParticipant] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[List["_models.CallParticipant"]] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.get_participant_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'serverCallId': self._serialize.url("server_call_id", server_call_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(get_participant_by_id_request, 'GetParticipantByIdRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('[CallParticipant]', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_participant_by_id.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants/:getUser'} # type: ignore + + def get_participant( + self, + server_call_id, # type: str + participant_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.CallParticipant" + """Get participant by participant id from a call. + + Get participant by participant id from a call. + + :param server_call_id: The server call id. + :type server_call_id: str + :param participant_id: The participant id. + :type participant_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CallParticipant, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.CallParticipant + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CallParticipant"] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get_participant.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'serverCallId': self._serialize.url("server_call_id", server_call_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('CallParticipant', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_participant.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants/{participantId}'} # type: ignore + + def remove_participant( + self, + server_call_id, # type: str + participant_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Remove participant from the call. + + Remove participant from the call. + + :param server_call_id: The server call id. + :type server_call_id: str + :param participant_id: The participant id. + :type participant_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.remove_participant.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'serverCallId': self._serialize.url("server_call_id", server_call_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + remove_participant.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants/{participantId}'} # type: ignore + + def start_hold_music( + self, + server_call_id, # type: str + participant_id, # type: str + request, # type: "_models.StartHoldMusicRequest" **kwargs # type: Any ): - # type: (...) -> "_models.AddParticipantResult" - """Add a participant to the call. + # type: (...) -> "_models.StartHoldMusicResult" + """Play hold music to a participant. - Add a participant to the call. + Play hold music to a participant. :param server_call_id: The server call id. :type server_call_id: str - :param add_participant_request: The add participant request. - :type add_participant_request: ~azure.communication.callingserver.models.AddParticipantRequest + :param participant_id: The participant id. + :type participant_id: str + :param request: The start hold music request. + :type request: ~azure.communication.callingserver.models.StartHoldMusicRequest :keyword callable cls: A custom type or function that will be passed the direct response - :return: AddParticipantResult, or the result of cls(response) - :rtype: ~azure.communication.callingserver.models.AddParticipantResult + :return: StartHoldMusicResult, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.StartHoldMusicResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AddParticipantResult"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.StartHoldMusicResult"] error_map = { 409: ResourceExistsError, 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), @@ -73,15 +475,16 @@ def add_participant( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL - url = self.add_participant.metadata['url'] # type: ignore + url = self.start_hold_music.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), 'serverCallId': self._serialize.url("server_call_id", server_call_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -95,7 +498,7 @@ def add_participant( header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(add_participant_request, 'AddParticipantRequest') + body_content = self._serialize.body(request, 'StartHoldMusicRequest') body_content_kwargs['content'] = body_content request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) @@ -105,29 +508,180 @@ def add_participant( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = self._deserialize('AddParticipantResult', pipeline_response) + deserialized = self._deserialize('StartHoldMusicResult', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - add_participant.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants'} # type: ignore + start_hold_music.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants/{participantId}/:startHoldMusic'} # type: ignore - def remove_participant( + def stop_hold_music( self, server_call_id, # type: str participant_id, # type: str + stop_hold_music_request, # type: "_models.StopHoldMusicRequest" **kwargs # type: Any ): - # type: (...) -> None - """Remove participant from the call. + # type: (...) -> "_models.StopHoldMusicResult" + """Stop hold music to a participant. - Remove participant from the call. + Stop hold music to a participant. + + :param server_call_id: The server call id. + :type server_call_id: str + :param participant_id: The participant id. + :type participant_id: str + :param stop_hold_music_request: The stop hold music request. + :type stop_hold_music_request: ~azure.communication.callingserver.models.StopHoldMusicRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StopHoldMusicResult, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.StopHoldMusicResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.StopHoldMusicResult"] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.stop_hold_music.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'serverCallId': self._serialize.url("server_call_id", server_call_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(stop_hold_music_request, 'StopHoldMusicRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('StopHoldMusicResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + stop_hold_music.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants/{participantId}/:stopHoldMusic'} # type: ignore + + def participant_play_audio( + self, + server_call_id, # type: str + participant_id, # type: str + play_audio_request, # type: "_models.PlayAudioRequest" + **kwargs # type: Any + ): + # type: (...) -> "_models.PlayAudioResult" + """Play audio to a participant. + + Play audio to a participant. :param server_call_id: Server call id. :type server_call_id: str :param participant_id: Participant id. :type participant_id: str + :param play_audio_request: PlayAudioRequest body. + :type play_audio_request: ~azure.communication.callingserver.models.PlayAudioRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PlayAudioResult, or the result of cls(response) + :rtype: ~azure.communication.callingserver.models.PlayAudioResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PlayAudioResult"] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.participant_play_audio.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'serverCallId': self._serialize.url("server_call_id", server_call_id, 'str'), + 'participantId': self._serialize.url("participant_id", participant_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(play_audio_request, 'PlayAudioRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('PlayAudioResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + participant_play_audio.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants/{participantId}/:playAudio'} # type: ignore + + def cancel_participant_media_operation( + self, + server_call_id, # type: str + participant_id, # type: str + cancel_media_operation_request, # type: "_models.CancelMediaOperationRequest" + **kwargs # type: Any + ): + # type: (...) -> None + """cancel media operation for a participant. + + cancel media operation for a participant. + + :param server_call_id: The server call id. + :type server_call_id: str + :param participant_id: The participant id. + :type participant_id: str + :param cancel_media_operation_request: The cancel media operation request. + :type cancel_media_operation_request: ~azure.communication.callingserver.models.CancelMediaOperationRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -143,11 +697,12 @@ def remove_participant( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL - url = self.remove_participant.metadata['url'] # type: ignore + url = self.cancel_participant_media_operation.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), 'serverCallId': self._serialize.url("server_call_id", server_call_id, 'str'), @@ -161,20 +716,24 @@ def remove_participant( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.delete(url, query_parameters, header_parameters) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(cancel_media_operation_request, 'CancelMediaOperationRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [202]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) if cls: return cls(pipeline_response, None, {}) - remove_participant.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants/{participantId}'} # type: ignore + cancel_participant_media_operation.metadata = {'url': '/calling/serverCalls/{serverCallId}/participants/{participantId}/:cancelMediaOperation'} # type: ignore def start_recording( self, @@ -183,9 +742,9 @@ def start_recording( **kwargs # type: Any ): # type: (...) -> "_models.StartCallRecordingResult" - """Start recording of the call. + """Start recording the call. - Start recording of the call. + Start recording the call. :param server_call_id: The server call id. :type server_call_id: str @@ -206,7 +765,7 @@ def start_recording( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -276,7 +835,7 @@ def get_recording_properties( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" accept = "application/json" # Construct URL @@ -342,7 +901,7 @@ def stop_recording( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" accept = "application/json" # Construct URL @@ -405,7 +964,7 @@ def pause_recording( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" accept = "application/json" # Construct URL @@ -468,7 +1027,7 @@ def resume_recording( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" accept = "application/json" # Construct URL @@ -531,7 +1090,7 @@ def join_call( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -601,7 +1160,7 @@ def play_audio( 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-15-preview" + api_version = "2021-09-15-preview" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -640,3 +1199,70 @@ def play_audio( return deserialized play_audio.metadata = {'url': '/calling/serverCalls/{serverCallId}/:playAudio'} # type: ignore + + def cancel_media_operation( + self, + server_call_id, # type: str + cancel_media_operation_request, # type: "_models.CancelMediaOperationRequest" + **kwargs # type: Any + ): + # type: (...) -> None + """cancel media operation. + + cancel media operation. + + :param server_call_id: The server call id. + :type server_call_id: str + :param cancel_media_operation_request: The cancel media operation request. + :type cancel_media_operation_request: ~azure.communication.callingserver.models.CancelMediaOperationRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 409: ResourceExistsError, + 400: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 401: lambda response: ClientAuthenticationError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 403: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + 500: lambda response: HttpResponseError(response=response, model=self._deserialize(_models.CommunicationErrorResponse, response)), + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.cancel_media_operation.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'serverCallId': self._serialize.url("server_call_id", server_call_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(cancel_media_operation_request, 'CancelMediaOperationRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_media_operation.metadata = {'url': '/calling/serverCalls/{serverCallId}/:cancelMediaOperation'} # type: ignore diff --git a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_server_call.py b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_server_call.py index 79d7788a6b8a..5f21d51dfe30 100644 --- a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_server_call.py +++ b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_server_call.py @@ -10,6 +10,7 @@ from ._communication_identifier_serializer import serialize_identifier from ._converters import (AddParticipantRequestConverter, + CancelMediaOperationRequestConverter, PlayAudioRequestConverter) from ._generated.models import (AddParticipantResult, PhoneNumberIdentifierModel, @@ -94,3 +95,47 @@ def remove_participant( participant_id=participant_id, **kwargs ) + + @distributed_trace() + def cancel_media_operation( + self, + media_operation_id, # type: str + **kwargs # type: Any + ): # type: (...) -> None + + if not media_operation_id: + raise ValueError("media_operation_id can not be None") + + cancel_media_operation_request = CancelMediaOperationRequestConverter.convert( + media_operation_id=media_operation_id + ) + return self._server_call_client.cancel_media_operation( + server_call_id=self.server_call_id, + cancel_media_operation_request=cancel_media_operation_request, + **kwargs + ) + + @distributed_trace() + def cancel_participant_media_operation( + self, + participant_id, # type: str + media_operation_id, # type: str + **kwargs # type: Any + ): # type: (...) -> None + + if not participant_id: + raise ValueError("participant_id can not be None") + + if not media_operation_id: + raise ValueError("media_operation_id can not be None") + + cancel_media_operation_request = CancelMediaOperationRequestConverter.convert( + media_operation_id=media_operation_id + ) + + return self._server_call_client.cancel_participant_media_operation( + server_call_id=self.server_call_id, + participant_id=participant_id, + cancel_media_operation_request=cancel_media_operation_request, + **kwargs + ) diff --git a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/aio/_call_connection_async.py b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/aio/_call_connection_async.py index 6da30f0bda09..e0a7496632ba 100644 --- a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/aio/_call_connection_async.py +++ b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/aio/_call_connection_async.py @@ -13,9 +13,13 @@ from azure.core.tracing.decorator_async import distributed_trace_async from .._communication_identifier_serializer import serialize_identifier -from .._converters import (AddParticipantRequestConverter, - PlayAudioRequestConverter, - CancelAllMediaOperationsConverter) +from .._converters import ( + AddParticipantRequestConverter, + CancelAllMediaOperationsConverter, + TransferCallRequestConverter, + CancelMediaOperationRequestConverter, + PlayAudioRequestConverter + ) from .._generated.models import (AddParticipantResult, CancelAllMediaOperationsResult, PhoneNumberIdentifierModel, PlayAudioResult) @@ -128,6 +132,53 @@ async def remove_participant( **kwargs ) + @distributed_trace_async() + async def cancel_participant_media_operation( + self, + participant_id: str, + media_operation_id: str, + **kwargs: Any + )-> None: + + if not participant_id: + raise ValueError("participant_id can not be None") + + if not media_operation_id: + raise ValueError("media_operation_id can not be None") + + cancel_media_operation_request = CancelMediaOperationRequestConverter.convert( + media_operation_id=media_operation_id + ) + + return await self._call_connection_client.cancel_participant_media_operation( + call_connection_id=self.call_connection_id, + participant_id=participant_id, + cancel_media_operation_request=cancel_media_operation_request, + **kwargs + ) + + @distributed_trace_async() + async def transfer_call( + self, + target_participant: CommunicationIdentifier, + user_to_user_information: Optional[str], + **kwargs: Any + )-> None: + + if not target_participant: + raise ValueError("target_participant can not be None") + + transfer_call_request = TransferCallRequestConverter.convert( + target_participant=serialize_identifier(target_participant), + user_to_user_information=user_to_user_information + ) + + return await self._call_connection_client.transfer( + call_connection_id=self.call_connection_id, + transfer_call_request=transfer_call_request, + **kwargs + ) + async def close(self) -> None: await self._callingserver_service_client.close() diff --git a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/aio/_server_call_async.py b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/aio/_server_call_async.py index 299542d3112b..db4eda9f02af 100644 --- a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/aio/_server_call_async.py +++ b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/aio/_server_call_async.py @@ -14,6 +14,7 @@ from .._communication_identifier_serializer import serialize_identifier from .._converters import (AddParticipantRequestConverter, + CancelMediaOperationRequestConverter, PlayAudioRequestConverter) from .._generated.models import (AddParticipantResult, PhoneNumberIdentifierModel, @@ -103,6 +104,50 @@ async def remove_participant( **kwargs ) + @distributed_trace_async() + async def cancel_media_operation( + self, + media_operation_id: str, + **kwargs: Any + ) -> None: + + if not media_operation_id: + raise ValueError("media_operation_id can not be None") + + cancel_media_operation_request = CancelMediaOperationRequestConverter.convert( + media_operation_id=media_operation_id + ) + + return await self._server_call_client.cancel_media_operation( + server_call_id=self.server_call_id, + cancel_media_operation_request=cancel_media_operation_request, + **kwargs + ) + + @distributed_trace_async() + async def cancel_participant_media_operation( + self, + participant_id: str, + media_operation_id: str, + **kwargs: Any + ) -> None: + + if not participant_id: + raise ValueError("participant_id can not be None") + + if not media_operation_id: + raise ValueError("media_operation_id can not be None") + + cancel_media_operation_request = CancelMediaOperationRequestConverter.convert( + media_operation_id=media_operation_id + ) + + return await self._server_call_client.cancel_participant_media_operation( + server_call_id=self.server_call_id, + participant_id=participant_id, + cancel_media_operation_request=cancel_media_operation_request, + **kwargs + ) async def close(self) -> None: await self._callingserver_service_client.close() diff --git a/sdk/communication/azure-communication-callingserver/swagger/SWAGGER.md b/sdk/communication/azure-communication-callingserver/swagger/SWAGGER.md index f8ebb86713e0..5509a0d14405 100644 --- a/sdk/communication/azure-communication-callingserver/swagger/SWAGGER.md +++ b/sdk/communication/azure-communication-callingserver/swagger/SWAGGER.md @@ -15,7 +15,7 @@ autorest SWAGGER.md ### Settings ``` yaml -require: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/e0b9ed9e1913aa30da29062715bc14bd38113776/specification/communication/data-plane/CallingServer/readme.md +require: https://raw.githubusercontent.com/navali-msft/azure-rest-api-specs/2b4bddc11bb41ab64fc3d4da7d7bb87c0b50beda/specification/communication/data-plane/CallingServer/readme.md output-folder: ../azure/communication/callingserver/_generated namespace: azure.communication.callingserver no-namespace-folders: true diff --git a/sdk/communication/azure-communication-callingserver/tests/test_call_connection.py b/sdk/communication/azure-communication-callingserver/tests/test_call_connection.py index 460bc1814200..f3ab312bbe42 100644 --- a/sdk/communication/azure-communication-callingserver/tests/test_call_connection.py +++ b/sdk/communication/azure-communication-callingserver/tests/test_call_connection.py @@ -105,6 +105,26 @@ def data_source_test_add_participant(): return parameters +def data_source_test_transfer_call(): + + parameters = [] + parameters.append(( + _test_constants.ClientType_ConnectionString, + _test_constants.CALL_ID, + CommunicationUserIdentifier(_test_constants.RESOURCE_SOURCE), + _test_constants.USER_TO_USER_INFORMATION, + )) + + parameters.append(( + _test_constants.ClientType_ManagedIdentity, + _test_constants.CALL_ID, + CommunicationUserIdentifier(_test_constants.RESOURCE_SOURCE), + _test_constants.USER_TO_USER_INFORMATION, + True, + )) + + return parameters + def data_source_test_remove_participant(): parameters = [] @@ -123,6 +143,26 @@ def data_source_test_remove_participant(): return parameters +def data_source_test_cancel_participant_media_operation(): + + parameters = [] + parameters.append(( + _test_constants.ClientType_ConnectionString, + _test_constants.CALL_ID, + _test_constants.PARTICIPANT_ID, + _test_constants.MEDIA_OPERATION_ID, + )) + + parameters.append(( + _test_constants.ClientType_ManagedIdentity, + _test_constants.CALL_ID, + _test_constants.PARTICIPANT_ID, + _test_constants.MEDIA_OPERATION_ID, + True, + )) + + return parameters + def verify_cancel_all_media_operations_result(result): # type: (CancelAllMediaOperationsResult) -> None assert "dummyId" == result.operation_id @@ -369,4 +409,104 @@ def test_remove_participant_failed( ) except: raised = True + assert raised == True + + @parameterized.expand(data_source_test_cancel_participant_media_operation()) + def test_cancel_participant_media_operation( + self, + test_name, # type: str + call_connection_id, # type: str + participant_id, # type: str + media_operation_id, # type: str + use_managed_identity = False # type: bool + ): + + call_connection = _test_utils.create_mock_call_connection( + call_connection_id, + status_code=200, + payload=None, + use_managed_identity=use_managed_identity + ) + + call_connection.cancel_participant_media_operation( + participant_id = participant_id, + media_operation_id = media_operation_id + ) + assert call_connection.call_connection_id == _test_constants.CALL_ID + + @parameterized.expand(data_source_test_cancel_participant_media_operation()) + def test_cancel_participant_media_operation_failed( + self, + test_name, # type: str + call_connection_id, # type: str + participant_id, # type: str + media_operation_id, # type: str + use_managed_identity = False # type: bool + ): + + call_connection = _test_utils.create_mock_call_connection( + call_connection_id, + status_code=404, + payload=None, + use_managed_identity=use_managed_identity + ) + + raised = False + try: + call_connection.cancel_participant_media_operation( + participant_id = participant_id, + media_operation_id = media_operation_id + ) + except: + raised = True + assert raised == True + + @parameterized.expand(data_source_test_transfer_call()) + def test_transfer_call_succeed( + self, + test_name, # type: str + call_connection_id, # type: str + participant, # type: CommunicationIdentifier + user_to_user_information, # type: str + use_managed_identity = False # type: bool + ): + + call_connection = _test_utils.create_mock_call_connection( + call_connection_id, + status_code=202, + payload=None, + use_managed_identity=use_managed_identity + ) + + call_connection.transfer_call( + target_participant = participant, + user_to_user_information = user_to_user_information + ) + assert call_connection.call_connection_id == _test_constants.CALL_ID + + @parameterized.expand(data_source_test_transfer_call()) + def test_transfer_call_failed( + self, + test_name, # type: str + call_connection_id, # type: str + participant, # type: CommunicationIdentifier + user_to_user_information, # type: str + use_managed_identity = False # type: bool + ): + + call_connection = _test_utils.create_mock_call_connection( + call_connection_id, + status_code=404, + payload=None, + use_managed_identity = use_managed_identity + ) + + raised = False + try: + call_connection.transfer_call( + target_participant = participant, + user_to_user_information = user_to_user_information + ) + except: + raised = True assert raised == True \ No newline at end of file diff --git a/sdk/communication/azure-communication-callingserver/tests/test_call_connection_async.py b/sdk/communication/azure-communication-callingserver/tests/test_call_connection_async.py index 7e053854975f..a49d37c16446 100644 --- a/sdk/communication/azure-communication-callingserver/tests/test_call_connection_async.py +++ b/sdk/communication/azure-communication-callingserver/tests/test_call_connection_async.py @@ -104,6 +104,26 @@ def data_source_test_add_participant(): return parameters +def data_source_test_transfer_call(): + + parameters = [] + parameters.append(( + _test_constants.ClientType_ConnectionString, + _test_constants.CALL_ID, + CommunicationUserIdentifier(_test_constants.RESOURCE_SOURCE), + _test_constants.USER_TO_USER_INFORMATION, + )) + + parameters.append(( + _test_constants.ClientType_ManagedIdentity, + _test_constants.CALL_ID, + CommunicationUserIdentifier(_test_constants.RESOURCE_SOURCE), + _test_constants.USER_TO_USER_INFORMATION, + True, + )) + + return parameters + def data_source_test_remove_participant(): parameters = [] @@ -122,6 +142,26 @@ def data_source_test_remove_participant(): return parameters +def data_source_test_cancel_participant_media_operation(): + + parameters = [] + parameters.append(( + _test_constants.ClientType_ConnectionString, + _test_constants.CALL_ID, + _test_constants.PARTICIPANT_ID, + _test_constants.MEDIA_OPERATION_ID, + )) + + parameters.append(( + _test_constants.ClientType_ManagedIdentity, + _test_constants.CALL_ID, + _test_constants.PARTICIPANT_ID, + _test_constants.MEDIA_OPERATION_ID, + True, + )) + + return parameters + def verify_cancel_all_media_operations_result(result): # type: (CancelAllMediaOperationsResult) -> None assert "dummyId" == result.operation_id @@ -366,4 +406,104 @@ async def test_remove_participant_failed( ) except: raised = True + assert raised == True + +@parameterized.expand(data_source_test_cancel_participant_media_operation()) +@pytest.mark.asyncio +async def test_cancel_participant_media_operation( + test_name, # type: str + call_connection_id, # type: str + participant_id, # type: str + media_operation_id, # type: str + use_managed_identity = False # type: bool + ): + + call_connection = _test_utils_async.create_mock_call_connection( + call_connection_id, + status_code=200, + payload=None, + use_managed_identity=use_managed_identity + ) + + await call_connection.cancel_participant_media_operation( + participant_id = participant_id, + media_operation_id = media_operation_id + ) + assert call_connection.call_connection_id == _test_constants.CALL_ID + +@parameterized.expand(data_source_test_cancel_participant_media_operation()) +@pytest.mark.asyncio +async def test_cancel_participant_media_operation_failed( + test_name, # type: str + call_connection_id, # type: str + participant_id, # type: str + media_operation_id, # type: str + use_managed_identity = False # type: bool + ): + + call_connection = _test_utils_async.create_mock_call_connection( + call_connection_id, + status_code=404, + payload=_test_constants.ErrorPayload, + use_managed_identity = use_managed_identity + ) + + raised = False + try: + await call_connection.cancel_participant_media_operation( + participant_id = participant_id, + media_operation_id = media_operation_id + ) + except: + raised = True + assert raised == True + +@parameterized.expand(data_source_test_transfer_call()) +@pytest.mark.asyncio +async def test_transfer_call_succeed( + test_name, # type: str + call_connection_id, # type: str + participant, # type: CommunicationIdentifier + user_to_user_information, # type: str + use_managed_identity = False # type: bool + ): + + call_connection = _test_utils_async.create_mock_call_connection( + call_connection_id, + status_code=202, + payload=None, + use_managed_identity=use_managed_identity + ) + + await call_connection.transfer_call( + target_participant = participant, + user_to_user_information = user_to_user_information + ) + assert call_connection.call_connection_id == _test_constants.CALL_ID + +@parameterized.expand(data_source_test_transfer_call()) +@pytest.mark.asyncio +async def test_transfer_call_failed( + test_name, # type: str + call_connection_id, # type: str + participant, # type: CommunicationIdentifier + user_to_user_information, # type: str + use_managed_identity = False # type: bool + ): + + call_connection = _test_utils_async.create_mock_call_connection( + call_connection_id, + status_code=404, + payload=None, + use_managed_identity = use_managed_identity + ) + + raised = False + try: + await call_connection.transfer_call( + target_participant = participant, + user_to_user_information = user_to_user_information + ) + except: + raised = True assert raised == True \ No newline at end of file diff --git a/sdk/communication/azure-communication-callingserver/tests/test_server_call.py b/sdk/communication/azure-communication-callingserver/tests/test_server_call.py index f909d146f57c..b01409ce91d7 100644 --- a/sdk/communication/azure-communication-callingserver/tests/test_server_call.py +++ b/sdk/communication/azure-communication-callingserver/tests/test_server_call.py @@ -90,6 +90,44 @@ def data_source_test_remove_participant(): return parameters +def data_source_test_cancel_media_operation(): + + parameters = [] + parameters.append(( + _test_constants.ClientType_ConnectionString, + _test_constants.SERVER_CALL_ID, + _test_constants.MEDIA_OPERATION_ID, + )) + + parameters.append(( + _test_constants.ClientType_ManagedIdentity, + _test_constants.SERVER_CALL_ID, + _test_constants.MEDIA_OPERATION_ID, + True, + )) + + return parameters + +def data_source_test_cancel_participant_media_operation(): + + parameters = [] + parameters.append(( + _test_constants.ClientType_ConnectionString, + _test_constants.SERVER_CALL_ID, + _test_constants.PARTICIPANT_ID, + _test_constants.MEDIA_OPERATION_ID, + )) + + parameters.append(( + _test_constants.ClientType_ManagedIdentity, + _test_constants.SERVER_CALL_ID, + _test_constants.PARTICIPANT_ID, + _test_constants.MEDIA_OPERATION_ID, + True, + )) + + return parameters + def verify_play_audio_result(result): # type: (CancelAllMediaOperationsResult) -> None assert "dummyId" == result.operation_id @@ -251,4 +289,100 @@ def test_remove_participant_failed( ) except: raised = True + assert raised == True + + @parameterized.expand(data_source_test_cancel_media_operation()) + def test_cancel_media_operation_succeed( + self, + test_name, # type: str + server_call_id, # type: str + media_operation_id, # type: str + use_managed_identity = False # type: bool + ): + + server_call = _test_utils.create_mock_server_call( + server_call_id, + status_code=200, + payload=None, + use_managed_identity=use_managed_identity + ) + + server_call.cancel_media_operation( + media_operation_id = media_operation_id + ) + assert server_call.server_call_id == _test_constants.SERVER_CALL_ID + + @parameterized.expand(data_source_test_cancel_media_operation()) + def test_cancel_media_operation_failed( + self, + test_name, # type: str + server_call_id, # type: str + media_operation_id, # type: str + use_managed_identity = False # type: bool + ): + + server_call = _test_utils.create_mock_server_call( + server_call_id, + status_code=404, + payload=_test_constants.ErrorPayload, + use_managed_identity = use_managed_identity + ) + + raised = False + try: + server_call.cancel_media_operation( + media_operation_id = media_operation_id + ) + except: + raised = True + assert raised == True + + @parameterized.expand(data_source_test_cancel_participant_media_operation()) + def test_cancel_participant_media_operation( + self, + test_name, # type: str + server_call_id, # type: str + participant_id, # type: str + media_operation_id, # type: str + use_managed_identity = False # type: bool + ): + + server_call = _test_utils.create_mock_server_call( + server_call_id, + status_code=200, + payload=None, + use_managed_identity=use_managed_identity + ) + + server_call.cancel_participant_media_operation( + participant_id = participant_id, + media_operation_id = media_operation_id + ) + assert server_call.server_call_id == _test_constants.SERVER_CALL_ID + + @parameterized.expand(data_source_test_cancel_participant_media_operation()) + def test_cancel_media_operation_failed( + self, + test_name, # type: str + server_call_id, # type: str + participant_id, # type: str + media_operation_id, # type: str + use_managed_identity = False # type: bool + ): + + server_call = _test_utils.create_mock_server_call( + server_call_id, + status_code=404, + payload=_test_constants.ErrorPayload, + use_managed_identity = use_managed_identity + ) + + raised = False + try: + server_call.cancel_participant_media_operation( + participant_id = participant_id, + media_operation_id = media_operation_id + ) + except: + raised = True assert raised == True \ No newline at end of file diff --git a/sdk/communication/azure-communication-callingserver/tests/test_server_call_async.py b/sdk/communication/azure-communication-callingserver/tests/test_server_call_async.py index c9740108560c..3fac4d174bec 100644 --- a/sdk/communication/azure-communication-callingserver/tests/test_server_call_async.py +++ b/sdk/communication/azure-communication-callingserver/tests/test_server_call_async.py @@ -89,6 +89,44 @@ def data_source_test_remove_participant(): return parameters +def data_source_test_cancel_media_operation(): + + parameters = [] + parameters.append(( + _test_constants.ClientType_ConnectionString, + _test_constants.SERVER_CALL_ID, + _test_constants.MEDIA_OPERATION_ID, + )) + + parameters.append(( + _test_constants.ClientType_ManagedIdentity, + _test_constants.SERVER_CALL_ID, + _test_constants.MEDIA_OPERATION_ID, + True, + )) + + return parameters + +def data_source_test_cancel_participant_media_operation(): + + parameters = [] + parameters.append(( + _test_constants.ClientType_ConnectionString, + _test_constants.SERVER_CALL_ID, + _test_constants.PARTICIPANT_ID, + _test_constants.MEDIA_OPERATION_ID, + )) + + parameters.append(( + _test_constants.ClientType_ManagedIdentity, + _test_constants.SERVER_CALL_ID, + _test_constants.PARTICIPANT_ID, + _test_constants.MEDIA_OPERATION_ID, + True, + )) + + return parameters + def verify_play_audio_result(result): # type: (CancelAllMediaOperationsResult) -> None assert "dummyId" == result.operation_id @@ -248,4 +286,100 @@ async def test_remove_participant_failed( ) except: raised = True + assert raised == True + +@parameterized.expand(data_source_test_cancel_media_operation()) +@pytest.mark.asyncio +async def test_cancel_media_operation_succeed( + test_name, # type: str + server_call_id, # type: str + media_operation_id, # type: str + use_managed_identity = False # type: bool + ): + + server_call = _test_utils_async.create_mock_server_call( + server_call_id, + status_code=200, + payload=None, + use_managed_identity=use_managed_identity + ) + + await server_call.cancel_media_operation( + media_operation_id = media_operation_id + ) + assert server_call.server_call_id == _test_constants.SERVER_CALL_ID + +@parameterized.expand(data_source_test_cancel_media_operation()) +@pytest.mark.asyncio +async def test_cancel_media_operation_failed( + test_name, # type: str + server_call_id, # type: str + media_operation_id, # type: str + use_managed_identity = False # type: bool + ): + + server_call = _test_utils_async.create_mock_server_call( + server_call_id, + status_code=404, + payload=_test_constants.ErrorPayload, + use_managed_identity = use_managed_identity + ) + + raised = False + try: + await server_call.cancel_media_operation( + media_operation_id = media_operation_id + ) + except: + raised = True + assert raised == True + +@parameterized.expand(data_source_test_cancel_participant_media_operation()) +@pytest.mark.asyncio +async def test_cancel_participant_media_operation( + test_name, # type: str + server_call_id, # type: str + participant_id, # type: str + media_operation_id, # type: str + use_managed_identity = False # type: bool + ): + + server_call = _test_utils_async.create_mock_server_call( + server_call_id, + status_code=200, + payload=None, + use_managed_identity=use_managed_identity + ) + + await server_call.cancel_participant_media_operation( + participant_id = participant_id, + media_operation_id = media_operation_id + ) + assert server_call.server_call_id == _test_constants.SERVER_CALL_ID + +@parameterized.expand(data_source_test_cancel_participant_media_operation()) +@pytest.mark.asyncio +async def test_cancel_participant_media_operation_failed( + test_name, # type: str + server_call_id, # type: str + participant_id, # type: str + media_operation_id, # type: str + use_managed_identity = False # type: bool + ): + + server_call = _test_utils_async.create_mock_server_call( + server_call_id, + status_code=404, + payload=_test_constants.ErrorPayload, + use_managed_identity = use_managed_identity + ) + + raised = False + try: + await server_call.cancel_participant_media_operation( + participant_id = participant_id, + media_operation_id = media_operation_id + ) + except: + raised = True assert raised == True \ No newline at end of file diff --git a/sdk/communication/azure-communication-callingserver/tests/utils/_test_constants.py b/sdk/communication/azure-communication-callingserver/tests/utils/_test_constants.py index 54f74dfe8760..60080825a04b 100644 --- a/sdk/communication/azure-communication-callingserver/tests/utils/_test_constants.py +++ b/sdk/communication/azure-communication-callingserver/tests/utils/_test_constants.py @@ -43,6 +43,8 @@ CALLBACK_URI = "https://bot.contoso.io/callback" CONNECTION_STRING = "endpoint=https://REDACTED.communication.azure.com/;accesskey=eyJhbG==" PARTICIPANT_ID = "dummyParticipantId" +MEDIA_OPERATION_ID = "dummyMediaOperationId" +USER_TO_USER_INFORMATION = "dummyUserToUserInformation" # CancelAllMediaOperaions CancelAllMediaOperaionsResponsePayload = { @@ -76,3 +78,4 @@ AddParticipantResultPayload = { "participantId": PARTICIPANT_ID } +