diff --git a/sdk/communication/Azure.Communication.CallAutomation/api/Azure.Communication.CallAutomation.net8.0.cs b/sdk/communication/Azure.Communication.CallAutomation/api/Azure.Communication.CallAutomation.net8.0.cs index 1aee4414a994a..b3f4c66ed5a65 100644 --- a/sdk/communication/Azure.Communication.CallAutomation/api/Azure.Communication.CallAutomation.net8.0.cs +++ b/sdk/communication/Azure.Communication.CallAutomation/api/Azure.Communication.CallAutomation.net8.0.cs @@ -871,6 +871,17 @@ public HoldOptions(Azure.Communication.CommunicationIdentifier targetParticipant public Azure.Communication.CallAutomation.PlaySource PlaySourceInfo { get { throw null; } set { } } public Azure.Communication.CommunicationIdentifier TargetParticipant { get { throw null; } } } + public partial class IncomingCall : Azure.Communication.CallAutomation.CallAutomationEventBase + { + internal IncomingCall() { } + public string CallerDisplayName { get { throw null; } } + public Azure.Communication.CallAutomation.CustomCallingContext CustomContext { get { throw null; } } + public Azure.Communication.CommunicationIdentifier From { get { throw null; } } + public string IncomingCallContext { get { throw null; } } + public Azure.Communication.CommunicationIdentifier OnBehalfOfCallee { get { throw null; } } + public Azure.Communication.CommunicationIdentifier To { get { throw null; } } + public static Azure.Communication.CallAutomation.IncomingCall Deserialize(string content) { throw null; } + } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct MediaEventReasonCode : System.IEquatable { diff --git a/sdk/communication/Azure.Communication.CallAutomation/api/Azure.Communication.CallAutomation.netstandard2.0.cs b/sdk/communication/Azure.Communication.CallAutomation/api/Azure.Communication.CallAutomation.netstandard2.0.cs index 29cb16e2cc568..ff91e052e6988 100644 --- a/sdk/communication/Azure.Communication.CallAutomation/api/Azure.Communication.CallAutomation.netstandard2.0.cs +++ b/sdk/communication/Azure.Communication.CallAutomation/api/Azure.Communication.CallAutomation.netstandard2.0.cs @@ -870,6 +870,17 @@ public HoldOptions(Azure.Communication.CommunicationIdentifier targetParticipant public Azure.Communication.CallAutomation.PlaySource PlaySourceInfo { get { throw null; } set { } } public Azure.Communication.CommunicationIdentifier TargetParticipant { get { throw null; } } } + public partial class IncomingCall : Azure.Communication.CallAutomation.CallAutomationEventBase + { + internal IncomingCall() { } + public string CallerDisplayName { get { throw null; } } + public Azure.Communication.CallAutomation.CustomCallingContext CustomContext { get { throw null; } } + public Azure.Communication.CommunicationIdentifier From { get { throw null; } } + public string IncomingCallContext { get { throw null; } } + public Azure.Communication.CommunicationIdentifier OnBehalfOfCallee { get { throw null; } } + public Azure.Communication.CommunicationIdentifier To { get { throw null; } } + public static Azure.Communication.CallAutomation.IncomingCall Deserialize(string content) { throw null; } + } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct MediaEventReasonCode : System.IEquatable { diff --git a/sdk/communication/Azure.Communication.CallAutomation/src/Generated/Models/CustomCallingContextInternal.Serialization.cs b/sdk/communication/Azure.Communication.CallAutomation/src/Generated/Models/CustomCallingContextInternal.Serialization.cs index 0031ba9f3b7a3..ec8cd88b39724 100644 --- a/sdk/communication/Azure.Communication.CallAutomation/src/Generated/Models/CustomCallingContextInternal.Serialization.cs +++ b/sdk/communication/Azure.Communication.CallAutomation/src/Generated/Models/CustomCallingContextInternal.Serialization.cs @@ -5,6 +5,7 @@ #nullable disable +using System.Collections.Generic; using System.Text.Json; using Azure.Core; @@ -40,6 +41,56 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteEndObject(); } + internal static CustomCallingContextInternal DeserializeCustomCallingContextInternal(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary voipHeaders = default; + IDictionary sipHeaders = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("voipHeaders"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + voipHeaders = dictionary; + continue; + } + if (property.NameEquals("sipHeaders"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + sipHeaders = dictionary; + continue; + } + } + return new CustomCallingContextInternal(voipHeaders ?? new ChangeTrackingDictionary(), sipHeaders ?? new ChangeTrackingDictionary()); + } + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CustomCallingContextInternal FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeCustomCallingContextInternal(document.RootElement); + } + /// Convert into a . internal virtual RequestContent ToRequestContent() { diff --git a/sdk/communication/Azure.Communication.CallAutomation/src/Generated/Models/IncomingCallInternal.Serialization.cs b/sdk/communication/Azure.Communication.CallAutomation/src/Generated/Models/IncomingCallInternal.Serialization.cs new file mode 100644 index 0000000000000..3669f80caeaa2 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallAutomation/src/Generated/Models/IncomingCallInternal.Serialization.cs @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; + +namespace Azure.Communication.CallAutomation +{ + internal partial class IncomingCallInternal + { + internal static IncomingCallInternal DeserializeIncomingCallInternal(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CommunicationIdentifierModel to = default; + CommunicationIdentifierModel @from = default; + string serverCallId = default; + string callerDisplayName = default; + CustomCallingContextInternal customContext = default; + string incomingCallContext = default; + CommunicationIdentifierModel onBehalfOfCallee = default; + string correlationId = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("to"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + to = CommunicationIdentifierModel.DeserializeCommunicationIdentifierModel(property.Value); + continue; + } + if (property.NameEquals("from"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + @from = CommunicationIdentifierModel.DeserializeCommunicationIdentifierModel(property.Value); + continue; + } + if (property.NameEquals("serverCallId"u8)) + { + serverCallId = property.Value.GetString(); + continue; + } + if (property.NameEquals("callerDisplayName"u8)) + { + callerDisplayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("customContext"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + customContext = CustomCallingContextInternal.DeserializeCustomCallingContextInternal(property.Value); + continue; + } + if (property.NameEquals("incomingCallContext"u8)) + { + incomingCallContext = property.Value.GetString(); + continue; + } + if (property.NameEquals("onBehalfOfCallee"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + onBehalfOfCallee = CommunicationIdentifierModel.DeserializeCommunicationIdentifierModel(property.Value); + continue; + } + if (property.NameEquals("correlationId"u8)) + { + correlationId = property.Value.GetString(); + continue; + } + } + return new IncomingCallInternal( + to, + @from, + serverCallId, + callerDisplayName, + customContext, + incomingCallContext, + onBehalfOfCallee, + correlationId); + } + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static IncomingCallInternal FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeIncomingCallInternal(document.RootElement); + } + } +} diff --git a/sdk/communication/Azure.Communication.CallAutomation/src/Generated/Models/IncomingCallInternal.cs b/sdk/communication/Azure.Communication.CallAutomation/src/Generated/Models/IncomingCallInternal.cs new file mode 100644 index 0000000000000..a5c3e1aa6cb87 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallAutomation/src/Generated/Models/IncomingCallInternal.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.Communication.CallAutomation +{ + /// The incoming call event. + internal partial class IncomingCallInternal + { + /// Initializes a new instance of . + internal IncomingCallInternal() + { + } + + /// Initializes a new instance of . + /// The communication identifier of the target user. + /// The communication identifier of the user who initiated the call. + /// The server call id. + /// Display name of caller. + /// Custom Context of Incoming Call. + /// Incoming call context. + /// The communication identifier of the user on behalf of whom the call is made. + /// Correlation ID for event to call correlation. Also called ChainId for skype chain ID. + internal IncomingCallInternal(CommunicationIdentifierModel to, CommunicationIdentifierModel @from, string serverCallId, string callerDisplayName, CustomCallingContextInternal customContext, string incomingCallContext, CommunicationIdentifierModel onBehalfOfCallee, string correlationId) + { + To = to; + From = @from; + ServerCallId = serverCallId; + CallerDisplayName = callerDisplayName; + CustomContext = customContext; + IncomingCallContext = incomingCallContext; + OnBehalfOfCallee = onBehalfOfCallee; + CorrelationId = correlationId; + } + + /// The communication identifier of the target user. + public CommunicationIdentifierModel To { get; } + /// The communication identifier of the user who initiated the call. + public CommunicationIdentifierModel From { get; } + /// The server call id. + public string ServerCallId { get; } + /// Display name of caller. + public string CallerDisplayName { get; } + /// Custom Context of Incoming Call. + public CustomCallingContextInternal CustomContext { get; } + /// Incoming call context. + public string IncomingCallContext { get; } + /// The communication identifier of the user on behalf of whom the call is made. + public CommunicationIdentifierModel OnBehalfOfCallee { get; } + /// Correlation ID for event to call correlation. Also called ChainId for skype chain ID. + public string CorrelationId { get; } + } +} diff --git a/sdk/communication/Azure.Communication.CallAutomation/src/Models/CustomCallingContextInternal.cs b/sdk/communication/Azure.Communication.CallAutomation/src/Models/CustomCallingContextInternal.cs index 03383a8306e14..03310ccb122ca 100644 --- a/sdk/communication/Azure.Communication.CallAutomation/src/Models/CustomCallingContextInternal.cs +++ b/sdk/communication/Azure.Communication.CallAutomation/src/Models/CustomCallingContextInternal.cs @@ -7,7 +7,7 @@ namespace Azure.Communication.CallAutomation { - [CodeGenModel("CustomCallingContext")] + [CodeGenModel("CustomCallingContext", Usage = new string[] { "output" }, Formats = new string[] { "json" })] internal partial class CustomCallingContextInternal { public CustomCallingContextInternal(IDictionary sipHeaders, IDictionary voipHeaders) diff --git a/sdk/communication/Azure.Communication.CallAutomation/src/Models/Events/CallAutomationEventParser.cs b/sdk/communication/Azure.Communication.CallAutomation/src/Models/Events/CallAutomationEventParser.cs index fef569f852634..0ece0d38fd11d 100644 --- a/sdk/communication/Azure.Communication.CallAutomation/src/Models/Events/CallAutomationEventParser.cs +++ b/sdk/communication/Azure.Communication.CallAutomation/src/Models/Events/CallAutomationEventParser.cs @@ -178,6 +178,10 @@ private static CallAutomationEventBase Deserialize(string eventData, string type case nameof(DialogUpdated): return DialogUpdated.Deserialize(eventData); #endregion + #region Incoming Call + case nameof(IncomingCall): + return IncomingCall.Deserialize(eventData); + #endregion default: return null; } diff --git a/sdk/communication/Azure.Communication.CallAutomation/src/Models/Events/IncomingCall.cs b/sdk/communication/Azure.Communication.CallAutomation/src/Models/Events/IncomingCall.cs new file mode 100644 index 0000000000000..ee51109282c41 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallAutomation/src/Models/Events/IncomingCall.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Text.Json; + +namespace Azure.Communication.CallAutomation +{ + /// + /// The add participant failed event. + /// + public class IncomingCall : CallAutomationEventBase + { + /// Initializes a new instance of . + internal IncomingCall() + { + } + + /// Initializes a new instance of . + /// Internal Representation of the IncomingCall. + internal IncomingCall(IncomingCallInternal internalEvent) + { + To = CommunicationIdentifierSerializer.Deserialize(internalEvent.To); + From = CommunicationIdentifierSerializer.Deserialize(internalEvent.From); + ServerCallId = internalEvent.ServerCallId; + CallerDisplayName = internalEvent.CallerDisplayName; + CustomContext = new CustomCallingContext(internalEvent.CustomContext.SipHeaders, internalEvent.CustomContext.VoipHeaders); + IncomingCallContext = internalEvent.IncomingCallContext; + + if (internalEvent.OnBehalfOfCallee != null) + { + OnBehalfOfCallee = CommunicationIdentifierSerializer.Deserialize(internalEvent.OnBehalfOfCallee); + } + + CorrelationId = internalEvent.CorrelationId; + } + + /// The communication identifier of the target user. + public CommunicationIdentifier To { get; } + /// The communication identifier of the user who initiated the call. + public CommunicationIdentifier From { get; } + /// Display name of caller. + public string CallerDisplayName { get; } + /// Custom Context of Incoming Call. + public CustomCallingContext CustomContext { get; } + /// Incoming call context. + public string IncomingCallContext { get; } + /// The communication identifier of the user on behalf of whom the call is made. + public CommunicationIdentifier OnBehalfOfCallee { get; } + + /// + /// Deserialize event. + /// + /// The json content. + /// The new object. + public static IncomingCall Deserialize(string content) + { + using var document = JsonDocument.Parse(content); + JsonElement element = document.RootElement; + + var internalEvent = IncomingCallInternal.DeserializeIncomingCallInternal(element); + return new IncomingCall(internalEvent); + } + } +} diff --git a/sdk/communication/Azure.Communication.CallAutomation/src/Models/Events/IncomingCallInternal.cs b/sdk/communication/Azure.Communication.CallAutomation/src/Models/Events/IncomingCallInternal.cs new file mode 100644 index 0000000000000..249bfe0f9fb76 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallAutomation/src/Models/Events/IncomingCallInternal.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Text.Json; +using Azure.Core; + +namespace Azure.Communication.CallAutomation +{ + /// + /// The incoming call event internal. + /// + [CodeGenModel("IncomingCall", Usage = new string[] { "output" }, Formats = new string[] { "json" })] + internal partial class IncomingCallInternal + { + } +} diff --git a/sdk/communication/Azure.Communication.CallAutomation/src/autorest.md b/sdk/communication/Azure.Communication.CallAutomation/src/autorest.md index 1375dcb6ca1d0..a86cd2009fbf8 100644 --- a/sdk/communication/Azure.Communication.CallAutomation/src/autorest.md +++ b/sdk/communication/Azure.Communication.CallAutomation/src/autorest.md @@ -10,7 +10,7 @@ model-namespace: false tag: package-2023-10-03-preview require: - - https://github.com/Azure/azure-rest-api-specs/blob/be2a0fa68829fcb15c4e6b47aa6bc4bdd566c1cf/specification/communication/data-plane/CallAutomation/readme.md + - https://github.com/Azure/azure-rest-api-specs/blob/caabf7f24ee18b923a01bd51461c188e861a044e/specification/communication/data-plane/CallAutomation/readme.md title: Azure Communication Services