diff --git a/sdk/communication/azure-communication-callingserver/README.md b/sdk/communication/azure-communication-callingserver/README.md index 8b5d665635f24..761a89dee5cc4 100644 --- a/sdk/communication/azure-communication-callingserver/README.md +++ b/sdk/communication/azure-communication-callingserver/README.md @@ -46,7 +46,7 @@ Based on if the Contoso app join a call or not, APIs can be divided into two cat You can provide the connection string using the connectionString() function of `CallingServerClientBuilder`. Once you initialized a `CallingServerClient` class, you can do the different server calling operations. - + ```java // Your connectionString retrieved from your Azure Communication Service String connectionString = "endpoint=https://.communication.azure.com/;accesskey="; @@ -60,22 +60,21 @@ CallingServerClient callingServerClient = builder.buildClient(); ### Create call, Add participant and Hangup a call #### Create a Call: - + ```java CommunicationIdentifier source = new CommunicationUserIdentifier(""); CommunicationIdentifier firstCallee = new CommunicationUserIdentifier(""); CommunicationIdentifier secondCallee = new CommunicationUserIdentifier(""); -CommunicationIdentifier[] targets = new CommunicationIdentifier[] { firstCallee, secondCallee }; +List targets = Arrays.asList(firstCallee, secondCallee); String callbackUri = ""; -MediaType[] requestedMediaTypes = new MediaType[] { MediaType.AUDIO, MediaType.VIDEO }; +List requestedMediaTypes = Arrays.asList(MediaType.AUDIO, MediaType.VIDEO); -EventSubscriptionType[] requestedCallEvents = new EventSubscriptionType[] { +List requestedCallEvents = Arrays.asList( EventSubscriptionType.DTMF_RECEIVED, - EventSubscriptionType.PARTICIPANTS_UPDATED -}; + EventSubscriptionType.PARTICIPANTS_UPDATED); CreateCallOptions createCallOptions = new CreateCallOptions( callbackUri, @@ -86,14 +85,14 @@ CallConnection callConnection = callingServerClient.createCallConnection(source, ``` #### Add a participant to a Call: - + ```java CommunicationIdentifier thirdCallee = new CommunicationUserIdentifier(""); callConnection.addParticipant(thirdCallee, "ACS User 3", ""); ``` #### Hangup a Call: - + ```java callConnection.hangup(); ``` @@ -134,6 +133,16 @@ serverCall.stopRecording(recordingId); CallRecordingStateResult callRecordingStateResult = serverCall.getRecordingState(recordingId); ``` +#### Download a Recording into a file: + +```java +callingServerClient.downloadTo( + recordingUrl, + Paths.get(filePath), + null, + true + ); +``` ### Play Audio in Call #### Play Audio: diff --git a/sdk/communication/azure-communication-callingserver/pom.xml b/sdk/communication/azure-communication-callingserver/pom.xml index e452b3940a8ea..5c2b24f2638e6 100644 --- a/sdk/communication/azure-communication-callingserver/pom.xml +++ b/sdk/communication/azure-communication-callingserver/pom.xml @@ -124,7 +124,7 @@ - + org.jacoco jacoco-maven-plugin @@ -134,6 +134,15 @@ com/azure/communication/callingserver/*.class + + + coverage-report + verify + + report + + + org.apache.maven.plugins @@ -149,6 +158,22 @@ + + org.revapi + revapi-maven-plugin + 0.11.2 + + + + + java.method.added + com.azure.core.util.HttpClientOptions + Transitive from Core. Not our problem + + + + + diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallConnection.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallConnection.java index add9b7e100c13..99c140ad16faa 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallConnection.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallConnection.java @@ -4,6 +4,7 @@ package com.azure.communication.callingserver; import com.azure.communication.callingserver.models.AddParticipantResult; +import com.azure.communication.callingserver.models.CallingServerErrorException; import com.azure.communication.callingserver.models.CancelAllMediaOperationsResult; import com.azure.communication.callingserver.models.PlayAudioOptions; import com.azure.communication.callingserver.models.PlayAudioResult; @@ -45,6 +46,8 @@ public String getCallConnectionId() { * @param callbackUri call back uri to receive notifications. * @param operationContext The value to identify context of the operation. This is used to co-relate other * communications related to this operation + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response payload for play audio operation. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -65,6 +68,8 @@ public PlayAudioResult playAudio( * 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. * @param playAudioOptions Options for play audio. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response payload for play audio operation. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -72,39 +77,6 @@ public PlayAudioResult playAudio(String audioFileUri, PlayAudioOptions playAudio return callConnectionAsync.playAudioInternal(audioFileUri, playAudioOptions).block(); } - /** - * Play audio in a call. - * - * @param audioFileUri 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. - * @param loop The flag indicating whether audio file needs to be played in loop or not. - * @param audioFileId An id for the media in the AudioFileUri, using which we cache the media. - * @param callbackUri call back uri to receive notifications. - * @param operationContext The value to identify context of the operation. This is used to co-relate other - * communications related to this operation - * @param context A {@link Context} representing the request context. - * @return the response payload for play audio operation. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response playAudioWithResponse( - String audioFileUri, - boolean loop, - String audioFileId, - String callbackUri, - String operationContext, - final Context context) { - return callConnectionAsync - .playAudioWithResponseInternal( - audioFileUri, - loop, - audioFileId, - callbackUri, - operationContext, - context) - .block(); - } - /** * Play audio in a call. * @@ -113,6 +85,8 @@ public Response playAudioWithResponse( * be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate. * @param playAudioOptions Options for play audio. * @param context A {@link Context} representing the request context. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response payload for play audio operation. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -127,6 +101,9 @@ public Response playAudioWithResponse( /** * Disconnect the current caller in a group-call or end a p2p-call. + * + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. */ @ServiceMethod(returns = ReturnType.SINGLE) public void hangup() { @@ -137,6 +114,8 @@ public void hangup() { * Disconnect the current caller in a group-call or end a p2p-call. * * @param context A {@link Context} representing the request context. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful hangup request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -149,6 +128,8 @@ public Response hangupWithResponse(final Context context) { * * @param operationContext The value to identify context of the operation. This is used to co-relate other * communications related to this operation + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful cancel all media operations request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -162,6 +143,8 @@ public CancelAllMediaOperationsResult cancelAllMediaOperations(String operationC * @param operationContext The value to identify context of the operation. This is used to co-relate other * communications related to this operation * @param context A {@link Context} representing the request context. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful cancel all media operations request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -178,6 +161,8 @@ public Response cancelAllMediaOperationsWithResp * @param alternateCallerId The phone number to use when adding a phone number participant. * @param operationContext The value to identify context of the operation. This is used to co-relate other * communications related to this operation + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful add participant request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -196,6 +181,8 @@ public AddParticipantResult addParticipant( * @param operationContext The value to identify context of the operation. This is used to co-relate other * communications related to this operation * @param context A {@link Context} representing the request context. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful add participant request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -212,6 +199,8 @@ public Response addParticipantWithResponse( * Remove a participant from the call. * * @param participantId Participant id. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. */ @ServiceMethod(returns = ReturnType.SINGLE) public void removeParticipant(String participantId) { @@ -223,6 +212,8 @@ public void removeParticipant(String participantId) { * * @param participantId Participant id. * @param context A {@link Context} representing the request context. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful remove participant request. */ @ServiceMethod(returns = ReturnType.SINGLE) diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallConnectionAsync.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallConnectionAsync.java index 9aa425bbfdc47..5638660cf0df6 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallConnectionAsync.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallConnectionAsync.java @@ -13,6 +13,7 @@ import com.azure.communication.callingserver.implementation.models.CommunicationErrorResponseException; import com.azure.communication.callingserver.implementation.models.PlayAudioRequest; import com.azure.communication.callingserver.models.AddParticipantResult; +import com.azure.communication.callingserver.models.CallingServerErrorException; import com.azure.communication.callingserver.models.CancelAllMediaOperationsResult; import com.azure.communication.callingserver.models.PlayAudioOptions; import com.azure.communication.callingserver.models.PlayAudioResult; @@ -64,6 +65,8 @@ public String getCallConnectionId() { * @param callbackUri call back uri to receive notifications. * @param operationContext The value to identify context of the operation. This is used to co-relate other * communications related to this operation + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response payload for play audio operation. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -83,6 +86,8 @@ public Mono playAudio( * 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. * @param playAudioOptions Options for play audio. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response payload for play audio operation. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -139,35 +144,6 @@ Mono playAudioInternal(PlayAudioRequest playAudioRequest) { } } - /** - * Play audio in a call. - * - * @param audioFileUri 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. - * @param loop The flag indicating whether audio file needs to be played in loop or not. - * @param audioFileId An id for the media in the AudioFileUri, using which we cache the media. - * @param callbackUri call back uri to receive notifications. - * @param operationContext The value to identify context of the operation. This is used to co-relate other - * communications related to this operation - * @return the response payload for play audio operation. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> playAudioWithResponse( - String audioFileUri, - boolean loop, - String audioFileId, - String callbackUri, - String operationContext) { - return playAudioWithResponseInternal( - audioFileUri, - loop, - audioFileId, - callbackUri, - operationContext, - null); - } - /** * Play audio in a call. * @@ -175,6 +151,8 @@ public Mono> playAudioWithResponse( * 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. * @param playAudioOptions Options for play audio. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response payload for play audio operation. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -248,6 +226,8 @@ Mono> playAudioWithResponseInternal( /** * Hangup a call. * + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful hangup request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -264,6 +244,8 @@ public Mono hangup() { /** * Hangup a call. * + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful hangup request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -288,6 +270,8 @@ Mono> hangupWithResponse(Context context) { * * @param operationContext The value to identify context of the operation. This is used to co-relate other * communications related to this operation + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response payload of the cancel all media operations. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -308,6 +292,8 @@ public Mono cancelAllMediaOperations(String oper * * @param operationContext The value to identify context of the operation. This is used to co-relate other * communications related to this operation + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response payload of the cancel all media operations. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -341,6 +327,8 @@ Mono> cancelAllMediaOperationsWithRespo * @param alternateCallerId The phone number to use when adding a phone number participant. * @param operationContext The value to identify context of the operation. This is used to co-relate other * communications related to this operation + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful add participant request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -369,6 +357,8 @@ public Mono addParticipant( * @param alternateCallerId The phone number to use when adding a phone number participant. * @param operationContext The value to identify context of the operation. This is used to co-relate other * communications related to this operation + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful add participant request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -406,6 +396,8 @@ Mono> addParticipantWithResponse( * Remove a participant from the call. * * @param participantId Participant id. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful remove participant request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -423,6 +415,8 @@ public Mono removeParticipant(String participantId) { * Remove a participant from the call. * * @param participantId Participant id. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful remove participant request. */ @ServiceMethod(returns = ReturnType.SINGLE) diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerAsyncClient.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerAsyncClient.java index d82f0c541b0a9..e9c0d3b9815cc 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerAsyncClient.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerAsyncClient.java @@ -11,6 +11,7 @@ import com.azure.communication.callingserver.implementation.converters.JoinCallRequestConverter; import com.azure.communication.callingserver.implementation.models.CommunicationErrorResponseException; import com.azure.communication.callingserver.implementation.models.CreateCallRequest; +import com.azure.communication.callingserver.models.CallingServerErrorException; import com.azure.communication.callingserver.models.CreateCallOptions; import com.azure.communication.callingserver.models.JoinCallOptions; import com.azure.communication.callingserver.models.ParallelDownloadOptions; @@ -34,6 +35,7 @@ import java.nio.file.Path; import java.nio.file.StandardOpenOption; import java.util.HashSet; +import java.util.List; import java.util.Objects; import java.util.Set; @@ -75,6 +77,8 @@ public final class CallingServerAsyncClient { * @param source The source of the call. * @param targets The targets of the call. * @param createCallOptions The call Options. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful CreateCallConnection request. * * {@codesnippet com.azure.communication.callingserver.CallingServerAsyncClient.create.call.connection.async} @@ -82,7 +86,7 @@ public final class CallingServerAsyncClient { @ServiceMethod(returns = ReturnType.SINGLE) public Mono createCallConnection( CommunicationIdentifier source, - CommunicationIdentifier[] targets, + List targets, CreateCallOptions createCallOptions) { try { Objects.requireNonNull(source, "'source' cannot be null."); @@ -103,12 +107,14 @@ public Mono createCallConnection( * @param source The source of the call. * @param targets The targets of the call. * @param createCallOptions The call Options. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful CreateCallConnection request. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> createCallConnectionWithResponse( CommunicationIdentifier source, - CommunicationIdentifier[] targets, + List targets, CreateCallOptions createCallOptions) { try { Objects.requireNonNull(source, "'source' cannot be null."); @@ -125,7 +131,7 @@ public Mono> createCallConnectionWithResponse( Mono createCallConnectionInternal( CommunicationIdentifier source, - CommunicationIdentifier[] targets, + List targets, CreateCallOptions createCallOptions) { try { Objects.requireNonNull(source, "'source' cannot be null."); @@ -142,7 +148,7 @@ Mono createCallConnectionInternal( Mono> createCallConnectionWithResponseInternal( CommunicationIdentifier source, - CommunicationIdentifier[] targets, + List targets, CreateCallOptions createCallOptions, Context context) { try { @@ -168,10 +174,12 @@ Mono> createCallConnectionWithResponseInternal( * @param serverCallId The server call id. * @param source to Join Call. * @param joinCallOptions join call options. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful join request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono join( + public Mono joinCall( String serverCallId, CommunicationIdentifier source, JoinCallOptions joinCallOptions) { @@ -193,10 +201,12 @@ public Mono join( * @param serverCallId The server call id. * @param source to Join Call. * @param joinCallOptions join call options. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful join request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono>joinWithResponse( + public Mono> joinCallWithResponse( String serverCallId, CommunicationIdentifier source, JoinCallOptions joinCallOptions) { diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerClient.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerClient.java index 1ab8665d967ed..723ee3949c9ff 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerClient.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerClient.java @@ -3,6 +3,7 @@ package com.azure.communication.callingserver; +import com.azure.communication.callingserver.models.CallingServerErrorException; import com.azure.communication.callingserver.models.CreateCallOptions; import com.azure.communication.callingserver.models.JoinCallOptions; import com.azure.communication.callingserver.models.ParallelDownloadOptions; @@ -16,6 +17,7 @@ import java.io.OutputStream; import java.nio.file.Path; +import java.util.List; import java.util.Objects; @@ -44,6 +46,8 @@ public final class CallingServerClient { * @param source The source of the call. * @param targets The targets of the call. * @param createCallOptions The call Options. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful CreateCallConnection request. * * {@codesnippet com.azure.communication.callingserver.CallingServerClient.create.call.connection} @@ -51,7 +55,7 @@ public final class CallingServerClient { @ServiceMethod(returns = ReturnType.SINGLE) public CallConnection createCallConnection( CommunicationIdentifier source, - CommunicationIdentifier[] targets, + List targets, CreateCallOptions createCallOptions) { return callingServerAsyncClient.createCallConnectionInternal(source, targets, createCallOptions).block(); } @@ -63,12 +67,14 @@ public CallConnection createCallConnection( * @param targets The targets of the call. * @param createCallOptions The call Options. * @param context A {@link Context} representing the request context. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful CreateCallConnection request. */ @ServiceMethod(returns = ReturnType.SINGLE) public Response createCallConnectionWithResponse( CommunicationIdentifier source, - CommunicationIdentifier[] targets, + List targets, CreateCallOptions createCallOptions, final Context context) { return callingServerAsyncClient @@ -81,10 +87,12 @@ public Response createCallConnectionWithResponse( * @param serverCallId The server call id. * @param source of Join Call request. * @param joinCallOptions to Join Call. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return CallConnection for a successful Join request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public CallConnection join( + public CallConnection joinCall( String serverCallId, CommunicationIdentifier source, JoinCallOptions joinCallOptions) { @@ -97,11 +105,13 @@ public CallConnection join( * @param serverCallId The server call id. * @param source of Join Call request. * @param joinCallOptions to Join Call. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @param context A {@link Context} representing the request context. * @return response for a successful Join request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response joinWithResponse( + public Response joinCallWithResponse( String serverCallId, CommunicationIdentifier source, JoinCallOptions joinCallOptions, diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerClientBuilder.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerClientBuilder.java index 5c36aeefc8b6b..a4e369fbdf5e5 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerClientBuilder.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerClientBuilder.java @@ -90,7 +90,7 @@ public CallingServerClientBuilder pipeline(HttpPipeline pipeline) { * @return The updated {@link CallingServerClientBuilder} object. * @throws NullPointerException If {@code tokenCredential} is null. */ - public CallingServerClientBuilder credential(TokenCredential tokenCredential) { + CallingServerClientBuilder credential(TokenCredential tokenCredential) { this.tokenCredential = Objects.requireNonNull(tokenCredential, "'tokenCredential' cannot be null."); return this; } @@ -103,7 +103,7 @@ public CallingServerClientBuilder credential(TokenCredential tokenCredential) { * @return The updated {@link CallingServerClientBuilder} object. * @throws NullPointerException If {@code keyCredential} is null. */ - public CallingServerClientBuilder credential(AzureKeyCredential keyCredential) { + CallingServerClientBuilder credential(AzureKeyCredential keyCredential) { this.azureKeyCredential = Objects.requireNonNull(keyCredential, "'keyCredential' cannot be null."); return this; } diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerServiceVersion.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerServiceVersion.java index bfa102b34da9e..8398f77f9eeaa 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerServiceVersion.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerServiceVersion.java @@ -9,8 +9,7 @@ * The versions of CallingServer Service supported by this client library. */ public enum CallingServerServiceVersion implements ServiceVersion { - V2021_06_015("2021-06-15"), - V2021_06_15_preview("2021-06-15-preview"); + V2021_06_15_PREVIEW("2021-06-15-preview"); private final String version; @@ -32,6 +31,6 @@ public String getVersion() { * @return the latest {@link CallingServerServiceVersion} */ public static CallingServerServiceVersion getLatest() { - return V2021_06_15_preview; + return V2021_06_15_PREVIEW; } } diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ContentDownloader.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ContentDownloader.java index 6ee8317fe7f1c..c243906e7b257 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ContentDownloader.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ContentDownloader.java @@ -5,7 +5,6 @@ import com.azure.communication.callingserver.implementation.Constants; import com.azure.communication.callingserver.models.CallingServerErrorException; import com.azure.communication.callingserver.models.ParallelDownloadOptions; -import com.azure.communication.callingserver.models.ProgressReporter; import com.azure.core.http.HttpMethod; import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpRange; @@ -92,7 +91,7 @@ Mono> downloadToFileWithResponse( return downloadFirstChunk(parallelDownloadOptions, downloadFunc) .flatMap(setupTuple2 -> { long newCount = setupTuple2.getT1(); - int numChunks = calculateNumBlocks(newCount, parallelDownloadOptions.getBlockSizeLong()); + int numChunks = calculateNumBlocks(newCount, parallelDownloadOptions.getBlockSize()); // In case it is an empty blob, this ensures we still actually perform a download operation. numChunks = numChunks == 0 ? 1 : numChunks; @@ -205,7 +204,7 @@ private HttpRequest getHttpRequest(String sourceEndpoint, HttpRange httpRange) { private Mono>>> downloadFirstChunk( ParallelDownloadOptions parallelDownloadOptions, Function>>> downloader) { - return downloader.apply(new HttpRange(0, parallelDownloadOptions.getBlockSizeLong())) + return downloader.apply(new HttpRange(0, parallelDownloadOptions.getBlockSize())) .subscribeOn(Schedulers.boundedElastic()) .flatMap(response -> { // Extract the total length of the blob from the contentRange header. e.g. "bytes 1-6/7" @@ -243,8 +242,8 @@ private Flux downloadChunk( } // Calculate whether we need a full chunk or something smaller because we are at the end. - long modifier = chunkNum.longValue() * parallelDownloadOptions.getBlockSizeLong(); - long chunkSizeActual = Math.min(parallelDownloadOptions.getBlockSizeLong(), + long modifier = chunkNum.longValue() * parallelDownloadOptions.getBlockSize(); + long chunkSizeActual = Math.min(parallelDownloadOptions.getBlockSize(), newCount - modifier); HttpRange chunkRange = new HttpRange(modifier, chunkSizeActual); @@ -269,7 +268,7 @@ private static Mono writeBodyToFile( parallelDownloadOptions.getProgressReceiver(), progressLock, totalProgress); // Write to the file. - return FluxUtil.writeFile(data, file, chunkNum * parallelDownloadOptions.getBlockSizeLong()); + return FluxUtil.writeFile(data, file, chunkNum * parallelDownloadOptions.getBlockSize()); } void downloadToFileCleanup(AsynchronousFileChannel channel, Path filePath, SignalType signalType) { diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/ProgressReporter.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ProgressReporter.java similarity index 98% rename from sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/ProgressReporter.java rename to sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ProgressReporter.java index 79a5e62f2e13c..de8eac668554f 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/ProgressReporter.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ProgressReporter.java @@ -1,8 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.communication.callingserver.models; +package com.azure.communication.callingserver; +import com.azure.communication.callingserver.models.ProgressReceiver; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -13,7 +14,7 @@ /** * {@code ProgressReporter} offers a convenient way to add progress tracking to a given Flux. */ -public final class ProgressReporter { +final class ProgressReporter { private abstract static class ProgressReporterImpl implements ProgressReceiver { long blockProgress; diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCall.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCall.java index a572ded3d9b9a..35df8e2370586 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCall.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCall.java @@ -5,6 +5,7 @@ import com.azure.communication.callingserver.models.AddParticipantResult; import com.azure.communication.callingserver.models.CallRecordingProperties; +import com.azure.communication.callingserver.models.CallingServerErrorException; import com.azure.communication.callingserver.models.PlayAudioOptions; import com.azure.communication.callingserver.models.PlayAudioResult; import com.azure.communication.callingserver.models.StartCallRecordingResult; @@ -41,6 +42,8 @@ public String getServerCallId() { * @param alternateCallerId The phone number to use when adding a phone number participant. * @param operationContext The value to identify context of the operation. This is used to co-relate other * communications related to this operation + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful add participant request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -61,6 +64,8 @@ public AddParticipantResult addParticipant( * @param operationContext The value to identify context of the operation. This is used to co-relate other * communications related to this operation * @param context A {@link Context} representing the request context. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful add participant request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -93,6 +98,8 @@ public void removeParticipant(String participantId) { * * @param participantId Participant id. * @param context A {@link Context} representing the request context. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful remove participant request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -104,6 +111,8 @@ public Response removeParticipantWithResponse(String participantId, final * Start recording * * @param recordingStateCallbackUri The uri to send state change callbacks. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return result for a successful start recording request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -116,6 +125,8 @@ public StartCallRecordingResult startRecording(String recordingStateCallbackUri) * * @param recordingStateCallbackUri The uri to send state change callbacks. * @param context A {@link Context} representing the request context. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return result for a successful start recording request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -129,6 +140,8 @@ public Response startRecordingWithResponse( * Stop recording * * @param recordingId The recording id to stop. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. */ @ServiceMethod(returns = ReturnType.SINGLE) public void stopRecording(String recordingId) { @@ -140,6 +153,8 @@ public void stopRecording(String recordingId) { * * @param recordingId The recording id to stop. * @param context A {@link Context} representing the request context. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful stop recording request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -151,6 +166,8 @@ public Response stopRecordingWithResponse(String recordingId, final Contex * Pause recording * * @param recordingId The recording id to stop. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. */ @ServiceMethod(returns = ReturnType.SINGLE) public void pauseRecording(String recordingId) { @@ -162,6 +179,8 @@ public void pauseRecording(String recordingId) { * * @param recordingId The recording id to stop. * @param context A {@link Context} representing the request context. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful pause recording request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -173,6 +192,8 @@ public Response pauseRecordingWithResponse(String recordingId, final Conte * Resume recording * * @param recordingId The recording id to stop. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. */ @ServiceMethod(returns = ReturnType.SINGLE) public void resumeRecording(String recordingId) { @@ -184,6 +205,8 @@ public void resumeRecording(String recordingId) { * * @param recordingId The recording id to stop. * @param context A {@link Context} representing the request context. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful resume recording request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -195,6 +218,8 @@ public Response resumeRecordingWithResponse(String recordingId, final Cont * Get recording state * * @param recordingId The recording id to stop. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful get recording state request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -207,6 +232,8 @@ public CallRecordingProperties getRecordingState(String recordingId) { * * @param recordingId The recording id to stop. * @param context A {@link Context} representing the request context. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful get recording state request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -224,6 +251,8 @@ public Response getRecordingStateWithResponse(String re * @param callbackUri The callback Uri to receive PlayAudio status notifications. * @param operationContext The value to identify context of the operation. This is used to co-relate other * communications related to this operation + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response payload for play audio operation. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -242,6 +271,8 @@ public PlayAudioResult playAudio( * 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. * @param playAudioOptions Options for play audio. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response payload for play audio operation. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -249,35 +280,6 @@ public PlayAudioResult playAudio(String audioFileUri, PlayAudioOptions playAudio return serverCallAsync.playAudioInternal(audioFileUri, playAudioOptions).block(); } - /** - * Play audio in a call. - * - * @param audioFileUri 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. - * @param audioFileId An id for the media in the AudioFileUri, using which we cache the media. - * @param callbackUri The callback Uri to receive PlayAudio status notifications. - * @param operationContext The value to identify context of the operation. This is used to co-relate other - * communications related to this operation - * @param context A {@link Context} representing the request context. - * @return the response payload for play audio operation. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response playAudioWithResponse( - String audioFileUri, - String audioFileId, - String callbackUri, - String operationContext, - final Context context) { - return serverCallAsync - .playAudioWithResponseInternal( - audioFileUri, - audioFileId, - callbackUri, - operationContext, - context).block(); - } - /** * Play audio in a call. * @@ -286,6 +288,8 @@ public Response playAudioWithResponse( * be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate. * @param playAudioOptions Options for play audio. * @param context A {@link Context} representing the request context. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response payload for play audio operation. */ @ServiceMethod(returns = ReturnType.SINGLE) diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCallAsync.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCallAsync.java index 43e6af1eabea0..d28cdafea76b7 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCallAsync.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCallAsync.java @@ -13,6 +13,7 @@ import com.azure.communication.callingserver.implementation.models.StartCallRecordingRequest; import com.azure.communication.callingserver.models.AddParticipantResult; import com.azure.communication.callingserver.models.CallRecordingProperties; +import com.azure.communication.callingserver.models.CallingServerErrorException; import com.azure.communication.callingserver.models.PlayAudioOptions; import com.azure.communication.callingserver.models.PlayAudioResult; import com.azure.communication.callingserver.models.StartCallRecordingResult; @@ -63,6 +64,8 @@ public String getServerCallId() { * @param alternateCallerId The phone number to use when adding a phone number participant. * @param operationContext The value to identify context of the operation. This is used to co-relate other * communications related to this operation + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful add participant request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -94,6 +97,8 @@ public Mono addParticipant( * @param alternateCallerId The phone number to use when adding a phone number participant. * @param operationContext The value to identify context of the operation. This is used to co-relate other * communications related to this operation + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful add participant request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -139,6 +144,8 @@ Mono> addParticipantWithResponse( * Remove a participant from the call. * * @param participantId Participant id. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful remove participant request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -156,6 +163,8 @@ public Mono removeParticipant(String participantId) { * Remove a participant from the call. * * @param participantId Participant id. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful remove participant request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -181,6 +190,8 @@ Mono> removeParticipantWithResponse(String participantId, Context * * @param recordingStateCallbackUri The uri to send state change callbacks. * @throws InvalidParameterException is recordingStateCallbackUri is absolute uri. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful start recording request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -207,6 +218,8 @@ public Mono startRecording(String recordingStateCallba * * @param recordingStateCallbackUri The uri to send state change callbacks. * @throws InvalidParameterException is recordingStateCallbackUri is absolute uri. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful start recording request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -243,6 +256,8 @@ Mono> startRecordingWithResponse( * Stop recording * * @param recordingId The recording id to stop. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful stop recording request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -260,6 +275,8 @@ public Mono stopRecording(String recordingId) { * Stop recording * * @param recordingId The recording id to stop. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful stop recording request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -284,6 +301,8 @@ Mono> stopRecordingWithResponse(String recordingId, Context conte * Pause recording * * @param recordingId The recording id to stop. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful pause recording request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -301,6 +320,8 @@ public Mono pauseRecording(String recordingId) { * Pause recording * * @param recordingId The recording id to stop. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful pause recording request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -325,6 +346,8 @@ Mono> pauseRecordingWithResponse(String recordingId, Context cont * Resume recording * * @param recordingId The recording id to stop. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful resume recording request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -342,6 +365,8 @@ public Mono resumeRecording(String recordingId) { * Resume recording * * @param recordingId The recording id to stop. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful resume recording request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -366,6 +391,8 @@ Mono> resumeRecordingWithResponse(String recordingId, Context con * Get recording state * * @param recordingId The recording id to stop. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful get recording state request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -383,6 +410,8 @@ public Mono getRecordingState(String recordingId) { * Get recording state * * @param recordingId The recording id to stop. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return response for a successful get recording state request. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -415,6 +444,8 @@ Mono> getRecordingStateWithResponse(String rec * @param callbackUri The callback Uri to receive PlayAudio status notifications. * @param operationContext The value to identify context of the operation. This is used to co-relate other * communications related to this operation + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response payload for play audio operation. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -433,6 +464,8 @@ public Mono playAudio( * 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. * @param playAudioOptions Options for play audio. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response payload for play audio operation. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -492,27 +525,6 @@ Mono playAudioInternal(PlayAudioRequest playAudioRequest) { } } - /** - * Play audio in a call. - * - * @param audioFileUri 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. - * @param audioFileId Tne id for the media in the AudioFileUri, using which we cache the media resource. - * @param callbackUri The callback Uri to receive PlayAudio status notifications. - * @param operationContext The value to identify context of the operation. This is used to co-relate other - * communications related to this operation - * @return the response payload for play audio operation. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> playAudioWithResponse( - String audioFileUri, - String audioFileId, - String callbackUri, - String operationContext) { - return playAudioWithResponseInternal(audioFileUri, audioFileId, callbackUri, operationContext, null); - } - /** * Play audio in a call. * @@ -520,6 +532,8 @@ public Mono> playAudioWithResponse( * 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. * @param playAudioOptions Options for play audio. + * @throws CallingServerErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response payload for play audio operation. */ @ServiceMethod(returns = ReturnType.SINGLE) diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/CallConnectionRequestConverter.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/CallConnectionRequestConverter.java index 02b870911de19..b3ec70ff82d94 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/CallConnectionRequestConverter.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/CallConnectionRequestConverter.java @@ -10,8 +10,6 @@ import com.azure.communication.callingserver.models.MediaType; import com.azure.communication.common.CommunicationIdentifier; -import java.util.ArrayList; -import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; @@ -26,16 +24,16 @@ public final class CallConnectionRequestConverter { */ public static CreateCallRequest convert( CommunicationIdentifier source, - CommunicationIdentifier[] targets, + List targets, CreateCallOptions createCallOptions) { - if (source == null || targets == null || targets.length == 0) { + if (source == null || targets == null || targets.size() == 0) { return null; } CreateCallRequest createCallRequest = new CreateCallRequest() .setSource(CommunicationIdentifierConverter.convert(source)) - .setTargets(new ArrayList<>(Arrays.asList(targets)) + .setTargets(targets .stream() .map(CommunicationIdentifierConverter::convert) .collect(Collectors.toList())); diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/JoinCallRequestConverter.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/JoinCallRequestConverter.java index 22f8a1f30602f..4ee6108841ec2 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/JoinCallRequestConverter.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/JoinCallRequestConverter.java @@ -4,14 +4,10 @@ package com.azure.communication.callingserver.implementation.converters; import com.azure.communication.callingserver.implementation.models.JoinCallRequest; -import com.azure.communication.callingserver.models.EventSubscriptionType; import com.azure.communication.callingserver.models.JoinCallOptions; -import com.azure.communication.callingserver.models.MediaType; import com.azure.communication.common.CommunicationIdentifier; import java.util.ArrayList; -import java.util.Collections; -import java.util.List; /** * A converter for {@link JoinCallRequest} @@ -35,15 +31,8 @@ public static JoinCallRequest convert(CommunicationIdentifier source, JoinCallOp joinCallRequest.setSubject(joinCallOptions.getSubject()); joinCallRequest.setCallbackUri(joinCallOptions.getCallbackUri()); - - List requestedModalities = new ArrayList<>(); - Collections.addAll(requestedModalities, joinCallOptions.getRequestedMediaTypes()); - joinCallRequest.setRequestedMediaTypes(requestedModalities); - - List requestedCallEvents = new ArrayList<>(); - Collections.addAll(requestedCallEvents, joinCallOptions.getRequestedCallEvents()); - joinCallRequest.setRequestedCallEvents(requestedCallEvents); - + joinCallRequest.setRequestedMediaTypes(new ArrayList<>(joinCallOptions.getRequestedMediaTypes())); + joinCallRequest.setRequestedCallEvents(new ArrayList<>(joinCallOptions.getRequestedCallEvents())); return joinCallRequest; } diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/AddParticipantResultEventInternal.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/AddParticipantResultEventInternal.java index b4e95f3ea95d9..db5b23f241c55 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/AddParticipantResultEventInternal.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/AddParticipantResultEventInternal.java @@ -26,7 +26,7 @@ public final class AddParticipantResultEventInternal { /* * The status of the operation */ - @JsonProperty(value = "status") + @JsonProperty(value = "status", required = true) private OperationStatus status; /** diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/CallConnectionStateChangedEventInternal.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/CallConnectionStateChangedEventInternal.java index 3e29101ece8ff..a9fc9dde843bf 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/CallConnectionStateChangedEventInternal.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/CallConnectionStateChangedEventInternal.java @@ -26,7 +26,7 @@ public final class CallConnectionStateChangedEventInternal { /* * The call connection state. */ - @JsonProperty(value = "callConnectionState") + @JsonProperty(value = "callConnectionState", required = true) private CallConnectionState callConnectionState; /** diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/CallParticipantInternal.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/CallParticipantInternal.java index 77f6cf0adbc71..f6bc1a7fa0ee5 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/CallParticipantInternal.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/CallParticipantInternal.java @@ -25,8 +25,8 @@ public final class CallParticipantInternal { /* * Is participant muted */ - @JsonProperty(value = "isMuted") - private Boolean isMuted; + @JsonProperty(value = "isMuted", required = true) + private boolean isMuted; /** * Get the identifier property: Communication identifier of the participant. @@ -73,7 +73,7 @@ public CallParticipantInternal setParticipantId(String participantId) { * * @return the isMuted value. */ - public Boolean isMuted() { + public boolean isMuted() { return this.isMuted; } @@ -83,7 +83,7 @@ public Boolean isMuted() { * @param isMuted the isMuted value to set. * @return the CallParticipantInternal object itself. */ - public CallParticipantInternal setIsMuted(Boolean isMuted) { + public CallParticipantInternal setIsMuted(boolean isMuted) { this.isMuted = isMuted; return this; } diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/CallRecordingPropertiesInternal.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/CallRecordingPropertiesInternal.java index be47d9b17f41a..d84362e0a54a4 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/CallRecordingPropertiesInternal.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/CallRecordingPropertiesInternal.java @@ -14,7 +14,7 @@ public final class CallRecordingPropertiesInternal { /* * The state of the recording */ - @JsonProperty(value = "recordingState") + @JsonProperty(value = "recordingState", required = true) private CallRecordingState recordingState; /** diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/CallRecordingStateChangeEventInternal.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/CallRecordingStateChangeEventInternal.java index 8501c53e647b4..3c0d36fc080ea 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/CallRecordingStateChangeEventInternal.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/CallRecordingStateChangeEventInternal.java @@ -21,13 +21,13 @@ public final class CallRecordingStateChangeEventInternal { /* * The state of the recording */ - @JsonProperty(value = "state") + @JsonProperty(value = "state", required = true) private CallRecordingState state; /* * The time of the recording started */ - @JsonProperty(value = "startDateTime") + @JsonProperty(value = "startDateTime", required = true) private OffsetDateTime startDateTime; /* diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/CancelAllMediaOperationsResultInternal.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/CancelAllMediaOperationsResultInternal.java index 5b2abaceebda6..316a9f1ed1dc5 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/CancelAllMediaOperationsResultInternal.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/CancelAllMediaOperationsResultInternal.java @@ -20,7 +20,7 @@ public final class CancelAllMediaOperationsResultInternal { /* * The status of the operation */ - @JsonProperty(value = "status") + @JsonProperty(value = "status", required = true) private OperationStatus status; /* diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/PlayAudioResultEventInternal.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/PlayAudioResultEventInternal.java index 9a93fe0027d6b..4b5ff93656fb2 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/PlayAudioResultEventInternal.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/PlayAudioResultEventInternal.java @@ -26,7 +26,7 @@ public final class PlayAudioResultEventInternal { /* * The status of the operation */ - @JsonProperty(value = "status") + @JsonProperty(value = "status", required = true) private OperationStatus status; /** diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/PlayAudioResultInternal.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/PlayAudioResultInternal.java index 186ef3c6dbc68..47e2a20ccccd6 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/PlayAudioResultInternal.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/PlayAudioResultInternal.java @@ -20,7 +20,7 @@ public final class PlayAudioResultInternal { /* * The status of the operation */ - @JsonProperty(value = "status") + @JsonProperty(value = "status", required = true) private OperationStatus status; /* diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/ResultInfoInternal.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/ResultInfoInternal.java index d44a254798679..b6a69a059951d 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/ResultInfoInternal.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/ResultInfoInternal.java @@ -11,71 +11,65 @@ @Fluent public final class ResultInfoInternal { /* - * Gets or sets the result code - * For synchronous failures, this maps one-to-one with HTTP responses. For - * asynchronous failures or messages, it is contextual. + * The result code associated with the operation. */ - @JsonProperty(value = "code") - private Integer code; + @JsonProperty(value = "code", required = true) + private int code; /* - * Gets or sets the result subcode. - * The subcode further classifies a failure. For example. + * The subcode that further classifies the result. */ - @JsonProperty(value = "subcode") - private Integer subcode; + @JsonProperty(value = "subcode", required = true) + private int subcode; /* - * Gets or sets the message * The message is a detail explanation of subcode. */ @JsonProperty(value = "message") private String message; /** - * Get the code property: Gets or sets the result code For synchronous failures, this maps one-to-one with HTTP - * responses. For asynchronous failures or messages, it is contextual. + * Get the code property: The result code associated with the operation. * * @return the code value. */ - public Integer getCode() { + public int getCode() { return this.code; } /** - * Set the code property: Gets or sets the result code For synchronous failures, this maps one-to-one with HTTP - * responses. For asynchronous failures or messages, it is contextual. + * Set the code property: The result code associated with the operation. * * @param code the code value to set. * @return the ResultInfoInternal object itself. */ - public ResultInfoInternal setCode(Integer code) { + public ResultInfoInternal setCode(int code) { this.code = code; return this; } /** - * Get the subcode property: Gets or sets the result subcode. The subcode further classifies a failure. For example. + * Get the subcode property: The subcode that further classifies the result. * * @return the subcode value. */ - public Integer getSubcode() { + public int getSubcode() { return this.subcode; } /** - * Set the subcode property: Gets or sets the result subcode. The subcode further classifies a failure. For example. + * Set the subcode property: The subcode that further classifies the result. * * @param subcode the subcode value to set. * @return the ResultInfoInternal object itself. */ - public ResultInfoInternal setSubcode(Integer subcode) { + public ResultInfoInternal setSubcode(int subcode) { this.subcode = subcode; return this; } /** - * Get the message property: Gets or sets the message The message is a detail explanation of subcode. + * Get the message property: The message is a detail explanation of subcode. * * @return the message value. */ @@ -84,7 +78,7 @@ public String getMessage() { } /** - * Set the message property: Gets or sets the message The message is a detail explanation of subcode. + * Set the message property: The message is a detail explanation of subcode. * * @param message the message value to set. * @return the ResultInfoInternal object itself. diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/ToneInfoInternal.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/ToneInfoInternal.java index a3d17cd58efcd..95f9daec53341 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/ToneInfoInternal.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/ToneInfoInternal.java @@ -8,47 +8,46 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; -/** Gets or sets the tone info. */ +/** The information about the tone. */ @Fluent public final class ToneInfoInternal { /* - * Gets or sets the sequence id. This id can be used to determine if the - * same tone - * was played multiple times or if any tones were missed. + * The sequence id which can be used to determine if the same tone was + * played multiple times or if any tones were missed. */ - @JsonProperty(value = "sequenceId") - private Integer sequenceId; + @JsonProperty(value = "sequenceId", required = true) + private int sequenceId; /* - * Gets or sets the tone detected. + * The tone value. */ - @JsonProperty(value = "tone") + @JsonProperty(value = "tone", required = true) private ToneValue tone; /** - * Get the sequenceId property: Gets or sets the sequence id. This id can be used to determine if the same tone was - * played multiple times or if any tones were missed. + * Get the sequenceId property: The sequence id which can be used to determine if the same tone was played multiple + * times or if any tones were missed. * * @return the sequenceId value. */ - public Integer getSequenceId() { + public int getSequenceId() { return this.sequenceId; } /** - * Set the sequenceId property: Gets or sets the sequence id. This id can be used to determine if the same tone was - * played multiple times or if any tones were missed. + * Set the sequenceId property: The sequence id which can be used to determine if the same tone was played multiple + * times or if any tones were missed. * * @param sequenceId the sequenceId value to set. * @return the ToneInfoInternal object itself. */ - public ToneInfoInternal setSequenceId(Integer sequenceId) { + public ToneInfoInternal setSequenceId(int sequenceId) { this.sequenceId = sequenceId; return this; } /** - * Get the tone property: Gets or sets the tone detected. + * Get the tone property: The tone value. * * @return the tone value. */ @@ -57,7 +56,7 @@ public ToneValue getTone() { } /** - * Set the tone property: Gets or sets the tone detected. + * Set the tone property: The tone value. * * @param tone the tone value to set. * @return the ToneInfoInternal object itself. diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/ToneReceivedEventInternal.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/ToneReceivedEventInternal.java index cc0f5897123a6..ebb63e9288b5b 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/ToneReceivedEventInternal.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/models/ToneReceivedEventInternal.java @@ -13,7 +13,7 @@ public final class ToneReceivedEventInternal { /* * The tone info. */ - @JsonProperty(value = "toneInfo") + @JsonProperty(value = "toneInfo", required = true) private ToneInfoInternal toneInfo; /* diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/CallParticipant.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/CallParticipant.java index 8d67860d7681c..9b8f852222fda 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/CallParticipant.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/CallParticipant.java @@ -50,7 +50,7 @@ public String getParticipantId() { * * @return the communication identity of the participant object itself */ - public boolean getIsMuted() { + public boolean isMuted() { return isMuted; } diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/CreateCallOptions.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/CreateCallOptions.java index 60447786dfec2..6e0742597ed29 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/CreateCallOptions.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/CreateCallOptions.java @@ -6,6 +6,8 @@ import com.azure.communication.common.PhoneNumberIdentifier; import com.azure.core.annotation.Fluent; +import java.util.List; + /** * The options for creating a call. */ @@ -30,12 +32,12 @@ public final class CreateCallOptions { /** * The requested media types. */ - private final MediaType[] requestedMediaTypes; + private final List requestedMediaTypes; /** * The requested call events to subscribe to. */ - private final EventSubscriptionType[] requestedCallEvents; + private final List requestedCallEvents; /** * Get the alternate caller id of the source. @@ -91,8 +93,8 @@ public String getCallbackUri() { * * @return the requested modalities object itself. */ - public MediaType[] getRequestedMediaTypes() { - return this.requestedMediaTypes == null ? new MediaType[0] : this.requestedMediaTypes.clone(); + public List getRequestedMediaTypes() { + return requestedMediaTypes; } /** @@ -100,8 +102,8 @@ public MediaType[] getRequestedMediaTypes() { * * @return the requested call events to subscribe to object itself. */ - public EventSubscriptionType[] getRequestedCallEvents() { - return requestedCallEvents.clone(); + public List getRequestedCallEvents() { + return requestedCallEvents; } /** @@ -114,22 +116,19 @@ public EventSubscriptionType[] getRequestedCallEvents() { */ public CreateCallOptions( String callbackUri, - MediaType[] requestedMediaTypes, - EventSubscriptionType[] requestedCallEvents) { + List requestedMediaTypes, + List requestedCallEvents) { if (callbackUri == null) { throw new IllegalArgumentException("object callbackUri cannot be null"); } - if (requestedMediaTypes == null) { throw new IllegalArgumentException("object requestedMediaTypes cannot be null"); } if (requestedCallEvents == null) { throw new IllegalArgumentException("object requestedCallEvents cannot be null"); } - this.callbackUri = callbackUri; - - this.requestedMediaTypes = requestedMediaTypes.clone(); - this.requestedCallEvents = requestedCallEvents.clone(); + this.requestedMediaTypes = requestedMediaTypes; + this.requestedCallEvents = requestedCallEvents; } } diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/JoinCallOptions.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/JoinCallOptions.java index 7a2fa269c4c0b..dfc2621c0ddc1 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/JoinCallOptions.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/JoinCallOptions.java @@ -6,6 +6,8 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + /** The options for join call. */ @Fluent public final class JoinCallOptions { @@ -25,13 +27,13 @@ public final class JoinCallOptions { * The requested MediaTypes. */ @JsonProperty(value = "requestedMediaTypes", required = true) - private MediaType[] requestedMediaTypes; + private List requestedMediaTypes; /* * The requested call events to subscribe to. */ @JsonProperty(value = "requestedCallEvents", required = true) - private EventSubscriptionType[] requestedCallEvents; + private List requestedCallEvents; /** * Get the subject property: The subject. @@ -78,8 +80,8 @@ public JoinCallOptions setCallbackUri(String callbackUri) { * * @return the requestedMediaTypes value. */ - public MediaType[] getRequestedMediaTypes() { - return requestedMediaTypes == null ? new MediaType[0] : requestedMediaTypes.clone(); + public List getRequestedMediaTypes() { + return requestedMediaTypes; } /** @@ -88,8 +90,8 @@ public MediaType[] getRequestedMediaTypes() { * @param requestedMediaTypes the requestedModalities value to set. * @return the JoinCallOptions object itself. */ - public JoinCallOptions setRequestedMediaTypes(MediaType[] requestedMediaTypes) { - this.requestedMediaTypes = requestedMediaTypes == null ? new MediaType[0] : requestedMediaTypes.clone(); + public JoinCallOptions setRequestedMediaTypes(List requestedMediaTypes) { + this.requestedMediaTypes = requestedMediaTypes; return this; } @@ -99,8 +101,8 @@ public JoinCallOptions setRequestedMediaTypes(MediaType[] requestedMediaTypes) { * * @return the requestedCallEvents value. */ - public EventSubscriptionType[] getRequestedCallEvents() { - return requestedCallEvents == null ? new EventSubscriptionType[0] : requestedCallEvents.clone(); + public List getRequestedCallEvents() { + return requestedCallEvents; } /** @@ -110,8 +112,8 @@ public EventSubscriptionType[] getRequestedCallEvents() { * @param requestedCallEvents the requestedCallEvents value to set. * @return the JoinCallOptions object itself. */ - public JoinCallOptions setRequestedCallEvents(EventSubscriptionType[] requestedCallEvents) { - this.requestedCallEvents = requestedCallEvents == null ? new EventSubscriptionType[0] : requestedCallEvents.clone(); + public JoinCallOptions setRequestedCallEvents(List requestedCallEvents) { + this.requestedCallEvents = requestedCallEvents; return this; } @@ -125,22 +127,19 @@ public JoinCallOptions setRequestedCallEvents(EventSubscriptionType[] requestedC */ public JoinCallOptions( String callbackUri, - MediaType[] requestedMediaTypes, - EventSubscriptionType[] requestedCallEvents) { + List requestedMediaTypes, + List requestedCallEvents) { if (callbackUri == null) { throw new IllegalArgumentException("object callbackUri cannot be null"); } - if (requestedMediaTypes == null) { throw new IllegalArgumentException("object requestedMediaTypes cannot be null"); } if (requestedCallEvents == null) { throw new IllegalArgumentException("object requestedCallEvents cannot be null"); } - this.callbackUri = callbackUri; - - this.requestedMediaTypes = requestedMediaTypes.clone(); - this.requestedCallEvents = requestedCallEvents.clone(); + this.requestedMediaTypes = requestedMediaTypes; + this.requestedCallEvents = requestedCallEvents; } } diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/JoinCallResult.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/JoinCallResult.java deleted file mode 100644 index 2e57e3b3c898f..0000000000000 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/JoinCallResult.java +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.communication.callingserver.models; - -import com.azure.core.annotation.Immutable; - -/** The response payload of the join call operation. */ -@Immutable -public final class JoinCallResult { - /* - * The call connection id. - */ - private final String callConnectionId; - - /** - * Get the callConnectionId property: The call connection id. - * - * @return the callConnectionId value. - */ - public String getCallConnectionId() { - return callConnectionId; - } - - /** - * Initializes a new instance of JoinCallResult. - * - * @param callConnectionId the callConnectionId value to set. - */ - public JoinCallResult(String callConnectionId) { - this.callConnectionId = callConnectionId; - } -} diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/ParallelDownloadOptions.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/ParallelDownloadOptions.java index 66519aad53ac2..741c887385adf 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/ParallelDownloadOptions.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/ParallelDownloadOptions.java @@ -30,7 +30,7 @@ public ParallelDownloadOptions() { * Gets the block size (chunk size) to transfer at a time. * @return The block size. */ - public long getBlockSizeLong() { + public long getBlockSize() { return blockSize == null ? ContentDownloader.DEFAULT_BUFFER_SIZE : blockSize; } @@ -47,7 +47,7 @@ public long getBlockSizeLong() { * @param blockSize The block size. * @return The ParallelDownloadOptions object itself. */ - public ParallelDownloadOptions setBlockSizeLong(Long blockSize) { + public ParallelDownloadOptions setBlockSize(Long blockSize) { if (blockSize != null) { assertInBounds("blockSize", blockSize, 1, Long.MAX_VALUE); } diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/ProgressReceiver.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/ProgressReceiver.java index 6e300e663bcce..6e2b54a8c9363 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/ProgressReceiver.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/ProgressReceiver.java @@ -3,17 +3,15 @@ package com.azure.communication.callingserver.models; -import reactor.core.publisher.Flux; - /** * A {@code ProgressReceiver} is an object that can be used to report progress on network transfers. When specified on * transfer operations, the {@code reportProgress} method will be called periodically with the total number of bytes - * transferred. The user may configure this method to report progress in whatever format desired. It is recommended - * that this type be used in conjunction with {@link ProgressReporter#addProgressReporting(Flux, ProgressReceiver)} to - * enable reporting on sequential transfers. Note that any method accepting a {@link ParallelDownloadOptions} will use + * transferred. The user may configure this method to report progress in whatever format desired. + * Note that any method accepting a {@link ParallelDownloadOptions} will use * the {@code ProgressReceiver} specified there and will handle the logic to coordinate the reporting between parallel * operations. */ +@FunctionalInterface public interface ProgressReceiver { /** diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/AddParticipantResultEvent.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/AddParticipantResultEvent.java index f3e2758ba2683..cca79cedacb19 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/AddParticipantResultEvent.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/AddParticipantResultEvent.java @@ -63,7 +63,7 @@ public OperationStatus getStatus() { * communications related to this operation * @param status the status value. */ - public AddParticipantResultEvent(ResultInfo resultInfo, String operationContext, OperationStatus status) { + AddParticipantResultEvent(ResultInfo resultInfo, String operationContext, OperationStatus status) { this.resultInfo = resultInfo; this.operationContext = operationContext; this.status = status; diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/CallConnectionStateChangedEvent.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/CallConnectionStateChangedEvent.java index 16c0658e2900f..58567398f5985 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/CallConnectionStateChangedEvent.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/CallConnectionStateChangedEvent.java @@ -60,7 +60,7 @@ public CallConnectionState getCallConnectionState() { * @param callConnectionId the callConnectionId value. * @param callConnectionState the callConnectionState value. */ - public CallConnectionStateChangedEvent( + CallConnectionStateChangedEvent( String serverCallId, String callConnectionId, CallConnectionState callConnectionState) { diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/CallRecordingStateChangeEvent.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/CallRecordingStateChangeEvent.java index 317b7db464b39..dc541cac5d5da 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/CallRecordingStateChangeEvent.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/CallRecordingStateChangeEvent.java @@ -77,7 +77,7 @@ public String getServerCallId() { * @param startDateTime the startDateTime value. * @param serverCallId the serverCallId value. */ - public CallRecordingStateChangeEvent( + CallRecordingStateChangeEvent( String recordingId, CallRecordingState state, OffsetDateTime startDateTime, diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/ParticipantsUpdatedEvent.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/ParticipantsUpdatedEvent.java index 30e81b39c9fba..0e1a2003f6d5d 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/ParticipantsUpdatedEvent.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/ParticipantsUpdatedEvent.java @@ -26,7 +26,7 @@ public final class ParticipantsUpdatedEvent extends CallingServerEventBase { /** * The participants. */ - private final CallParticipant[] participants; + private final List participants; /** * Get the callConnectionId property: The call connection id. @@ -43,8 +43,8 @@ public String getCallConnectionId() { * * @return the list of participants value. */ - public CallParticipant[] getParticipants() { - return participants == null ? new CallParticipant[0] : participants.clone(); + public List getParticipants() { + return participants; } /** @@ -54,7 +54,7 @@ public CallParticipant[] getParticipants() { * @param participants The participants * @throws IllegalArgumentException if any parameter is null or empty. */ - public ParticipantsUpdatedEvent(String callConnectionId, CallParticipant[] participants) { + ParticipantsUpdatedEvent(String callConnectionId, List participants) { if (callConnectionId == null || callConnectionId.isEmpty()) { throw new IllegalArgumentException("object callConnectionId cannot be null or empty"); } @@ -62,7 +62,7 @@ public ParticipantsUpdatedEvent(String callConnectionId, CallParticipant[] parti throw new IllegalArgumentException("object participants cannot be null"); } this.callConnectionId = callConnectionId; - this.participants = participants.clone(); + this.participants = participants; } /** @@ -85,7 +85,6 @@ public static ParticipantsUpdatedEvent deserialize(BinaryData eventData) { callParticipantInternal.isMuted())); } - return new ParticipantsUpdatedEvent(internalEvent.getCallConnectionId(), - participants.toArray(new CallParticipant[0])); + return new ParticipantsUpdatedEvent(internalEvent.getCallConnectionId(), participants); } } diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/PlayAudioResultEvent.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/PlayAudioResultEvent.java index 7f4149dc54093..02041c8dad6c4 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/PlayAudioResultEvent.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/PlayAudioResultEvent.java @@ -63,7 +63,7 @@ public OperationStatus getStatus() { * communications related to this operation * @param status the status value. */ - public PlayAudioResultEvent(ResultInfo resultInfo, String operationContext, OperationStatus status) { + PlayAudioResultEvent(ResultInfo resultInfo, String operationContext, OperationStatus status) { this.resultInfo = resultInfo; this.operationContext = operationContext; this.status = status; diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/ToneReceivedEvent.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/ToneReceivedEvent.java index 866fbcc4e0aec..c5075b016fe5f 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/ToneReceivedEvent.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/ToneReceivedEvent.java @@ -45,7 +45,7 @@ public String getCallConnectionId() { * @param toneInfo the toneInfo value. * @param callConnectionId the callConnectionId value. */ - public ToneReceivedEvent(ToneInfo toneInfo, String callConnectionId) { + ToneReceivedEvent(ToneInfo toneInfo, String callConnectionId) { this.toneInfo = toneInfo; this.callConnectionId = callConnectionId; } diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/module-info.java b/sdk/communication/azure-communication-callingserver/src/main/java/module-info.java index b3ead38e94a3b..5d9b0f10d9ff8 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/module-info.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/module-info.java @@ -13,4 +13,5 @@ // exporting some packages specifically for Jackson opens com.azure.communication.callingserver.models to com.fasterxml.jackson.databind; opens com.azure.communication.callingserver.implementation.models to com.fasterxml.jackson.databind, com.azure.core; + opens com.azure.communication.callingserver to com.fasterxml.jackson.databind; } diff --git a/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/CallingServerAsyncClientJavaDocCodeSnippets.java b/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/CallingServerAsyncClientJavaDocCodeSnippets.java index 7e672afa8a342..798a78e2f6c9e 100644 --- a/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/CallingServerAsyncClientJavaDocCodeSnippets.java +++ b/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/CallingServerAsyncClientJavaDocCodeSnippets.java @@ -11,6 +11,9 @@ import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpPipelineBuilder; +import java.util.Arrays; +import java.util.List; + public class CallingServerAsyncClientJavaDocCodeSnippets { public CallingServerAsyncClient createCallingServerAsyncClientWithPipeline() { @@ -44,12 +47,11 @@ public void createCallConnectionAsync() { String callbackUri = ""; // BEGIN: com.azure.communication.callingserver.CallingServerAsyncClient.create.call.connection.async - CommunicationIdentifier[] targets = new CommunicationIdentifier[] { firstCallee, secondCallee }; - MediaType[] requestedMediaTypes = new MediaType[] { MediaType.AUDIO, MediaType.VIDEO }; - EventSubscriptionType[] requestedCallEvents = new EventSubscriptionType[] { + List targets = Arrays.asList(firstCallee, secondCallee); + List requestedMediaTypes = Arrays.asList(MediaType.AUDIO, MediaType.VIDEO); + List requestedCallEvents = Arrays.asList( EventSubscriptionType.DTMF_RECEIVED, - EventSubscriptionType.PARTICIPANTS_UPDATED - }; + EventSubscriptionType.PARTICIPANTS_UPDATED); CreateCallOptions createCallOptions = new CreateCallOptions( callbackUri, requestedMediaTypes, diff --git a/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/CallingServerClientJavaDocCodeSnippets.java b/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/CallingServerClientJavaDocCodeSnippets.java index edd91a97c3887..c42cb9ec5617c 100644 --- a/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/CallingServerClientJavaDocCodeSnippets.java +++ b/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/CallingServerClientJavaDocCodeSnippets.java @@ -11,6 +11,9 @@ import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpPipelineBuilder; +import java.util.Arrays; +import java.util.List; + public class CallingServerClientJavaDocCodeSnippets { public CallingServerClient createCallingServerClientWithPipeline() { @@ -44,12 +47,11 @@ public void createCallConnection() { String callbackUri = ""; // BEGIN: com.azure.communication.callingserver.CallingServerClient.create.call.connection - CommunicationIdentifier[] targets = new CommunicationIdentifier[] { firstCallee, secondCallee }; - MediaType[] requestedMediaTypes = new MediaType[] { MediaType.AUDIO, MediaType.VIDEO }; - EventSubscriptionType[] requestedCallEvents = new EventSubscriptionType[] { + List targets = Arrays.asList(firstCallee, secondCallee); + List requestedMediaTypes = Arrays.asList(MediaType.AUDIO, MediaType.VIDEO); + List requestedCallEvents = Arrays.asList( EventSubscriptionType.DTMF_RECEIVED, - EventSubscriptionType.PARTICIPANTS_UPDATED - }; + EventSubscriptionType.PARTICIPANTS_UPDATED); CreateCallOptions createCallOptions = new CreateCallOptions( callbackUri, requestedMediaTypes, diff --git a/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/ReadmeSamples.java b/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/ReadmeSamples.java index 71f3cbd6554ac..4bba2b0d43c26 100644 --- a/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/ReadmeSamples.java +++ b/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/ReadmeSamples.java @@ -3,12 +3,16 @@ package com.azure.communication.callingserver; -import com.azure.communication.callingserver.models.EventSubscriptionType; import com.azure.communication.callingserver.models.CreateCallOptions; +import com.azure.communication.callingserver.models.EventSubscriptionType; import com.azure.communication.callingserver.models.MediaType; import com.azure.communication.common.CommunicationIdentifier; import com.azure.communication.common.CommunicationUserIdentifier; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; + /** * WARNING: MODIFYING THIS FILE WILL REQUIRE CORRESPONDING UPDATES TO README.md FILE. LINE NUMBERS * ARE USED TO EXTRACT APPROPRIATE CODE SEGMENTS FROM THIS FILE. ADD NEW CODE AT THE BOTTOM TO AVOID CHANGING @@ -47,16 +51,15 @@ public void createCallConnection() { CommunicationIdentifier firstCallee = new CommunicationUserIdentifier(""); CommunicationIdentifier secondCallee = new CommunicationUserIdentifier(""); - CommunicationIdentifier[] targets = new CommunicationIdentifier[] { firstCallee, secondCallee }; + List targets = Arrays.asList(firstCallee, secondCallee); String callbackUri = ""; - MediaType[] requestedMediaTypes = new MediaType[] { MediaType.AUDIO, MediaType.VIDEO }; + List requestedMediaTypes = Arrays.asList(MediaType.AUDIO, MediaType.VIDEO); - EventSubscriptionType[] requestedCallEvents = new EventSubscriptionType[] { + List requestedCallEvents = Arrays.asList( EventSubscriptionType.DTMF_RECEIVED, - EventSubscriptionType.PARTICIPANTS_UPDATED - }; + EventSubscriptionType.PARTICIPANTS_UPDATED); CreateCallOptions createCallOptions = new CreateCallOptions( callbackUri, @@ -86,4 +89,19 @@ public void addParticipant() { CommunicationIdentifier thirdCallee = new CommunicationUserIdentifier(""); callConnection.addParticipant(thirdCallee, "ACS User 3", ""); } + + /** + * Sample code for downloading a recording into a file. + */ + public void getRecordingStream() { + String recordingUrl = "https://ams.skype.com/objects/v1/document_id/video"; + String filePath = "filePath.mp4"; + CallingServerClient callingServerClient = createCallingServerClient(); + callingServerClient.downloadTo( + recordingUrl, + Paths.get(filePath), + null, + true + ); + } } diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionAsyncLiveTests.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionAsyncLiveTests.java index f2f56f02a7264..df0ded5848d0f 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionAsyncLiveTests.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionAsyncLiveTests.java @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package com.azure.communication.callingserver; import com.azure.communication.callingserver.models.AddParticipantResult; @@ -8,8 +9,8 @@ import com.azure.communication.callingserver.models.EventSubscriptionType; import com.azure.communication.callingserver.models.JoinCallOptions; import com.azure.communication.callingserver.models.MediaType; +import com.azure.communication.callingserver.models.PlayAudioOptions; import com.azure.communication.callingserver.models.PlayAudioResult; -import com.azure.communication.common.CommunicationIdentifier; import com.azure.communication.common.CommunicationUserIdentifier; import com.azure.communication.common.PhoneNumberIdentifier; import com.azure.core.http.HttpClient; @@ -18,6 +19,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; +import java.util.Collections; import java.util.UUID; public class CallConnectionAsyncLiveTests extends CallingServerTestBase { @@ -28,7 +30,7 @@ public class CallConnectionAsyncLiveTests extends CallingServerTestBase { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void runCreatePlayCancelHangupScenarioAsync(HttpClient httpClient) { @@ -40,14 +42,14 @@ public void runCreatePlayCancelHangupScenarioAsync(HttpClient httpClient) { // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnectionAsync callConnectionAsync = callingServerAsyncClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options).block(); CallingServerTestUtils.validateCallConnectionAsync(callConnectionAsync); @@ -80,7 +82,7 @@ public void runCreatePlayCancelHangupScenarioAsync(HttpClient httpClient) { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void runCreatePlayCancelHangupScenarioWithResponseAsync(HttpClient httpClient) { @@ -92,15 +94,15 @@ public void runCreatePlayCancelHangupScenarioWithResponseAsync(HttpClient httpCl // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); Response callConnectionAsyncResponse = callingServerAsyncClient.createCallConnectionWithResponse( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options).block(); CallingServerTestUtils.validateCallConnectionAsyncResponse(callConnectionAsyncResponse); @@ -109,13 +111,14 @@ public void runCreatePlayCancelHangupScenarioWithResponseAsync(HttpClient httpCl // Play Audio String operationContext = UUID.randomUUID().toString(); + PlayAudioOptions playAudioOptions = + new PlayAudioOptions() + .setLoop(false) + .setAudioFileId(UUID.randomUUID().toString()) + .setCallbackUri(null) + .setOperationContext(operationContext); Response playAudioResponse = - callConnectionAsync.playAudioWithResponse( - AUDIO_FILE_URI, - false, - UUID.randomUUID().toString(), - null, - operationContext).block(); + callConnectionAsync.playAudioWithResponse(AUDIO_FILE_URI, playAudioOptions).block(); CallingServerTestUtils.validatePlayAudioResponse(playAudioResponse); // Cancel All Media Operations @@ -136,7 +139,7 @@ public void runCreatePlayCancelHangupScenarioWithResponseAsync(HttpClient httpCl @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void runCreateAddRemoveHangupScenarioAsync(HttpClient httpClient) { @@ -148,14 +151,14 @@ public void runCreateAddRemoveHangupScenarioAsync(HttpClient httpClient) { // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnectionAsync callConnectionAsync = callingServerAsyncClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options).block(); CallingServerTestUtils.validateCallConnectionAsync(callConnectionAsync); @@ -183,7 +186,7 @@ public void runCreateAddRemoveHangupScenarioAsync(HttpClient httpClient) { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void runCreateAddRemoveHangupScenarioWithResponseAsync(HttpClient httpClient) { @@ -195,15 +198,15 @@ public void runCreateAddRemoveHangupScenarioWithResponseAsync(HttpClient httpCli // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); Response callConnectionAsyncResponse = callingServerAsyncClient.createCallConnectionWithResponse( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options).block(); CallingServerTestUtils.validateCallConnectionAsyncResponse(callConnectionAsyncResponse); @@ -237,7 +240,7 @@ public void runCreateAddRemoveHangupScenarioWithResponseAsync(HttpClient httpCli @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void runCreateJoinHangupScenarioAsync(HttpClient httpClient) { @@ -249,14 +252,14 @@ public void runCreateJoinHangupScenarioAsync(HttpClient httpClient) { // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnectionAsync callConnectionAsync = callingServerAsyncClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options).block(); CallingServerTestUtils.validateCallConnectionAsync(callConnectionAsync); @@ -269,10 +272,10 @@ public void runCreateJoinHangupScenarioAsync(HttpClient httpClient) { String serverCallId = "aHR0cHM6Ly94LWNvbnYtdXN3ZS0wMS5jb252LnNreXBlLmNvbS9jb252L3VodHNzZEZ3NFVHX1J4d1lHYWlLRmc_aT0yJmU9NjM3NTg0Mzk2NDM5NzQ5NzY4"; JoinCallOptions joinCallOptions = new JoinCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); CallConnectionAsync joinedCallConnectionAsync = - callingServerAsyncClient.join( + callingServerAsyncClient.joinCall( serverCallId, new CommunicationUserIdentifier(toUser), joinCallOptions).block(); @@ -292,7 +295,7 @@ public void runCreateJoinHangupScenarioAsync(HttpClient httpClient) { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void runCreateJoinHangupScenarioWithResponseAsync(HttpClient httpClient) { @@ -304,15 +307,15 @@ public void runCreateJoinHangupScenarioWithResponseAsync(HttpClient httpClient) // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); Response callConnectionAsyncResponse = callingServerAsyncClient.createCallConnectionWithResponse( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options).block(); CallingServerTestUtils.validateCallConnectionAsyncResponse(callConnectionAsyncResponse); @@ -327,10 +330,10 @@ public void runCreateJoinHangupScenarioWithResponseAsync(HttpClient httpClient) String serverCallId = "aHR0cHM6Ly94LWNvbnYtdXN3ZS0wMS5jb252LnNreXBlLmNvbS9jb252L3lKQXY0TnVlOEV5bUpYVm1IYklIeUE_aT0wJmU9NjM3NTg0MzkwMjcxMzg0MTc3"; JoinCallOptions joinCallOptions = new JoinCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); Response joinedCallConnectionAsyncResponse = - callingServerAsyncClient.joinWithResponse( + callingServerAsyncClient.joinCallWithResponse( serverCallId, new CommunicationUserIdentifier(toUser), joinCallOptions).block(); diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionLiveTests.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionLiveTests.java index 4f3b5003bc763..479b46f9ea987 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionLiveTests.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionLiveTests.java @@ -8,8 +8,8 @@ import com.azure.communication.callingserver.models.EventSubscriptionType; import com.azure.communication.callingserver.models.JoinCallOptions; import com.azure.communication.callingserver.models.MediaType; +import com.azure.communication.callingserver.models.PlayAudioOptions; import com.azure.communication.callingserver.models.PlayAudioResult; -import com.azure.communication.common.CommunicationIdentifier; import com.azure.communication.common.CommunicationUserIdentifier; import com.azure.communication.common.PhoneNumberIdentifier; import com.azure.core.http.HttpClient; @@ -18,6 +18,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; +import java.util.Collections; import java.util.UUID; public class CallConnectionLiveTests extends CallingServerTestBase { @@ -28,7 +29,7 @@ public class CallConnectionLiveTests extends CallingServerTestBase { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void runCreatePlayCancelHangupScenario(HttpClient httpClient) { @@ -39,14 +40,14 @@ public void runCreatePlayCancelHangupScenario(HttpClient httpClient) { // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnection callConnection = callingServerClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options); CallingServerTestUtils.validateCallConnection(callConnection); @@ -78,7 +79,7 @@ public void runCreatePlayCancelHangupScenario(HttpClient httpClient) { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void runCreatePlayCancelHangupScenarioWithResponse(HttpClient httpClient) { @@ -90,15 +91,15 @@ public void runCreatePlayCancelHangupScenarioWithResponse(HttpClient httpClient) // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); Response callConnectionResponse = callingServerClient.createCallConnectionWithResponse( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options, null); @@ -107,14 +108,14 @@ public void runCreatePlayCancelHangupScenarioWithResponse(HttpClient httpClient) // Play Audio String operationContext = UUID.randomUUID().toString(); + PlayAudioOptions playAudioOptions = + new PlayAudioOptions() + .setLoop(false) + .setAudioFileId(UUID.randomUUID().toString()) + .setCallbackUri(null) + .setOperationContext(operationContext); Response playAudioResult = - callConnection.playAudioWithResponse( - AUDIO_FILE_URI, - false, - UUID.randomUUID().toString(), - null, - operationContext, - null); + callConnection.playAudioWithResponse(AUDIO_FILE_URI, playAudioOptions, null); CallingServerTestUtils.validatePlayAudioResponse(playAudioResult); // Cancel All Media Operations @@ -135,7 +136,7 @@ public void runCreatePlayCancelHangupScenarioWithResponse(HttpClient httpClient) @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void runCreateAddRemoveHangupScenario(HttpClient httpClient) { @@ -146,14 +147,14 @@ public void runCreateAddRemoveHangupScenario(HttpClient httpClient) { // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnection callConnection = callingServerClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options); CallingServerTestUtils.validateCallConnection(callConnection); @@ -176,7 +177,7 @@ public void runCreateAddRemoveHangupScenario(HttpClient httpClient) { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void runCreateAddRemoveHangupScenarioWithResponse(HttpClient httpClient) { @@ -188,15 +189,15 @@ public void runCreateAddRemoveHangupScenarioWithResponse(HttpClient httpClient) // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); Response callConnectionResponse = callingServerClient.createCallConnectionWithResponse( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options, null); @@ -230,7 +231,7 @@ public void runCreateAddRemoveHangupScenarioWithResponse(HttpClient httpClient) @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void runCreateJoinHangupScenario(HttpClient httpClient) { @@ -241,14 +242,14 @@ public void runCreateJoinHangupScenario(HttpClient httpClient) { // Establish a call CreateCallOptions createCallOptions = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); createCallOptions.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnection callConnection = callingServerClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), createCallOptions); CallingServerTestUtils.validateCallConnection(callConnection); @@ -261,10 +262,10 @@ public void runCreateJoinHangupScenario(HttpClient httpClient) { String serverCallId = "aHR0cHM6Ly94LWNvbnYtdXN3ZS0wMS5jb252LnNreXBlLmNvbS9jb252L2RUUjRPVGFxVzAyZ3cxVGpNSUNBdEE_aT0wJmU9NjM3NTg0MzkwMjcxMzg0MTc3"; JoinCallOptions joinCallOptions = new JoinCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); CallConnection joinedCallConnection = - callingServerClient.join(serverCallId, new CommunicationUserIdentifier(toUser), joinCallOptions); + callingServerClient.joinCall(serverCallId, new CommunicationUserIdentifier(toUser), joinCallOptions); CallingServerTestUtils.validateCallConnection(joinedCallConnection); //Hangup @@ -279,7 +280,7 @@ public void runCreateJoinHangupScenario(HttpClient httpClient) { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void runCreateJoinHangupScenarioWithResponse(HttpClient httpClient) { @@ -291,14 +292,14 @@ public void runCreateJoinHangupScenarioWithResponse(HttpClient httpClient) { // Establish a call CreateCallOptions createCallOptions = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); createCallOptions.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); Response callConnectionResponse = callingServerClient.createCallConnectionWithResponse( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), createCallOptions, null); @@ -309,10 +310,10 @@ public void runCreateJoinHangupScenarioWithResponse(HttpClient httpClient) { String serverCallId = "aHR0cHM6Ly94LWNvbnYtdXN3ZS0wMS5jb252LnNreXBlLmNvbS9jb252L3dXZW9hNjAweGtPZ0d6eHE2eG1tQVE_aT0yJmU9NjM3NTg0Mzk2NDM5NzQ5NzY4"; JoinCallOptions joinCallOptions = new JoinCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); Response joinedCallConnectionResponse = - callingServerClient.joinWithResponse( + callingServerClient.joinCallWithResponse( serverCallId, new CommunicationUserIdentifier(toUser), joinCallOptions, diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallingServerTestBase.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallingServerTestBase.java index 7307e021cff6a..f1ea73fdb1a69 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallingServerTestBase.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallingServerTestBase.java @@ -23,6 +23,7 @@ import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.StringJoiner; @@ -41,7 +42,7 @@ public class CallingServerTestBase extends TestBase { .get("COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING", "endpoint=https://REDACTED.communication.azure.com/;accesskey=QWNjZXNzS2V5"); - protected static final String RESOURCE_IDENTIFIER = Configuration.getGlobalConfiguration() + protected static final String AZURE_TENANT_ID = Configuration.getGlobalConfiguration() .get("COMMUNICATION_LIVETEST_STATIC_RESOURCE_IDENTIFIER", "016a7064-0581-40b9-be73-6dde64d69d72"); @@ -98,8 +99,8 @@ protected String getNewUserId() { return getRandomUserId(); } - private String getRandomUserId() { - return "8:acs:" + RESOURCE_IDENTIFIER + "_" + UUID.randomUUID(); + protected String getRandomUserId() { + return "8:acs:" + AZURE_TENANT_ID + "_" + UUID.randomUUID(); } protected String getGroupId(String testName) { @@ -176,18 +177,18 @@ protected List createCall(CallingServerClient callingServerClien JoinCallOptions fromCallOptions = new JoinCallOptions( callBackUri, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); - fromCallConnection = callingServerClient.join(groupId, fromParticipant, fromCallOptions); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); + fromCallConnection = callingServerClient.joinCall(groupId, fromParticipant, fromCallOptions); sleepIfRunningAgainstService(1000); CallingServerTestUtils.validateCallConnection(fromCallConnection); JoinCallOptions joinCallOptions = new JoinCallOptions( callBackUri, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); - toCallConnection = callingServerClient.join(groupId, toParticipant, joinCallOptions); + toCallConnection = callingServerClient.joinCall(groupId, toParticipant, joinCallOptions); sleepIfRunningAgainstService(1000); CallingServerTestUtils.validateCallConnection(toCallConnection); @@ -221,18 +222,18 @@ protected List createAsyncCall(CallingServerAsyncClient cal JoinCallOptions fromCallOptions = new JoinCallOptions( callBackUri, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); - fromCallConnection = callingServerClient.join(groupId, fromParticipant, fromCallOptions).block(); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); + fromCallConnection = callingServerClient.joinCall(groupId, fromParticipant, fromCallOptions).block(); sleepIfRunningAgainstService(1000); CallingServerTestUtils.validateCallConnectionAsync(fromCallConnection); JoinCallOptions joinCallOptions = new JoinCallOptions( callBackUri, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); - toCallConnection = callingServerClient.join(groupId, toParticipant, joinCallOptions).block(); + toCallConnection = callingServerClient.joinCall(groupId, toParticipant, joinCallOptions).block(); sleepIfRunningAgainstService(1000); CallingServerTestUtils.validateCallConnectionAsync(toCallConnection); diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentAsyncLiveTests.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentAsyncLiveTests.java index 899ffe2d8f77c..66c78edcb63d3 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentAsyncLiveTests.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentAsyncLiveTests.java @@ -36,7 +36,7 @@ public class DownloadContentAsyncLiveTests extends CallingServerTestBase { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void downloadMetadataAsync(HttpClient httpClient) { @@ -58,12 +58,12 @@ public void downloadMetadataAsync(HttpClient httpClient) { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void downloadMetadataRetryingAsync(HttpClient httpClient) { CallingServerClientBuilder builder = getConversationClientUsingConnectionString(httpClient); - CallingServerAsyncClient conversationAsyncClient = setupAsyncClient(builder, "downloadMetadataAsync"); + CallingServerAsyncClient conversationAsyncClient = setupAsyncClient(builder, "downloadMetadataRetryingAsync"); try { Flux content = conversationAsyncClient.downloadStream(METADATA_URL); @@ -80,7 +80,7 @@ public void downloadMetadataRetryingAsync(HttpClient httpClient) { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void downloadVideoAsync(HttpClient httpClient) { @@ -102,7 +102,7 @@ public void downloadVideoAsync(HttpClient httpClient) { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void downloadToFileAsync(HttpClient httpClient) { @@ -127,7 +127,7 @@ public void downloadToFileAsync(HttpClient httpClient) { .downloadToWithResponse(METADATA_URL, Paths.get("dummyPath"), channel, - new ParallelDownloadOptions().setBlockSizeLong(479L), + new ParallelDownloadOptions().setBlockSize(479L), null).block(); Mockito.verify(channel, times(2)).write(any(ByteBuffer.class), anyLong(), @@ -137,12 +137,12 @@ public void downloadToFileAsync(HttpClient httpClient) { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void downloadToFileRetryingAsync(HttpClient httpClient) { CallingServerClientBuilder builder = getConversationClientUsingConnectionString(httpClient); - CallingServerAsyncClient conversationAsyncClient = setupAsyncClient(builder, "downloadToFileAsync"); + CallingServerAsyncClient conversationAsyncClient = setupAsyncClient(builder, "downloadToFileRetryingAsync"); AsynchronousFileChannel channel = Mockito.mock(AsynchronousFileChannel.class); doAnswer(invocation -> { @@ -171,6 +171,10 @@ public void downloadToFileRetryingAsync(HttpClient httpClient) { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") + @DisabledIfEnvironmentVariable( + named = "SKIP_LIVE_TEST", + matches = "(?i)(true)", + disabledReason = "Requires human intervention") public void downloadContent404Async(HttpClient httpClient) { CallingServerClientBuilder builder = getConversationClientUsingConnectionString(httpClient); CallingServerAsyncClient conversationAsyncClient = setupAsyncClient(builder, "downloadContent404Async"); diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentLiveTests.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentLiveTests.java index 24433330c0696..d1b508bac18a6 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentLiveTests.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentLiveTests.java @@ -29,7 +29,7 @@ public class DownloadContentLiveTests extends CallingServerTestBase { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void downloadMetadata(HttpClient httpClient) throws UnsupportedEncodingException { @@ -50,7 +50,7 @@ public void downloadMetadata(HttpClient httpClient) throws UnsupportedEncodingEx @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void downloadVideo(HttpClient httpClient) { @@ -76,6 +76,10 @@ public void downloadVideo(HttpClient httpClient) { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") + @DisabledIfEnvironmentVariable( + named = "SKIP_LIVE_TEST", + matches = "(?i)(true)", + disabledReason = "Requires human intervention") public void downloadContent404(HttpClient httpClient) { CallingServerClientBuilder builder = getConversationClientUsingConnectionString(httpClient); CallingServerClient conversationClient = setupClient(builder, "downloadContent404"); @@ -91,7 +95,7 @@ public void downloadContent404(HttpClient httpClient) { @MethodSource("com.azure.core.test.TestBase#getHttpClients") public void downloadContentWrongUrl(HttpClient httpClient) { CallingServerClientBuilder builder = getConversationClientUsingConnectionString(httpClient); - CallingServerClient conversationClient = setupClient(builder, "downloadContent404"); + CallingServerClient conversationClient = setupClient(builder, "downloadContentWrongUrl"); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); IllegalArgumentException ex = @@ -104,6 +108,10 @@ public void downloadContentWrongUrl(HttpClient httpClient) { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") + @DisabledIfEnvironmentVariable( + named = "SKIP_LIVE_TEST", + matches = "(?i)(true)", + disabledReason = "Requires human intervention") public void downloadContentStreamFailure(HttpClient httpClient) throws IOException { CallingServerClientBuilder builder = getConversationClientUsingConnectionString(httpClient); CallingServerClient conversationClient = setupClient(builder, "downloadContent404"); diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallAsyncLiveTests.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallAsyncLiveTests.java index f6c5c62a50c60..517fb9c0917eb 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallAsyncLiveTests.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallAsyncLiveTests.java @@ -13,7 +13,6 @@ import com.azure.communication.callingserver.models.PlayAudioOptions; import com.azure.communication.callingserver.models.PlayAudioResult; import com.azure.communication.callingserver.models.StartCallRecordingResult; -import com.azure.communication.common.CommunicationIdentifier; import com.azure.communication.common.CommunicationUserIdentifier; import com.azure.communication.common.PhoneNumberIdentifier; import com.azure.core.http.HttpClient; @@ -23,6 +22,7 @@ import org.junit.jupiter.params.provider.MethodSource; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.UUID; @@ -31,8 +31,8 @@ public class ServerCallAsyncLiveTests extends CallingServerTestBase { - private final String fromUser = getNewUserId(); - private final String toUser = getNewUserId(); + private final String fromUser = getRandomUserId(); + private final String toUser = getRandomUserId(); @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @@ -209,7 +209,7 @@ public void startRecordingFailsAsync(HttpClient httpClient) { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void runAddRemoveScenarioAsync(HttpClient httpClient) { @@ -221,14 +221,14 @@ public void runAddRemoveScenarioAsync(HttpClient httpClient) { // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnectionAsync callConnectionAsync = callingServerAsyncClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options).block(); CallingServerTestUtils.validateCallConnectionAsync(callConnectionAsync); @@ -267,7 +267,7 @@ public void runAddRemoveScenarioAsync(HttpClient httpClient) { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void runAddRemoveScenarioWithResponseAsync(HttpClient httpClient) { @@ -278,14 +278,14 @@ public void runAddRemoveScenarioWithResponseAsync(HttpClient httpClient) { // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnectionAsync callConnectionAsync = callingServerAsyncClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options).block(); CallingServerTestUtils.validateCallConnectionAsync(callConnectionAsync); diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallLiveTests.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallLiveTests.java index bd98c67c09beb..d84a635db2c23 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallLiveTests.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallLiveTests.java @@ -13,7 +13,6 @@ import com.azure.communication.callingserver.models.PlayAudioOptions; import com.azure.communication.callingserver.models.PlayAudioResult; import com.azure.communication.callingserver.models.StartCallRecordingResult; -import com.azure.communication.common.CommunicationIdentifier; import com.azure.communication.common.CommunicationUserIdentifier; import com.azure.communication.common.PhoneNumberIdentifier; import com.azure.core.http.HttpClient; @@ -24,6 +23,7 @@ import org.junit.jupiter.params.provider.MethodSource; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.UUID; @@ -36,8 +36,8 @@ public class ServerCallLiveTests extends CallingServerTestBase { - private final String fromUser = getNewUserId(); - private final String toUser = getNewUserId(); + private final String fromUser = getRandomUserId(); + private final String toUser = getRandomUserId(); @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @@ -167,13 +167,16 @@ public void runPlayAudioFunctionWithResponse(HttpClient httpClient) { try { callConnections = createCall(callingServerClient, groupId, fromUser, toUser, CALLBACK_URI); + PlayAudioOptions playAudioOptions = + new PlayAudioOptions() + .setLoop(false) + .setAudioFileId(UUID.randomUUID().toString()) + .setCallbackUri(CALLBACK_URI) + .setOperationContext(operationContext); serverCall = callingServerClient.initializeServerCall(groupId); Response playAudioResult = - serverCall.playAudioWithResponse( - AUDIO_FILE_URI, operationContext, - CALLBACK_URI, operationContext, - Context.NONE); + serverCall.playAudioWithResponse(AUDIO_FILE_URI, playAudioOptions, Context.NONE); validatePlayAudioResponse(playAudioResult); } catch (Exception e) { @@ -204,7 +207,7 @@ public void startRecordingFails(HttpClient httpClient) { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void runAddRemoveScenario(HttpClient httpClient) { @@ -214,14 +217,14 @@ public void runAddRemoveScenario(HttpClient httpClient) { // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnection callConnection = callingServerClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options); validateCallConnection(callConnection); @@ -257,7 +260,7 @@ public void runAddRemoveScenario(HttpClient httpClient) { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @DisabledIfEnvironmentVariable( - named = "RUN_CALLINGSERVER_TEST_RECORD", + named = "SKIP_LIVE_TEST", matches = "(?i)(true)", disabledReason = "Requires human intervention") public void runAddRemoveScenarioWithResponse(HttpClient httpClient) { @@ -268,14 +271,14 @@ public void runAddRemoveScenarioWithResponse(HttpClient httpClient) { // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnection callConnection = callingServerClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options); validateCallConnection(callConnection); diff --git a/sdk/communication/azure-communication-callingserver/swagger/README.md b/sdk/communication/azure-communication-callingserver/swagger/README.md index cd4929b924c02..4443936f29d64 100644 --- a/sdk/communication/azure-communication-callingserver/swagger/README.md +++ b/sdk/communication/azure-communication-callingserver/swagger/README.md @@ -33,7 +33,7 @@ To update generated files for calling service, run the following command ``` yaml tag: package-2021-06-15-preview require: - - https://github.com/Azure/azure-rest-api-specs/blob/60ae3d6b8806c896f2e54e4bfd900357dbcfd54a/specification/communication/data-plane/CallingServer/readme.md + - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/b4b5fa5ee23f8cce9e1ade4a82076b4c34b25651/specification/communication/data-plane/CallingServer/readme.md java: true output-folder: ..\ license-header: MICROSOFT_MIT_SMALL diff --git a/sdk/communication/azure-communication-callingserver/tests.yml b/sdk/communication/azure-communication-callingserver/tests.yml index b66a735649257..afd6c1d779248 100644 --- a/sdk/communication/azure-communication-callingserver/tests.yml +++ b/sdk/communication/azure-communication-callingserver/tests.yml @@ -5,3 +5,4 @@ stages: parameters: PackageName: azure-communication-callingserver SafeName: azurecommunicationcallingserver +