|
9 | 9 | import com.azure.communication.callautomation.implementation.accesshelpers.AddParticipantResponseConstructorProxy; |
10 | 10 | import com.azure.communication.callautomation.implementation.accesshelpers.CallConnectionPropertiesConstructorProxy; |
11 | 11 | import com.azure.communication.callautomation.implementation.accesshelpers.CancelAddParticipantResponseConstructorProxy; |
| 12 | +import com.azure.communication.callautomation.implementation.accesshelpers.MoveParticipantsResponseConstructorProxy; |
12 | 13 | import com.azure.communication.callautomation.implementation.accesshelpers.MuteParticipantsResponseConstructorProxy; |
13 | 14 | import com.azure.communication.callautomation.implementation.accesshelpers.RemoveParticipantResponseConstructorProxy; |
14 | 15 | import com.azure.communication.callautomation.implementation.accesshelpers.TransferCallResponseConstructorProxy; |
|
19 | 20 | import com.azure.communication.callautomation.implementation.models.AddParticipantRequestInternal; |
20 | 21 | import com.azure.communication.callautomation.implementation.models.CancelAddParticipantRequest; |
21 | 22 | import com.azure.communication.callautomation.implementation.models.CustomCallingContext; |
| 23 | +import com.azure.communication.callautomation.implementation.models.MoveParticipantsRequest; |
22 | 24 | import com.azure.communication.callautomation.implementation.models.MuteParticipantsRequestInternal; |
23 | 25 | import com.azure.communication.callautomation.implementation.models.RemoveParticipantRequestInternal; |
24 | 26 | import com.azure.communication.callautomation.implementation.models.TransferToParticipantRequestInternal; |
|
30 | 32 | import com.azure.communication.callautomation.models.CallParticipant; |
31 | 33 | import com.azure.communication.callautomation.models.CancelAddParticipantOperationOptions; |
32 | 34 | import com.azure.communication.callautomation.models.CancelAddParticipantOperationResult; |
| 35 | +import com.azure.communication.callautomation.models.MoveParticipantsOptions; |
| 36 | +import com.azure.communication.callautomation.models.MoveParticipantsResult; |
33 | 37 | import com.azure.communication.callautomation.models.MuteParticipantOptions; |
34 | 38 | import com.azure.communication.callautomation.models.MuteParticipantResult; |
35 | 39 | import com.azure.communication.callautomation.models.RemoveParticipantOptions; |
|
59 | 63 | import java.net.URLEncoder; |
60 | 64 | import java.nio.charset.StandardCharsets; |
61 | 65 | import java.util.Collections; |
| 66 | +import java.util.List; |
| 67 | +import java.util.stream.Collectors; |
62 | 68 |
|
63 | 69 | import static com.azure.core.util.FluxUtil.monoError; |
64 | 70 | import static com.azure.core.util.FluxUtil.withContext; |
@@ -441,6 +447,74 @@ public Mono<RemoveParticipantResult> removeParticipant(CommunicationIdentifier p |
441 | 447 | } |
442 | 448 | } |
443 | 449 |
|
| 450 | + /** |
| 451 | + * Move participants from one call to another. |
| 452 | + * |
| 453 | + * @param targetParticipants participants to move. |
| 454 | + * @param fromCall The CallConnectionId for the call you want to move the participant from. |
| 455 | + * @throws HttpResponseException thrown if the request is rejected by server. |
| 456 | + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. |
| 457 | + * @return Result of moving participants to the call. |
| 458 | + */ |
| 459 | + @ServiceMethod(returns = ReturnType.SINGLE) |
| 460 | + public Mono<MoveParticipantsResult> moveParticipants(List<CommunicationIdentifier> targetParticipants, |
| 461 | + String fromCall) { |
| 462 | + return moveParticipants(new MoveParticipantsOptions(targetParticipants, fromCall)); |
| 463 | + } |
| 464 | + |
| 465 | + /** |
| 466 | + * Move participants from one call to another. |
| 467 | + * |
| 468 | + * @param moveParticipantsOptions Options bag for moveParticipants |
| 469 | + * @throws HttpResponseException thrown if the request is rejected by server. |
| 470 | + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. |
| 471 | + * @return Result of moving participants to the call. |
| 472 | + */ |
| 473 | + @ServiceMethod(returns = ReturnType.SINGLE) |
| 474 | + public Mono<MoveParticipantsResult> moveParticipants(MoveParticipantsOptions moveParticipantsOptions) { |
| 475 | + return moveParticipantsWithResponse(moveParticipantsOptions).flatMap(FluxUtil::toMono); |
| 476 | + } |
| 477 | + |
| 478 | + /** |
| 479 | + * Move participants from one call to another. |
| 480 | + * |
| 481 | + * @param moveParticipantsOptions Options bag for moveParticipants |
| 482 | + * @throws HttpResponseException thrown if the request is rejected by server. |
| 483 | + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. |
| 484 | + * @return Response with result of moving participants to the call. |
| 485 | + */ |
| 486 | + @ServiceMethod(returns = ReturnType.SINGLE) |
| 487 | + public Mono<Response<MoveParticipantsResult>> |
| 488 | + moveParticipantsWithResponse(MoveParticipantsOptions moveParticipantsOptions) { |
| 489 | + return withContext(context -> moveParticipantsWithResponseInternal(moveParticipantsOptions, context)); |
| 490 | + } |
| 491 | + |
| 492 | + Mono<Response<MoveParticipantsResult>> |
| 493 | + moveParticipantsWithResponseInternal(MoveParticipantsOptions moveParticipantsOptions, Context context) { |
| 494 | + try { |
| 495 | + context = context == null ? Context.NONE : context; |
| 496 | + |
| 497 | + MoveParticipantsRequest request = new MoveParticipantsRequest() |
| 498 | + .setTargetParticipants(moveParticipantsOptions.getTargetParticipants() |
| 499 | + .stream() |
| 500 | + .map(CommunicationIdentifierConverter::convert) |
| 501 | + .collect(Collectors.toList())) |
| 502 | + .setFromCall(moveParticipantsOptions.getFromCall()) |
| 503 | + .setOperationContext(moveParticipantsOptions.getOperationContext()) |
| 504 | + .setOperationCallbackUri(moveParticipantsOptions.getOperationCallbackUrl()); |
| 505 | + |
| 506 | + return callConnectionInternal.moveParticipantsWithResponseAsync(callConnectionId, request, context) |
| 507 | + .map(response -> { |
| 508 | + MoveParticipantsResult result |
| 509 | + = MoveParticipantsResponseConstructorProxy.create(response.getValue()); |
| 510 | + result.setEventProcessor(eventProcessor, callConnectionId, result.getOperationContext()); |
| 511 | + return new SimpleResponse<>(response, result); |
| 512 | + }); |
| 513 | + } catch (RuntimeException ex) { |
| 514 | + return monoError(logger, ex); |
| 515 | + } |
| 516 | + } |
| 517 | + |
444 | 518 | /** |
445 | 519 | * Mutes a participant in the call. |
446 | 520 | * |
|
0 commit comments