Skip to content

Commit

Permalink
Using the latest swagger (#35303)
Browse files Browse the repository at this point in the history
* Using the latest swagger

* Updating files

* Removing imports

* Moving to official swagger branch

* Fixing test

* Fixing tests

* Updating latest swagger

* Updated latest swagger and live tests

* Updating swagger location
  • Loading branch information
cochi2 authored Jun 20, 2023
1 parent 335b6ed commit a209338
Show file tree
Hide file tree
Showing 43 changed files with 2,757 additions and 566 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import com.azure.core.util.FluxUtil;
import com.azure.core.util.logging.ClientLogger;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.util.DateTimeRfc1123;
import java.time.OffsetDateTime;
import reactor.core.publisher.Mono;

Expand Down Expand Up @@ -164,7 +163,7 @@ Mono<Response<CreateCallResult>> createCallWithResponseInternal(CreateCallOption
return azureCommunicationCallAutomationServiceInternal.createCallWithResponseAsync(
request,
UUID.randomUUID(),
DateTimeRfc1123.toRfc1123String(OffsetDateTime.now()),
OffsetDateTime.now(),
context)
.map(response -> {
try {
Expand All @@ -189,7 +188,7 @@ Mono<Response<CreateCallResult>> createGroupCallWithResponseInternal(CreateGroup
return azureCommunicationCallAutomationServiceInternal.createCallWithResponseAsync(
request,
UUID.randomUUID(),
DateTimeRfc1123.toRfc1123String(OffsetDateTime.now()),
OffsetDateTime.now(),
context)
.map(response -> {
try {
Expand Down Expand Up @@ -340,7 +339,7 @@ Mono<Response<AnswerCallResult>> answerCallWithResponseInternal(AnswerCallOption
return azureCommunicationCallAutomationServiceInternal.answerCallWithResponseAsync(
request,
UUID.randomUUID(),
DateTimeRfc1123.toRfc1123String(OffsetDateTime.now()),
OffsetDateTime.now(),
context)
.map(response -> {
try {
Expand Down Expand Up @@ -404,7 +403,7 @@ Mono<Response<Void>> redirectCallWithResponseInternal(RedirectCallOptions redire
return azureCommunicationCallAutomationServiceInternal.redirectCallWithResponseAsync(
request,
UUID.randomUUID(),
DateTimeRfc1123.toRfc1123String(OffsetDateTime.now()),
OffsetDateTime.now(),
context);
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand Down Expand Up @@ -451,7 +450,7 @@ Mono<Response<Void>> rejectCallWithResponseInternal(RejectCallOptions rejectCall
return azureCommunicationCallAutomationServiceInternal.rejectCallWithResponseAsync(
request,
UUID.randomUUID(),
DateTimeRfc1123.toRfc1123String(OffsetDateTime.now()),
OffsetDateTime.now(),
context);
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
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.ListParticipantsResult;
import com.azure.communication.callautomation.models.MuteParticipantsOptions;
import com.azure.communication.callautomation.models.MuteParticipantsResult;
import com.azure.communication.callautomation.models.RemoveParticipantOptions;
Expand All @@ -20,6 +19,7 @@
import com.azure.communication.common.CommunicationIdentifier;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.Response;
import com.azure.core.util.Context;
import com.azure.core.exception.HttpResponseException;
Expand Down Expand Up @@ -119,9 +119,9 @@ public Response<CallParticipant> getParticipantWithResponse(CommunicationIdentif
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return A list of all participants in the call.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public ListParticipantsResult listParticipants() {
return callConnectionAsync.listParticipants().block();
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<CallParticipant> listParticipants() {
return new PagedIterable<>(callConnectionAsync.listParticipants());
}

/**
Expand All @@ -132,9 +132,9 @@ public ListParticipantsResult listParticipants() {
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return Response with a list of all participants in the call.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<ListParticipantsResult> listParticipantsWithResponse(Context context) {
return callConnectionAsync.listParticipantsWithResponseInternal(context).block();
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<CallParticipant> listParticipants(Context context) {
return new PagedIterable<>(callConnectionAsync.listParticipantsWithContext(context));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.azure.communication.callautomation.implementation.CallMediasImpl;
import com.azure.communication.callautomation.implementation.accesshelpers.AddParticipantResponseConstructorProxy;
import com.azure.communication.callautomation.implementation.accesshelpers.CallConnectionPropertiesConstructorProxy;
import com.azure.communication.callautomation.implementation.accesshelpers.ListParticipantsResponseConstructorProxy;
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 @@ -26,7 +25,6 @@
import com.azure.communication.callautomation.models.AddParticipantOptions;
import com.azure.communication.callautomation.models.CallConnectionProperties;
import com.azure.communication.callautomation.models.CallInvite;
import com.azure.communication.callautomation.models.ListParticipantsResult;
import com.azure.communication.callautomation.models.MuteParticipantsOptions;
import com.azure.communication.callautomation.models.MuteParticipantsResult;
import com.azure.communication.callautomation.models.RemoveParticipantOptions;
Expand All @@ -41,10 +39,10 @@
import com.azure.communication.common.PhoneNumberIdentifier;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.http.rest.PagedFlux;
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.DateTimeRfc1123;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.logging.ClientLogger;
import reactor.core.publisher.Mono;
Expand Down Expand Up @@ -152,7 +150,7 @@ Mono<Response<Void>> hangUpWithResponseInternal(boolean isForEveryone, Context c
return (isForEveryone ? callConnectionInternal.terminateCallWithResponseAsync(
callConnectionId,
UUID.randomUUID(),
DateTimeRfc1123.toRfc1123String(OffsetDateTime.now()),
OffsetDateTime.now(),
context)
: callConnectionInternal.hangupCallWithResponseAsync(callConnectionId, context));
} catch (RuntimeException ex) {
Expand Down Expand Up @@ -199,39 +197,33 @@ Mono<Response<CallParticipant>> getParticipantWithResponseInternal(Communication
}
}

/**
* Get all participants.
*
* @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 getting all participants in the call.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<ListParticipantsResult> listParticipants() {
return listParticipantsWithResponse().flatMap(FluxUtil::toMono);
}

/**
* Get all participants.
*
* @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 getting all participants in the call.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<ListParticipantsResult>> listParticipantsWithResponse() {
return withContext(this::listParticipantsWithResponseInternal);
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<CallParticipant> listParticipants() {
try {
return new PagedFlux<>(
() -> withContext(context -> this.callConnectionInternal.getParticipantsSinglePageAsync(
callConnectionId, context)),
nextLink -> withContext(context -> this.callConnectionInternal.getParticipantsNextSinglePageAsync(
nextLink, context)))
.mapPage(CallParticipantConverter::convert);
} catch (RuntimeException ex) {
return new PagedFlux<>(() -> monoError(logger, ex));
}
}

Mono<Response<ListParticipantsResult>> listParticipantsWithResponseInternal(Context context) {
PagedFlux<CallParticipant> listParticipantsWithContext(Context context) {
try {
context = context == null ? Context.NONE : context;

return callConnectionInternal.getParticipantsWithResponseAsync(callConnectionId, context)
.map(response -> new SimpleResponse<>(response,
ListParticipantsResponseConstructorProxy.create(response.getValue())));
final Context serviceContext = context == null ? Context.NONE : context;
return callConnectionInternal.getParticipantsAsync(callConnectionId, serviceContext).mapPage(CallParticipantConverter::convert);
} catch (RuntimeException ex) {
return monoError(logger, ex);
return new PagedFlux<>(() -> monoError(logger, ex));
}
}

Expand Down Expand Up @@ -291,7 +283,7 @@ Mono<Response<TransferCallResult>> transferCallToParticipantWithResponseInternal
callConnectionId,
request,
UUID.randomUUID(),
DateTimeRfc1123.toRfc1123String(OffsetDateTime.now()),
OffsetDateTime.now(),
context).map(response -> new SimpleResponse<>(response, TransferCallResponseConstructorProxy.create(response.getValue())));
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand Down Expand Up @@ -350,7 +342,7 @@ Mono<Response<AddParticipantResult>> addParticipantWithResponseInternal(AddParti
callConnectionId,
request,
UUID.randomUUID(),
DateTimeRfc1123.toRfc1123String(OffsetDateTime.now()),
OffsetDateTime.now(),
context
).map(response -> new SimpleResponse<>(response, AddParticipantResponseConstructorProxy.create(response.getValue())));
} catch (RuntimeException ex) {
Expand Down Expand Up @@ -396,7 +388,7 @@ Mono<Response<RemoveParticipantResult>> removeParticipantWithResponseInternal(Re
callConnectionId,
request,
UUID.randomUUID(),
DateTimeRfc1123.toRfc1123String(OffsetDateTime.now()),
OffsetDateTime.now(),
context).map(response -> new SimpleResponse<>(response, RemoveParticipantResponseConstructorProxy.create(response.getValue())));
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand Down Expand Up @@ -439,7 +431,7 @@ Mono<Response<MuteParticipantsResult>> muteParticipantWithResponseInternal(MuteP
callConnectionId,
request,
UUID.randomUUID(),
DateTimeRfc1123.toRfc1123String(OffsetDateTime.now()),
OffsetDateTime.now(),
context).map(internalResponse -> new SimpleResponse<>(internalResponse, MuteParticipantsResponseConstructorProxy.create(internalResponse.getValue())));
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand Down Expand Up @@ -482,7 +474,7 @@ Mono<Response<UnmuteParticipantsResult>> unmuteParticipantWithResponseInternal(U
callConnectionId,
request,
UUID.randomUUID(),
DateTimeRfc1123.toRfc1123String(OffsetDateTime.now()),
OffsetDateTime.now(),
context).map(internalResponse -> new SimpleResponse<>(internalResponse, UnmuteParticipantsResponseConstructorProxy.create(internalResponse.getValue())));
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.BinaryData;
import com.azure.core.util.Context;
import com.azure.core.util.DateTimeRfc1123;
import com.azure.core.util.logging.ClientLogger;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
Expand Down Expand Up @@ -124,7 +123,7 @@ Mono<Response<RecordingStateResult>> startWithResponseInternal(StartRecordingOpt
.startRecordingWithResponseAsync(
request,
UUID.randomUUID(),
DateTimeRfc1123.toRfc1123String(OffsetDateTime.now()),
OffsetDateTime.now(),
contextValue)
.map(response ->
new SimpleResponse<>(response, RecordingStateResponseConstructorProxy.create(response.getValue()))
Expand Down
Loading

0 comments on commit a209338

Please sign in to comment.