customPolicies = new ArrayList<>();
+ private ClientOptions clientOptions;
+ private RetryPolicy retryPolicy;
+
+ /**
+ * Set endpoint of the service
+ *
+ * @param endpoint url of the service
+ * @return CallingServerClientBuilder
+ */
+ public CallingServerClientBuilder endpoint(String endpoint) {
+ this.endpoint = Objects.requireNonNull(endpoint, "'endpoint' cannot be null.");
+ return this;
+ }
+
+ /**
+ * Set endpoint of the service
+ *
+ * @param pipeline HttpPipeline to use, if a pipeline is not supplied, the
+ * credential and httpClient fields must be set
+ * @return CallingServerClientBuilder
+ */
+ public CallingServerClientBuilder pipeline(HttpPipeline pipeline) {
+ this.pipeline = Objects.requireNonNull(pipeline, "'pipeline' cannot be null.");
+ return this;
+ }
+
+ /**
+ * Sets the {@link TokenCredential} used to authenticate HTTP requests.
+ *
+ * @param tokenCredential {@link TokenCredential} used to authenticate HTTP
+ * requests.
+ * @return The updated {@link CallingServerClientBuilder} object.
+ * @throws NullPointerException If {@code tokenCredential} is null.
+ */
+ public CallingServerClientBuilder credential(TokenCredential tokenCredential) {
+ this.tokenCredential = Objects.requireNonNull(tokenCredential, "'tokenCredential' cannot be null.");
+ return this;
+ }
+
+ /**
+ * Sets the {@link AzureKeyCredential} used to authenticate HTTP requests.
+ *
+ * @param keyCredential The {@link AzureKeyCredential} used to authenticate HTTP
+ * requests.
+ * @return The updated {@link CallingServerClientBuilder} object.
+ * @throws NullPointerException If {@code keyCredential} is null.
+ */
+ public CallingServerClientBuilder credential(AzureKeyCredential keyCredential) {
+ this.azureKeyCredential = Objects.requireNonNull(keyCredential, "'keyCredential' cannot be null.");
+ return this;
+ }
+
+ /**
+ * Set connectionString to use
+ *
+ * @param connectionString connection string to set
+ * @return The updated {@link CallingServerClientBuilder} object.
+ */
+ public CallingServerClientBuilder connectionString(String connectionString) {
+ Objects.requireNonNull(connectionString, "'connectionString' cannot be null.");
+ this.connectionString = connectionString;
+ return this;
+ }
+
+ /**
+ * Sets the retry policy to use (using the RetryPolicy type).
+ *
+ * @param retryPolicy object to be applied
+ * @return The updated {@link CallingServerClientBuilder} object.
+ */
+ public CallingServerClientBuilder retryPolicy(RetryPolicy retryPolicy) {
+ this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null.");
+ return this;
+ }
+
+ /**
+ * Sets the configuration object used to retrieve environment configuration
+ * values during building of the client.
+ *
+ * @param configuration Configuration store used to retrieve environment
+ * configurations.
+ * @return The updated {@link CallingServerClientBuilder} object.
+ */
+ public CallingServerClientBuilder configuration(Configuration configuration) {
+ this.configuration = Objects.requireNonNull(configuration, "'configuration' cannot be null.");
+ return this;
+ }
+
+ /**
+ * Sets the {@link HttpLogOptions} for service requests.
+ *
+ * @param logOptions The logging configuration to use when sending and receiving
+ * HTTP requests/responses.
+ * @return The updated {@link CallingServerClientBuilder} object.
+ */
+ public CallingServerClientBuilder httpLogOptions(HttpLogOptions logOptions) {
+ this.httpLogOptions = Objects.requireNonNull(logOptions, "'logOptions' cannot be null.");
+ return this;
+ }
+
+ /**
+ * Sets the {@link CallingServerClientBuilder} that is used when making API requests.
+ *
+ * If a service version is not provided, the service version that will be used
+ * will be the latest known service version based on the version of the client
+ * library being used. If no service version is specified, updating to a newer
+ * version of the client library will have the result of potentially moving to a
+ * newer service version.
+ *
+ * Targeting a specific service version may also mean that the service will
+ * return an error for newer APIs.
+ *
+ * @param version {@link CallingServerClientBuilder} of the service to be used when
+ * making requests.
+ * @return the updated CallingServerClientBuilder object
+ */
+ public CallingServerClientBuilder serviceVersion(CallingServerClientBuilder version) {
+ return this;
+ }
+
+ /**
+ * Set httpClient to use
+ *
+ * @param httpClient httpClient to use, overridden by the pipeline field.
+ * @return The updated {@link CallingServerClientBuilder} object.
+ */
+ public CallingServerClientBuilder httpClient(HttpClient httpClient) {
+ this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null.");
+ return this;
+ }
+
+ /**
+ * Apply additional HttpPipelinePolicy
+ *
+ * @param customPolicy HttpPipelinePolicy object to be applied after
+ * AzureKeyCredentialPolicy, UserAgentPolicy, RetryPolicy, and CookiePolicy
+ * @return The updated {@link CallingServerClientBuilder} object.
+ */
+ public CallingServerClientBuilder addPolicy(HttpPipelinePolicy customPolicy) {
+ this.customPolicies.add(Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."));
+ return this;
+ }
+
+ /**
+ * Create asynchronous client applying HMACAuthenticationPolicy,
+ * UserAgentPolicy, RetryPolicy, and CookiePolicy. Additional HttpPolicies
+ * specified by additionalPolicies will be applied after them
+ *
+ * @return The updated {@link CallingServerClientBuilder} object.
+ */
+ public CallingServerAsyncClient buildAsyncClient() {
+ return new CallingServerAsyncClient(createServiceImpl());
+ }
+
+ /**
+ * Create synchronous client applying HmacAuthenticationPolicy, UserAgentPolicy,
+ * RetryPolicy, and CookiePolicy. Additional HttpPolicies specified by
+ * additionalPolicies will be applied after them
+ *
+ * @return The updated {@link CallingServerClientBuilder} object.
+ */
+ public CallingServerClient buildClient() {
+ return new CallingServerClient(buildAsyncClient());
+ }
+
+ private AzureCommunicationCallingServerServiceImpl createServiceImpl() {
+ boolean isConnectionStringSet = connectionString != null && !connectionString.trim().isEmpty();
+ boolean isEndpointSet = endpoint != null && !endpoint.trim().isEmpty();
+ boolean isAzureKeyCredentialSet = azureKeyCredential != null;
+ boolean isTokenCredentialSet = tokenCredential != null;
+
+ if (isConnectionStringSet && isEndpointSet) {
+ throw logger.logExceptionAsError(new IllegalArgumentException(
+ "Both 'connectionString' and 'endpoint' are set. Just one may be used."));
+ }
+
+ if (isConnectionStringSet && isAzureKeyCredentialSet) {
+ throw logger.logExceptionAsError(new IllegalArgumentException(
+ "Both 'connectionString' and 'keyCredential' are set. Just one may be used."));
+ }
+
+ if (isConnectionStringSet && isTokenCredentialSet) {
+ throw logger.logExceptionAsError(new IllegalArgumentException(
+ "Both 'connectionString' and 'tokenCredential' are set. Just one may be used."));
+ }
+
+ if (isAzureKeyCredentialSet && isTokenCredentialSet) {
+ throw logger.logExceptionAsError(new IllegalArgumentException(
+ "Both 'tokenCredential' and 'keyCredential' are set. Just one may be used."));
+ }
+
+ if (isConnectionStringSet) {
+ CommunicationConnectionString connectionStringObject = new CommunicationConnectionString(connectionString);
+ String endpoint = connectionStringObject.getEndpoint();
+ String accessKey = connectionStringObject.getAccessKey();
+ endpoint(endpoint).credential(new AzureKeyCredential(accessKey));
+ }
+
+ Objects.requireNonNull(endpoint);
+ if (pipeline == null) {
+ Objects.requireNonNull(httpClient);
+ }
+
+ HttpPipeline builderPipeline = pipeline;
+ if (pipeline == null) {
+ builderPipeline = createHttpPipeline(httpClient);
+ }
+
+ AzureCommunicationCallingServerServiceImplBuilder clientBuilder = new AzureCommunicationCallingServerServiceImplBuilder();
+ clientBuilder.endpoint(endpoint).pipeline(builderPipeline);
+
+ return clientBuilder.buildClient();
+ }
+
+ /**
+ * Allows the user to set a variety of client-related options, such as
+ * user-agent string, headers, etc.
+ *
+ * @param clientOptions object to be applied
+ * @return The updated {@link CallingServerClientBuilder} object.
+ */
+ public CallingServerClientBuilder clientOptions(ClientOptions clientOptions) {
+ this.clientOptions = clientOptions;
+ return this;
+ }
+
+ private HttpPipelinePolicy createHttpPipelineAuthPolicy() {
+ if (tokenCredential != null && azureKeyCredential != null) {
+ throw logger.logExceptionAsError(new IllegalArgumentException(
+ "Both 'credential' and 'keyCredential' are set. Just one may be used."));
+ }
+ if (tokenCredential != null) {
+ return new BearerTokenAuthenticationPolicy(tokenCredential,
+ "https://communication.azure.com//.default");
+ } else if (azureKeyCredential != null) {
+ return new HmacAuthenticationPolicy(azureKeyCredential);
+ } else {
+ throw logger.logExceptionAsError(
+ new IllegalArgumentException("Missing credential information while building a client."));
+ }
+ }
+
+ private HttpPipeline createHttpPipeline(HttpClient httpClient) {
+ if (pipeline != null) {
+ return pipeline;
+ }
+
+ List policyList = new ArrayList<>();
+
+ ClientOptions buildClientOptions = (clientOptions == null) ? new ClientOptions() : clientOptions;
+ HttpLogOptions buildLogOptions = (httpLogOptions == null) ? new HttpLogOptions() : httpLogOptions;
+
+ String applicationId = null;
+ if (!CoreUtils.isNullOrEmpty(buildClientOptions.getApplicationId())) {
+ applicationId = buildClientOptions.getApplicationId();
+ } else if (!CoreUtils.isNullOrEmpty(buildLogOptions.getApplicationId())) {
+ applicationId = buildLogOptions.getApplicationId();
+ }
+
+ // Add required policies
+ String clientName = properties.getOrDefault(SDK_NAME, "UnknownName");
+ String clientVersion = properties.getOrDefault(SDK_VERSION, "UnknownVersion");
+ policyList.add(new UserAgentPolicy(applicationId, clientName, clientVersion, configuration));
+ policyList.add(new RequestIdPolicy());
+ policyList.add((retryPolicy == null) ? new RetryPolicy() : retryPolicy);
+ policyList.add(createHttpPipelineAuthPolicy());
+ policyList.add(new CookiePolicy());
+
+ // Add additional policies
+ if (!customPolicies.isEmpty()) {
+ policyList.addAll(customPolicies);
+ }
+
+ // Add logging policy
+ policyList.add(new HttpLoggingPolicy(getHttpLogOptions()));
+
+ return new HttpPipelineBuilder().policies(policyList.toArray(new HttpPipelinePolicy[0])).httpClient(httpClient)
+ .build();
+ }
+
+ private HttpLogOptions getHttpLogOptions() {
+ if (httpLogOptions == null) {
+ httpLogOptions = new HttpLogOptions();
+ }
+
+ return httpLogOptions;
+ }
+}
diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ContentDownloader.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ContentDownloader.java
new file mode 100644
index 0000000000000..6ee8317fe7f1c
--- /dev/null
+++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ContentDownloader.java
@@ -0,0 +1,286 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+package com.azure.communication.callingserver;
+
+import com.azure.communication.callingserver.implementation.Constants;
+import com.azure.communication.callingserver.models.CallingServerErrorException;
+import com.azure.communication.callingserver.models.ParallelDownloadOptions;
+import com.azure.communication.callingserver.models.ProgressReporter;
+import com.azure.core.http.HttpMethod;
+import com.azure.core.http.HttpPipeline;
+import com.azure.core.http.HttpRange;
+import com.azure.core.http.HttpRequest;
+import com.azure.core.http.HttpResponse;
+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.FluxUtil;
+import com.azure.core.util.logging.ClientLogger;
+import reactor.core.Exceptions;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+import reactor.core.publisher.SignalType;
+import reactor.core.scheduler.Schedulers;
+import reactor.util.function.Tuple2;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UncheckedIOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.ByteBuffer;
+import java.nio.channels.AsynchronousFileChannel;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.function.Function;
+
+import static java.lang.StrictMath.toIntExact;
+
+class ContentDownloader {
+ private final String resourceEndpoint;
+ private final HttpPipeline httpPipeline;
+ private final ClientLogger logger = new ClientLogger(ContentDownloader.class);
+
+ ContentDownloader(String resourceEndpoint, HttpPipeline httpPipeline) {
+ this.resourceEndpoint = resourceEndpoint;
+ this.httpPipeline = httpPipeline;
+ }
+
+ Mono> downloadToStreamWithResponse(
+ String sourceEndpoint,
+ OutputStream destinationStream,
+ HttpRange httpRange,
+ Context context) {
+ return downloadStreamWithResponse(sourceEndpoint, httpRange, context)
+ .flatMap(response -> response.getValue().reduce(destinationStream, (outputStream, buffer) -> {
+ try {
+ outputStream.write(FluxUtil.byteBufferToArray(buffer));
+ return outputStream;
+ } catch (IOException ex) {
+ throw logger.logExceptionAsError(Exceptions.propagate(new UncheckedIOException(ex)));
+ }
+ }).thenReturn(new SimpleResponse<>(response.getRequest(), response.getStatusCode(),
+ response.getHeaders(), null)));
+ }
+
+ Mono>> downloadStreamWithResponse(
+ String sourceEndpoint,
+ HttpRange httpRange,
+ Context context) {
+ Mono httpResponse = makeDownloadRequest(sourceEndpoint, httpRange, context);
+ return httpResponse.map(response -> {
+ Flux result = getFluxStream(response, sourceEndpoint, httpRange, context);
+ return new SimpleResponse<>(response.getRequest(), response.getStatusCode(),
+ response.getHeaders(), result);
+ });
+ }
+
+ Mono> downloadToFileWithResponse(
+ String sourceEndpoint,
+ AsynchronousFileChannel destinationFile,
+ ParallelDownloadOptions parallelDownloadOptions,
+ Context context) {
+ Lock progressLock = new ReentrantLock();
+ AtomicLong totalProgress = new AtomicLong(0);
+
+ Function>>> downloadFunc =
+ range -> downloadStreamWithResponse(sourceEndpoint, range, context);
+
+ return downloadFirstChunk(parallelDownloadOptions, downloadFunc)
+ .flatMap(setupTuple2 -> {
+ long newCount = setupTuple2.getT1();
+ int numChunks = calculateNumBlocks(newCount, parallelDownloadOptions.getBlockSizeLong());
+
+ // In case it is an empty blob, this ensures we still actually perform a download operation.
+ numChunks = numChunks == 0 ? 1 : numChunks;
+
+ Response> initialResponse = setupTuple2.getT2();
+ return Flux.range(0, numChunks)
+ .flatMap(chunkNum -> downloadChunk(chunkNum, initialResponse,
+ parallelDownloadOptions, newCount, downloadFunc,
+ response ->
+ writeBodyToFile(response, destinationFile, chunkNum,
+ parallelDownloadOptions, progressLock, totalProgress).flux()))
+ .then(Mono.just(new SimpleResponse<>(initialResponse, null)));
+ });
+ }
+
+ private Flux getFluxStream(
+ HttpResponse httpResponse,
+ String sourceEndpoint,
+ HttpRange httpRange,
+ Context context) {
+ return FluxUtil.createRetriableDownloadFlux(
+ () -> getResponseBody(httpResponse),
+ (Throwable throwable, Long aLong) -> {
+ if (throwable instanceof CallingServerErrorException) {
+ CallingServerErrorException exception = (CallingServerErrorException) throwable;
+ if (exception.getResponse().getStatusCode() == 416) {
+ return makeDownloadRequest(sourceEndpoint, null, context)
+ .map(this::getResponseBody)
+ .flux()
+ .flatMap(flux -> flux);
+ }
+ }
+
+ HttpRange range;
+ if (httpRange != null) {
+ range = new HttpRange(aLong + 1, httpRange.getLength() - aLong - 1);
+ } else {
+ range = new HttpRange(aLong + 1);
+ }
+
+ return makeDownloadRequest(sourceEndpoint, range, context)
+ .map(this::getResponseBody)
+ .flux()
+ .flatMap(flux -> flux);
+ },
+ Constants.ContentDownloader.MAX_RETRIES
+ );
+ }
+
+ private Flux getResponseBody(HttpResponse response) {
+ switch (response.getStatusCode()) {
+ case 200:
+ case 206:
+ return response.getBody();
+ case 416: // Retriable with new HttpRange, potentially bytes=0-
+ return FluxUtil.fluxError(logger,
+ new CallingServerErrorException(formatExceptionMessage(response), response));
+ default:
+ throw logger.logExceptionAsError(
+ new CallingServerErrorException(formatExceptionMessage(response), response)
+ );
+ }
+ }
+
+ private String formatExceptionMessage(HttpResponse httpResponse) {
+ return String.format("Service Request failed!%nStatus: %s", httpResponse.getStatusCode());
+ }
+
+ private Mono makeDownloadRequest(
+ String sourceEndpoint,
+ HttpRange httpRange,
+ Context context) {
+ HttpRequest request = getHttpRequest(sourceEndpoint, httpRange);
+ URL urlToSignWith = getUrlToSignRequestWith(sourceEndpoint);
+
+ Context finalContext;
+ if (context == null) {
+ finalContext = new Context("hmacSignatureURL", urlToSignWith);
+ } else {
+ finalContext = context.addData("hmacSignatureURL", urlToSignWith);
+ }
+
+ return httpPipeline.send(request, finalContext);
+ }
+
+ private URL getUrlToSignRequestWith(String endpoint) {
+ try {
+ String path = new URL(endpoint).getPath();
+
+ if (path.startsWith("/")) {
+ path = path.substring(1);
+ }
+
+ return new URL(resourceEndpoint + path);
+ } catch (MalformedURLException ex) {
+ throw logger.logExceptionAsError(new IllegalArgumentException(ex));
+ }
+ }
+
+ private HttpRequest getHttpRequest(String sourceEndpoint, HttpRange httpRange) {
+ HttpRequest request = new HttpRequest(HttpMethod.GET, sourceEndpoint);
+
+ if (null != httpRange) {
+ request.setHeader(Constants.HeaderNames.RANGE, httpRange.toString());
+ }
+
+ return request;
+ }
+
+ private Mono>>> downloadFirstChunk(
+ ParallelDownloadOptions parallelDownloadOptions,
+ Function>>> downloader) {
+ return downloader.apply(new HttpRange(0, parallelDownloadOptions.getBlockSizeLong()))
+ .subscribeOn(Schedulers.boundedElastic())
+ .flatMap(response -> {
+ // Extract the total length of the blob from the contentRange header. e.g. "bytes 1-6/7"
+ long totalLength = extractTotalBlobLength(
+ response.getHeaders().getValue(Constants.HeaderNames.CONTENT_RANGE)
+ );
+
+ return Mono.zip(Mono.just(totalLength), Mono.just(response));
+ });
+ }
+
+ private long extractTotalBlobLength(String contentRange) {
+ return contentRange == null ? 0 : Long.parseLong(contentRange.split("/")[1]);
+ }
+
+ private int calculateNumBlocks(long dataSize, long blockLength) {
+ // Can successfully cast to an int because MaxBlockSize is an int, which this expression must be less than.
+ int numBlocks = toIntExact(dataSize / blockLength);
+ // Include an extra block for trailing data.
+ if (dataSize % blockLength != 0) {
+ numBlocks++;
+ }
+ return numBlocks;
+ }
+
+ private Flux downloadChunk(
+ Integer chunkNum,
+ Response> initialResponse,
+ ParallelDownloadOptions parallelDownloadOptions,
+ long newCount,
+ Function>>> downloader,
+ Function>, Flux> returnTransformer) {
+ if (chunkNum == 0) {
+ return returnTransformer.apply(initialResponse);
+ }
+
+ // Calculate whether we need a full chunk or something smaller because we are at the end.
+ long modifier = chunkNum.longValue() * parallelDownloadOptions.getBlockSizeLong();
+ long chunkSizeActual = Math.min(parallelDownloadOptions.getBlockSizeLong(),
+ newCount - modifier);
+ HttpRange chunkRange = new HttpRange(modifier, chunkSizeActual);
+
+ // Make the download call.
+ return downloader.apply(chunkRange)
+ .subscribeOn(Schedulers.boundedElastic())
+ .flatMapMany(returnTransformer);
+ }
+
+ private static Mono writeBodyToFile(
+ Response> response,
+ AsynchronousFileChannel file,
+ long chunkNum,
+ ParallelDownloadOptions parallelDownloadOptions,
+ Lock progressLock,
+ AtomicLong totalProgress) {
+ // Extract the body.
+ Flux data = response.getValue();
+
+ // Report progress as necessary.
+ data = ProgressReporter.addParallelProgressReporting(data,
+ parallelDownloadOptions.getProgressReceiver(), progressLock, totalProgress);
+
+ // Write to the file.
+ return FluxUtil.writeFile(data, file, chunkNum * parallelDownloadOptions.getBlockSizeLong());
+ }
+
+ void downloadToFileCleanup(AsynchronousFileChannel channel, Path filePath, SignalType signalType) {
+ try {
+ channel.close();
+ if (!signalType.equals(SignalType.ON_COMPLETE)) {
+ Files.deleteIfExists(filePath);
+ logger.verbose("Downloading to file failed. Cleaning up resources.");
+ }
+ } catch (IOException e) {
+ throw logger.logExceptionAsError(new UncheckedIOException(e));
+ }
+ }
+}
diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCall.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCall.java
new file mode 100644
index 0000000000000..653db215187f7
--- /dev/null
+++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCall.java
@@ -0,0 +1,301 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.communication.callingserver;
+
+import com.azure.communication.callingserver.models.CallRecordingStateResult;
+import com.azure.communication.callingserver.models.PlayAudioOptions;
+import com.azure.communication.callingserver.models.PlayAudioResult;
+import com.azure.communication.callingserver.models.StartCallRecordingResult;
+import com.azure.communication.common.CommunicationIdentifier;
+import com.azure.core.annotation.ReturnType;
+import com.azure.core.annotation.ServiceMethod;
+import com.azure.core.http.rest.Response;
+import com.azure.core.util.Context;
+
+/**
+ * Sync Client that supports server call operations.
+ */
+public final class ServerCall {
+ private final ServerCallAsync serverCallAsync;
+
+ ServerCall(ServerCallAsync serverCallAsync) {
+ this.serverCallAsync = serverCallAsync;
+ }
+
+ /**
+ * Get the server call id property
+ *
+ * @return the id value.
+ */
+ public String getServerCallId() {
+ return serverCallAsync.getServerCallId();
+ }
+
+ /**
+ * Add a participant to the call.
+ *
+ * @param participant Invited participant.
+ * @param callBackUri callBackUri to get notifications.
+ * @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
+ * @return response for a successful add participant request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Void addParticipant(
+ CommunicationIdentifier participant,
+ String callBackUri,
+ String alternateCallerId,
+ String operationContext) {
+ return serverCallAsync.addParticipant(participant, alternateCallerId, operationContext, callBackUri).block();
+ }
+
+ /**
+ * Add a participant to the call.
+ *
+ * @param participant Invited participant.
+ * @param callBackUri callBackUri to get notifications.
+ * @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 context A {@link Context} representing the request context.
+ * @return response for a successful add participant request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response addParticipantWithResponse(
+ CommunicationIdentifier participant,
+ String callBackUri,
+ String alternateCallerId,
+ String operationContext,
+ Context context) {
+ return serverCallAsync.addParticipantWithResponse(
+ participant,
+ callBackUri,
+ alternateCallerId,
+ operationContext,
+ context).block();
+ }
+
+ /**
+ * Remove a participant from the call.
+ *
+ * @param participantId Participant id.
+ * @return response for a successful remove participant request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Void removeParticipant(String participantId) {
+ return serverCallAsync.removeParticipant(participantId).block();
+ }
+
+ /**
+ * Remove a participant from the call.
+ *
+ * @param participantId Participant id.
+ * @param context A {@link Context} representing the request context.
+ * @return response for a successful remove participant request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response removeParticipantWithResponse(String participantId, Context context) {
+ return serverCallAsync.removeParticipantWithResponse(participantId, context).block();
+ }
+
+ /**
+ * Start recording
+ *
+ * @param recordingStateCallbackUri The uri to send state change callbacks.
+ * @return result for a successful start recording request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public StartCallRecordingResult startRecording(String recordingStateCallbackUri) {
+ return serverCallAsync.startRecording(recordingStateCallbackUri).block();
+ }
+
+ /**
+ * Start recording
+ *
+ * @param recordingStateCallbackUri The uri to send state change callbacks.
+ * @param context A {@link Context} representing the request context.
+ * @return result for a successful start recording request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response startRecordingWithResponse(
+ String recordingStateCallbackUri,
+ Context context) {
+ return serverCallAsync.startRecordingWithResponse(recordingStateCallbackUri, context).block();
+ }
+
+ /**
+ * Stop recording
+ *
+ * @param recordingId The recording id to stop.
+ * @return response for a successful stop recording request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Void stopRecording(String recordingId) {
+ return serverCallAsync.stopRecording(recordingId).block();
+ }
+
+ /**
+ * Stop recording
+ *
+ * @param recordingId The recording id to stop.
+ * @param context A {@link Context} representing the request context.
+ * @return response for a successful stop recording request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response stopRecordingWithResponse(String recordingId, Context context) {
+ return serverCallAsync.stopRecordingWithResponse(recordingId, context).block();
+ }
+
+ /**
+ * Pause recording
+ *
+ * @param recordingId The recording id to stop.
+ * @return response for a successful pause recording request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Void pauseRecording(String recordingId) {
+ return serverCallAsync.pauseRecording(recordingId).block();
+ }
+
+ /**
+ * Pause recording
+ *
+ * @param recordingId The recording id to stop.
+ * @param context A {@link Context} representing the request context.
+ * @return response for a successful pause recording request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response pauseRecordingWithResponse(String recordingId, Context context) {
+ return serverCallAsync.pauseRecordingWithResponse(recordingId, context).block();
+ }
+
+ /**
+ * Resume recording
+ *
+ * @param recordingId The recording id to stop.
+ * @return response for a successful resume recording request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Void resumeRecording(String recordingId) {
+ return serverCallAsync.resumeRecording(recordingId).block();
+ }
+
+ /**
+ * Resume recording
+ *
+ * @param recordingId The recording id to stop.
+ * @param context A {@link Context} representing the request context.
+ * @return response for a successful resume recording request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response resumeRecordingWithResponse(String recordingId, Context context) {
+ return serverCallAsync.resumeRecordingWithResponse(recordingId, context).block();
+ }
+
+ /**
+ * Get recording state
+ *
+ * @param recordingId The recording id to stop.
+ * @return response for a successful get recording state request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public CallRecordingStateResult getRecordingState(String recordingId) {
+ return serverCallAsync.getRecordingState(recordingId).block();
+ }
+
+ /**
+ * Get recording state
+ *
+ * @param recordingId The recording id to stop.
+ * @param context A {@link Context} representing the request context.
+ * @return response for a successful get recording state request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response getRecordingStateWithResponse(String recordingId, Context context) {
+ return serverCallAsync.getRecordingStateWithResponse(recordingId, context).block();
+ }
+
+ /**
+ * Play audio in a call.
+ *
+ * @param audioFileUri The media resource uri of the play audio request. Currently only Wave file (.wav) format
+ * audio prompts are supported. More specifically, the audio content in the wave file must
+ * be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate.
+ * @param audioFileId An id for the media in the AudioFileUri, using which we cache the media.
+ * @param callbackUri The callback Uri to receive PlayAudio status notifications.
+ * @param operationContext The value to identify context of the operation. This is used to co-relate other
+ * communications related to this operation
+ * @return the response payload for play audio operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public PlayAudioResult playAudio(
+ String audioFileUri,
+ String audioFileId,
+ String callbackUri,
+ String operationContext) {
+ return serverCallAsync.playAudioInternal(audioFileUri, audioFileId, callbackUri, operationContext).block();
+ }
+
+ /**
+ * Play audio in a call.
+ *
+ * @param audioFileUri The media resource uri of the play audio request. Currently only Wave file (.wav) format
+ * audio prompts are supported. More specifically, the audio content in the wave file must
+ * be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate.
+ * @param playAudioOptions Options for play audio.
+ * @return the response payload for play audio operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public PlayAudioResult playAudio(String audioFileUri, PlayAudioOptions playAudioOptions) {
+ return serverCallAsync.playAudioInternal(audioFileUri, playAudioOptions).block();
+ }
+
+ /**
+ * Play audio in a call.
+ *
+ * @param audioFileUri The media resource uri of the play audio request. Currently only Wave file (.wav) format
+ * audio prompts are supported. More specifically, the audio content in the wave file must
+ * be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate.
+ * @param audioFileId An id for the media in the AudioFileUri, using which we cache the media.
+ * @param callbackUri The callback Uri to receive PlayAudio status notifications.
+ * @param operationContext The value to identify context of the operation. This is used to co-relate other
+ * communications related to this operation
+ * @param context A {@link Context} representing the request context.
+ * @return the response payload for play audio operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response playAudioWithResponse(
+ String audioFileUri,
+ String audioFileId,
+ String callbackUri,
+ String operationContext,
+ Context context) {
+ return serverCallAsync
+ .playAudioWithResponseInternal(
+ audioFileUri,
+ audioFileId,
+ callbackUri,
+ operationContext,
+ context).block();
+ }
+
+ /**
+ * Play audio in a call.
+ *
+ * @param audioFileUri The media resource uri of the play audio request. Currently only Wave file (.wav) format
+ * audio prompts are supported. More specifically, the audio content in the wave file must
+ * be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate.
+ * @param playAudioOptions Options for play audio.
+ * @param context A {@link Context} representing the request context.
+ * @return the response payload for play audio operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response playAudioWithResponse(
+ String audioFileUri,
+ PlayAudioOptions playAudioOptions,
+ Context context) {
+ return serverCallAsync.playAudioWithResponseInternal(audioFileUri, playAudioOptions, context).block();
+ }
+}
diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCallAsync.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCallAsync.java
new file mode 100644
index 0000000000000..067bec9db3baa
--- /dev/null
+++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCallAsync.java
@@ -0,0 +1,586 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.communication.callingserver;
+
+import com.azure.communication.callingserver.implementation.ServerCallsImpl;
+import com.azure.communication.callingserver.implementation.converters.CallingServerErrorConverter;
+import com.azure.communication.callingserver.implementation.converters.InviteParticipantRequestConverter;
+import com.azure.communication.callingserver.implementation.converters.PlayAudioResultConverter;
+import com.azure.communication.callingserver.implementation.models.CommunicationErrorException;
+import com.azure.communication.callingserver.implementation.models.InviteParticipantsRequest;
+import com.azure.communication.callingserver.implementation.models.PlayAudioRequest;
+import com.azure.communication.callingserver.implementation.models.StartCallRecordingRequest;
+import com.azure.communication.callingserver.models.CallRecordingStateResult;
+import com.azure.communication.callingserver.models.PlayAudioOptions;
+import com.azure.communication.callingserver.models.PlayAudioResult;
+import com.azure.communication.callingserver.models.StartCallRecordingResult;
+import com.azure.communication.common.CommunicationIdentifier;
+import com.azure.core.annotation.ReturnType;
+import com.azure.core.annotation.ServiceMethod;
+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.logging.ClientLogger;
+import reactor.core.publisher.Mono;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.security.InvalidParameterException;
+import java.util.Objects;
+
+import static com.azure.core.util.FluxUtil.monoError;
+import static com.azure.core.util.FluxUtil.withContext;
+
+/**
+ * Async client that supports server call operations.
+ */
+public final class ServerCallAsync {
+ private final String serverCallId;
+ private final ServerCallsImpl serverCallInternal;
+ private final ClientLogger logger = new ClientLogger(ServerCallAsync.class);
+
+ ServerCallAsync(String serverCallId, ServerCallsImpl serverCallInternal) {
+ this.serverCallId = serverCallId;
+ this.serverCallInternal = serverCallInternal;
+ }
+
+ /**
+ * Get the server call id property
+ *
+ * @return the id value.
+ */
+ public String getServerCallId() {
+ return serverCallId;
+ }
+
+ /**
+ * Add a participant to the call.
+ *
+ * @param participant Invited participant.
+ * @param callBackUri callBackUri to get notifications.
+ * @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
+ * @return response for a successful add participant request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono addParticipant(
+ CommunicationIdentifier participant,
+ String callBackUri,
+ String alternateCallerId,
+ String operationContext) {
+ try {
+ Objects.requireNonNull(participant, "'participant' cannot be null.");
+ InviteParticipantsRequest request =
+ InviteParticipantRequestConverter.convert(participant,
+ alternateCallerId,
+ operationContext,
+ callBackUri);
+ return serverCallInternal.inviteParticipantsAsync(serverCallId, request)
+ .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
+ } catch (RuntimeException ex) {
+ return monoError(logger, ex);
+ }
+ }
+
+ /**
+ * Add a participant to the call.
+ *
+ * @param participant Invited participant.
+ * @param callBackUri callBackUri to get notifications.
+ * @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
+ * @return response for a successful add participant request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> addParticipantWithResponse(
+ CommunicationIdentifier participant,
+ String callBackUri,
+ String alternateCallerId,
+ String operationContext) {
+ return addParticipantWithResponse(participant,
+ callBackUri,
+ alternateCallerId,
+ operationContext,
+ null);
+ }
+
+ Mono> addParticipantWithResponse(
+ CommunicationIdentifier participant,
+ String callBackUri,
+ String alternateCallerId,
+ String operationContext,
+ Context context) {
+ try {
+ Objects.requireNonNull(participant, "'participant' cannot be null.");
+ InviteParticipantsRequest request =
+ InviteParticipantRequestConverter.convert(participant,
+ alternateCallerId,
+ operationContext,
+ callBackUri);
+ return withContext(contextValue -> {
+ contextValue = context == null ? contextValue : context;
+ return serverCallInternal
+ .inviteParticipantsWithResponseAsync(serverCallId, request, contextValue)
+ .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
+ });
+ } catch (RuntimeException ex) {
+ return monoError(logger, ex);
+ }
+ }
+
+ /**
+ * Remove a participant from the call.
+ *
+ * @param participantId Participant id.
+ * @return response for a successful remove participant request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono removeParticipant(String participantId) {
+ try {
+ return serverCallInternal.removeParticipantAsync(serverCallId, participantId)
+ .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
+ } catch (RuntimeException ex) {
+ return monoError(logger, ex);
+ }
+ }
+
+ /**
+ * Remove a participant from the call.
+ *
+ * @param participantId Participant id.
+ * @return response for a successful remove participant request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> removeParticipantWithResponse(String participantId) {
+ return removeParticipantWithResponse(participantId, null);
+ }
+
+ Mono> removeParticipantWithResponse(String participantId, Context context) {
+ try {
+ return withContext(contextValue -> {
+ contextValue = context == null ? contextValue : context;
+ return serverCallInternal
+ .removeParticipantWithResponseAsync(serverCallId, participantId, contextValue)
+ .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
+ });
+ } catch (RuntimeException ex) {
+ return monoError(logger, ex);
+ }
+ }
+
+ /**
+ * Start recording
+ *
+ * @param recordingStateCallbackUri The uri to send state change callbacks.
+ * @throws InvalidParameterException is recordingStateCallbackUri is absolute uri.
+ * @return response for a successful start recording request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono startRecording(String recordingStateCallbackUri) {
+ try {
+ Objects.requireNonNull(recordingStateCallbackUri, "'recordingStateCallbackUri' cannot be null.");
+ if (!Boolean.TRUE.equals(new URI(recordingStateCallbackUri).isAbsolute())) {
+ throw logger.logExceptionAsError(new InvalidParameterException("'recordingStateCallbackUri' has to be an absolute Uri"));
+ }
+ StartCallRecordingRequest request = new StartCallRecordingRequest();
+ request.setRecordingStateCallbackUri(recordingStateCallbackUri);
+ return serverCallInternal.startRecordingAsync(serverCallId, request)
+ .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
+ .flatMap(result -> Mono.just(new StartCallRecordingResult(result.getRecordingId())));
+ } catch (RuntimeException ex) {
+ return monoError(logger, ex);
+ } catch (URISyntaxException ex) {
+ return monoError(logger, new RuntimeException(ex.getMessage()));
+ }
+ }
+
+ /**
+ * Start recording
+ *
+ * @param recordingStateCallbackUri The uri to send state change callbacks.
+ * @throws InvalidParameterException is recordingStateCallbackUri is absolute uri.
+ * @return response for a successful start recording request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> startRecordingWithResponse(String recordingStateCallbackUri) {
+ return startRecordingWithResponse(recordingStateCallbackUri, null);
+ }
+
+ Mono> startRecordingWithResponse(
+ String recordingStateCallbackUri,
+ Context context) {
+ try {
+ Objects.requireNonNull(recordingStateCallbackUri, "'recordingStateCallbackUri' cannot be null.");
+ if (!Boolean.TRUE.equals(new URI(recordingStateCallbackUri).isAbsolute())) {
+ throw logger.logExceptionAsError(new InvalidParameterException("'recordingStateCallbackUri' has to be an absolute Uri"));
+ }
+ StartCallRecordingRequest request = new StartCallRecordingRequest();
+ request.setRecordingStateCallbackUri(recordingStateCallbackUri);
+ return withContext(contextValue -> {
+ contextValue = context == null ? contextValue : context;
+ return serverCallInternal
+ .startRecordingWithResponseAsync(serverCallId, request, contextValue)
+ .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
+ .map(response ->
+ new SimpleResponse<>(response, new StartCallRecordingResult(response.getValue().getRecordingId())));
+ });
+ } catch (RuntimeException ex) {
+ return monoError(logger, ex);
+ } catch (URISyntaxException ex) {
+ return monoError(logger, new RuntimeException(ex.getMessage()));
+ }
+ }
+
+ /**
+ * Stop recording
+ *
+ * @param recordingId The recording id to stop.
+ * @return response for a successful stop recording request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono stopRecording(String recordingId) {
+ try {
+ return serverCallInternal.stopRecordingAsync(serverCallId, recordingId)
+ .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
+ } catch (RuntimeException ex) {
+ return monoError(logger, ex);
+ }
+ }
+
+ /**
+ * Stop recording
+ *
+ * @param recordingId The recording id to stop.
+ * @return response for a successful stop recording request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> stopRecordingWithResponse(String recordingId) {
+ return stopRecordingWithResponse(recordingId, null);
+ }
+
+ Mono> stopRecordingWithResponse(String recordingId, Context context) {
+ try {
+ return withContext(contextValue -> {
+ contextValue = context == null ? contextValue : context;
+ return serverCallInternal
+ .stopRecordingWithResponseAsync(serverCallId, recordingId, contextValue)
+ .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
+ });
+ } catch (RuntimeException ex) {
+ return monoError(logger, ex);
+ }
+ }
+
+ /**
+ * Pause recording
+ *
+ * @param recordingId The recording id to stop.
+ * @return response for a successful pause recording request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono pauseRecording(String recordingId) {
+ try {
+ return serverCallInternal.pauseRecordingAsync(serverCallId, recordingId)
+ .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
+ } catch (RuntimeException ex) {
+ return monoError(logger, ex);
+ }
+ }
+
+ /**
+ * Pause recording
+ *
+ * @param recordingId The recording id to stop.
+ * @return response for a successful pause recording request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> pauseRecordingWithResponse(String recordingId) {
+ return pauseRecordingWithResponse(recordingId, null);
+ }
+
+ Mono> pauseRecordingWithResponse(String recordingId, Context context) {
+ try {
+ return withContext(contextValue -> {
+ contextValue = context == null ? contextValue : context;
+ return serverCallInternal
+ .pauseRecordingWithResponseAsync(serverCallId, recordingId, contextValue)
+ .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
+ });
+ } catch (RuntimeException ex) {
+ return monoError(logger, ex);
+ }
+ }
+
+ /**
+ * Resume recording
+ *
+ * @param recordingId The recording id to stop.
+ * @return response for a successful resume recording request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono resumeRecording(String recordingId) {
+ try {
+ return serverCallInternal.resumeRecordingAsync(serverCallId, recordingId)
+ .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
+ } catch (RuntimeException ex) {
+ return monoError(logger, ex);
+ }
+ }
+
+ /**
+ * Resume recording
+ *
+ * @param recordingId The recording id to stop.
+ * @return response for a successful resume recording request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> resumeRecordingWithResponse(String recordingId) {
+ return resumeRecordingWithResponse(recordingId, null);
+ }
+
+ Mono> resumeRecordingWithResponse(String recordingId, Context context) {
+ try {
+ return withContext(contextValue -> {
+ contextValue = context == null ? contextValue : context;
+ return serverCallInternal
+ .resumeRecordingWithResponseAsync(serverCallId, recordingId, contextValue)
+ .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
+ });
+ } catch (RuntimeException ex) {
+ return monoError(logger, ex);
+ }
+ }
+
+ /**
+ * Get recording state
+ *
+ * @param recordingId The recording id to stop.
+ * @return response for a successful get recording state request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono getRecordingState(String recordingId) {
+ try {
+ return serverCallInternal.recordingStateAsync(serverCallId, recordingId)
+ .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
+ .flatMap(result -> Mono.just(new CallRecordingStateResult(result.getRecordingState())));
+ } catch (RuntimeException ex) {
+ return monoError(logger, ex);
+ }
+ }
+
+ /**
+ * Get recording state
+ *
+ * @param recordingId The recording id to stop.
+ * @return response for a successful get recording state request.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> getRecordingStateWithResponse(String recordingId) {
+ return getRecordingStateWithResponse(recordingId, null);
+ }
+
+ Mono> getRecordingStateWithResponse(String recordingId, Context context) {
+ try {
+ return withContext(contextValue -> {
+ contextValue = context == null ? contextValue : context;
+ return serverCallInternal
+ .recordingStateWithResponseAsync(serverCallId, recordingId, contextValue)
+ .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
+ .map(response ->
+ new SimpleResponse<>(response, new CallRecordingStateResult(response.getValue().getRecordingState())));
+ });
+ } catch (RuntimeException ex) {
+ return monoError(logger, ex);
+ }
+ }
+
+ /**
+ * Play audio in a call.
+ *
+ * @param audioFileUri The media resource uri of the play audio request. Currently only Wave file (.wav) format
+ * audio prompts are supported. More specifically, the audio content in the wave file must
+ * be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate.
+ * @param audioFileId Tne id for the media in the AudioFileUri, using which we cache the media resource.
+ * @param callbackUri The callback Uri to receive PlayAudio status notifications.
+ * @param operationContext The value to identify context of the operation. This is used to co-relate other
+ * communications related to this operation
+ * @return the response payload for play audio operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono playAudio(
+ String audioFileUri,
+ String audioFileId,
+ String callbackUri,
+ String operationContext) {
+ return playAudioInternal(audioFileUri, audioFileId, callbackUri, operationContext);
+ }
+
+ /**
+ * Play audio in a call.
+ *
+ * @param audioFileUri The media resource uri of the play audio request. Currently only Wave file (.wav) format
+ * audio prompts are supported. More specifically, the audio content in the wave file must
+ * be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate.
+ * @param playAudioOptions Options for play audio.
+ * @return the response payload for play audio operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono playAudio(String audioFileUri, PlayAudioOptions playAudioOptions) {
+ return playAudioInternal(audioFileUri, playAudioOptions);
+ }
+
+ Mono playAudioInternal(
+ String audioFileUri,
+ String audioFileId,
+ String callbackUri,
+ String operationContext) {
+ try {
+ Objects.requireNonNull(audioFileUri, "'audioFileUri' cannot be null.");
+
+ //Currently we do not support loop on the audio media for out-call, thus setting the loop to false
+ PlayAudioRequest playAudioRequest =
+ new PlayAudioRequest()
+ .setAudioFileUri(audioFileUri)
+ .setLoop(false)
+ .setAudioFileId(audioFileId)
+ .setOperationContext(operationContext)
+ .setCallbackUri(callbackUri);
+ return playAudioInternal(playAudioRequest);
+ } catch (RuntimeException ex) {
+ return monoError(logger, ex);
+ }
+ }
+
+ Mono playAudioInternal(String audioFileUri, PlayAudioOptions playAudioOptions) {
+ try {
+ Objects.requireNonNull(audioFileUri, "'audioFileUri' cannot be null.");
+
+ //Currently we do not support loop on the audio media for out-call, thus setting the loop to false
+ PlayAudioRequest request = new PlayAudioRequest().setAudioFileUri(audioFileUri);
+ if (playAudioOptions != null) {
+ request
+ .setLoop(false)
+ .setOperationContext(playAudioOptions.getOperationContext())
+ .setAudioFileId(playAudioOptions.getAudioFileId())
+ .setCallbackUri(playAudioOptions.getCallbackUri());
+ }
+ return playAudioInternal(request);
+ } catch (RuntimeException ex) {
+ return monoError(logger, ex);
+ }
+
+ }
+
+ Mono playAudioInternal(PlayAudioRequest playAudioRequest) {
+ try {
+ return serverCallInternal.playAudioAsync(serverCallId, playAudioRequest)
+ .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
+ .flatMap(result -> Mono.just(PlayAudioResultConverter.convert(result)));
+ } catch (RuntimeException ex) {
+ return monoError(logger, ex);
+ }
+ }
+
+ /**
+ * Play audio in a call.
+ *
+ * @param audioFileUri The media resource uri of the play audio request. Currently only Wave file (.wav) format
+ * audio prompts are supported. More specifically, the audio content in the wave file must
+ * be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate.
+ * @param audioFileId Tne id for the media in the AudioFileUri, using which we cache the media resource.
+ * @param callbackUri The callback Uri to receive PlayAudio status notifications.
+ * @param operationContext The value to identify context of the operation. This is used to co-relate other
+ * communications related to this operation
+ * @return the response payload for play audio operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> playAudioWithResponse(
+ String audioFileUri,
+ String audioFileId,
+ String callbackUri,
+ String operationContext) {
+ return playAudioWithResponseInternal(audioFileUri, audioFileId, callbackUri, operationContext, null);
+ }
+
+ /**
+ * Play audio in a call.
+ *
+ * @param audioFileUri The media resource uri of the play audio request. Currently only Wave file (.wav) format
+ * audio prompts are supported. More specifically, the audio content in the wave file must
+ * be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate.
+ * @param playAudioOptions Options for play audio.
+ * @return the response payload for play audio operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> playAudioWithResponse(
+ String audioFileUri,
+ PlayAudioOptions playAudioOptions) {
+ return playAudioWithResponseInternal(audioFileUri, playAudioOptions, null);
+ }
+
+ Mono> playAudioWithResponseInternal(
+ String audioFileUri,
+ String audioFileId,
+ String callbackUri,
+ String operationContext,
+ Context context) {
+ try {
+ Objects.requireNonNull(audioFileUri, "'audioFileUri' cannot be null.");
+
+ //Currently we do not support loop on the audio media for out-call, thus setting the loop to false
+ PlayAudioRequest playAudioRequest =
+ new PlayAudioRequest()
+ .setAudioFileUri(audioFileUri)
+ .setLoop(false)
+ .setAudioFileId(audioFileId)
+ .setOperationContext(operationContext)
+ .setCallbackUri(callbackUri);
+ return playAudioWithResponse(playAudioRequest, context);
+ } catch (RuntimeException ex) {
+ return monoError(logger, ex);
+ }
+
+
+ }
+
+ Mono> playAudioWithResponseInternal(
+ String audioFileUri,
+ PlayAudioOptions playAudioOptions,
+ Context context) {
+ try {
+ Objects.requireNonNull(audioFileUri, "'audioFileUri' cannot be null.");
+
+ //Currently we do not support loop on the audio media for out-call, thus setting the loop to false
+ PlayAudioRequest request = new PlayAudioRequest().setAudioFileUri(audioFileUri);
+ if (playAudioOptions != null) {
+ request
+ .setLoop(false)
+ .setOperationContext(playAudioOptions.getOperationContext())
+ .setAudioFileId(playAudioOptions.getAudioFileId())
+ .setCallbackUri(playAudioOptions.getCallbackUri());
+ }
+ return playAudioWithResponse(request, context);
+ } catch (RuntimeException ex) {
+ return monoError(logger, ex);
+ }
+ }
+
+ Mono> playAudioWithResponse(PlayAudioRequest playAudioRequest, Context context) {
+ try {
+ return withContext(contextValue -> {
+ contextValue = context == null ? contextValue : context;
+ return serverCallInternal
+ .playAudioWithResponseAsync(serverCallId, playAudioRequest, contextValue)
+ .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
+ .map(response ->
+ new SimpleResponse<>(response, PlayAudioResultConverter.convert(response.getValue())));
+ });
+ } catch (RuntimeException ex) {
+ return monoError(logger, ex);
+ }
+ }
+}
+
diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/AzureCommunicationCallingServerServiceImpl.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/AzureCommunicationCallingServerServiceImpl.java
new file mode 100644
index 0000000000000..8e504c2dabb94
--- /dev/null
+++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/AzureCommunicationCallingServerServiceImpl.java
@@ -0,0 +1,133 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+
+package com.azure.communication.callingserver.implementation;
+
+import com.azure.core.http.HttpPipeline;
+import com.azure.core.http.HttpPipelineBuilder;
+import com.azure.core.http.policy.CookiePolicy;
+import com.azure.core.http.policy.RetryPolicy;
+import com.azure.core.http.policy.UserAgentPolicy;
+import com.azure.core.util.serializer.JacksonAdapter;
+import com.azure.core.util.serializer.SerializerAdapter;
+
+/** Initializes a new instance of the AzureCommunicationCallingServerService type. */
+public final class AzureCommunicationCallingServerServiceImpl {
+ /** The endpoint of the Azure Communication resource. */
+ private final String endpoint;
+
+ /**
+ * Gets The endpoint of the Azure Communication resource.
+ *
+ * @return the endpoint value.
+ */
+ public String getEndpoint() {
+ return this.endpoint;
+ }
+
+ /** Api Version. */
+ private final String apiVersion;
+
+ /**
+ * Gets Api Version.
+ *
+ * @return the apiVersion value.
+ */
+ public String getApiVersion() {
+ return this.apiVersion;
+ }
+
+ /** The HTTP pipeline to send requests through. */
+ private final HttpPipeline httpPipeline;
+
+ /**
+ * Gets The HTTP pipeline to send requests through.
+ *
+ * @return the httpPipeline value.
+ */
+ public HttpPipeline getHttpPipeline() {
+ return this.httpPipeline;
+ }
+
+ /** The serializer to serialize an object into a string. */
+ private final SerializerAdapter serializerAdapter;
+
+ /**
+ * Gets The serializer to serialize an object into a string.
+ *
+ * @return the serializerAdapter value.
+ */
+ public SerializerAdapter getSerializerAdapter() {
+ return this.serializerAdapter;
+ }
+
+ /** The CallConnectionsImpl object to access its operations. */
+ private final CallConnectionsImpl callConnections;
+
+ /**
+ * Gets the CallConnectionsImpl object to access its operations.
+ *
+ * @return the CallConnectionsImpl object.
+ */
+ public CallConnectionsImpl getCallConnections() {
+ return this.callConnections;
+ }
+
+ /** The ServerCallsImpl object to access its operations. */
+ private final ServerCallsImpl serverCalls;
+
+ /**
+ * Gets the ServerCallsImpl object to access its operations.
+ *
+ * @return the ServerCallsImpl object.
+ */
+ public ServerCallsImpl getServerCalls() {
+ return this.serverCalls;
+ }
+
+ /**
+ * Initializes an instance of AzureCommunicationCallingServerService client.
+ *
+ * @param endpoint The endpoint of the Azure Communication resource.
+ * @param apiVersion Api Version.
+ */
+ AzureCommunicationCallingServerServiceImpl(String endpoint, String apiVersion) {
+ this(
+ new HttpPipelineBuilder()
+ .policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy())
+ .build(),
+ JacksonAdapter.createDefaultSerializerAdapter(),
+ endpoint,
+ apiVersion);
+ }
+
+ /**
+ * Initializes an instance of AzureCommunicationCallingServerService client.
+ *
+ * @param httpPipeline The HTTP pipeline to send requests through.
+ * @param endpoint The endpoint of the Azure Communication resource.
+ * @param apiVersion Api Version.
+ */
+ AzureCommunicationCallingServerServiceImpl(HttpPipeline httpPipeline, String endpoint, String apiVersion) {
+ this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, apiVersion);
+ }
+
+ /**
+ * Initializes an instance of AzureCommunicationCallingServerService client.
+ *
+ * @param httpPipeline The HTTP pipeline to send requests through.
+ * @param serializerAdapter The serializer to serialize an object into a string.
+ * @param endpoint The endpoint of the Azure Communication resource.
+ * @param apiVersion Api Version.
+ */
+ AzureCommunicationCallingServerServiceImpl(
+ HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, String apiVersion) {
+ this.httpPipeline = httpPipeline;
+ this.serializerAdapter = serializerAdapter;
+ this.endpoint = endpoint;
+ this.apiVersion = apiVersion;
+ this.callConnections = new CallConnectionsImpl(this);
+ this.serverCalls = new ServerCallsImpl(this);
+ }
+}
diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/AzureCommunicationCallingServerServiceImplBuilder.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/AzureCommunicationCallingServerServiceImplBuilder.java
new file mode 100644
index 0000000000000..0af415c24b57a
--- /dev/null
+++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/AzureCommunicationCallingServerServiceImplBuilder.java
@@ -0,0 +1,230 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+
+package com.azure.communication.callingserver.implementation;
+
+import com.azure.core.annotation.ServiceClientBuilder;
+import com.azure.core.http.HttpClient;
+import com.azure.core.http.HttpPipeline;
+import com.azure.core.http.HttpPipelineBuilder;
+import com.azure.core.http.policy.CookiePolicy;
+import com.azure.core.http.policy.HttpLogOptions;
+import com.azure.core.http.policy.HttpLoggingPolicy;
+import com.azure.core.http.policy.HttpPipelinePolicy;
+import com.azure.core.http.policy.HttpPolicyProviders;
+import com.azure.core.http.policy.RetryPolicy;
+import com.azure.core.http.policy.UserAgentPolicy;
+import com.azure.core.util.Configuration;
+import com.azure.core.util.serializer.JacksonAdapter;
+import com.azure.core.util.serializer.SerializerAdapter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/** A builder for creating a new instance of the AzureCommunicationCallingServerService type. */
+@ServiceClientBuilder(serviceClients = {AzureCommunicationCallingServerServiceImpl.class})
+public final class AzureCommunicationCallingServerServiceImplBuilder {
+ private static final String SDK_NAME = "name";
+
+ private static final String SDK_VERSION = "version";
+
+ private final Map properties = new HashMap<>();
+
+ /** Create an instance of the AzureCommunicationCallingServerServiceImplBuilder. */
+ public AzureCommunicationCallingServerServiceImplBuilder() {
+ this.pipelinePolicies = new ArrayList<>();
+ }
+
+ /*
+ * The endpoint of the Azure Communication resource.
+ */
+ private String endpoint;
+
+ /**
+ * Sets The endpoint of the Azure Communication resource.
+ *
+ * @param endpoint the endpoint value.
+ * @return the AzureCommunicationCallingServerServiceImplBuilder.
+ */
+ public AzureCommunicationCallingServerServiceImplBuilder endpoint(String endpoint) {
+ this.endpoint = endpoint;
+ return this;
+ }
+
+ /*
+ * Api Version
+ */
+ private String apiVersion;
+
+ /**
+ * Sets Api Version.
+ *
+ * @param apiVersion the apiVersion value.
+ * @return the AzureCommunicationCallingServerServiceImplBuilder.
+ */
+ public AzureCommunicationCallingServerServiceImplBuilder apiVersion(String apiVersion) {
+ this.apiVersion = apiVersion;
+ return this;
+ }
+
+ /*
+ * The HTTP pipeline to send requests through
+ */
+ private HttpPipeline pipeline;
+
+ /**
+ * Sets The HTTP pipeline to send requests through.
+ *
+ * @param pipeline the pipeline value.
+ * @return the AzureCommunicationCallingServerServiceImplBuilder.
+ */
+ public AzureCommunicationCallingServerServiceImplBuilder pipeline(HttpPipeline pipeline) {
+ this.pipeline = pipeline;
+ return this;
+ }
+
+ /*
+ * The serializer to serialize an object into a string
+ */
+ private SerializerAdapter serializerAdapter;
+
+ /**
+ * Sets The serializer to serialize an object into a string.
+ *
+ * @param serializerAdapter the serializerAdapter value.
+ * @return the AzureCommunicationCallingServerServiceImplBuilder.
+ */
+ public AzureCommunicationCallingServerServiceImplBuilder serializerAdapter(SerializerAdapter serializerAdapter) {
+ this.serializerAdapter = serializerAdapter;
+ return this;
+ }
+
+ /*
+ * The HTTP client used to send the request.
+ */
+ private HttpClient httpClient;
+
+ /**
+ * Sets The HTTP client used to send the request.
+ *
+ * @param httpClient the httpClient value.
+ * @return the AzureCommunicationCallingServerServiceImplBuilder.
+ */
+ public AzureCommunicationCallingServerServiceImplBuilder httpClient(HttpClient httpClient) {
+ this.httpClient = httpClient;
+ return this;
+ }
+
+ /*
+ * The configuration store that is used during construction of the service
+ * client.
+ */
+ private Configuration configuration;
+
+ /**
+ * Sets The configuration store that is used during construction of the service client.
+ *
+ * @param configuration the configuration value.
+ * @return the AzureCommunicationCallingServerServiceImplBuilder.
+ */
+ public AzureCommunicationCallingServerServiceImplBuilder configuration(Configuration configuration) {
+ this.configuration = configuration;
+ return this;
+ }
+
+ /*
+ * The logging configuration for HTTP requests and responses.
+ */
+ private HttpLogOptions httpLogOptions;
+
+ /**
+ * Sets The logging configuration for HTTP requests and responses.
+ *
+ * @param httpLogOptions the httpLogOptions value.
+ * @return the AzureCommunicationCallingServerServiceImplBuilder.
+ */
+ public AzureCommunicationCallingServerServiceImplBuilder httpLogOptions(HttpLogOptions httpLogOptions) {
+ this.httpLogOptions = httpLogOptions;
+ return this;
+ }
+
+ /*
+ * The retry policy that will attempt to retry failed requests, if
+ * applicable.
+ */
+ private RetryPolicy retryPolicy;
+
+ /**
+ * Sets The retry policy that will attempt to retry failed requests, if applicable.
+ *
+ * @param retryPolicy the retryPolicy value.
+ * @return the AzureCommunicationCallingServerServiceImplBuilder.
+ */
+ public AzureCommunicationCallingServerServiceImplBuilder retryPolicy(RetryPolicy retryPolicy) {
+ this.retryPolicy = retryPolicy;
+ return this;
+ }
+
+ /*
+ * The list of Http pipeline policies to add.
+ */
+ private final List pipelinePolicies;
+
+ /**
+ * Adds a custom Http pipeline policy.
+ *
+ * @param customPolicy The custom Http pipeline policy to add.
+ * @return the AzureCommunicationCallingServerServiceImplBuilder.
+ */
+ public AzureCommunicationCallingServerServiceImplBuilder addPolicy(HttpPipelinePolicy customPolicy) {
+ pipelinePolicies.add(customPolicy);
+ return this;
+ }
+
+ /**
+ * Builds an instance of AzureCommunicationCallingServerServiceImpl with the provided parameters.
+ *
+ * @return an instance of AzureCommunicationCallingServerServiceImpl.
+ */
+ public AzureCommunicationCallingServerServiceImpl buildClient() {
+ if (apiVersion == null) {
+ this.apiVersion = "2021-06-15-preview";
+ }
+ if (pipeline == null) {
+ this.pipeline = createHttpPipeline();
+ }
+ if (serializerAdapter == null) {
+ this.serializerAdapter = JacksonAdapter.createDefaultSerializerAdapter();
+ }
+ AzureCommunicationCallingServerServiceImpl client =
+ new AzureCommunicationCallingServerServiceImpl(pipeline, serializerAdapter, endpoint, apiVersion);
+ return client;
+ }
+
+ private HttpPipeline createHttpPipeline() {
+ Configuration buildConfiguration =
+ (configuration == null) ? Configuration.getGlobalConfiguration() : configuration;
+ if (httpLogOptions == null) {
+ httpLogOptions = new HttpLogOptions();
+ }
+ List policies = new ArrayList<>();
+ String clientName = properties.getOrDefault(SDK_NAME, "UnknownName");
+ String clientVersion = properties.getOrDefault(SDK_VERSION, "UnknownVersion");
+ policies.add(
+ new UserAgentPolicy(httpLogOptions.getApplicationId(), clientName, clientVersion, buildConfiguration));
+ HttpPolicyProviders.addBeforeRetryPolicies(policies);
+ policies.add(retryPolicy == null ? new RetryPolicy() : retryPolicy);
+ policies.add(new CookiePolicy());
+ policies.addAll(this.pipelinePolicies);
+ HttpPolicyProviders.addAfterRetryPolicies(policies);
+ policies.add(new HttpLoggingPolicy(httpLogOptions));
+ HttpPipeline httpPipeline =
+ new HttpPipelineBuilder()
+ .policies(policies.toArray(new HttpPipelinePolicy[0]))
+ .httpClient(httpClient)
+ .build();
+ return httpPipeline;
+ }
+}
diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/CallConnectionsImpl.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/CallConnectionsImpl.java
new file mode 100644
index 0000000000000..7593a6c1d74aa
--- /dev/null
+++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/CallConnectionsImpl.java
@@ -0,0 +1,812 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+
+package com.azure.communication.callingserver.implementation;
+
+import com.azure.communication.callingserver.implementation.models.CancelAllMediaOperationsRequest;
+import com.azure.communication.callingserver.implementation.models.CancelAllMediaOperationsResultInternal;
+import com.azure.communication.callingserver.implementation.models.CommunicationErrorException;
+import com.azure.communication.callingserver.implementation.models.CreateCallRequest;
+import com.azure.communication.callingserver.implementation.models.CreateCallResultInternal;
+import com.azure.communication.callingserver.implementation.models.InviteParticipantsRequest;
+import com.azure.communication.callingserver.implementation.models.PlayAudioRequest;
+import com.azure.communication.callingserver.implementation.models.PlayAudioResultInternal;
+import com.azure.core.annotation.BodyParam;
+import com.azure.core.annotation.Delete;
+import com.azure.core.annotation.ExpectedResponses;
+import com.azure.core.annotation.HeaderParam;
+import com.azure.core.annotation.Host;
+import com.azure.core.annotation.HostParam;
+import com.azure.core.annotation.PathParam;
+import com.azure.core.annotation.Post;
+import com.azure.core.annotation.QueryParam;
+import com.azure.core.annotation.ReturnType;
+import com.azure.core.annotation.ServiceInterface;
+import com.azure.core.annotation.ServiceMethod;
+import com.azure.core.annotation.UnexpectedResponseExceptionType;
+import com.azure.core.http.rest.Response;
+import com.azure.core.http.rest.RestProxy;
+import com.azure.core.util.Context;
+import com.azure.core.util.FluxUtil;
+import reactor.core.publisher.Mono;
+
+/** An instance of this class provides access to all the operations defined in CallConnections. */
+public final class CallConnectionsImpl {
+ /** The proxy service used to perform REST calls. */
+ private final CallConnectionsService service;
+
+ /** The service client containing this operation class. */
+ private final AzureCommunicationCallingServerServiceImpl client;
+
+ /**
+ * Initializes an instance of CallConnectionsImpl.
+ *
+ * @param client the instance of the service client containing this operation class.
+ */
+ CallConnectionsImpl(AzureCommunicationCallingServerServiceImpl client) {
+ this.service =
+ RestProxy.create(CallConnectionsService.class, client.getHttpPipeline(), client.getSerializerAdapter());
+ this.client = client;
+ }
+
+ /**
+ * The interface defining all the services for AzureCommunicationCallingServerServiceCallConnections to be used by
+ * the proxy service to perform REST calls.
+ */
+ @Host("{endpoint}")
+ @ServiceInterface(name = "AzureCommunicationCa")
+ private interface CallConnectionsService {
+ @Post("/calling/callConnections")
+ @ExpectedResponses({201})
+ @UnexpectedResponseExceptionType(CommunicationErrorException.class)
+ Mono> createCall(
+ @HostParam("endpoint") String endpoint,
+ @QueryParam("api-version") String apiVersion,
+ @BodyParam("application/json") CreateCallRequest callRequest,
+ @HeaderParam("Accept") String accept,
+ Context context);
+
+ @Post("/calling/callConnections/{callConnectionId}/:hangup")
+ @ExpectedResponses({202})
+ @UnexpectedResponseExceptionType(CommunicationErrorException.class)
+ Mono> hangupCall(
+ @HostParam("endpoint") String endpoint,
+ @PathParam("callConnectionId") String callConnectionId,
+ @QueryParam("api-version") String apiVersion,
+ @HeaderParam("Accept") String accept,
+ Context context);
+
+ @Post("/calling/callConnections/{callConnectionId}/:playAudio")
+ @ExpectedResponses({202})
+ @UnexpectedResponseExceptionType(CommunicationErrorException.class)
+ Mono> playAudio(
+ @HostParam("endpoint") String endpoint,
+ @PathParam("callConnectionId") String callConnectionId,
+ @QueryParam("api-version") String apiVersion,
+ @BodyParam("application/json") PlayAudioRequest request,
+ @HeaderParam("Accept") String accept,
+ Context context);
+
+ @Post("/calling/callConnections/{callConnectionId}/:cancelAllMediaOperations")
+ @ExpectedResponses({200})
+ @UnexpectedResponseExceptionType(CommunicationErrorException.class)
+ Mono> cancelAllMediaOperations(
+ @HostParam("endpoint") String endpoint,
+ @PathParam("callConnectionId") String callConnectionId,
+ @QueryParam("api-version") String apiVersion,
+ @BodyParam("application/json") CancelAllMediaOperationsRequest cancelAllMediaOperationRequest,
+ @HeaderParam("Accept") String accept,
+ Context context);
+
+ @Post("/calling/callConnections/{callConnectionId}/participants")
+ @ExpectedResponses({202})
+ @UnexpectedResponseExceptionType(CommunicationErrorException.class)
+ Mono> inviteParticipants(
+ @HostParam("endpoint") String endpoint,
+ @PathParam("callConnectionId") String callConnectionId,
+ @QueryParam("api-version") String apiVersion,
+ @BodyParam("application/json") InviteParticipantsRequest inviteParticipantsRequest,
+ @HeaderParam("Accept") String accept,
+ Context context);
+
+ @Delete("/calling/callConnections/{callConnectionId}/participants/{participantId}")
+ @ExpectedResponses({202})
+ @UnexpectedResponseExceptionType(CommunicationErrorException.class)
+ Mono> removeParticipant(
+ @HostParam("endpoint") String endpoint,
+ @PathParam("callConnectionId") String callConnectionId,
+ @PathParam("participantId") String participantId,
+ @QueryParam("api-version") String apiVersion,
+ @HeaderParam("Accept") String accept,
+ Context context);
+ }
+
+ /**
+ * Create a new call.
+ *
+ * @param callRequest Create call request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of the create call operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> createCallWithResponseAsync(CreateCallRequest callRequest) {
+ final String accept = "application/json";
+ return FluxUtil.withContext(
+ context ->
+ service.createCall(
+ this.client.getEndpoint(), this.client.getApiVersion(), callRequest, accept, context));
+ }
+
+ /**
+ * Create a new call.
+ *
+ * @param callRequest Create call 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of the create call operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> createCallWithResponseAsync(
+ CreateCallRequest callRequest, Context context) {
+ final String accept = "application/json";
+ return service.createCall(this.client.getEndpoint(), this.client.getApiVersion(), callRequest, accept, context);
+ }
+
+ /**
+ * Create a new call.
+ *
+ * @param callRequest Create call request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of the create call operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono createCallAsync(CreateCallRequest callRequest) {
+ return createCallWithResponseAsync(callRequest)
+ .flatMap(
+ (Response res) -> {
+ if (res.getValue() != null) {
+ return Mono.just(res.getValue());
+ } else {
+ return Mono.empty();
+ }
+ });
+ }
+
+ /**
+ * Create a new call.
+ *
+ * @param callRequest Create call 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of the create call operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono createCallAsync(CreateCallRequest callRequest, Context context) {
+ return createCallWithResponseAsync(callRequest, context)
+ .flatMap(
+ (Response res) -> {
+ if (res.getValue() != null) {
+ return Mono.just(res.getValue());
+ } else {
+ return Mono.empty();
+ }
+ });
+ }
+
+ /**
+ * Create a new call.
+ *
+ * @param callRequest Create call request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of the create call operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public CreateCallResultInternal createCall(CreateCallRequest callRequest) {
+ return createCallAsync(callRequest).block();
+ }
+
+ /**
+ * Create a new call.
+ *
+ * @param callRequest Create call 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of the create call operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response createCallWithResponse(CreateCallRequest callRequest, Context context) {
+ return createCallWithResponseAsync(callRequest, context).block();
+ }
+
+ /**
+ * Hangup a call.
+ *
+ * @param callConnectionId The call connection id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> hangupCallWithResponseAsync(String callConnectionId) {
+ final String accept = "application/json";
+ return FluxUtil.withContext(
+ context ->
+ service.hangupCall(
+ this.client.getEndpoint(),
+ callConnectionId,
+ this.client.getApiVersion(),
+ accept,
+ context));
+ }
+
+ /**
+ * Hangup a call.
+ *
+ * @param callConnectionId The call connection id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> hangupCallWithResponseAsync(String callConnectionId, Context context) {
+ final String accept = "application/json";
+ return service.hangupCall(
+ this.client.getEndpoint(), callConnectionId, this.client.getApiVersion(), accept, context);
+ }
+
+ /**
+ * Hangup a call.
+ *
+ * @param callConnectionId The call connection id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono hangupCallAsync(String callConnectionId) {
+ return hangupCallWithResponseAsync(callConnectionId).flatMap((Response res) -> Mono.empty());
+ }
+
+ /**
+ * Hangup a call.
+ *
+ * @param callConnectionId The call connection id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono hangupCallAsync(String callConnectionId, Context context) {
+ return hangupCallWithResponseAsync(callConnectionId, context).flatMap((Response res) -> Mono.empty());
+ }
+
+ /**
+ * Hangup a call.
+ *
+ * @param callConnectionId The call connection id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public void hangupCall(String callConnectionId) {
+ hangupCallAsync(callConnectionId).block();
+ }
+
+ /**
+ * Hangup a call.
+ *
+ * @param callConnectionId The call connection id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response hangupCallWithResponse(String callConnectionId, Context context) {
+ return hangupCallWithResponseAsync(callConnectionId, context).block();
+ }
+
+ /**
+ * Play audio in a call.
+ *
+ * @param callConnectionId The call connection id.
+ * @param request Play audio request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload for play audio operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> playAudioWithResponseAsync(
+ String callConnectionId, PlayAudioRequest request) {
+ final String accept = "application/json";
+ return FluxUtil.withContext(
+ context ->
+ service.playAudio(
+ this.client.getEndpoint(),
+ callConnectionId,
+ this.client.getApiVersion(),
+ request,
+ accept,
+ context));
+ }
+
+ /**
+ * Play audio in a call.
+ *
+ * @param callConnectionId The call connection id.
+ * @param request Play audio 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload for play audio operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> playAudioWithResponseAsync(
+ String callConnectionId, PlayAudioRequest request, Context context) {
+ final String accept = "application/json";
+ return service.playAudio(
+ this.client.getEndpoint(), callConnectionId, this.client.getApiVersion(), request, accept, context);
+ }
+
+ /**
+ * Play audio in a call.
+ *
+ * @param callConnectionId The call connection id.
+ * @param request Play audio request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload for play audio operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono playAudioAsync(String callConnectionId, PlayAudioRequest request) {
+ return playAudioWithResponseAsync(callConnectionId, request)
+ .flatMap(
+ (Response res) -> {
+ if (res.getValue() != null) {
+ return Mono.just(res.getValue());
+ } else {
+ return Mono.empty();
+ }
+ });
+ }
+
+ /**
+ * Play audio in a call.
+ *
+ * @param callConnectionId The call connection id.
+ * @param request Play audio 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload for play audio operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono playAudioAsync(
+ String callConnectionId, PlayAudioRequest request, Context context) {
+ return playAudioWithResponseAsync(callConnectionId, request, context)
+ .flatMap(
+ (Response res) -> {
+ if (res.getValue() != null) {
+ return Mono.just(res.getValue());
+ } else {
+ return Mono.empty();
+ }
+ });
+ }
+
+ /**
+ * Play audio in a call.
+ *
+ * @param callConnectionId The call connection id.
+ * @param request Play audio request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload for play audio operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public PlayAudioResultInternal playAudio(String callConnectionId, PlayAudioRequest request) {
+ return playAudioAsync(callConnectionId, request).block();
+ }
+
+ /**
+ * Play audio in a call.
+ *
+ * @param callConnectionId The call connection id.
+ * @param request Play audio 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload for play audio operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response playAudioWithResponse(
+ String callConnectionId, PlayAudioRequest request, Context context) {
+ return playAudioWithResponseAsync(callConnectionId, request, context).block();
+ }
+
+ /**
+ * Cancel all media operations.
+ *
+ * @param callConnectionId The call connection id.
+ * @param cancelAllMediaOperationRequest The cancel all media operations context.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of the cancel all media operations.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> cancelAllMediaOperationsWithResponseAsync(
+ String callConnectionId, CancelAllMediaOperationsRequest cancelAllMediaOperationRequest) {
+ final String accept = "application/json";
+ return FluxUtil.withContext(
+ context ->
+ service.cancelAllMediaOperations(
+ this.client.getEndpoint(),
+ callConnectionId,
+ this.client.getApiVersion(),
+ cancelAllMediaOperationRequest,
+ accept,
+ context));
+ }
+
+ /**
+ * Cancel all media operations.
+ *
+ * @param callConnectionId The call connection id.
+ * @param cancelAllMediaOperationRequest The cancel all media operations context.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of the cancel all media operations.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> cancelAllMediaOperationsWithResponseAsync(
+ String callConnectionId, CancelAllMediaOperationsRequest cancelAllMediaOperationRequest, Context context) {
+ final String accept = "application/json";
+ return service.cancelAllMediaOperations(
+ this.client.getEndpoint(),
+ callConnectionId,
+ this.client.getApiVersion(),
+ cancelAllMediaOperationRequest,
+ accept,
+ context);
+ }
+
+ /**
+ * Cancel all media operations.
+ *
+ * @param callConnectionId The call connection id.
+ * @param cancelAllMediaOperationRequest The cancel all media operations context.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of the cancel all media operations.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono cancelAllMediaOperationsAsync(
+ String callConnectionId, CancelAllMediaOperationsRequest cancelAllMediaOperationRequest) {
+ return cancelAllMediaOperationsWithResponseAsync(callConnectionId, cancelAllMediaOperationRequest)
+ .flatMap(
+ (Response res) -> {
+ if (res.getValue() != null) {
+ return Mono.just(res.getValue());
+ } else {
+ return Mono.empty();
+ }
+ });
+ }
+
+ /**
+ * Cancel all media operations.
+ *
+ * @param callConnectionId The call connection id.
+ * @param cancelAllMediaOperationRequest The cancel all media operations context.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of the cancel all media operations.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono cancelAllMediaOperationsAsync(
+ String callConnectionId, CancelAllMediaOperationsRequest cancelAllMediaOperationRequest, Context context) {
+ return cancelAllMediaOperationsWithResponseAsync(callConnectionId, cancelAllMediaOperationRequest, context)
+ .flatMap(
+ (Response res) -> {
+ if (res.getValue() != null) {
+ return Mono.just(res.getValue());
+ } else {
+ return Mono.empty();
+ }
+ });
+ }
+
+ /**
+ * Cancel all media operations.
+ *
+ * @param callConnectionId The call connection id.
+ * @param cancelAllMediaOperationRequest The cancel all media operations context.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of the cancel all media operations.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public CancelAllMediaOperationsResultInternal cancelAllMediaOperations(
+ String callConnectionId, CancelAllMediaOperationsRequest cancelAllMediaOperationRequest) {
+ return cancelAllMediaOperationsAsync(callConnectionId, cancelAllMediaOperationRequest).block();
+ }
+
+ /**
+ * Cancel all media operations.
+ *
+ * @param callConnectionId The call connection id.
+ * @param cancelAllMediaOperationRequest The cancel all media operations context.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of the cancel all media operations.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response cancelAllMediaOperationsWithResponse(
+ String callConnectionId, CancelAllMediaOperationsRequest cancelAllMediaOperationRequest, Context context) {
+ return cancelAllMediaOperationsWithResponseAsync(callConnectionId, cancelAllMediaOperationRequest, context)
+ .block();
+ }
+
+ /**
+ * Invite participants to the call.
+ *
+ * @param callConnectionId The call connection id.
+ * @param inviteParticipantsRequest Invite participant request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> inviteParticipantsWithResponseAsync(
+ String callConnectionId, InviteParticipantsRequest inviteParticipantsRequest) {
+ final String accept = "application/json";
+ return FluxUtil.withContext(
+ context ->
+ service.inviteParticipants(
+ this.client.getEndpoint(),
+ callConnectionId,
+ this.client.getApiVersion(),
+ inviteParticipantsRequest,
+ accept,
+ context));
+ }
+
+ /**
+ * Invite participants to the call.
+ *
+ * @param callConnectionId The call connection id.
+ * @param inviteParticipantsRequest Invite participant 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> inviteParticipantsWithResponseAsync(
+ String callConnectionId, InviteParticipantsRequest inviteParticipantsRequest, Context context) {
+ final String accept = "application/json";
+ return service.inviteParticipants(
+ this.client.getEndpoint(),
+ callConnectionId,
+ this.client.getApiVersion(),
+ inviteParticipantsRequest,
+ accept,
+ context);
+ }
+
+ /**
+ * Invite participants to the call.
+ *
+ * @param callConnectionId The call connection id.
+ * @param inviteParticipantsRequest Invite participant request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono inviteParticipantsAsync(
+ String callConnectionId, InviteParticipantsRequest inviteParticipantsRequest) {
+ return inviteParticipantsWithResponseAsync(callConnectionId, inviteParticipantsRequest)
+ .flatMap((Response res) -> Mono.empty());
+ }
+
+ /**
+ * Invite participants to the call.
+ *
+ * @param callConnectionId The call connection id.
+ * @param inviteParticipantsRequest Invite participant 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono inviteParticipantsAsync(
+ String callConnectionId, InviteParticipantsRequest inviteParticipantsRequest, Context context) {
+ return inviteParticipantsWithResponseAsync(callConnectionId, inviteParticipantsRequest, context)
+ .flatMap((Response res) -> Mono.empty());
+ }
+
+ /**
+ * Invite participants to the call.
+ *
+ * @param callConnectionId The call connection id.
+ * @param inviteParticipantsRequest Invite participant request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public void inviteParticipants(String callConnectionId, InviteParticipantsRequest inviteParticipantsRequest) {
+ inviteParticipantsAsync(callConnectionId, inviteParticipantsRequest).block();
+ }
+
+ /**
+ * Invite participants to the call.
+ *
+ * @param callConnectionId The call connection id.
+ * @param inviteParticipantsRequest Invite participant 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response inviteParticipantsWithResponse(
+ String callConnectionId, InviteParticipantsRequest inviteParticipantsRequest, Context context) {
+ return inviteParticipantsWithResponseAsync(callConnectionId, inviteParticipantsRequest, context).block();
+ }
+
+ /**
+ * Remove participant from the call.
+ *
+ * @param callConnectionId The call connection id.
+ * @param participantId The participant id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> removeParticipantWithResponseAsync(String callConnectionId, String participantId) {
+ final String accept = "application/json";
+ return FluxUtil.withContext(
+ context ->
+ service.removeParticipant(
+ this.client.getEndpoint(),
+ callConnectionId,
+ participantId,
+ this.client.getApiVersion(),
+ accept,
+ context));
+ }
+
+ /**
+ * Remove participant from the call.
+ *
+ * @param callConnectionId The call connection id.
+ * @param participantId The participant id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> removeParticipantWithResponseAsync(
+ String callConnectionId, String participantId, Context context) {
+ final String accept = "application/json";
+ return service.removeParticipant(
+ this.client.getEndpoint(),
+ callConnectionId,
+ participantId,
+ this.client.getApiVersion(),
+ accept,
+ context);
+ }
+
+ /**
+ * Remove participant from the call.
+ *
+ * @param callConnectionId The call connection id.
+ * @param participantId The participant id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono removeParticipantAsync(String callConnectionId, String participantId) {
+ return removeParticipantWithResponseAsync(callConnectionId, participantId)
+ .flatMap((Response res) -> Mono.empty());
+ }
+
+ /**
+ * Remove participant from the call.
+ *
+ * @param callConnectionId The call connection id.
+ * @param participantId The participant id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono removeParticipantAsync(String callConnectionId, String participantId, Context context) {
+ return removeParticipantWithResponseAsync(callConnectionId, participantId, context)
+ .flatMap((Response res) -> Mono.empty());
+ }
+
+ /**
+ * Remove participant from the call.
+ *
+ * @param callConnectionId The call connection id.
+ * @param participantId The participant id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public void removeParticipant(String callConnectionId, String participantId) {
+ removeParticipantAsync(callConnectionId, participantId).block();
+ }
+
+ /**
+ * Remove participant from the call.
+ *
+ * @param callConnectionId The call connection id.
+ * @param participantId The participant id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response removeParticipantWithResponse(
+ String callConnectionId, String participantId, Context context) {
+ return removeParticipantWithResponseAsync(callConnectionId, participantId, context).block();
+ }
+}
diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/Constants.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/Constants.java
new file mode 100644
index 0000000000000..e31a00bb73013
--- /dev/null
+++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/Constants.java
@@ -0,0 +1,30 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.communication.callingserver.implementation;
+
+/***
+ * Constants to be used by CallingServer.
+ */
+public final class Constants {
+ public static final int KB = 1024;
+ public static final int MB = KB * 1024;
+
+ /***
+ * Content downloader constants
+ */
+ public static class ContentDownloader {
+ public static final int DEFAULT_CONCURRENT_TRANSFERS_COUNT = 5;
+ public static final int DEFAULT_BUFFER_SIZE = 4 * MB;
+ public static final int DEFAULT_INITIAL_DOWNLOAD_RANGE_SIZE = 256 * MB;
+ public static final int MAX_RETRIES = 4;
+ }
+
+ /***
+ * HTTP Header Names
+ */
+ public static class HeaderNames {
+ public static final String RANGE = "Range";
+ public static final String CONTENT_RANGE = "Content-Range";
+ }
+}
diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/ServerCallsImpl.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/ServerCallsImpl.java
new file mode 100644
index 0000000000000..ed3b628daa51d
--- /dev/null
+++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/ServerCallsImpl.java
@@ -0,0 +1,1195 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+
+package com.azure.communication.callingserver.implementation;
+
+import com.azure.communication.callingserver.implementation.models.CallRecordingStateResultInternal;
+import com.azure.communication.callingserver.implementation.models.CommunicationErrorException;
+import com.azure.communication.callingserver.implementation.models.InviteParticipantsRequest;
+import com.azure.communication.callingserver.implementation.models.JoinCallRequest;
+import com.azure.communication.callingserver.implementation.models.JoinCallResultInternal;
+import com.azure.communication.callingserver.implementation.models.PlayAudioRequest;
+import com.azure.communication.callingserver.implementation.models.PlayAudioResultInternal;
+import com.azure.communication.callingserver.implementation.models.StartCallRecordingRequest;
+import com.azure.communication.callingserver.implementation.models.StartCallRecordingResultInternal;
+import com.azure.core.annotation.BodyParam;
+import com.azure.core.annotation.Delete;
+import com.azure.core.annotation.ExpectedResponses;
+import com.azure.core.annotation.Get;
+import com.azure.core.annotation.HeaderParam;
+import com.azure.core.annotation.Host;
+import com.azure.core.annotation.HostParam;
+import com.azure.core.annotation.PathParam;
+import com.azure.core.annotation.Post;
+import com.azure.core.annotation.QueryParam;
+import com.azure.core.annotation.ReturnType;
+import com.azure.core.annotation.ServiceInterface;
+import com.azure.core.annotation.ServiceMethod;
+import com.azure.core.annotation.UnexpectedResponseExceptionType;
+import com.azure.core.http.rest.Response;
+import com.azure.core.http.rest.RestProxy;
+import com.azure.core.util.Context;
+import com.azure.core.util.FluxUtil;
+import reactor.core.publisher.Mono;
+
+/** An instance of this class provides access to all the operations defined in ServerCalls. */
+public final class ServerCallsImpl {
+ /** The proxy service used to perform REST calls. */
+ private final ServerCallsService service;
+
+ /** The service client containing this operation class. */
+ private final AzureCommunicationCallingServerServiceImpl client;
+
+ /**
+ * Initializes an instance of ServerCallsImpl.
+ *
+ * @param client the instance of the service client containing this operation class.
+ */
+ ServerCallsImpl(AzureCommunicationCallingServerServiceImpl client) {
+ this.service =
+ RestProxy.create(ServerCallsService.class, client.getHttpPipeline(), client.getSerializerAdapter());
+ this.client = client;
+ }
+
+ /**
+ * The interface defining all the services for AzureCommunicationCallingServerServiceServerCalls to be used by the
+ * proxy service to perform REST calls.
+ */
+ @Host("{endpoint}")
+ @ServiceInterface(name = "AzureCommunicationCa")
+ private interface ServerCallsService {
+ @Post("/calling/serverCalls/{serverCallId}/participants")
+ @ExpectedResponses({202})
+ @UnexpectedResponseExceptionType(CommunicationErrorException.class)
+ Mono> inviteParticipants(
+ @HostParam("endpoint") String endpoint,
+ @PathParam("serverCallId") String serverCallId,
+ @QueryParam("api-version") String apiVersion,
+ @BodyParam("application/json") InviteParticipantsRequest inviteParticipantsRequest,
+ @HeaderParam("Accept") String accept,
+ Context context);
+
+ @Delete("/calling/serverCalls/{serverCallId}/participants/{participantId}")
+ @ExpectedResponses({202})
+ @UnexpectedResponseExceptionType(CommunicationErrorException.class)
+ Mono> removeParticipant(
+ @HostParam("endpoint") String endpoint,
+ @PathParam("serverCallId") String serverCallId,
+ @PathParam("participantId") String participantId,
+ @QueryParam("api-version") String apiVersion,
+ @HeaderParam("Accept") String accept,
+ Context context);
+
+ @Post("/calling/serverCalls/{serverCallId}/recordings")
+ @ExpectedResponses({200})
+ @UnexpectedResponseExceptionType(CommunicationErrorException.class)
+ Mono> startRecording(
+ @HostParam("endpoint") String endpoint,
+ @PathParam("serverCallId") String serverCallId,
+ @QueryParam("api-version") String apiVersion,
+ @BodyParam("application/json") StartCallRecordingRequest request,
+ @HeaderParam("Accept") String accept,
+ Context context);
+
+ @Get("/calling/serverCalls/{serverCallId}/recordings/{recordingId}")
+ @ExpectedResponses({200})
+ @UnexpectedResponseExceptionType(CommunicationErrorException.class)
+ Mono> recordingState(
+ @HostParam("endpoint") String endpoint,
+ @PathParam("serverCallId") String serverCallId,
+ @PathParam("recordingId") String recordingId,
+ @QueryParam("api-version") String apiVersion,
+ @HeaderParam("Accept") String accept,
+ Context context);
+
+ @Delete("/calling/serverCalls/{serverCallId}/recordings/{recordingId}")
+ @ExpectedResponses({200})
+ @UnexpectedResponseExceptionType(CommunicationErrorException.class)
+ Mono> stopRecording(
+ @HostParam("endpoint") String endpoint,
+ @PathParam("serverCallId") String serverCallId,
+ @PathParam("recordingId") String recordingId,
+ @QueryParam("api-version") String apiVersion,
+ @HeaderParam("Accept") String accept,
+ Context context);
+
+ @Post("/calling/serverCalls/{serverCallId}/recordings/{recordingId}/:pause")
+ @ExpectedResponses({200})
+ @UnexpectedResponseExceptionType(CommunicationErrorException.class)
+ Mono> pauseRecording(
+ @HostParam("endpoint") String endpoint,
+ @PathParam("serverCallId") String serverCallId,
+ @PathParam("recordingId") String recordingId,
+ @QueryParam("api-version") String apiVersion,
+ @HeaderParam("Accept") String accept,
+ Context context);
+
+ @Post("/calling/serverCalls/{serverCallId}/recordings/{recordingId}/:resume")
+ @ExpectedResponses({200})
+ @UnexpectedResponseExceptionType(CommunicationErrorException.class)
+ Mono> resumeRecording(
+ @HostParam("endpoint") String endpoint,
+ @PathParam("serverCallId") String serverCallId,
+ @PathParam("recordingId") String recordingId,
+ @QueryParam("api-version") String apiVersion,
+ @HeaderParam("Accept") String accept,
+ Context context);
+
+ @Post("/calling/serverCalls/{serverCallId}/:join")
+ @ExpectedResponses({202})
+ @UnexpectedResponseExceptionType(CommunicationErrorException.class)
+ Mono> joinCall(
+ @HostParam("endpoint") String endpoint,
+ @PathParam("serverCallId") String serverCallId,
+ @QueryParam("api-version") String apiVersion,
+ @BodyParam("application/json") JoinCallRequest callRequest,
+ @HeaderParam("Accept") String accept,
+ Context context);
+
+ @Post("/calling/serverCalls/{serverCallId}/:playAudio")
+ @ExpectedResponses({202})
+ @UnexpectedResponseExceptionType(CommunicationErrorException.class)
+ Mono> playAudio(
+ @HostParam("endpoint") String endpoint,
+ @PathParam("serverCallId") String serverCallId,
+ @QueryParam("api-version") String apiVersion,
+ @BodyParam("application/json") PlayAudioRequest request,
+ @HeaderParam("Accept") String accept,
+ Context context);
+ }
+
+ /**
+ * Invite participants to the call.
+ *
+ * @param serverCallId The server call id.
+ * @param inviteParticipantsRequest The invite participant request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> inviteParticipantsWithResponseAsync(
+ String serverCallId, InviteParticipantsRequest inviteParticipantsRequest) {
+ final String accept = "application/json";
+ return FluxUtil.withContext(
+ context ->
+ service.inviteParticipants(
+ this.client.getEndpoint(),
+ serverCallId,
+ this.client.getApiVersion(),
+ inviteParticipantsRequest,
+ accept,
+ context));
+ }
+
+ /**
+ * Invite participants to the call.
+ *
+ * @param serverCallId The server call id.
+ * @param inviteParticipantsRequest The invite participant 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> inviteParticipantsWithResponseAsync(
+ String serverCallId, InviteParticipantsRequest inviteParticipantsRequest, Context context) {
+ final String accept = "application/json";
+ return service.inviteParticipants(
+ this.client.getEndpoint(),
+ serverCallId,
+ this.client.getApiVersion(),
+ inviteParticipantsRequest,
+ accept,
+ context);
+ }
+
+ /**
+ * Invite participants to the call.
+ *
+ * @param serverCallId The server call id.
+ * @param inviteParticipantsRequest The invite participant request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono inviteParticipantsAsync(
+ String serverCallId, InviteParticipantsRequest inviteParticipantsRequest) {
+ return inviteParticipantsWithResponseAsync(serverCallId, inviteParticipantsRequest)
+ .flatMap((Response res) -> Mono.empty());
+ }
+
+ /**
+ * Invite participants to the call.
+ *
+ * @param serverCallId The server call id.
+ * @param inviteParticipantsRequest The invite participant 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono inviteParticipantsAsync(
+ String serverCallId, InviteParticipantsRequest inviteParticipantsRequest, Context context) {
+ return inviteParticipantsWithResponseAsync(serverCallId, inviteParticipantsRequest, context)
+ .flatMap((Response res) -> Mono.empty());
+ }
+
+ /**
+ * Invite participants to the call.
+ *
+ * @param serverCallId The server call id.
+ * @param inviteParticipantsRequest The invite participant request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public void inviteParticipants(String serverCallId, InviteParticipantsRequest inviteParticipantsRequest) {
+ inviteParticipantsAsync(serverCallId, inviteParticipantsRequest).block();
+ }
+
+ /**
+ * Invite participants to the call.
+ *
+ * @param serverCallId The server call id.
+ * @param inviteParticipantsRequest The invite participant 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response inviteParticipantsWithResponse(
+ String serverCallId, InviteParticipantsRequest inviteParticipantsRequest, Context context) {
+ return inviteParticipantsWithResponseAsync(serverCallId, inviteParticipantsRequest, context).block();
+ }
+
+ /**
+ * Remove participant from the call.
+ *
+ * @param serverCallId Server call id.
+ * @param participantId Participant id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> removeParticipantWithResponseAsync(String serverCallId, String participantId) {
+ final String accept = "application/json";
+ return FluxUtil.withContext(
+ context ->
+ service.removeParticipant(
+ this.client.getEndpoint(),
+ serverCallId,
+ participantId,
+ this.client.getApiVersion(),
+ accept,
+ context));
+ }
+
+ /**
+ * Remove participant from the call.
+ *
+ * @param serverCallId Server call id.
+ * @param participantId Participant id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> removeParticipantWithResponseAsync(
+ String serverCallId, String participantId, Context context) {
+ final String accept = "application/json";
+ return service.removeParticipant(
+ this.client.getEndpoint(), serverCallId, participantId, this.client.getApiVersion(), accept, context);
+ }
+
+ /**
+ * Remove participant from the call.
+ *
+ * @param serverCallId Server call id.
+ * @param participantId Participant id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono removeParticipantAsync(String serverCallId, String participantId) {
+ return removeParticipantWithResponseAsync(serverCallId, participantId)
+ .flatMap((Response res) -> Mono.empty());
+ }
+
+ /**
+ * Remove participant from the call.
+ *
+ * @param serverCallId Server call id.
+ * @param participantId Participant id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono removeParticipantAsync(String serverCallId, String participantId, Context context) {
+ return removeParticipantWithResponseAsync(serverCallId, participantId, context)
+ .flatMap((Response res) -> Mono.empty());
+ }
+
+ /**
+ * Remove participant from the call.
+ *
+ * @param serverCallId Server call id.
+ * @param participantId Participant id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public void removeParticipant(String serverCallId, String participantId) {
+ removeParticipantAsync(serverCallId, participantId).block();
+ }
+
+ /**
+ * Remove participant from the call.
+ *
+ * @param serverCallId Server call id.
+ * @param participantId Participant id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response removeParticipantWithResponse(String serverCallId, String participantId, Context context) {
+ return removeParticipantWithResponseAsync(serverCallId, participantId, context).block();
+ }
+
+ /**
+ * Start call recording request.
+ *
+ * @param serverCallId The server call id.
+ * @param request The request body of start call recording request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of start call recording operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> startRecordingWithResponseAsync(
+ String serverCallId, StartCallRecordingRequest request) {
+ final String accept = "application/json";
+ return FluxUtil.withContext(
+ context ->
+ service.startRecording(
+ this.client.getEndpoint(),
+ serverCallId,
+ this.client.getApiVersion(),
+ request,
+ accept,
+ context));
+ }
+
+ /**
+ * Start call recording request.
+ *
+ * @param serverCallId The server call id.
+ * @param request The request body of start call recording 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of start call recording operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> startRecordingWithResponseAsync(
+ String serverCallId, StartCallRecordingRequest request, Context context) {
+ final String accept = "application/json";
+ return service.startRecording(
+ this.client.getEndpoint(), serverCallId, this.client.getApiVersion(), request, accept, context);
+ }
+
+ /**
+ * Start call recording request.
+ *
+ * @param serverCallId The server call id.
+ * @param request The request body of start call recording request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of start call recording operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono startRecordingAsync(
+ String serverCallId, StartCallRecordingRequest request) {
+ return startRecordingWithResponseAsync(serverCallId, request)
+ .flatMap(
+ (Response res) -> {
+ if (res.getValue() != null) {
+ return Mono.just(res.getValue());
+ } else {
+ return Mono.empty();
+ }
+ });
+ }
+
+ /**
+ * Start call recording request.
+ *
+ * @param serverCallId The server call id.
+ * @param request The request body of start call recording 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of start call recording operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono startRecordingAsync(
+ String serverCallId, StartCallRecordingRequest request, Context context) {
+ return startRecordingWithResponseAsync(serverCallId, request, context)
+ .flatMap(
+ (Response res) -> {
+ if (res.getValue() != null) {
+ return Mono.just(res.getValue());
+ } else {
+ return Mono.empty();
+ }
+ });
+ }
+
+ /**
+ * Start call recording request.
+ *
+ * @param serverCallId The server call id.
+ * @param request The request body of start call recording request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of start call recording operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public StartCallRecordingResultInternal startRecording(String serverCallId, StartCallRecordingRequest request) {
+ return startRecordingAsync(serverCallId, request).block();
+ }
+
+ /**
+ * Start call recording request.
+ *
+ * @param serverCallId The server call id.
+ * @param request The request body of start call recording 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of start call recording operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response startRecordingWithResponse(
+ String serverCallId, StartCallRecordingRequest request, Context context) {
+ return startRecordingWithResponseAsync(serverCallId, request, context).block();
+ }
+
+ /**
+ * Get call recording state.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return call recording state.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> recordingStateWithResponseAsync(
+ String serverCallId, String recordingId) {
+ final String accept = "application/json";
+ return FluxUtil.withContext(
+ context ->
+ service.recordingState(
+ this.client.getEndpoint(),
+ serverCallId,
+ recordingId,
+ this.client.getApiVersion(),
+ accept,
+ context));
+ }
+
+ /**
+ * Get call recording state.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return call recording state.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> recordingStateWithResponseAsync(
+ String serverCallId, String recordingId, Context context) {
+ final String accept = "application/json";
+ return service.recordingState(
+ this.client.getEndpoint(), serverCallId, recordingId, this.client.getApiVersion(), accept, context);
+ }
+
+ /**
+ * Get call recording state.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return call recording state.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono recordingStateAsync(String serverCallId, String recordingId) {
+ return recordingStateWithResponseAsync(serverCallId, recordingId)
+ .flatMap(
+ (Response res) -> {
+ if (res.getValue() != null) {
+ return Mono.just(res.getValue());
+ } else {
+ return Mono.empty();
+ }
+ });
+ }
+
+ /**
+ * Get call recording state.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return call recording state.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono recordingStateAsync(
+ String serverCallId, String recordingId, Context context) {
+ return recordingStateWithResponseAsync(serverCallId, recordingId, context)
+ .flatMap(
+ (Response res) -> {
+ if (res.getValue() != null) {
+ return Mono.just(res.getValue());
+ } else {
+ return Mono.empty();
+ }
+ });
+ }
+
+ /**
+ * Get call recording state.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return call recording state.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public CallRecordingStateResultInternal recordingState(String serverCallId, String recordingId) {
+ return recordingStateAsync(serverCallId, recordingId).block();
+ }
+
+ /**
+ * Get call recording state.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return call recording state.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response recordingStateWithResponse(
+ String serverCallId, String recordingId, Context context) {
+ return recordingStateWithResponseAsync(serverCallId, recordingId, context).block();
+ }
+
+ /**
+ * Stop recording a call.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> stopRecordingWithResponseAsync(String serverCallId, String recordingId) {
+ final String accept = "application/json";
+ return FluxUtil.withContext(
+ context ->
+ service.stopRecording(
+ this.client.getEndpoint(),
+ serverCallId,
+ recordingId,
+ this.client.getApiVersion(),
+ accept,
+ context));
+ }
+
+ /**
+ * Stop recording a call.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> stopRecordingWithResponseAsync(
+ String serverCallId, String recordingId, Context context) {
+ final String accept = "application/json";
+ return service.stopRecording(
+ this.client.getEndpoint(), serverCallId, recordingId, this.client.getApiVersion(), accept, context);
+ }
+
+ /**
+ * Stop recording a call.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono stopRecordingAsync(String serverCallId, String recordingId) {
+ return stopRecordingWithResponseAsync(serverCallId, recordingId).flatMap((Response res) -> Mono.empty());
+ }
+
+ /**
+ * Stop recording a call.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono stopRecordingAsync(String serverCallId, String recordingId, Context context) {
+ return stopRecordingWithResponseAsync(serverCallId, recordingId, context)
+ .flatMap((Response res) -> Mono.empty());
+ }
+
+ /**
+ * Stop recording a call.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public void stopRecording(String serverCallId, String recordingId) {
+ stopRecordingAsync(serverCallId, recordingId).block();
+ }
+
+ /**
+ * Stop recording a call.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response stopRecordingWithResponse(String serverCallId, String recordingId, Context context) {
+ return stopRecordingWithResponseAsync(serverCallId, recordingId, context).block();
+ }
+
+ /**
+ * Pause recording a call.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> pauseRecordingWithResponseAsync(String serverCallId, String recordingId) {
+ final String accept = "application/json";
+ return FluxUtil.withContext(
+ context ->
+ service.pauseRecording(
+ this.client.getEndpoint(),
+ serverCallId,
+ recordingId,
+ this.client.getApiVersion(),
+ accept,
+ context));
+ }
+
+ /**
+ * Pause recording a call.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> pauseRecordingWithResponseAsync(
+ String serverCallId, String recordingId, Context context) {
+ final String accept = "application/json";
+ return service.pauseRecording(
+ this.client.getEndpoint(), serverCallId, recordingId, this.client.getApiVersion(), accept, context);
+ }
+
+ /**
+ * Pause recording a call.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono pauseRecordingAsync(String serverCallId, String recordingId) {
+ return pauseRecordingWithResponseAsync(serverCallId, recordingId).flatMap((Response res) -> Mono.empty());
+ }
+
+ /**
+ * Pause recording a call.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono pauseRecordingAsync(String serverCallId, String recordingId, Context context) {
+ return pauseRecordingWithResponseAsync(serverCallId, recordingId, context)
+ .flatMap((Response res) -> Mono.empty());
+ }
+
+ /**
+ * Pause recording a call.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public void pauseRecording(String serverCallId, String recordingId) {
+ pauseRecordingAsync(serverCallId, recordingId).block();
+ }
+
+ /**
+ * Pause recording a call.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response pauseRecordingWithResponse(String serverCallId, String recordingId, Context context) {
+ return pauseRecordingWithResponseAsync(serverCallId, recordingId, context).block();
+ }
+
+ /**
+ * Resume recording a call.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> resumeRecordingWithResponseAsync(String serverCallId, String recordingId) {
+ final String accept = "application/json";
+ return FluxUtil.withContext(
+ context ->
+ service.resumeRecording(
+ this.client.getEndpoint(),
+ serverCallId,
+ recordingId,
+ this.client.getApiVersion(),
+ accept,
+ context));
+ }
+
+ /**
+ * Resume recording a call.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> resumeRecordingWithResponseAsync(
+ String serverCallId, String recordingId, Context context) {
+ final String accept = "application/json";
+ return service.resumeRecording(
+ this.client.getEndpoint(), serverCallId, recordingId, this.client.getApiVersion(), accept, context);
+ }
+
+ /**
+ * Resume recording a call.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono resumeRecordingAsync(String serverCallId, String recordingId) {
+ return resumeRecordingWithResponseAsync(serverCallId, recordingId)
+ .flatMap((Response res) -> Mono.empty());
+ }
+
+ /**
+ * Resume recording a call.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the completion.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono resumeRecordingAsync(String serverCallId, String recordingId, Context context) {
+ return resumeRecordingWithResponseAsync(serverCallId, recordingId, context)
+ .flatMap((Response res) -> Mono.empty());
+ }
+
+ /**
+ * Resume recording a call.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public void resumeRecording(String serverCallId, String recordingId) {
+ resumeRecordingAsync(serverCallId, recordingId).block();
+ }
+
+ /**
+ * Resume recording a call.
+ *
+ * @param serverCallId The server call id.
+ * @param recordingId The recording id.
+ * @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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response resumeRecordingWithResponse(String serverCallId, String recordingId, Context context) {
+ return resumeRecordingWithResponseAsync(serverCallId, recordingId, context).block();
+ }
+
+ /**
+ * Join a call.
+ *
+ * @param serverCallId The server call id.
+ * @param callRequest The join call request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of the join call operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> joinCallWithResponseAsync(
+ String serverCallId, JoinCallRequest callRequest) {
+ final String accept = "application/json";
+ return FluxUtil.withContext(
+ context ->
+ service.joinCall(
+ this.client.getEndpoint(),
+ serverCallId,
+ this.client.getApiVersion(),
+ callRequest,
+ accept,
+ context));
+ }
+
+ /**
+ * Join a call.
+ *
+ * @param serverCallId The server call id.
+ * @param callRequest The join call 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of the join call operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> joinCallWithResponseAsync(
+ String serverCallId, JoinCallRequest callRequest, Context context) {
+ final String accept = "application/json";
+ return service.joinCall(
+ this.client.getEndpoint(), serverCallId, this.client.getApiVersion(), callRequest, accept, context);
+ }
+
+ /**
+ * Join a call.
+ *
+ * @param serverCallId The server call id.
+ * @param callRequest The join call request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of the join call operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono joinCallAsync(String serverCallId, JoinCallRequest callRequest) {
+ return joinCallWithResponseAsync(serverCallId, callRequest)
+ .flatMap(
+ (Response res) -> {
+ if (res.getValue() != null) {
+ return Mono.just(res.getValue());
+ } else {
+ return Mono.empty();
+ }
+ });
+ }
+
+ /**
+ * Join a call.
+ *
+ * @param serverCallId The server call id.
+ * @param callRequest The join call 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of the join call operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono joinCallAsync(
+ String serverCallId, JoinCallRequest callRequest, Context context) {
+ return joinCallWithResponseAsync(serverCallId, callRequest, context)
+ .flatMap(
+ (Response res) -> {
+ if (res.getValue() != null) {
+ return Mono.just(res.getValue());
+ } else {
+ return Mono.empty();
+ }
+ });
+ }
+
+ /**
+ * Join a call.
+ *
+ * @param serverCallId The server call id.
+ * @param callRequest The join call request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of the join call operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public JoinCallResultInternal joinCall(String serverCallId, JoinCallRequest callRequest) {
+ return joinCallAsync(serverCallId, callRequest).block();
+ }
+
+ /**
+ * Join a call.
+ *
+ * @param serverCallId The server call id.
+ * @param callRequest The join call 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload of the join call operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response joinCallWithResponse(
+ String serverCallId, JoinCallRequest callRequest, Context context) {
+ return joinCallWithResponseAsync(serverCallId, callRequest, context).block();
+ }
+
+ /**
+ * Play audio in a call.
+ *
+ * @param serverCallId The server call id.
+ * @param request Play audio request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload for play audio operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> playAudioWithResponseAsync(
+ String serverCallId, PlayAudioRequest request) {
+ final String accept = "application/json";
+ return FluxUtil.withContext(
+ context ->
+ service.playAudio(
+ this.client.getEndpoint(),
+ serverCallId,
+ this.client.getApiVersion(),
+ request,
+ accept,
+ context));
+ }
+
+ /**
+ * Play audio in a call.
+ *
+ * @param serverCallId The server call id.
+ * @param request Play audio 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload for play audio operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> playAudioWithResponseAsync(
+ String serverCallId, PlayAudioRequest request, Context context) {
+ final String accept = "application/json";
+ return service.playAudio(
+ this.client.getEndpoint(), serverCallId, this.client.getApiVersion(), request, accept, context);
+ }
+
+ /**
+ * Play audio in a call.
+ *
+ * @param serverCallId The server call id.
+ * @param request Play audio request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload for play audio operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono playAudioAsync(String serverCallId, PlayAudioRequest request) {
+ return playAudioWithResponseAsync(serverCallId, request)
+ .flatMap(
+ (Response res) -> {
+ if (res.getValue() != null) {
+ return Mono.just(res.getValue());
+ } else {
+ return Mono.empty();
+ }
+ });
+ }
+
+ /**
+ * Play audio in a call.
+ *
+ * @param serverCallId The server call id.
+ * @param request Play audio 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload for play audio operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono playAudioAsync(
+ String serverCallId, PlayAudioRequest request, Context context) {
+ return playAudioWithResponseAsync(serverCallId, request, context)
+ .flatMap(
+ (Response res) -> {
+ if (res.getValue() != null) {
+ return Mono.just(res.getValue());
+ } else {
+ return Mono.empty();
+ }
+ });
+ }
+
+ /**
+ * Play audio in a call.
+ *
+ * @param serverCallId The server call id.
+ * @param request Play audio request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws CommunicationErrorException thrown if the request is rejected by server.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload for play audio operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public PlayAudioResultInternal playAudio(String serverCallId, PlayAudioRequest request) {
+ return playAudioAsync(serverCallId, request).block();
+ }
+
+ /**
+ * Play audio in a call.
+ *
+ * @param serverCallId The server call id.
+ * @param request Play audio 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.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return the response payload for play audio operation.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response playAudioWithResponse(
+ String serverCallId, PlayAudioRequest request, Context context) {
+ return playAudioWithResponseAsync(serverCallId, request, context).block();
+ }
+}
diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/CallConnectionRequestConverter.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/CallConnectionRequestConverter.java
new file mode 100644
index 0000000000000..49d5357d607b3
--- /dev/null
+++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/CallConnectionRequestConverter.java
@@ -0,0 +1,69 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.communication.callingserver.implementation.converters;
+
+import com.azure.communication.callingserver.implementation.models.CreateCallRequest;
+import com.azure.communication.callingserver.implementation.models.PhoneNumberIdentifierModel;
+import com.azure.communication.callingserver.models.CallModality;
+import com.azure.communication.callingserver.models.CreateCallOptions;
+import com.azure.communication.callingserver.models.EventSubscriptionType;
+import com.azure.communication.common.CommunicationIdentifier;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * A converter for {@link CreateCallRequest}
+ */
+public final class CallConnectionRequestConverter {
+
+ /**
+ * Converts to {@link CreateCallRequest}.
+ */
+ public static CreateCallRequest convert(
+ CommunicationIdentifier source,
+ CommunicationIdentifier[] targets,
+ CreateCallOptions createCallOptions) {
+ if (source == null || targets == null || targets.length == 0) {
+ return null;
+ }
+
+ CreateCallRequest createCallRequest =
+ new CreateCallRequest()
+ .setSource(CommunicationIdentifierConverter.convert(source))
+ .setTargets(new ArrayList<>(Arrays.asList(targets))
+ .stream()
+ .map(CommunicationIdentifierConverter::convert)
+ .collect(Collectors.toList()));
+
+ if (createCallOptions == null) {
+ return createCallRequest;
+ }
+
+ List requestedMediaTypes = new LinkedList<>();
+ for (CallModality modality : createCallOptions.getRequestedMediaTypes()) {
+ requestedMediaTypes.add(CallModality.fromString(modality.toString()));
+ }
+
+ List requestedCallEvents = new LinkedList<>();
+ for (EventSubscriptionType requestedCallEvent : createCallOptions.getRequestedCallEvents()) {
+ requestedCallEvents.add(EventSubscriptionType.fromString(requestedCallEvent.toString()));
+ }
+
+ PhoneNumberIdentifierModel sourceAlternateIdentity = null;
+ if (createCallOptions.getAlternateCallerId() != null) {
+ sourceAlternateIdentity = new PhoneNumberIdentifierModel()
+ .setValue(createCallOptions.getAlternateCallerId().getPhoneNumber());
+ }
+
+ return createCallRequest
+ .setRequestedMediaTypes(requestedMediaTypes)
+ .setRequestedCallEvents(requestedCallEvents)
+ .setAlternateCallerId(sourceAlternateIdentity)
+ .setCallbackUri(createCallOptions.getCallbackUri());
+ }
+}
diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/CallingServerErrorConverter.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/CallingServerErrorConverter.java
new file mode 100644
index 0000000000000..4099ec4e20963
--- /dev/null
+++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/CallingServerErrorConverter.java
@@ -0,0 +1,60 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.communication.callingserver.implementation.converters;
+
+import com.azure.communication.callingserver.implementation.models.CommunicationError;
+import com.azure.communication.callingserver.implementation.models.CommunicationErrorException;
+import com.azure.communication.callingserver.models.CallingServerError;
+import com.azure.communication.callingserver.models.CallingServerErrorException;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * A converter between {@link CommunicationError} and {@link CallingServerError}.
+ */
+public final class CallingServerErrorConverter {
+ /**
+ * Maps from {@link CommunicationError} to {@link CallingServerError}.
+ */
+ public static CallingServerError convert(CommunicationError communicationError) {
+ if (communicationError == null) {
+ return null;
+ }
+
+ List