Skip to content
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 @@ -8,19 +8,18 @@
import com.azure.communication.callingserver.implementation.converters.CommunicationIdentifierConverter;
import com.azure.communication.callingserver.implementation.converters.InviteParticipantsRequestConverter;
import com.azure.communication.callingserver.implementation.converters.ResultInfoConverter;
import com.azure.communication.callingserver.implementation.models.CancelMediaOperationsResponse;
import com.azure.communication.callingserver.implementation.models.CallModalityModel;
import com.azure.communication.callingserver.implementation.models.CallModality;
import com.azure.communication.callingserver.implementation.models.CancelAllMediaOperationsRequest;
import com.azure.communication.callingserver.implementation.models.CancelAllMediaOperationsResponse;
import com.azure.communication.callingserver.implementation.models.CreateCallRequestInternal;
import com.azure.communication.callingserver.implementation.models.CreateCallResponse;
import com.azure.communication.callingserver.implementation.models.EventSubscriptionTypeModel;
import com.azure.communication.callingserver.implementation.models.EventSubscriptionType;
import com.azure.communication.callingserver.implementation.models.PhoneNumberIdentifierModel;
import com.azure.communication.callingserver.implementation.models.PlayAudioRequestInternal;
import com.azure.communication.callingserver.implementation.models.PlayAudioResponse;
import com.azure.communication.callingserver.models.CallModality;
import com.azure.communication.callingserver.models.CancelMediaOperationsResult;
import com.azure.communication.callingserver.models.CreateCallOptions;
import com.azure.communication.callingserver.models.CreateCallResult;
import com.azure.communication.callingserver.models.EventSubscriptionType;
import com.azure.communication.callingserver.models.InviteParticipantsRequest;
import com.azure.communication.callingserver.models.OperationStatus;
import com.azure.communication.callingserver.models.PlayAudioRequest;
Expand Down Expand Up @@ -305,13 +304,13 @@ Mono<Response<Void>> deleteCallWithResponse(String callId, Context context) {
* @return the response payload of the cancel media operations.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<CancelMediaOperationsResult> cancelMediaOperations(String callId) {
public Mono<CancelMediaOperationsResult> cancelAllMediaOperations(String callId, CancelAllMediaOperationsRequest request) {
try {
Objects.requireNonNull(callId, "'callId' cannot be null.");

return this.callClient.cancelMediaOperationsAsync(callId)
.flatMap((CancelMediaOperationsResponse response) -> {
CancelMediaOperationsResult cancelMediaOperationsResult = convertCancelMediaOperationsResponse(
return this.callClient.cancelAllMediaOperationsAsync(callId, request)
.flatMap((CancelAllMediaOperationsResponse response) -> {
CancelMediaOperationsResult cancelMediaOperationsResult = convertCancelAllMediaOperationsResponse(
response);
return Mono.just(cancelMediaOperationsResult);
});
Expand All @@ -327,22 +326,22 @@ public Mono<CancelMediaOperationsResult> cancelMediaOperations(String callId) {
* @return the response payload of the cancel media operations.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<CancelMediaOperationsResult>> cancelMediaOperationsWithResponse(String callId) {
return cancelMediaOperationsWithResponse(callId, null);
public Mono<Response<CancelMediaOperationsResult>> cancelAllMediaOperationsWithResponse(String callId, CancelAllMediaOperationsRequest request) {
return cancelAllMediaOperationsWithResponse(callId, request, null);
}

Mono<Response<CancelMediaOperationsResult>> cancelMediaOperationsWithResponse(String callId, Context context) {
Mono<Response<CancelMediaOperationsResult>> cancelAllMediaOperationsWithResponse(String callId, CancelAllMediaOperationsRequest request, Context context) {
try {
Objects.requireNonNull(callId, "'callId' cannot be null.");
return withContext(contextValue -> {
if (context != null) {
contextValue = context;
}
return this.callClient
.cancelMediaOperationsWithResponseAsync(callId, context)
.cancelAllMediaOperationsWithResponseAsync(callId, request, context)
.flatMap((
Response<CancelMediaOperationsResponse> response) -> {
CancelMediaOperationsResult cancelMediaOperationsResult = convertCancelMediaOperationsResponse(
Response<CancelAllMediaOperationsResponse> response) -> {
CancelMediaOperationsResult cancelMediaOperationsResult = convertCancelAllMediaOperationsResponse(
response.getValue());
return Mono.just(new SimpleResponse<>(response, cancelMediaOperationsResult));
});
Expand Down Expand Up @@ -457,13 +456,13 @@ private CreateCallRequestInternal createCreateCallRequest(CommunicationIdentifie
List<CommunicationIdentifier> targetsList = new ArrayList<>();
targets.forEach(targetsList::add);

List<CallModalityModel> requestedModalities = new ArrayList<>();
List<CallModality> requestedModalities = new ArrayList<CallModality>();
for (CallModality modality : createCallOptions.getRequestedModalities()) {
requestedModalities.add(CallModalityModel.fromString(modality.toString()));
requestedModalities.add(CallModality.fromString(modality.toString()));
}
List<EventSubscriptionTypeModel> requestedCallEvents = new ArrayList<>();
List<EventSubscriptionType> requestedCallEvents = new ArrayList<>();
for (EventSubscriptionType requestedCallEvent : createCallOptions.getRequestedCallEvents()) {
requestedCallEvents.add(EventSubscriptionTypeModel.fromString(requestedCallEvent.toString()));
requestedCallEvents.add(EventSubscriptionType.fromString(requestedCallEvent.toString()));
}

PhoneNumberIdentifierModel sourceAlternateIdentity = createCallOptions.getAlternateCallerId() == null
Expand All @@ -473,8 +472,9 @@ private CreateCallRequestInternal createCreateCallRequest(CommunicationIdentifie
request.setSource(CommunicationIdentifierConverter.convert(source))
.setTargets(targetsList.stream().map(target -> CommunicationIdentifierConverter.convert(target))
.collect(Collectors.toList()))
.setCallbackUri(createCallOptions.getCallbackUri()).setRequestedModalities(requestedModalities)
.setRequestedCallEvents(requestedCallEvents).setSourceAlternateIdentity(sourceAlternateIdentity);
.setCallbackUri(createCallOptions.getCallbackUri());
request.setRequestedModalities(requestedModalities);
request.setRequestedCallEvents(requestedCallEvents).setSourceAlternateIdentity(sourceAlternateIdentity);

return request;
}
Expand All @@ -486,7 +486,7 @@ private PlayAudioResult convertPlayAudioResponse(PlayAudioResponse response) {
.setResultInfo(ResultInfoConverter.convert(response.getResultInfo()));
}

private CancelMediaOperationsResult convertCancelMediaOperationsResponse(CancelMediaOperationsResponse response) {
private CancelMediaOperationsResult convertCancelAllMediaOperationsResponse(CancelAllMediaOperationsResponse response) {
return new CancelMediaOperationsResult().setId(response.getId())
.setStatus(OperationStatus.fromString(response.getStatus().toString()))
.setOperationContext(response.getOperationContext())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.azure.communication.callingserver.models.InviteParticipantsRequest;
import com.azure.communication.callingserver.models.PlayAudioRequest;
import com.azure.communication.callingserver.models.PlayAudioResult;
import com.azure.communication.callingserver.implementation.models.CancelAllMediaOperationsRequest;
import com.azure.communication.callingserver.models.CancelMediaOperationsResult;
import com.azure.communication.common.CommunicationIdentifier;
import com.azure.core.annotation.ReturnType;
Expand Down Expand Up @@ -153,8 +154,8 @@ public Response<Void> deleteCallWithResponse(String callId, Context context) {
* @return response for a successful CancelMediaOperations request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public CancelMediaOperationsResult cancelMediaOperations(String callId) {
return callAsyncClient.cancelMediaOperations(callId).block();
public CancelMediaOperationsResult cancelAllMediaOperations(String callId, CancelAllMediaOperationsRequest request) {
return callAsyncClient.cancelAllMediaOperations(callId, request).block();
}

/**
Expand All @@ -165,8 +166,8 @@ public CancelMediaOperationsResult cancelMediaOperations(String callId) {
* @return response for a successful CancelMediaOperations request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<CancelMediaOperationsResult> cancelMediaOperationsWithResponse(String callId, Context context) {
return callAsyncClient.cancelMediaOperationsWithResponse(callId, context).block();
public Response<CancelMediaOperationsResult> cancelAllMediaOperationsWithResponse(String callId, CancelAllMediaOperationsRequest request, Context context) {
return callAsyncClient.cancelAllMediaOperationsWithResponse(callId, request, context).block();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

package com.azure.communication.callingserver.implementation;

import com.azure.communication.callingserver.implementation.models.CancelMediaOperationsResponse;
import com.azure.communication.callingserver.implementation.models.CancelAllMediaOperationsRequest;
import com.azure.communication.callingserver.implementation.models.CancelAllMediaOperationsResponse;
import com.azure.communication.callingserver.implementation.models.CommunicationErrorException;
import com.azure.communication.callingserver.implementation.models.CreateCallRequestInternal;
import com.azure.communication.callingserver.implementation.models.CreateCallResponse;
Expand Down Expand Up @@ -108,16 +109,17 @@ Mono<Response<PlayAudioResponse>> playAudio(
@HeaderParam("Accept") String accept,
Context context);

@Post("/calling/calls/{callId}/CancelMediaOperations")
@Post("/calling/calls/{callId}/CancelMediaProcessing")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(
value = CommunicationErrorException.class,
code = {400, 401, 500})
@UnexpectedResponseExceptionType(CommunicationErrorException.class)
Mono<Response<CancelMediaOperationsResponse>> cancelMediaOperations(
Mono<Response<CancelAllMediaOperationsResponse>> cancelAllMediaOperations(
@HostParam("endpoint") String endpoint,
@PathParam("callId") String callId,
@QueryParam("api-version") String apiVersion,
@BodyParam("application/json") CancelAllMediaOperationsRequest request,
@HeaderParam("Accept") String accept,
Context context);

Expand Down Expand Up @@ -592,25 +594,33 @@ public Response<PlayAudioResponse> playAudioWithResponse(
* Cancel Media Processing.
*
* @param callId The call id.
* @param request The cancel media processing request.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws CommunicationErrorException thrown if the request is rejected by server.
* @throws CommunicationErrorException thrown if the request is rejected by server on status code 400, 401, 500.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the response payload of the cancel media processing operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<CancelMediaOperationsResponse>> cancelMediaOperationsWithResponseAsync(String callId) {
public Mono<Response<CancelAllMediaOperationsResponse>> cancelAllMediaOperationsWithResponseAsync(
String callId, CancelAllMediaOperationsRequest request) {
final String accept = "application/json";
return FluxUtil.withContext(
context ->
service.cancelMediaOperations(
this.client.getEndpoint(), callId, this.client.getApiVersion(), accept, context));
service.cancelAllMediaOperations(
this.client.getEndpoint(),
callId,
this.client.getApiVersion(),
request,
accept,
context));
}

/**
* Cancel Media Processing.
*
* @param callId The call id.
* @param request The cancel media processing request.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws CommunicationErrorException thrown if the request is rejected by server.
Expand All @@ -619,28 +629,30 @@ public Mono<Response<CancelMediaOperationsResponse>> cancelMediaOperationsWithRe
* @return the response payload of the cancel media processing operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<CancelMediaOperationsResponse>> cancelMediaOperationsWithResponseAsync(
String callId, Context context) {
public Mono<Response<CancelAllMediaOperationsResponse>> cancelAllMediaOperationsWithResponseAsync(
String callId, CancelAllMediaOperationsRequest request, Context context) {
final String accept = "application/json";
return service.cancelMediaOperations(
this.client.getEndpoint(), callId, this.client.getApiVersion(), accept, context);
return service.cancelAllMediaOperations(
this.client.getEndpoint(), callId, this.client.getApiVersion(), request, accept, context);
}

/**
* Cancel Media Processing.
*
* @param callId The call id.
* @param request The cancel media processing request.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws CommunicationErrorException thrown if the request is rejected by server.
* @throws CommunicationErrorException thrown if the request is rejected by server on status code 400, 401, 500.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the response payload of the cancel media processing operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<CancelMediaOperationsResponse> cancelMediaOperationsAsync(String callId) {
return cancelMediaOperationsWithResponseAsync(callId)
public Mono<CancelAllMediaOperationsResponse> cancelAllMediaOperationsAsync(
String callId, CancelAllMediaOperationsRequest request) {
return cancelAllMediaOperationsWithResponseAsync(callId, request)
.flatMap(
(Response<CancelMediaOperationsResponse> res) -> {
(Response<CancelAllMediaOperationsResponse> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
Expand All @@ -653,6 +665,7 @@ public Mono<CancelMediaOperationsResponse> cancelMediaOperationsAsync(String cal
* Cancel Media Processing.
*
* @param callId The call id.
* @param request The cancel media processing request.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws CommunicationErrorException thrown if the request is rejected by server.
Expand All @@ -661,10 +674,11 @@ public Mono<CancelMediaOperationsResponse> cancelMediaOperationsAsync(String cal
* @return the response payload of the cancel media processing operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<CancelMediaOperationsResponse> cancelMediaOperationsAsync(String callId, Context context) {
return cancelMediaOperationsWithResponseAsync(callId, context)
public Mono<CancelAllMediaOperationsResponse> cancelAllMediaOperationsAsync(
String callId, CancelAllMediaOperationsRequest request, Context context) {
return cancelAllMediaOperationsWithResponseAsync(callId, request, context)
.flatMap(
(Response<CancelMediaOperationsResponse> res) -> {
(Response<CancelAllMediaOperationsResponse> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
Expand All @@ -677,21 +691,24 @@ public Mono<CancelMediaOperationsResponse> cancelMediaOperationsAsync(String cal
* Cancel Media Processing.
*
* @param callId The call id.
* @param request The cancel media processing request.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws CommunicationErrorException thrown if the request is rejected by server.
* @throws CommunicationErrorException thrown if the request is rejected by server on status code 400, 401, 500.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the response payload of the cancel media processing operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public CancelMediaOperationsResponse cancelMediaOperations(String callId) {
return cancelMediaOperationsAsync(callId).block();
public CancelAllMediaOperationsResponse cancelAllMediaOperations(
String callId, CancelAllMediaOperationsRequest request) {
return cancelAllMediaOperationsAsync(callId, request).block();
}

/**
* Cancel Media Processing.
*
* @param callId The call id.
* @param request The cancel media processing request.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws CommunicationErrorException thrown if the request is rejected by server.
Expand All @@ -700,8 +717,9 @@ public CancelMediaOperationsResponse cancelMediaOperations(String callId) {
* @return the response payload of the cancel media processing operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<CancelMediaOperationsResponse> cancelMediaOperationsWithResponse(String callId, Context context) {
return cancelMediaOperationsWithResponseAsync(callId, context).block();
public Response<CancelAllMediaOperationsResponse> cancelAllMediaOperationsWithResponse(
String callId, CancelAllMediaOperationsRequest request, Context context) {
return cancelAllMediaOperationsWithResponseAsync(callId, request, context).block();
}

/**
Expand Down
Loading