From fa7024a735bdcc8fd9af61ece221c2d945eb9fcf Mon Sep 17 00:00:00 2001 From: Arif Saikat <71465659+arifsaikat-microsoft@users.noreply.github.com> Date: Tue, 15 Jun 2021 16:44:44 -0700 Subject: [PATCH] apiview review fix --- .../callingserver/CallConnection.java | 23 +++++------ .../callingserver/CallConnectionAsync.java | 6 ++- .../callingserver/CallingServerClient.java | 8 ++-- .../CallingServerClientBuilder.java | 18 ++++----- .../CallingServerServiceVersion.java | 37 ++++++++++++++++++ .../callingserver/ServerCall.java | 38 +++++++++---------- .../callingserver/ServerCallAsync.java | 12 ++++-- .../models/events/CallingServerEventType.java | 2 +- .../callingserver/CallingServerTestBase.java | 2 +- 9 files changed, 89 insertions(+), 57 deletions(-) create mode 100644 sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerServiceVersion.java 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 48ec1f5fc7c2..cd146830294b 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 @@ -93,7 +93,7 @@ public Response playAudioWithResponse( String audioFileId, String callbackUri, String operationContext, - Context context) { + final Context context) { return callConnectionAsync .playAudioWithResponseInternal( audioFileUri, @@ -119,7 +119,7 @@ public Response playAudioWithResponse( public Response playAudioWithResponse( String audioFileUri, PlayAudioOptions playAudioOptions, - Context context) { + final Context context) { return callConnectionAsync .playAudioWithResponseInternal(audioFileUri, playAudioOptions, context) .block(); @@ -127,12 +127,10 @@ public Response playAudioWithResponse( /** * Disconnect the current caller in a group-call or end a p2p-call. - * - * @return response for a successful hangup request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Void hangup() { - return callConnectionAsync.hangup().block(); + public void hangup() { + callConnectionAsync.hangup().block(); } /** @@ -142,7 +140,7 @@ public Void hangup() { * @return response for a successful hangup request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response hangupWithResponse(Context context) { + public Response hangupWithResponse(final Context context) { return callConnectionAsync.hangupWithResponse(context).block(); } @@ -169,7 +167,7 @@ public CancelAllMediaOperationsResult cancelAllMediaOperations(String operationC @ServiceMethod(returns = ReturnType.SINGLE) public Response cancelAllMediaOperationsWithResponse( String operationContext, - Context context) { + final Context context) { return callConnectionAsync.cancelAllMediaOperationsWithResponse(operationContext, context).block(); } @@ -205,7 +203,7 @@ public Response addParticipantWithResponse( CommunicationIdentifier participant, String alternateCallerId, String operationContext, - Context context) { + final Context context) { return callConnectionAsync .addParticipantWithResponse(participant, alternateCallerId, operationContext, context).block(); } @@ -214,11 +212,10 @@ public Response addParticipantWithResponse( * Remove a participant from the call. * * @param participantId Participant id. - * @return response for a successful remove participant request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Void removeParticipant(String participantId) { - return callConnectionAsync.removeParticipant(participantId).block(); + public void removeParticipant(String participantId) { + callConnectionAsync.removeParticipant(participantId).block(); } /** @@ -229,7 +226,7 @@ public Void removeParticipant(String participantId) { * @return response for a successful remove participant request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response removeParticipantWithResponse(String participantId, Context context) { + public Response removeParticipantWithResponse(String participantId, final Context context) { return callConnectionAsync.removeParticipantWithResponse(participantId, context).block(); } } 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 95438d826073..4196ff809e97 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 @@ -254,7 +254,8 @@ Mono> playAudioWithResponseInternal( public Mono hangup() { try { return callConnectionInternal.hangupCallAsync(callConnectionId) - .onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException); + .onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException) + .flatMap(result -> Mono.empty()); } catch (RuntimeException ex) { return monoError(logger, ex); } @@ -411,7 +412,8 @@ Mono> addParticipantWithResponse( public Mono removeParticipant(String participantId) { try { return callConnectionInternal.removeParticipantAsync(callConnectionId, participantId) - .onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException); + .onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException) + .flatMap(result -> Mono.empty()); } catch (RuntimeException ex) { return monoError(logger, ex); } 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 adc0284c0851..1ab8665d967e 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 @@ -70,7 +70,7 @@ public Response createCallConnectionWithResponse( CommunicationIdentifier source, CommunicationIdentifier[] targets, CreateCallOptions createCallOptions, - Context context) { + final Context context) { return callingServerAsyncClient .createCallConnectionWithResponseInternal(source, targets, createCallOptions, context).block(); } @@ -105,7 +105,7 @@ public Response joinWithResponse( String serverCallId, CommunicationIdentifier source, JoinCallOptions joinCallOptions, - Context context) { + final Context context) { return callingServerAsyncClient.joinWithResponseInternal(serverCallId, source, joinCallOptions, context).block(); } @@ -156,7 +156,7 @@ public void downloadTo(String sourceEndpoint, OutputStream destinationStream, Ht public Response downloadToWithResponse(String sourceEndpoint, OutputStream destinationStream, HttpRange httpRange, - Context context) { + final Context context) { Objects.requireNonNull(sourceEndpoint, "'sourceEndpoint' cannot be null"); Objects.requireNonNull(destinationStream, "'destinationStream' cannot be null"); return callingServerAsyncClient @@ -197,7 +197,7 @@ public Response downloadToWithResponse(String sourceEndpoint, Path destinationPath, ParallelDownloadOptions parallelDownloadOptions, boolean overwrite, - Context context) { + final Context context) { Objects.requireNonNull(sourceEndpoint, "'sourceEndpoint' cannot be null"); Objects.requireNonNull(destinationPath, "'destinationPath' cannot be null"); return callingServerAsyncClient.downloadToWithResponse(sourceEndpoint, destinationPath, 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 f7e0f9b929f5..5c36aeefc8b6 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 @@ -157,22 +157,18 @@ public CallingServerClientBuilder httpLogOptions(HttpLogOptions logOptions) { } /** - * Sets the {@link CallingServerClientBuilder} that is used when making API requests. + * Sets the {@link CallingServerServiceVersion} that is used when making API requests. *

- * If a service version is not provided, the service version that will be used - * will be the latest known service version based on the version of the client - * library being used. If no service version is specified, updating to a newer - * version of the client library will have the result of potentially moving to a - * newer service version. + * If a service version is not provided, the service version that will be used will be the latest known service + * version based on the version of the client library being used. If no service version is specified, updating to a + * newer version of the client library will have the result of potentially moving to a newer service version. *

- * Targeting a specific service version may also mean that the service will - * return an error for newer APIs. + * Targeting a specific service version may also mean that the service will return an error for newer APIs. * - * @param version {@link CallingServerClientBuilder} of the service to be used when - * making requests. + * @param version {@link CallingServerServiceVersion} of the service to be used when making requests. * @return the updated CallingServerClientBuilder object */ - public CallingServerClientBuilder serviceVersion(CallingServerClientBuilder version) { + public CallingServerClientBuilder serviceVersion(CallingServerServiceVersion version) { 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 new file mode 100644 index 000000000000..bfa102b34da9 --- /dev/null +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerServiceVersion.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.communication.callingserver; + +import com.azure.core.util.ServiceVersion; + +/** + * 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"); + + private final String version; + + CallingServerServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library + * + * @return the latest {@link CallingServerServiceVersion} + */ + public static CallingServerServiceVersion getLatest() { + return V2021_06_15_preview; + } +} 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 b86fd08ddae4..f0c1f42053e3 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 @@ -69,7 +69,7 @@ public Response addParticipantWithResponse( String callBackUri, String alternateCallerId, String operationContext, - Context context) { + final Context context) { return serverCallAsync.addParticipantWithResponse( participant, callBackUri, @@ -82,11 +82,10 @@ public Response addParticipantWithResponse( * Remove a participant from the call. * * @param participantId Participant id. - * @return response for a successful remove participant request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Void removeParticipant(String participantId) { - return serverCallAsync.removeParticipant(participantId).block(); + public void removeParticipant(String participantId) { + serverCallAsync.removeParticipant(participantId).block(); } /** @@ -97,7 +96,7 @@ public Void removeParticipant(String participantId) { * @return response for a successful remove participant request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response removeParticipantWithResponse(String participantId, Context context) { + public Response removeParticipantWithResponse(String participantId, final Context context) { return serverCallAsync.removeParticipantWithResponse(participantId, context).block(); } @@ -122,7 +121,7 @@ public StartCallRecordingResult startRecording(String recordingStateCallbackUri) @ServiceMethod(returns = ReturnType.SINGLE) public Response startRecordingWithResponse( String recordingStateCallbackUri, - Context context) { + final Context context) { return serverCallAsync.startRecordingWithResponse(recordingStateCallbackUri, context).block(); } @@ -130,11 +129,10 @@ public Response startRecordingWithResponse( * Stop recording * * @param recordingId The recording id to stop. - * @return response for a successful stop recording request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Void stopRecording(String recordingId) { - return serverCallAsync.stopRecording(recordingId).block(); + public void stopRecording(String recordingId) { + serverCallAsync.stopRecording(recordingId).block(); } /** @@ -145,7 +143,7 @@ public Void stopRecording(String recordingId) { * @return response for a successful stop recording request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response stopRecordingWithResponse(String recordingId, Context context) { + public Response stopRecordingWithResponse(String recordingId, final Context context) { return serverCallAsync.stopRecordingWithResponse(recordingId, context).block(); } @@ -153,11 +151,10 @@ public Response stopRecordingWithResponse(String recordingId, Context cont * Pause recording * * @param recordingId The recording id to stop. - * @return response for a successful pause recording request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Void pauseRecording(String recordingId) { - return serverCallAsync.pauseRecording(recordingId).block(); + public void pauseRecording(String recordingId) { + serverCallAsync.pauseRecording(recordingId).block(); } /** @@ -168,7 +165,7 @@ public Void pauseRecording(String recordingId) { * @return response for a successful pause recording request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response pauseRecordingWithResponse(String recordingId, Context context) { + public Response pauseRecordingWithResponse(String recordingId, final Context context) { return serverCallAsync.pauseRecordingWithResponse(recordingId, context).block(); } @@ -176,11 +173,10 @@ public Response pauseRecordingWithResponse(String recordingId, Context con * Resume recording * * @param recordingId The recording id to stop. - * @return response for a successful resume recording request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Void resumeRecording(String recordingId) { - return serverCallAsync.resumeRecording(recordingId).block(); + public void resumeRecording(String recordingId) { + serverCallAsync.resumeRecording(recordingId).block(); } /** @@ -191,7 +187,7 @@ public Void resumeRecording(String recordingId) { * @return response for a successful resume recording request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response resumeRecordingWithResponse(String recordingId, Context context) { + public Response resumeRecordingWithResponse(String recordingId, final Context context) { return serverCallAsync.resumeRecordingWithResponse(recordingId, context).block(); } @@ -214,7 +210,7 @@ public CallRecordingProperties getRecordingState(String recordingId) { * @return response for a successful get recording state request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getRecordingStateWithResponse(String recordingId, Context context) { + public Response getRecordingStateWithResponse(String recordingId, final Context context) { return serverCallAsync.getRecordingStateWithResponse(recordingId, context).block(); } @@ -272,7 +268,7 @@ public Response playAudioWithResponse( String audioFileId, String callbackUri, String operationContext, - Context context) { + final Context context) { return serverCallAsync .playAudioWithResponseInternal( audioFileUri, @@ -296,7 +292,7 @@ public Response playAudioWithResponse( public Response playAudioWithResponse( String audioFileUri, PlayAudioOptions playAudioOptions, - Context context) { + final Context context) { return serverCallAsync.playAudioWithResponseInternal(audioFileUri, playAudioOptions, context).block(); } } 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 4734edc974bd..6d72f20d5ea5 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 @@ -145,7 +145,8 @@ Mono> addParticipantWithResponse( public Mono removeParticipant(String participantId) { try { return serverCallInternal.removeParticipantAsync(serverCallId, participantId) - .onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException); + .onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException) + .flatMap(result -> Mono.empty()); } catch (RuntimeException ex) { return monoError(logger, ex); } @@ -248,7 +249,8 @@ Mono> startRecordingWithResponse( public Mono stopRecording(String recordingId) { try { return serverCallInternal.stopRecordingAsync(serverCallId, recordingId) - .onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException); + .onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException) + .flatMap(result -> Mono.empty()); } catch (RuntimeException ex) { return monoError(logger, ex); } @@ -288,7 +290,8 @@ Mono> stopRecordingWithResponse(String recordingId, Context conte public Mono pauseRecording(String recordingId) { try { return serverCallInternal.pauseRecordingAsync(serverCallId, recordingId) - .onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException); + .onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException) + .flatMap(result -> Mono.empty()); } catch (RuntimeException ex) { return monoError(logger, ex); } @@ -328,7 +331,8 @@ Mono> pauseRecordingWithResponse(String recordingId, Context cont public Mono resumeRecording(String recordingId) { try { return serverCallInternal.resumeRecordingAsync(serverCallId, recordingId) - .onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException); + .onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException) + .flatMap(result -> Mono.empty()); } catch (RuntimeException ex) { return monoError(logger, ex); } diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/CallingServerEventType.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/CallingServerEventType.java index d054b8f7a795..765a0bbe3fb7 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/CallingServerEventType.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/CallingServerEventType.java @@ -17,7 +17,7 @@ public final class CallingServerEventType extends ExpandableStringEnum