Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added call connection id for recording and live test and unit test code. #43584

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

package com.azure.communication.callautomation;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import com.azure.communication.callautomation.models.events.AddParticipantFailed;
import com.azure.communication.callautomation.models.events.AddParticipantSucceeded;
import com.azure.communication.callautomation.models.events.AnswerFailed;
Expand All @@ -27,6 +32,9 @@
import com.azure.communication.callautomation.models.events.DialogStarted;
import com.azure.communication.callautomation.models.events.DialogTransfer;
import com.azure.communication.callautomation.models.events.HoldFailed;
import com.azure.communication.callautomation.models.events.MediaStreamingFailed;
import com.azure.communication.callautomation.models.events.MediaStreamingStarted;
import com.azure.communication.callautomation.models.events.MediaStreamingStopped;
import com.azure.communication.callautomation.models.events.ParticipantsUpdated;
import com.azure.communication.callautomation.models.events.PlayCanceled;
import com.azure.communication.callautomation.models.events.PlayCompleted;
Expand All @@ -38,26 +46,19 @@
import com.azure.communication.callautomation.models.events.RecordingStateChanged;
import com.azure.communication.callautomation.models.events.RemoveParticipantFailed;
import com.azure.communication.callautomation.models.events.RemoveParticipantSucceeded;
import com.azure.communication.callautomation.models.events.SendDtmfTonesCompleted;
import com.azure.communication.callautomation.models.events.SendDtmfTonesFailed;
import com.azure.communication.callautomation.models.events.StartRecordingFailed;
import com.azure.communication.callautomation.models.events.TranscriptionFailed;
import com.azure.communication.callautomation.models.events.TranscriptionResumed;
import com.azure.communication.callautomation.models.events.TranscriptionStarted;
import com.azure.communication.callautomation.models.events.TranscriptionStopped;
import com.azure.communication.callautomation.models.events.SendDtmfTonesCompleted;
import com.azure.communication.callautomation.models.events.SendDtmfTonesFailed;
import com.azure.communication.callautomation.models.events.TranscriptionUpdated;
import com.azure.communication.callautomation.models.events.MediaStreamingStarted;
import com.azure.communication.callautomation.models.events.MediaStreamingStopped;
import com.azure.communication.callautomation.models.events.MediaStreamingFailed;
import com.azure.core.models.CloudEvent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.json.JsonProviders;
import com.azure.json.JsonReader;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
* Event handler for taking care of event related tasks.
*/
Expand Down Expand Up @@ -127,6 +128,8 @@ private static CallAutomationEventBase parseSingleCloudEvent(String data, String
ret = ParticipantsUpdated.fromJson(jsonReader);
} else if (Objects.equals(eventType, "Microsoft.Communication.RecordingStateChanged")) {
ret = RecordingStateChanged.fromJson(jsonReader);
}else if (Objects.equals(eventType, "Microsoft.Communication.StartRecordingFailed")) {
ret = StartRecordingFailed.fromJson(jsonReader);
} else if (Objects.equals(eventType, "Microsoft.Communication.PlayCompleted")) {
ret = PlayCompleted.fromJson(jsonReader);
} else if (Objects.equals(eventType, "Microsoft.Communication.PlayFailed")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@

package com.azure.communication.callautomation;

import java.io.IOException;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousFileChannel;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.security.InvalidParameterException;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

import com.azure.communication.callautomation.implementation.CallRecordingsImpl;
import com.azure.communication.callautomation.implementation.accesshelpers.RecordingStateResponseConstructorProxy;
import com.azure.communication.callautomation.implementation.converters.CommunicationIdentifierConverter;
Expand All @@ -24,8 +40,8 @@
import com.azure.communication.callautomation.models.GroupCallLocator;
import com.azure.communication.callautomation.models.ParallelDownloadOptions;
import com.azure.communication.callautomation.models.RecordingStateResult;
import com.azure.communication.callautomation.models.ServerCallLocator;
import com.azure.communication.callautomation.models.RoomCallLocator;
import com.azure.communication.callautomation.models.ServerCallLocator;
import com.azure.communication.callautomation.models.StartRecordingOptions;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceMethod;
Expand All @@ -38,29 +54,13 @@
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.BinaryData;
import com.azure.core.util.Context;
import static com.azure.core.util.FluxUtil.monoError;
import static com.azure.core.util.FluxUtil.withContext;
import com.azure.core.util.logging.ClientLogger;

import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.io.IOException;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousFileChannel;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.security.InvalidParameterException;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

import static com.azure.core.util.FluxUtil.monoError;
import static com.azure.core.util.FluxUtil.withContext;

/**
* CallRecordingAsync.
*/
Expand Down Expand Up @@ -126,23 +126,24 @@ Mono<Response<RecordingStateResult>> startWithResponseInternal(StartRecordingOpt
}

private StartCallRecordingRequestInternal getStartCallRecordingRequest(StartRecordingOptions options) {
CallLocator callLocator = options.getCallLocator();
CallLocatorInternal callLocatorInternal
= new CallLocatorInternal().setKind(CallLocatorKindInternal.fromString(callLocator.getKind().toString()));

if (callLocator.getKind() == CallLocatorKind.GROUP_CALL_LOCATOR) {
callLocatorInternal.setGroupCallId(((GroupCallLocator) callLocator).getGroupCallId());
} else if (callLocator.getKind() == CallLocatorKind.SERVER_CALL_LOCATOR) {
callLocatorInternal.setServerCallId(((ServerCallLocator) callLocator).getServerCallId());
} else if (callLocator.getKind() == CallLocatorKind.ROOM_CALL_LOCATOR) {
callLocatorInternal.setRoomId(((RoomCallLocator) callLocator).getRoomId());
} else {
throw logger.logExceptionAsError(new InvalidParameterException("callLocator has invalid kind."));
StartCallRecordingRequestInternal request = new StartCallRecordingRequestInternal();
if (options.getCallLocator() != null) {
CallLocator callLocator = options.getCallLocator();
CallLocatorInternal callLocatorInternal = new CallLocatorInternal()
.setKind(CallLocatorKindInternal.fromString(callLocator.getKind().toString()));

if (callLocator.getKind() == CallLocatorKind.GROUP_CALL_LOCATOR) {
callLocatorInternal.setGroupCallId(((GroupCallLocator) callLocator).getGroupCallId());
} else if (callLocator.getKind() == CallLocatorKind.SERVER_CALL_LOCATOR) {
callLocatorInternal.setServerCallId(((ServerCallLocator) callLocator).getServerCallId());
} else if (callLocator.getKind() == CallLocatorKind.ROOM_CALL_LOCATOR) {
callLocatorInternal.setRoomId(((RoomCallLocator) callLocator).getRoomId());
} else {
throw logger.logExceptionAsError(new InvalidParameterException("callLocator has invalid kind."));
}
request.setCallLocator(callLocatorInternal);
}

StartCallRecordingRequestInternal request
= new StartCallRecordingRequestInternal().setCallLocator(callLocatorInternal);

if (options.getRecordingContent() != null) {
request
.setRecordingContentType(RecordingContentInternal.fromString(options.getRecordingContent().toString()));
Expand Down Expand Up @@ -185,7 +186,9 @@ private StartCallRecordingRequestInternal getStartCallRecordingRequest(StartReco
if (options.isPauseOnStart() != null) {
request.setPauseOnStart(options.isPauseOnStart());
}

if (options.getCallConnectionId() != null) {
request.setCallConnectionId(options.getCallConnectionId());
}
return request;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public final class CreateCallRequestInternal implements JsonSerializable<CreateC
private CallIntelligenceOptionsInternal callIntelligenceOptions;

/*
* The identifier of the source in an OPS call
* The identifier of the source for creating call with Teams resource account ID.
*/
private MicrosoftTeamsAppIdentifierModel opsSource;
private MicrosoftTeamsAppIdentifierModel teamsAppSource;

/*
* Used by customer to send custom calling context to targets
Expand Down Expand Up @@ -225,22 +225,22 @@ public CallIntelligenceOptionsInternal getCallIntelligenceOptions() {
}

/**
* Get the opsSource property: The identifier of the source in an OPS call.
* Get the teamsAppSource property: The identifier of the source for creating call with Teams resource account ID.
*
* @return the opsSource value.
* @return the teamsAppSource value.
*/
public MicrosoftTeamsAppIdentifierModel getOpsSource() {
return this.opsSource;
public MicrosoftTeamsAppIdentifierModel getTeamsAppSource() {
return this.teamsAppSource;
}

/**
* Set the opsSource property: The identifier of the source in an OPS call.
* Set the teamsAppSource property: The identifier of the source for creating call with Teams resource account ID.
*
* @param opsSource the opsSource value to set.
* @param teamsAppSource the teamsAppSource value to set.
* @return the CreateCallRequestInternal object itself.
*/
public CreateCallRequestInternal setOpsSource(MicrosoftTeamsAppIdentifierModel opsSource) {
this.opsSource = opsSource;
public CreateCallRequestInternal setTeamsAppSource(MicrosoftTeamsAppIdentifierModel teamsAppSource) {
this.teamsAppSource = teamsAppSource;
return this;
}

Expand Down Expand Up @@ -317,7 +317,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeJsonField("source", this.source);
jsonWriter.writeStringField("operationContext", this.operationContext);
jsonWriter.writeJsonField("callIntelligenceOptions", this.callIntelligenceOptions);
jsonWriter.writeJsonField("opsSource", this.opsSource);
jsonWriter.writeJsonField("teamsAppSource", this.teamsAppSource);
jsonWriter.writeJsonField("customCallingContext", this.customCallingContext);
jsonWriter.writeJsonField("mediaStreamingOptions", this.mediaStreamingOptions);
jsonWriter.writeJsonField("transcriptionOptions", this.transcriptionOptions);
Expand Down Expand Up @@ -358,8 +358,9 @@ public static CreateCallRequestInternal fromJson(JsonReader jsonReader) throws I
} else if ("callIntelligenceOptions".equals(fieldName)) {
deserializedCreateCallRequestInternal.callIntelligenceOptions
= CallIntelligenceOptionsInternal.fromJson(reader);
} else if ("opsSource".equals(fieldName)) {
deserializedCreateCallRequestInternal.opsSource = MicrosoftTeamsAppIdentifierModel.fromJson(reader);
} else if ("teamsAppSource".equals(fieldName)) {
deserializedCreateCallRequestInternal.teamsAppSource
= MicrosoftTeamsAppIdentifierModel.fromJson(reader);
} else if ("customCallingContext".equals(fieldName)) {
deserializedCreateCallRequestInternal.customCallingContext = CustomCallingContext.fromJson(reader);
} else if ("mediaStreamingOptions".equals(fieldName)) {
Expand Down
Loading
Loading