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

Update SDK with latest swagger schema. #25560

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 @@ -107,7 +107,7 @@ CallConnection callConnection = callingServerClient.createCallConnection(source,
```java readme-sample-addParticipant
CommunicationIdentifier thirdCallee = new CommunicationUserIdentifier("<acs-user-identity-3>");
String callbackUri = "<callback-uri-for-notification>";
callConnection.addParticipant(thirdCallee, "ACS User 3", "<string-for-tracing-responses>", URI.create(callbackUri));
callConnection.addParticipant(thirdCallee, "ACS User 3", "<string-for-tracing-responses>");
```

#### Hangup a Call:
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ public Response<Void> cancelAllMediaOperationsWithResponse(
* @param alternateCallerId Phone number to use when adding a phone number participant.
* @param operationContext Value to identify context of the operation. This is used to co-relate other
* communications related to this operation
* @param callbackUri callBackUri to get notifications.
* @throws CallingServerErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return Response for a successful add participant request.
Expand All @@ -170,9 +169,8 @@ public Response<Void> cancelAllMediaOperationsWithResponse(
public AddParticipantResult addParticipant(
CommunicationIdentifier participant,
String alternateCallerId,
String operationContext,
URI callbackUri) {
return callConnectionAsync.addParticipant(participant, alternateCallerId, operationContext, callbackUri).block();
String operationContext) {
return callConnectionAsync.addParticipant(participant, alternateCallerId, operationContext).block();
}

/**
Expand All @@ -182,7 +180,6 @@ public AddParticipantResult addParticipant(
* @param alternateCallerId Phone number to use when adding a phone number participant.
* @param operationContext Value to identify context of the operation. This is used to co-relate other
* communications related to this operation
* @param callbackUri callBackUri to get notifications.
* @param context {@link Context} representing the request context.
* @throws CallingServerErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
Expand All @@ -193,10 +190,9 @@ public Response<AddParticipantResult> addParticipantWithResponse(
CommunicationIdentifier participant,
String alternateCallerId,
String operationContext,
URI callbackUri,
Context context) {
return callConnectionAsync
.addParticipantWithResponse(participant, alternateCallerId, operationContext, callbackUri, context).block();
.addParticipantWithResponse(participant, alternateCallerId, operationContext, context).block();
}

/**
Expand Down Expand Up @@ -315,7 +311,7 @@ public Response<List<CallParticipant>> getParticipantsWithResponse(Context conte
* @return Response for a successful get participant request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public List<CallParticipant> getParticipant(CommunicationIdentifier participant) {
public CallParticipant getParticipant(CommunicationIdentifier participant) {
return callConnectionAsync.getParticipant(participant).block();
}

Expand All @@ -329,7 +325,7 @@ public List<CallParticipant> getParticipant(CommunicationIdentifier participant)
* @return Response for a successful get participant request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<List<CallParticipant>> getParticipantWithResponse(CommunicationIdentifier participant, Context context) {
public Response<CallParticipant> getParticipantWithResponse(CommunicationIdentifier participant, Context context) {
return callConnectionAsync.getParticipantWithResponse(participant, context).block();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import java.net.URI;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import com.azure.communication.callingserver.implementation.CallConnectionsImpl;
Expand Down Expand Up @@ -97,14 +96,12 @@ public Mono<PlayAudioResult> playAudio(URI audioFileUri, PlayAudioOptions playAu

Mono<PlayAudioResult> playAudioInternal(URI audioFileUri, PlayAudioOptions playAudioOptions) {
try {
Objects.requireNonNull(audioFileUri, "'audioFileUri' cannot be null.");
PlayAudioRequest request = new PlayAudioRequest().setAudioFileUri(audioFileUri.toString());
if (playAudioOptions != null) {
request
.setLoop(playAudioOptions.isLoop())
.setOperationContext(playAudioOptions.getOperationContext())
.setAudioFileId(playAudioOptions.getAudioFileId())
.setCallbackUri(playAudioOptions.getCallbackUri().toString());
.setAudioFileId(playAudioOptions.getAudioFileId());
}
return playAudioInternal(request);
} catch (RuntimeException ex) {
Expand Down Expand Up @@ -145,14 +142,12 @@ Mono<Response<PlayAudioResult>> playAudioWithResponseInternal(
PlayAudioOptions playAudioOptions,
Context context) {
try {
Objects.requireNonNull(audioFileUri, "'audioFileUri' cannot be null.");
PlayAudioRequest request = new PlayAudioRequest().setAudioFileUri(audioFileUri.toString());
if (playAudioOptions != null) {
request
.setLoop(playAudioOptions.isLoop())
.setOperationContext(playAudioOptions.getOperationContext())
.setAudioFileId(playAudioOptions.getAudioFileId())
.setCallbackUri(playAudioOptions.getCallbackUri().toString());
.setAudioFileId(playAudioOptions.getAudioFileId());
}
return playAudioWithResponseInternal(request, context);
} catch (RuntimeException ex) {
Expand Down Expand Up @@ -312,7 +307,6 @@ Mono<Response<Void>> cancelAllMediaOperationsWithResponse(
* @param alternateCallerId The phone number to use when adding a phone number participant.
* @param operationContext The value to identify context of the operation. This is used to co-relate other
* communications related to this operation
* @param callbackUri callBackUri to get notifications.
* @throws CallingServerErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return Response for a successful add participant request.
Expand All @@ -321,13 +315,12 @@ Mono<Response<Void>> cancelAllMediaOperationsWithResponse(
public Mono<AddParticipantResult> addParticipant(
CommunicationIdentifier participant,
String alternateCallerId,
String operationContext,
URI callbackUri) {
String operationContext) {
try {
AddParticipantRequest request = getAddParticipantRequest(participant,
alternateCallerId,
operationContext,
callbackUri);
operationContext
);
return callConnectionInternal.addParticipantAsync(callConnectionId, request)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.flatMap(result -> Mono.just(new AddParticipantResult(result.getParticipantId())));
Expand All @@ -343,7 +336,6 @@ public Mono<AddParticipantResult> addParticipant(
* @param alternateCallerId The phone number to use when adding a phone number participant.
* @param operationContext The value to identify context of the operation. This is used to co-relate other
* communications related to this operation
* @param callbackUri callBackUri to get notifications.
* @throws CallingServerErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return Response for a successful add participant request.
Expand All @@ -352,22 +344,19 @@ public Mono<AddParticipantResult> addParticipant(
public Mono<Response<AddParticipantResult>> addParticipantWithResponse(
CommunicationIdentifier participant,
String alternateCallerId,
String operationContext,
URI callbackUri) {
return addParticipantWithResponse(participant, alternateCallerId, operationContext, callbackUri, Context.NONE);
String operationContext) {
return addParticipantWithResponse(participant, alternateCallerId, operationContext, Context.NONE);
}

Mono<Response<AddParticipantResult>> addParticipantWithResponse(
CommunicationIdentifier participant,
String alternateCallerId,
String operationContext,
URI callbackUri,
Context context) {
try {
AddParticipantRequest request = getAddParticipantRequest(participant,
alternateCallerId,
operationContext,
callbackUri);
operationContext);
return withContext(contextValue -> {
contextValue = context == null ? contextValue : context;
return callConnectionInternal
Expand Down Expand Up @@ -585,13 +574,12 @@ Mono<Response<List<CallParticipant>>> getParticipantsWithResponse(Context contex
* @return Response for a successful get participant request.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public Mono<List<CallParticipant>> getParticipant(CommunicationIdentifier participant) {
public Mono<CallParticipant> getParticipant(CommunicationIdentifier participant) {
try {
GetParticipantRequest request = new GetParticipantRequest().setIdentifier(CommunicationIdentifierConverter.convert(participant));
return callConnectionInternal.getParticipantAsync(callConnectionId, request)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.flatMap(result -> Mono.just(
result.stream().map(CallParticipantConverter::convert).collect(Collectors.toList())));
.flatMap(result -> Mono.just(CallParticipantConverter.convert(result)));
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand All @@ -606,11 +594,11 @@ public Mono<List<CallParticipant>> getParticipant(CommunicationIdentifier partic
* @return Response for a successful get participant request.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public Mono<Response<List<CallParticipant>>> getParticipantWithResponse(CommunicationIdentifier participant) {
public Mono<Response<CallParticipant>> getParticipantWithResponse(CommunicationIdentifier participant) {
return getParticipantWithResponse(participant, Context.NONE);
}

Mono<Response<List<CallParticipant>>> getParticipantWithResponse(CommunicationIdentifier participant, Context context) {
Mono<Response<CallParticipant>> getParticipantWithResponse(CommunicationIdentifier participant, Context context) {
try {
GetParticipantRequest request = new GetParticipantRequest().setIdentifier(CommunicationIdentifierConverter.convert(participant));
return withContext(contextValue -> {
Expand All @@ -619,13 +607,7 @@ Mono<Response<List<CallParticipant>>> getParticipantWithResponse(CommunicationId
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.map(response ->
new SimpleResponse<>(response,
response.getValue()
.stream()
.map(CallParticipantConverter::convert)
.collect(Collectors.toList()
)
)
);
CallParticipantConverter.convert(response.getValue())));
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand Down Expand Up @@ -697,18 +679,14 @@ public Mono<PlayAudioResult> playAudioToParticipant(
Mono<PlayAudioResult> playAudioToParticipantInternal(CommunicationIdentifier participant, URI audioFileUri,
PlayAudioOptions playAudioOptions, Context context) {
try {
Objects.requireNonNull(participant, "'participant' cannot be null.");
Objects.requireNonNull(audioFileUri, "'audioFileUri' cannot be null.");

PlayAudioToParticipantRequest playAudioToParticipantRequest = new PlayAudioToParticipantRequest()
.setAudioFileUri(audioFileUri.toString())
.setIdentifier(CommunicationIdentifierConverter.convert(participant));
if (playAudioOptions != null) {
playAudioToParticipantRequest
.setLoop(playAudioOptions.isLoop())
.setOperationContext(playAudioOptions.getOperationContext())
.setAudioFileId(playAudioOptions.getAudioFileId())
.setCallbackUri(playAudioOptions.getCallbackUri().toString());
.setAudioFileId(playAudioOptions.getAudioFileId());
}

return callConnectionInternal.participantPlayAudioAsync(callConnectionId, playAudioToParticipantRequest, context)
Expand Down Expand Up @@ -742,18 +720,14 @@ public Mono<Response<PlayAudioResult>> playAudioToParticipantWithResponse(
Mono<Response<PlayAudioResult>> playAudioToParticipantWithResponseInternal(CommunicationIdentifier participant, URI audioFileUri,
PlayAudioOptions playAudioOptions, Context context) {
try {
Objects.requireNonNull(participant, "'participant' cannot be null.");
Objects.requireNonNull(audioFileUri, "'audioFileUri' cannot be null.");

PlayAudioToParticipantRequest playAudioToParticipantRequest = new PlayAudioToParticipantRequest()
.setAudioFileUri(audioFileUri.toString())
.setIdentifier(CommunicationIdentifierConverter.convert(participant));
if (playAudioOptions != null) {
playAudioToParticipantRequest
.setLoop(playAudioOptions.isLoop())
.setOperationContext(playAudioOptions.getOperationContext())
.setAudioFileId(playAudioOptions.getAudioFileId())
.setCallbackUri(playAudioOptions.getCallbackUri().toString());
.setAudioFileId(playAudioOptions.getAudioFileId());
}

return withContext(contextValue -> {
Expand Down Expand Up @@ -1034,7 +1008,6 @@ public Mono<Void> resumeParticipantMeetingAudio(
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> resumeParticipantMeetingAudioWithResponse(
CommunicationIdentifier participant) {
Objects.requireNonNull(participant, "'participant' cannot be null.");
return resumeParticipantMeetingAudioWithResponseInternal(participant, Context.NONE);
}

Expand Down Expand Up @@ -1156,7 +1129,6 @@ public Mono<Response<Void>> updateAudioRoutingGroupWithResponse(

Mono<Response<Void>> updateAudioRoutingGroupWithResponseInternal(String audioRoutingGroupId, List<CommunicationIdentifier> targets, Context context) {
try {
Objects.requireNonNull(audioRoutingGroupId, "'audioRoutingGroupId' cannot be null.");
UpdateAudioRoutingGroupRequest request = getUpdateAudioRoutingGroupRequest(audioRoutingGroupId, targets);
return callConnectionInternal.updateAudioRoutingGroupWithResponseAsync(callConnectionId, audioRoutingGroupId, request, context)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException);
Expand Down Expand Up @@ -1254,8 +1226,6 @@ public Mono<Response<Void>> deleteAudioRoutingGroupWithResponse(

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

return callConnectionInternal.deleteAudioRoutingGroupWithResponseAsync(callConnectionId, audioRoutingGroupId, context)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException);
} catch (RuntimeException ex) {
Expand All @@ -1266,18 +1236,15 @@ Mono<Response<Void>> deleteAudioRoutingGroupWithResponseInternal(String audioRou
private AddParticipantRequest getAddParticipantRequest(
CommunicationIdentifier participant,
String alternateCallerId,
String operationContext,
URI callbackUri) {
String operationContext) {
AddParticipantRequest request = new AddParticipantRequest()
.setParticipant(CommunicationIdentifierConverter.convert(participant))
.setAlternateCallerId(PhoneNumberIdentifierConverter.convert(alternateCallerId))
.setOperationContext(operationContext)
.setCallbackUri(callbackUri.toString());
.setOperationContext(operationContext);
return request;
}

private AudioRoutingGroupRequest getAudioRoutingGroupRequest(AudioRoutingMode audioRoutingMode, List<CommunicationIdentifier> targets) {
Objects.requireNonNull(targets, "'targets' cannot be null.");
AudioRoutingGroupRequest request = new AudioRoutingGroupRequest()
.setAudioRoutingMode(audioRoutingMode)
.setTargets(targets
Expand All @@ -1288,7 +1255,6 @@ private AudioRoutingGroupRequest getAudioRoutingGroupRequest(AudioRoutingMode au
}

private UpdateAudioRoutingGroupRequest getUpdateAudioRoutingGroupRequest(String audioRoutingGroupId, List<CommunicationIdentifier> targets) {
Objects.requireNonNull(targets, "'targets' cannot be null.");
UpdateAudioRoutingGroupRequest request = new UpdateAudioRoutingGroupRequest()
.setTargets(targets
.stream()
Expand Down
Loading