Skip to content

Add MoveParticipants Functionality API and Event Handling Support #45653

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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 @@ -346,7 +346,7 @@ private TranscriptionOptionsInternal getTranscriptionOptionsInternal(Transcripti
.setLocale(transcriptionOptions.getLocale())
.setStartTranscription(transcriptionOptions.getStartTranscription())
.setEnableIntermediateResults(transcriptionOptions.isIntermediateResultsEnabled())
.setSpeechRecognitionModelEndpointId(transcriptionOptions.getSpeechRecognitionModelEndpointId());
.setSpeechModelEndpointId(transcriptionOptions.getSpeechRecognitionModelEndpointId());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import com.azure.communication.callautomation.models.events.MediaStreamingFailed;
import com.azure.communication.callautomation.models.events.MediaStreamingStarted;
import com.azure.communication.callautomation.models.events.MediaStreamingStopped;
import com.azure.communication.callautomation.models.events.MoveParticipantFailed;
import com.azure.communication.callautomation.models.events.MoveParticipantSucceeded;
import com.azure.communication.callautomation.models.events.ParticipantsUpdated;
import com.azure.communication.callautomation.models.events.PlayCanceled;
import com.azure.communication.callautomation.models.events.PlayCompleted;
Expand Down Expand Up @@ -161,6 +163,10 @@ private static CallAutomationEventBase parseSingleCloudEvent(String data, String
ret = RemoveParticipantFailed.fromJson(jsonReader);
} else if (Objects.equals(eventType, "Microsoft.Communication.RemoveParticipantSucceeded")) {
ret = RemoveParticipantSucceeded.fromJson(jsonReader);
} else if (Objects.equals(eventType, "Microsoft.Communication.MoveParticipantFailed")) {
ret = MoveParticipantFailed.fromJson(jsonReader);
} else if (Objects.equals(eventType, "Microsoft.Communication.MoveParticipantSucceeded")) {
ret = MoveParticipantSucceeded.fromJson(jsonReader);
} else if (Objects.equals(eventType, "Microsoft.Communication.ContinuousDtmfRecognitionToneReceived")) {
ret = ContinuousDtmfRecognitionToneReceived.fromJson(jsonReader);
} else if (Objects.equals(eventType, "Microsoft.Communication.ContinuousDtmfRecognitionToneFailed")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import com.azure.communication.callautomation.models.AddParticipantResult;
import com.azure.communication.callautomation.models.CallConnectionProperties;
import com.azure.communication.callautomation.models.CallInvite;
import com.azure.communication.callautomation.models.MoveParticipantsOptions;
import com.azure.communication.callautomation.models.MoveParticipantsResult;
import com.azure.communication.callautomation.models.MuteParticipantOptions;
import com.azure.communication.callautomation.models.MuteParticipantResult;
import com.azure.communication.callautomation.models.RemoveParticipantOptions;
Expand All @@ -25,6 +27,7 @@
import com.azure.core.http.rest.Response;
import com.azure.core.util.Context;
import com.azure.core.exception.HttpResponseException;
import java.util.List;

/**
* CallConnection for mid-call actions
Expand Down Expand Up @@ -226,6 +229,48 @@ public RemoveParticipantResult removeParticipant(CommunicationIdentifier partici
return callConnectionAsync.removeParticipantWithResponseInternal(removeParticipantOptions, context).block();
}

/**
* Move participants from one call to another.
*
* @param targetParticipants participants to move.
* @param fromCall The CallConnectionId for the call you want to move the participant from.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return Result of moving participants to the call.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public MoveParticipantsResult moveParticipants(List<CommunicationIdentifier> targetParticipants, String fromCall) {
return callConnectionAsync.moveParticipants(targetParticipants, fromCall).block();
}

/**
* Move participants from one call to another.
*
* @param moveParticipantsOptions Options bag for moveParticipants
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return Result of moving participants to the call.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public MoveParticipantsResult moveParticipants(MoveParticipantsOptions moveParticipantsOptions) {
return callConnectionAsync.moveParticipants(moveParticipantsOptions).block();
}

/**
* Move participants from one call to another.
*
* @param moveParticipantsOptions Options bag for moveParticipants
* @param context A {@link Context} representing the request context.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return Response with result of moving participants to the call.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<MoveParticipantsResult>
moveParticipantsWithResponse(MoveParticipantsOptions moveParticipantsOptions, Context context) {
return callConnectionAsync.moveParticipantsWithResponseInternal(moveParticipantsOptions, context).block();
}

/**
* Mutes a participant in the call.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.azure.communication.callautomation.implementation.accesshelpers.AddParticipantResponseConstructorProxy;
import com.azure.communication.callautomation.implementation.accesshelpers.CallConnectionPropertiesConstructorProxy;
import com.azure.communication.callautomation.implementation.accesshelpers.CancelAddParticipantResponseConstructorProxy;
import com.azure.communication.callautomation.implementation.accesshelpers.MoveParticipantsResponseConstructorProxy;
import com.azure.communication.callautomation.implementation.accesshelpers.MuteParticipantsResponseConstructorProxy;
import com.azure.communication.callautomation.implementation.accesshelpers.RemoveParticipantResponseConstructorProxy;
import com.azure.communication.callautomation.implementation.accesshelpers.TransferCallResponseConstructorProxy;
Expand All @@ -19,6 +20,7 @@
import com.azure.communication.callautomation.implementation.models.AddParticipantRequestInternal;
import com.azure.communication.callautomation.implementation.models.CancelAddParticipantRequest;
import com.azure.communication.callautomation.implementation.models.CustomCallingContext;
import com.azure.communication.callautomation.implementation.models.MoveParticipantsRequest;
import com.azure.communication.callautomation.implementation.models.MuteParticipantsRequestInternal;
import com.azure.communication.callautomation.implementation.models.RemoveParticipantRequestInternal;
import com.azure.communication.callautomation.implementation.models.TransferToParticipantRequestInternal;
Expand All @@ -30,6 +32,8 @@
import com.azure.communication.callautomation.models.CallParticipant;
import com.azure.communication.callautomation.models.CancelAddParticipantOperationOptions;
import com.azure.communication.callautomation.models.CancelAddParticipantOperationResult;
import com.azure.communication.callautomation.models.MoveParticipantsOptions;
import com.azure.communication.callautomation.models.MoveParticipantsResult;
import com.azure.communication.callautomation.models.MuteParticipantOptions;
import com.azure.communication.callautomation.models.MuteParticipantResult;
import com.azure.communication.callautomation.models.RemoveParticipantOptions;
Expand Down Expand Up @@ -59,6 +63,8 @@
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import static com.azure.core.util.FluxUtil.monoError;
import static com.azure.core.util.FluxUtil.withContext;
Expand Down Expand Up @@ -441,6 +447,74 @@ public Mono<RemoveParticipantResult> removeParticipant(CommunicationIdentifier p
}
}

/**
* Move participants from one call to another.
*
* @param targetParticipants participants to move.
* @param fromCall The CallConnectionId for the call you want to move the participant from.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return Result of moving participants to the call.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<MoveParticipantsResult> moveParticipants(List<CommunicationIdentifier> targetParticipants,
String fromCall) {
return moveParticipants(new MoveParticipantsOptions(targetParticipants, fromCall));
}

/**
* Move participants from one call to another.
*
* @param moveParticipantsOptions Options bag for moveParticipants
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return Result of moving participants to the call.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<MoveParticipantsResult> moveParticipants(MoveParticipantsOptions moveParticipantsOptions) {
return moveParticipantsWithResponse(moveParticipantsOptions).flatMap(FluxUtil::toMono);
}

/**
* Move participants from one call to another.
*
* @param moveParticipantsOptions Options bag for moveParticipants
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return Response with result of moving participants to the call.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<MoveParticipantsResult>>
moveParticipantsWithResponse(MoveParticipantsOptions moveParticipantsOptions) {
return withContext(context -> moveParticipantsWithResponseInternal(moveParticipantsOptions, context));
}

Mono<Response<MoveParticipantsResult>>
moveParticipantsWithResponseInternal(MoveParticipantsOptions moveParticipantsOptions, Context context) {
try {
context = context == null ? Context.NONE : context;

MoveParticipantsRequest request = new MoveParticipantsRequest()
.setTargetParticipants(moveParticipantsOptions.getTargetParticipants()
.stream()
.map(CommunicationIdentifierConverter::convert)
.collect(Collectors.toList()))
.setFromCall(moveParticipantsOptions.getFromCall())
.setOperationContext(moveParticipantsOptions.getOperationContext())
.setOperationCallbackUri(moveParticipantsOptions.getOperationCallbackUrl());

return callConnectionInternal.moveParticipantsWithResponseAsync(callConnectionId, request, context)
.map(response -> {
MoveParticipantsResult result
= MoveParticipantsResponseConstructorProxy.create(response.getValue());
result.setEventProcessor(eventProcessor, callConnectionId, result.getOperationContext());
return new SimpleResponse<>(response, result);
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
}

/**
* Mutes a participant in the call.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ Mono<Response<Void>> startTranscriptionWithResponseInternal(StartTranscriptionOp
if (options != null) {
request.setLocale(options.getLocale());
request.setOperationContext(options.getOperationContext());
request.setSpeechRecognitionModelEndpointId(options.getSpeechRecognitionModelEndpointId());
request.setSpeechModelEndpointId(options.getSpeechRecognitionModelEndpointId());
}
return contentsInternal.startTranscriptionWithResponseAsync(callConnectionId, request, context);
} catch (RuntimeException ex) {
Expand Down Expand Up @@ -936,7 +936,7 @@ Mono<Response<Void>> updateTranscriptionWithResponseInternal(String locale, Stri
context = context == null ? Context.NONE : context;
UpdateTranscriptionRequestInternal request = new UpdateTranscriptionRequestInternal();
request.setLocale(locale);
request.setSpeechRecognitionModelEndpointId(speechRecognitionModelEndpointId);
request.setSpeechModelEndpointId(speechRecognitionModelEndpointId);
request.setOperationContext(operationContext);
return contentsInternal.updateTranscriptionWithResponseAsync(callConnectionId, request, context);
} catch (RuntimeException ex) {
Expand Down
Loading
Loading