Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrwhit/style check2 #21941

Merged
merged 1 commit into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
import reactor.core.publisher.Mono;

Expand All @@ -39,6 +40,7 @@
import java.util.stream.Collectors;

import static com.azure.core.util.FluxUtil.monoError;
import static com.azure.core.util.FluxUtil.withContext;

/**
* Async client that supports server call operations.
Expand Down Expand Up @@ -89,17 +91,28 @@ public Mono<CreateCallResult> createCall(CommunicationIdentifier source, Iterabl
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<CreateCallResult>> createCallWithResponse(CommunicationIdentifier source,
Iterable<CommunicationIdentifier> targets, CreateCallOptions createCallOptions) {
return createCallWithResponse(source, targets, createCallOptions, null);
}

Mono<Response<CreateCallResult>> createCallWithResponse(CommunicationIdentifier source,
Iterable<CommunicationIdentifier> targets, CreateCallOptions createCallOptions, Context context) {
try {
Objects.requireNonNull(source, "'source' cannot be null.");
Objects.requireNonNull(targets, "'targets' cannot be null.");
Objects.requireNonNull(createCallOptions, "'CreateCallOptions' cannot be null.");

CreateCallRequestInternal request = createCreateCallRequest(source, targets, createCallOptions);
return this.callClient.createCallWithResponseAsync(request)
.flatMap((Response<CreateCallResponse> response) -> {
CreateCallResult createCallResult = convertCreateCallWithResponse(response.getValue());
return Mono.just(new SimpleResponse<>(response, createCallResult));
});

return withContext(contextValue -> {
if (context != null) {
contextValue = context;
}
return this.callClient.createCallWithResponseAsync(request)
.flatMap((Response<CreateCallResponse> response) -> {
CreateCallResult createCallResult = convertCreateCallWithResponse(response.getValue());
return Mono.just(new SimpleResponse<>(response, createCallResult));
});
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand Down Expand Up @@ -137,14 +150,22 @@ public Mono<PlayAudioResult> playAudio(String callId, PlayAudioRequest request)
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<PlayAudioResult>> playAudioWithResponse(String callId, PlayAudioRequest request) {
return playAudioWithResponse(callId, request, null);
}

Mono<Response<PlayAudioResult>> playAudioWithResponse(String callId, PlayAudioRequest request, Context context) {
try {
Objects.requireNonNull(callId, "'callId' cannot be null.");
Objects.requireNonNull(request, "'request' cannot be null.");

return this.callClient.playAudioWithResponseAsync(callId, convertPlayAudioRequest(request)).flatMap((
Response<com.azure.communication.callingserver.implementation.models.PlayAudioResponse> response) -> {
PlayAudioResult playAudioResult = convertPlayAudioResponse(response.getValue());
return Mono.just(new SimpleResponse<>(response, playAudioResult));
return withContext(contextValue -> {
if (context != null) {
contextValue = context;
}
return this.callClient.playAudioWithResponseAsync(callId, convertPlayAudioRequest(request)).flatMap((
Response<com.azure.communication.callingserver.implementation.models.PlayAudioResponse> response) -> {
PlayAudioResult playAudioResult = convertPlayAudioResponse(response.getValue());
return Mono.just(new SimpleResponse<>(response, playAudioResult));
});
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand Down Expand Up @@ -176,10 +197,18 @@ public Mono<Void> hangupCall(String callId) {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> hangupCallWithResponse(String callId) {
return hangupCallWithResponse(callId, null);
}

Mono<Response<Void>> hangupCallWithResponse(String callId, Context context) {
try {
Objects.requireNonNull(callId, "'callId' cannot be null.");

return this.callClient.hangupCallWithResponseAsync(callId);
return withContext(contextValue -> {
if (context != null) {
contextValue = context;
}
return this.callClient.hangupCallWithResponseAsync(callId);
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand Down Expand Up @@ -210,14 +239,22 @@ public Mono<Void> deleteCall(String callId) {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> deleteCallWithResponse(String callId) {
return deleteCallWithResponse(callId, null);
}

Mono<Response<Void>> deleteCallWithResponse(String callId, Context context) {
try {
Objects.requireNonNull(callId, "'callId' cannot be null.");

return this.callClient.deleteCallWithResponseAsync(callId);
return withContext(contextValue -> {
if (context != null) {
contextValue = context;
}
return this.callClient.deleteCallWithResponseAsync(callId);
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
}
}

/**
* Cancel Media Processing.
Expand Down Expand Up @@ -255,18 +292,27 @@ public Mono<CancelMediaProcessingResult> cancelMediaProcessing(String callId,
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<CancelMediaProcessingResult>> cancelMediaProcessingWithResponse(String callId,
CancelMediaProcessingRequest request) {
return cancelMediaProcessingWithResponse(callId, request, null);
}

Mono<Response<CancelMediaProcessingResult>> cancelMediaProcessingWithResponse(String callId,
CancelMediaProcessingRequest request, Context context) {
try {
Objects.requireNonNull(callId, "'callId' cannot be null.");
Objects.requireNonNull(request, "'request' cannot be null.");

return this.callClient
.cancelMediaProcessingWithResponseAsync(callId, convertCancelMediaProcessingRequest(request))
.flatMap((
Response<com.azure.communication.callingserver.implementation.models.CancelMediaProcessingResponse> response) -> {
CancelMediaProcessingResult cancelMediaProcessingResult = convertCancelMediaProcessingResponse(
response.getValue());
return Mono.just(new SimpleResponse<>(response, cancelMediaProcessingResult));
});
return withContext(contextValue -> {
if (context != null) {
contextValue = context;
}
return this.callClient
.cancelMediaProcessingWithResponseAsync(callId, convertCancelMediaProcessingRequest(request))
.flatMap((
Response<com.azure.communication.callingserver.implementation.models.CancelMediaProcessingResponse> response) -> {
CancelMediaProcessingResult cancelMediaProcessingResult = convertCancelMediaProcessingResponse(
response.getValue());
return Mono.just(new SimpleResponse<>(response, cancelMediaProcessingResult));
});
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand Down Expand Up @@ -300,12 +346,20 @@ public Mono<Void> inviteParticipants(String callId, InviteParticipantsRequest re
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> inviteParticipantsWithResponse(String callId, InviteParticipantsRequest request) {
return inviteParticipantsWithResponse(callId, request, null);
}

Mono<Response<Void>> inviteParticipantsWithResponse(String callId, InviteParticipantsRequest request, Context context) {
try {
Objects.requireNonNull(callId, "'callId' cannot be null.");
Objects.requireNonNull(request, "'request' cannot be null.");

return this.callClient.inviteParticipantsWithResponseAsync(callId,
InviteParticipantsRequestConverter.convert(request));
return withContext(contextValue -> {
if (context != null) {
contextValue = context;
}
return this.callClient.inviteParticipantsWithResponseAsync(callId,
InviteParticipantsRequestConverter.convert(request));
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand Down Expand Up @@ -339,11 +393,22 @@ public Mono<Void> removeParticipant(String callId, String participantId) {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> removeParticipantWithResponse(String callId, String participantId) {
return removeParticipantWithResponse(callId, participantId, null);
}

/**
* cancelMediaProcessingWithResponse method for use by sync client
*/
Mono<Response<Void>> removeParticipantWithResponse(String callId, String participantId, Context context) {
try {
Objects.requireNonNull(callId, "'callId' cannot be null.");
Objects.requireNonNull(participantId, "'request' cannot be null.");

return this.callClient.removeParticipantWithResponseAsync(callId, participantId);
return withContext(contextValue -> {
if (context != null) {
contextValue = context;
}
return this.callClient.removeParticipantWithResponseAsync(callId, participantId);
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.azure.core.annotation.ServiceClient;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.http.rest.Response;
import com.azure.core.util.Context;

/**
* Sync Client that supports server call operations.
Expand Down Expand Up @@ -45,11 +46,12 @@ public CreateCallResult createCall(CommunicationIdentifier source, Iterable<Comm
* @param source The source of the call.
* @param targets The targets of the call.
* @param createCallOptions The call Options.
* @param context A {@link Context} representing the request context.
* @return response for a successful CreateCall request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<CreateCallResult> createCallWithResponse(CommunicationIdentifier source, Iterable<CommunicationIdentifier> targets, CreateCallOptions createCallOptions) {
return callAsyncClient.createCallWithResponse(source, targets, createCallOptions).block();
public Response<CreateCallResult> createCallWithResponse(CommunicationIdentifier source, Iterable<CommunicationIdentifier> targets, CreateCallOptions createCallOptions, Context context) {
return callAsyncClient.createCallWithResponse(source, targets, createCallOptions, context).block();
}

/**
Expand All @@ -69,23 +71,6 @@ public PlayAudioResult playAudio(String callId, String audioFileUri, boolean loo
return callAsyncClient.playAudio(callId, playAudioRequest).block();
}

/**
* Play audio in a call.
*
* @param callId The call id.
* @param audioFileUri The media resource uri of the play audio request.
* @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 operationContext The value to identify context of the operation.
* @return the response payload for play audio operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<PlayAudioResult> playAudioWithResponse(String callId, String audioFileUri, boolean loop, String audioFileId, String operationContext) {
PlayAudioRequest playAudioRequest = new PlayAudioRequest().
setAudioFileUri(audioFileUri).setLoop(loop).setAudioFileId(audioFileId).setOperationContext(operationContext);
return callAsyncClient.playAudioWithResponse(callId, playAudioRequest).block();
}

/**
* Play audio in a call.
*
Expand All @@ -102,12 +87,18 @@ public PlayAudioResult playAudio(String callId, PlayAudioRequest playAudioReques
* Play audio in a call.
*
* @param callId The call id.
* @param playAudioRequest Play audio request.
* @param audioFileUri The media resource uri of the play audio request.
* @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 operationContext The value to identify context of the operation.
* @param context A {@link Context} representing the request context.
* @return the response payload for play audio operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<PlayAudioResult> playAudioWithResponse(String callId, PlayAudioRequest playAudioRequest) {
return callAsyncClient.playAudioWithResponse(callId, playAudioRequest).block();
public Response<PlayAudioResult> playAudioWithResponse(String callId, String audioFileUri, boolean loop, String audioFileId, String operationContext, Context context) {
PlayAudioRequest playAudioRequest = new PlayAudioRequest().
setAudioFileUri(audioFileUri).setLoop(loop).setAudioFileId(audioFileId).setOperationContext(operationContext);
return callAsyncClient.playAudioWithResponse(callId, playAudioRequest, context).block();
}

/**
Expand All @@ -125,11 +116,12 @@ public Void hangupCall(String callId) {
* Disconnect the current caller in a Group-call or end a p2p-call.
*
* @param callId Call id to to hang up.
* @param context A {@link Context} representing the request context.
* @return response for a successful HangupCall request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> hangupCallWithResponse(String callId) {
return callAsyncClient.hangupCallWithResponse(callId).block();
public Response<Void> hangupCallWithResponse(String callId, Context context) {
return callAsyncClient.hangupCallWithResponse(callId, context).block();
}

/**
Expand All @@ -147,11 +139,12 @@ public Void deleteCall(String callId) {
* Deletes a call.
*
* @param callId Call id to delete.
* @param context A {@link Context} representing the request context.
* @return response for a successful DeleteCall request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> deleteCallWithResponse(String callId) {
return callAsyncClient.deleteCallWithResponse(callId).block();
public Response<Void> deleteCallWithResponse(String callId, Context context) {
return callAsyncClient.deleteCallWithResponse(callId, context).block();
}

/**
Expand All @@ -171,11 +164,12 @@ public CancelMediaProcessingResult cancelMediaProcessing(String callId, CancelMe
*
* @param callId Call id to to cancel media processing.
* @param request Cancel Media Processing request.
* @param context A {@link Context} representing the request context.
* @return response for a successful CancelMediaProcessing request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<CancelMediaProcessingResult> cancelMediaProcessingWithResponse(String callId, CancelMediaProcessingRequest request) {
return callAsyncClient.cancelMediaProcessingWithResponse(callId, request).block();
public Response<CancelMediaProcessingResult> cancelMediaProcessingWithResponse(String callId, CancelMediaProcessingRequest request, Context context) {
return callAsyncClient.cancelMediaProcessingWithResponse(callId, request, context).block();
}

/**
Expand All @@ -195,11 +189,12 @@ public Void inviteParticipants(String callId, InviteParticipantsRequest request)
*
* @param callId Call id.
* @param request Invite participant request.
* @param context A {@link Context} representing the request context.
* @return response for a successful inviteParticipants request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> inviteParticipantsWithResponse(String callId, InviteParticipantsRequest request) {
return callAsyncClient.inviteParticipantsWithResponse(callId, request).block();
public Response<Void> inviteParticipantsWithResponse(String callId, InviteParticipantsRequest request, Context context) {
return callAsyncClient.inviteParticipantsWithResponse(callId, request, context).block();
}

/**
Expand All @@ -219,10 +214,11 @@ public Void removeParticipant(String callId, String participantId) {
*
* @param callId Call id.
* @param participantId Participant id.
* @param context A {@link Context} representing the request context.
* @return response for a successful removeParticipant request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> removeParticipantWithResponse(String callId, String participantId) {
return callAsyncClient.removeParticipantWithResponse(callId, participantId).block();
public Response<Void> removeParticipantWithResponse(String callId, String participantId, Context context) {
return callAsyncClient.removeParticipantWithResponse(callId, participantId, context).block();
}
}
Loading