diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/AddParticipantsOptions.Serialization.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/AddParticipantsOptions.Serialization.cs
new file mode 100644
index 000000000000..77031de59769
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/AddParticipantsOptions.Serialization.cs
@@ -0,0 +1,152 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.Communication.Messages
+{
+ public partial class AddParticipantsOptions : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(AddParticipantsOptions)} does not support writing '{format}' format.");
+ }
+
+ writer.WritePropertyName("participants"u8);
+ writer.WriteStartArray();
+ foreach (var item in Participants)
+ {
+ writer.WriteObjectValue(item, options);
+ }
+ writer.WriteEndArray();
+ if (options.Format != "W" && _serializedAdditionalRawData != null)
+ {
+ foreach (var item in _serializedAdditionalRawData)
+ {
+ writer.WritePropertyName(item.Key);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(item.Value);
+#else
+ using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ }
+ }
+
+ AddParticipantsOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(AddParticipantsOptions)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeAddParticipantsOptions(document.RootElement, options);
+ }
+
+ internal static AddParticipantsOptions DeserializeAddParticipantsOptions(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ IList participants = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("participants"u8))
+ {
+ List array = new List();
+ foreach (var item in property.Value.EnumerateArray())
+ {
+ array.Add(ConversationParticipant.DeserializeConversationParticipant(item, options));
+ }
+ participants = array;
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new AddParticipantsOptions(participants, serializedAdditionalRawData);
+ }
+
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(AddParticipantsOptions)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ AddParticipantsOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAddParticipantsOptions(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(AddParticipantsOptions)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static AddParticipantsOptions FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAddParticipantsOptions(document.RootElement);
+ }
+
+ /// Convert into a .
+ internal virtual RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions);
+ return content;
+ }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/AddParticipantsOptions.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/AddParticipantsOptions.cs
new file mode 100644
index 000000000000..4ddd8a8c034f
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/AddParticipantsOptions.cs
@@ -0,0 +1,88 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Azure.Communication.Messages
+{
+ /// Request payload for adding participants to a conversation.
+ public partial class AddParticipantsOptions
+ {
+ ///
+ /// Keeps track of any properties unknown to the library.
+ ///
+ /// To assign an object to the value of this property use .
+ ///
+ ///
+ /// To assign an already formatted json string to this property use .
+ ///
+ ///
+ /// Examples:
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson("foo")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromString("\"foo\"")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson(new { key = "value" })
+ /// Creates a payload of { "key": "value" }.
+ ///
+ /// -
+ /// BinaryData.FromString("{\"key\": \"value\"}")
+ /// Creates a payload of { "key": "value" }.
+ ///
+ ///
+ ///
+ ///
+ private IDictionary _serializedAdditionalRawData;
+
+ /// Initializes a new instance of .
+ ///
+ /// List of participants to add.
+ /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
+ /// The available derived classes include and .
+ ///
+ /// is null.
+ public AddParticipantsOptions(IEnumerable participants)
+ {
+ Argument.AssertNotNull(participants, nameof(participants));
+
+ Participants = participants.ToList();
+ }
+
+ /// Initializes a new instance of .
+ ///
+ /// List of participants to add.
+ /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
+ /// The available derived classes include and .
+ ///
+ /// Keeps track of any properties unknown to the library.
+ internal AddParticipantsOptions(IList participants, IDictionary serializedAdditionalRawData)
+ {
+ Participants = participants;
+ _serializedAdditionalRawData = serializedAdditionalRawData;
+ }
+
+ /// Initializes a new instance of for deserialization.
+ internal AddParticipantsOptions()
+ {
+ }
+
+ ///
+ /// List of participants to add.
+ /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
+ /// The available derived classes include and .
+ ///
+ public IList Participants { get; }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/AddParticipantsResult.Serialization.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/AddParticipantsResult.Serialization.cs
new file mode 100644
index 000000000000..e2e58afa863e
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/AddParticipantsResult.Serialization.cs
@@ -0,0 +1,152 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.Communication.Messages
+{
+ public partial class AddParticipantsResult : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(AddParticipantsResult)} does not support writing '{format}' format.");
+ }
+
+ writer.WritePropertyName("invalidParticipants"u8);
+ writer.WriteStartArray();
+ foreach (var item in InvalidParticipants)
+ {
+ writer.WriteObjectValue(item, options);
+ }
+ writer.WriteEndArray();
+ if (options.Format != "W" && _serializedAdditionalRawData != null)
+ {
+ foreach (var item in _serializedAdditionalRawData)
+ {
+ writer.WritePropertyName(item.Key);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(item.Value);
+#else
+ using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ }
+ }
+
+ AddParticipantsResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(AddParticipantsResult)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeAddParticipantsResult(document.RootElement, options);
+ }
+
+ internal static AddParticipantsResult DeserializeAddParticipantsResult(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ IReadOnlyList invalidParticipants = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("invalidParticipants"u8))
+ {
+ List array = new List();
+ foreach (var item in property.Value.EnumerateArray())
+ {
+ array.Add(UpdateParticipantsResult.DeserializeUpdateParticipantsResult(item, options));
+ }
+ invalidParticipants = array;
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new AddParticipantsResult(invalidParticipants, serializedAdditionalRawData);
+ }
+
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(AddParticipantsResult)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ AddParticipantsResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAddParticipantsResult(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(AddParticipantsResult)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static AddParticipantsResult FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAddParticipantsResult(document.RootElement);
+ }
+
+ /// Convert into a .
+ internal virtual RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions);
+ return content;
+ }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/AddParticipantsResult.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/AddParticipantsResult.cs
new file mode 100644
index 000000000000..4abe4b2343a6
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/AddParticipantsResult.cs
@@ -0,0 +1,76 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Azure.Communication.Messages
+{
+ /// Response for the add participants operation.
+ public partial class AddParticipantsResult
+ {
+ ///
+ /// Keeps track of any properties unknown to the library.
+ ///
+ /// To assign an object to the value of this property use .
+ ///
+ ///
+ /// To assign an already formatted json string to this property use .
+ ///
+ ///
+ /// Examples:
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson("foo")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromString("\"foo\"")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson(new { key = "value" })
+ /// Creates a payload of { "key": "value" }.
+ ///
+ /// -
+ /// BinaryData.FromString("{\"key\": \"value\"}")
+ /// Creates a payload of { "key": "value" }.
+ ///
+ ///
+ ///
+ ///
+ private IDictionary _serializedAdditionalRawData;
+
+ /// Initializes a new instance of .
+ /// List of Ids with Errors if failed to be added.
+ /// is null.
+ internal AddParticipantsResult(IEnumerable invalidParticipants)
+ {
+ Argument.AssertNotNull(invalidParticipants, nameof(invalidParticipants));
+
+ InvalidParticipants = invalidParticipants.ToList();
+ }
+
+ /// Initializes a new instance of .
+ /// List of Ids with Errors if failed to be added.
+ /// Keeps track of any properties unknown to the library.
+ internal AddParticipantsResult(IReadOnlyList invalidParticipants, IDictionary serializedAdditionalRawData)
+ {
+ InvalidParticipants = invalidParticipants;
+ _serializedAdditionalRawData = serializedAdditionalRawData;
+ }
+
+ /// Initializes a new instance of for deserialization.
+ internal AddParticipantsResult()
+ {
+ }
+
+ /// List of Ids with Errors if failed to be added.
+ public IReadOnlyList InvalidParticipants { get; }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/AudioConversationMessageContent.Serialization.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/AudioConversationMessageContent.Serialization.cs
new file mode 100644
index 000000000000..6f7ed711b00a
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/AudioConversationMessageContent.Serialization.cs
@@ -0,0 +1,134 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.Communication.Messages
+{
+ public partial class AudioConversationMessageContent : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(AudioConversationMessageContent)} does not support writing '{format}' format.");
+ }
+
+ base.JsonModelWriteCore(writer, options);
+ writer.WritePropertyName("mediaUri"u8);
+ writer.WriteStringValue(MediaUri.AbsoluteUri);
+ }
+
+ AudioConversationMessageContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(AudioConversationMessageContent)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeAudioConversationMessageContent(document.RootElement, options);
+ }
+
+ internal static AudioConversationMessageContent DeserializeAudioConversationMessageContent(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ Uri mediaUri = default;
+ CommunicationMessageKind kind = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("mediaUri"u8))
+ {
+ mediaUri = new Uri(property.Value.GetString());
+ continue;
+ }
+ if (property.NameEquals("kind"u8))
+ {
+ kind = new CommunicationMessageKind(property.Value.GetString());
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new AudioConversationMessageContent(kind, serializedAdditionalRawData, mediaUri);
+ }
+
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(AudioConversationMessageContent)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ AudioConversationMessageContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAudioConversationMessageContent(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(AudioConversationMessageContent)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static new AudioConversationMessageContent FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAudioConversationMessageContent(document.RootElement);
+ }
+
+ /// Convert into a .
+ internal override RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions);
+ return content;
+ }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/AudioConversationMessageContent.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/AudioConversationMessageContent.cs
new file mode 100644
index 000000000000..45727d927894
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/AudioConversationMessageContent.cs
@@ -0,0 +1,44 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+
+namespace Azure.Communication.Messages
+{
+ /// A request to send an audio conversation message.
+ public partial class AudioConversationMessageContent : ConversationMessageContent
+ {
+ /// Initializes a new instance of .
+ /// A media url for the file. Required if the type is one of the supported media types, e.g. image.
+ /// is null.
+ public AudioConversationMessageContent(Uri mediaUri)
+ {
+ Argument.AssertNotNull(mediaUri, nameof(mediaUri));
+
+ Kind = CommunicationMessageKind.Audio;
+ MediaUri = mediaUri;
+ }
+
+ /// Initializes a new instance of .
+ /// The type discriminator describing a message type.
+ /// Keeps track of any properties unknown to the library.
+ /// A media url for the file. Required if the type is one of the supported media types, e.g. image.
+ internal AudioConversationMessageContent(CommunicationMessageKind kind, IDictionary serializedAdditionalRawData, Uri mediaUri) : base(kind, serializedAdditionalRawData)
+ {
+ MediaUri = mediaUri;
+ }
+
+ /// Initializes a new instance of for deserialization.
+ internal AudioConversationMessageContent()
+ {
+ }
+
+ /// A media url for the file. Required if the type is one of the supported media types, e.g. image.
+ public Uri MediaUri { get; set; }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/AudioNotificationContent.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/AudioNotificationContent.cs
index 653d644d43db..c5609d2078ac 100644
--- a/sdk/communication/Azure.Communication.Messages/src/Generated/AudioNotificationContent.cs
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/AudioNotificationContent.cs
@@ -30,7 +30,7 @@ public AudioNotificationContent(Guid channelRegistrationId, IEnumerable
/// Initializes a new instance of .
/// The Channel Registration ID for the Business Identifier.
/// The native external platform user identifiers of the recipient.
- /// The type discriminator describing a notification type.
+ /// The type discriminator describing a message type.
/// Keeps track of any properties unknown to the library.
/// A media url for the file. Required if the type is one of the supported media types, e.g. image.
internal AudioNotificationContent(Guid channelRegistrationId, IList to, CommunicationMessageKind kind, IDictionary serializedAdditionalRawData, Uri mediaUri) : base(channelRegistrationId, to, kind, serializedAdditionalRawData)
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/BotContact.Serialization.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/BotContact.Serialization.cs
new file mode 100644
index 000000000000..7503c10f0b09
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/BotContact.Serialization.cs
@@ -0,0 +1,140 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.Communication.Messages
+{
+ public partial class BotContact : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(BotContact)} does not support writing '{format}' format.");
+ }
+
+ base.JsonModelWriteCore(writer, options);
+ writer.WritePropertyName("botAppId"u8);
+ writer.WriteStringValue(BotAppId);
+ }
+
+ BotContact IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(BotContact)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeBotContact(document.RootElement, options);
+ }
+
+ internal static BotContact DeserializeBotContact(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ string botAppId = default;
+ string id = default;
+ MessagePlatformKind kind = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("botAppId"u8))
+ {
+ botAppId = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("id"u8))
+ {
+ id = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("kind"u8))
+ {
+ kind = new MessagePlatformKind(property.Value.GetString());
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new BotContact(id, kind, serializedAdditionalRawData, botAppId);
+ }
+
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(BotContact)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ BotContact IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeBotContact(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(BotContact)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static new BotContact FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeBotContact(document.RootElement);
+ }
+
+ /// Convert into a .
+ internal override RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions);
+ return content;
+ }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/BotContact.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/BotContact.cs
new file mode 100644
index 000000000000..fe9f8ea215cb
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/BotContact.cs
@@ -0,0 +1,47 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+
+namespace Azure.Communication.Messages
+{
+ /// Bot Contact.
+ public partial class BotContact : ConversationContact
+ {
+ /// Initializes a new instance of .
+ /// External platform identifier.
+ /// Bot App Id of the Bot Contact.
+ /// or is null.
+ public BotContact(string id, string botAppId) : base(id)
+ {
+ Argument.AssertNotNull(id, nameof(id));
+ Argument.AssertNotNull(botAppId, nameof(botAppId));
+
+ Kind = MessagePlatformKind.Bot;
+ BotAppId = botAppId;
+ }
+
+ /// Initializes a new instance of .
+ /// External platform identifier.
+ /// Type of message platform (e.g., WhatsApp).
+ /// Keeps track of any properties unknown to the library.
+ /// Bot App Id of the Bot Contact.
+ internal BotContact(string id, MessagePlatformKind kind, IDictionary serializedAdditionalRawData, string botAppId) : base(id, kind, serializedAdditionalRawData)
+ {
+ BotAppId = botAppId;
+ }
+
+ /// Initializes a new instance of for deserialization.
+ internal BotContact()
+ {
+ }
+
+ /// Bot App Id of the Bot Contact.
+ public string BotAppId { get; set; }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationContact.Serialization.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationContact.Serialization.cs
new file mode 100644
index 000000000000..869bc9c72eeb
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationContact.Serialization.cs
@@ -0,0 +1,132 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.Communication.Messages
+{
+ public partial class CommunicationContact : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(CommunicationContact)} does not support writing '{format}' format.");
+ }
+
+ base.JsonModelWriteCore(writer, options);
+ }
+
+ CommunicationContact IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(CommunicationContact)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeCommunicationContact(document.RootElement, options);
+ }
+
+ internal static CommunicationContact DeserializeCommunicationContact(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ string id = default;
+ MessagePlatformKind kind = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("id"u8))
+ {
+ id = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("kind"u8))
+ {
+ kind = new MessagePlatformKind(property.Value.GetString());
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new CommunicationContact(id, kind, serializedAdditionalRawData);
+ }
+
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(CommunicationContact)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ CommunicationContact IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeCommunicationContact(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(CommunicationContact)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static new CommunicationContact FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeCommunicationContact(document.RootElement);
+ }
+
+ /// Convert into a .
+ internal override RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions);
+ return content;
+ }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationContact.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationContact.cs
new file mode 100644
index 000000000000..41b2101542d9
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationContact.cs
@@ -0,0 +1,39 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+
+namespace Azure.Communication.Messages
+{
+ /// Communication Contact.
+ public partial class CommunicationContact : ConversationContact
+ {
+ /// Initializes a new instance of .
+ /// External platform identifier.
+ /// is null.
+ public CommunicationContact(string id) : base(id)
+ {
+ Argument.AssertNotNull(id, nameof(id));
+
+ Kind = MessagePlatformKind.Communication;
+ }
+
+ /// Initializes a new instance of .
+ /// External platform identifier.
+ /// Type of message platform (e.g., WhatsApp).
+ /// Keeps track of any properties unknown to the library.
+ internal CommunicationContact(string id, MessagePlatformKind kind, IDictionary serializedAdditionalRawData) : base(id, kind, serializedAdditionalRawData)
+ {
+ }
+
+ /// Initializes a new instance of for deserialization.
+ internal CommunicationContact()
+ {
+ }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationConversation.Serialization.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationConversation.Serialization.cs
new file mode 100644
index 000000000000..da128e485f4c
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationConversation.Serialization.cs
@@ -0,0 +1,227 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.Communication.Messages
+{
+ public partial class CommunicationConversation : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(CommunicationConversation)} does not support writing '{format}' format.");
+ }
+
+ if (options.Format != "W")
+ {
+ writer.WritePropertyName("id"u8);
+ writer.WriteStringValue(Id);
+ }
+ if (Optional.IsDefined(Topic))
+ {
+ writer.WritePropertyName("topic"u8);
+ writer.WriteStringValue(Topic);
+ }
+ if (Optional.IsCollectionDefined(DeliveryChannelIds))
+ {
+ writer.WritePropertyName("deliveryChannelIds"u8);
+ writer.WriteStartArray();
+ foreach (var item in DeliveryChannelIds)
+ {
+ writer.WriteStringValue(item);
+ }
+ writer.WriteEndArray();
+ }
+ if (Optional.IsDefined(OutboundDeliveryStrategy))
+ {
+ writer.WritePropertyName("outboundDeliveryStrategy"u8);
+ writer.WriteStringValue(OutboundDeliveryStrategy.Value.ToString());
+ }
+ if (Optional.IsCollectionDefined(Participants))
+ {
+ writer.WritePropertyName("participants"u8);
+ writer.WriteStartArray();
+ foreach (var item in Participants)
+ {
+ writer.WriteObjectValue(item, options);
+ }
+ writer.WriteEndArray();
+ }
+ if (options.Format != "W" && _serializedAdditionalRawData != null)
+ {
+ foreach (var item in _serializedAdditionalRawData)
+ {
+ writer.WritePropertyName(item.Key);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(item.Value);
+#else
+ using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ }
+ }
+
+ CommunicationConversation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(CommunicationConversation)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeCommunicationConversation(document.RootElement, options);
+ }
+
+ internal static CommunicationConversation DeserializeCommunicationConversation(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ string id = default;
+ string topic = default;
+ IList deliveryChannelIds = default;
+ OutboundDeliveryStrategyKind? outboundDeliveryStrategy = default;
+ IList participants = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("id"u8))
+ {
+ id = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("topic"u8))
+ {
+ topic = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("deliveryChannelIds"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ List array = new List();
+ foreach (var item in property.Value.EnumerateArray())
+ {
+ array.Add(item.GetString());
+ }
+ deliveryChannelIds = array;
+ continue;
+ }
+ if (property.NameEquals("outboundDeliveryStrategy"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ outboundDeliveryStrategy = new OutboundDeliveryStrategyKind(property.Value.GetString());
+ continue;
+ }
+ if (property.NameEquals("participants"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ List array = new List();
+ foreach (var item in property.Value.EnumerateArray())
+ {
+ array.Add(ConversationParticipant.DeserializeConversationParticipant(item, options));
+ }
+ participants = array;
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new CommunicationConversation(
+ id,
+ topic,
+ deliveryChannelIds ?? new ChangeTrackingList(),
+ outboundDeliveryStrategy,
+ participants ?? new ChangeTrackingList(),
+ serializedAdditionalRawData);
+ }
+
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(CommunicationConversation)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ CommunicationConversation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeCommunicationConversation(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(CommunicationConversation)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static CommunicationConversation FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeCommunicationConversation(document.RootElement);
+ }
+
+ /// Convert into a .
+ internal virtual RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions);
+ return content;
+ }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationConversation.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationConversation.cs
new file mode 100644
index 000000000000..ec4bbea7166f
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationConversation.cs
@@ -0,0 +1,91 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+
+namespace Azure.Communication.Messages
+{
+ /// A conversation.
+ public partial class CommunicationConversation
+ {
+ ///
+ /// Keeps track of any properties unknown to the library.
+ ///
+ /// To assign an object to the value of this property use .
+ ///
+ ///
+ /// To assign an already formatted json string to this property use .
+ ///
+ ///
+ /// Examples:
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson("foo")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromString("\"foo\"")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson(new { key = "value" })
+ /// Creates a payload of { "key": "value" }.
+ ///
+ /// -
+ /// BinaryData.FromString("{\"key\": \"value\"}")
+ /// Creates a payload of { "key": "value" }.
+ ///
+ ///
+ ///
+ ///
+ private IDictionary _serializedAdditionalRawData;
+
+ /// Initializes a new instance of .
+ public CommunicationConversation()
+ {
+ DeliveryChannelIds = new ChangeTrackingList();
+ Participants = new ChangeTrackingList();
+ }
+
+ /// Initializes a new instance of .
+ /// The conversation ID.
+ /// The conversation topic.
+ /// List of delivery channel IDs.
+ /// Outbound delivery strategy for the conversation.
+ ///
+ /// List of participants involved in the conversation.
+ /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
+ /// The available derived classes include and .
+ ///
+ /// Keeps track of any properties unknown to the library.
+ internal CommunicationConversation(string id, string topic, IList deliveryChannelIds, OutboundDeliveryStrategyKind? outboundDeliveryStrategy, IList participants, IDictionary serializedAdditionalRawData)
+ {
+ Id = id;
+ Topic = topic;
+ DeliveryChannelIds = deliveryChannelIds;
+ OutboundDeliveryStrategy = outboundDeliveryStrategy;
+ Participants = participants;
+ _serializedAdditionalRawData = serializedAdditionalRawData;
+ }
+
+ /// The conversation ID.
+ public string Id { get; }
+ /// The conversation topic.
+ public string Topic { get; set; }
+ /// List of delivery channel IDs.
+ public IList DeliveryChannelIds { get; }
+ /// Outbound delivery strategy for the conversation.
+ public OutboundDeliveryStrategyKind? OutboundDeliveryStrategy { get; set; }
+ ///
+ /// List of participants involved in the conversation.
+ /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
+ /// The available derived classes include and .
+ ///
+ public IList Participants { get; }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationMessagesClientBuilderExtensions.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationMessagesClientBuilderExtensions.cs
index ed2d8514d8be..281cc15e785d 100644
--- a/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationMessagesClientBuilderExtensions.cs
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationMessagesClientBuilderExtensions.cs
@@ -12,7 +12,7 @@
namespace Microsoft.Extensions.Azure
{
- /// Extension methods to add , to client builder.
+ /// Extension methods to add , , , to client builder.
public static partial class CommunicationMessagesClientBuilderExtensions
{
/// Registers a instance.
@@ -53,6 +53,44 @@ public static IAzureClientBuilder((options, cred) => new MessageTemplateClient(endpoint, cred, options));
}
+ /// Registers a instance.
+ /// The builder to register with.
+ /// The communication resource, for example https://my-resource.communication.azure.com.
+ /// A credential used to authenticate to an Azure Service.
+ public static IAzureClientBuilder AddConversationAdministrationClient(this TBuilder builder, Uri endpoint, AzureKeyCredential credential)
+ where TBuilder : IAzureClientFactoryBuilder
+ {
+ return builder.RegisterClientFactory((options) => new ConversationAdministrationClient(endpoint, credential, options));
+ }
+
+ /// Registers a instance.
+ /// The builder to register with.
+ /// The communication resource, for example https://my-resource.communication.azure.com.
+ public static IAzureClientBuilder AddConversationAdministrationClient(this TBuilder builder, Uri endpoint)
+ where TBuilder : IAzureClientFactoryBuilderWithCredential
+ {
+ return builder.RegisterClientFactory((options, cred) => new ConversationAdministrationClient(endpoint, cred, options));
+ }
+
+ /// Registers a instance.
+ /// The builder to register with.
+ /// The communication resource, for example https://my-resource.communication.azure.com.
+ /// A credential used to authenticate to an Azure Service.
+ public static IAzureClientBuilder AddConversationThreadClient(this TBuilder builder, Uri endpoint, AzureKeyCredential credential)
+ where TBuilder : IAzureClientFactoryBuilder
+ {
+ return builder.RegisterClientFactory((options) => new ConversationThreadClient(endpoint, credential, options));
+ }
+
+ /// Registers a instance.
+ /// The builder to register with.
+ /// The communication resource, for example https://my-resource.communication.azure.com.
+ public static IAzureClientBuilder AddConversationThreadClient(this TBuilder builder, Uri endpoint)
+ where TBuilder : IAzureClientFactoryBuilderWithCredential
+ {
+ return builder.RegisterClientFactory((options, cred) => new ConversationThreadClient(endpoint, cred, options));
+ }
+
/// Registers a instance.
/// The builder to register with.
/// The configuration values.
@@ -69,5 +107,21 @@ public static IAzureClientBuilder(configuration);
}
+ /// Registers a instance.
+ /// The builder to register with.
+ /// The configuration values.
+ public static IAzureClientBuilder AddConversationAdministrationClient(this TBuilder builder, TConfiguration configuration)
+ where TBuilder : IAzureClientFactoryBuilderWithConfiguration
+ {
+ return builder.RegisterClientFactory(configuration);
+ }
+ /// Registers a instance.
+ /// The builder to register with.
+ /// The configuration values.
+ public static IAzureClientBuilder AddConversationThreadClient(this TBuilder builder, TConfiguration configuration)
+ where TBuilder : IAzureClientFactoryBuilderWithConfiguration
+ {
+ return builder.RegisterClientFactory(configuration);
+ }
}
}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationMessagesClientOptions.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationMessagesClientOptions.cs
index 9322a32fee38..9ffc2e4af50d 100644
--- a/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationMessagesClientOptions.cs
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationMessagesClientOptions.cs
@@ -13,7 +13,7 @@ namespace Azure.Communication.Messages
/// Client options for Azure.Communication.Messages library clients.
public partial class CommunicationMessagesClientOptions : ClientOptions
{
- private const ServiceVersion LatestVersion = ServiceVersion.V2025_01_15_Preview;
+ private const ServiceVersion LatestVersion = ServiceVersion.V2025_04_01_Preview;
/// The version of the service to use.
public enum ServiceVersion
@@ -24,6 +24,8 @@ public enum ServiceVersion
V2024_08_30 = 2,
/// Service version "2025-01-15-preview".
V2025_01_15_Preview = 3,
+ /// Service version "2025-04-01-preview".
+ V2025_04_01_Preview = 4,
}
internal string Version { get; }
@@ -36,6 +38,7 @@ public CommunicationMessagesClientOptions(ServiceVersion version = LatestVersion
ServiceVersion.V2024_02_01 => "2024-02-01",
ServiceVersion.V2024_08_30 => "2024-08-30",
ServiceVersion.V2025_01_15_Preview => "2025-01-15-preview",
+ ServiceVersion.V2025_04_01_Preview => "2025-04-01-preview",
_ => throw new NotSupportedException()
};
}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationMessagesModelFactory.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationMessagesModelFactory.cs
index 75228e42aea8..57c7476958cc 100644
--- a/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationMessagesModelFactory.cs
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/CommunicationMessagesModelFactory.cs
@@ -18,7 +18,7 @@ public static partial class CommunicationMessagesModelFactory
/// Initializes a new instance of .
/// The Channel Registration ID for the Business Identifier.
/// The native external platform user identifiers of the recipient.
- /// The type discriminator describing a notification type.
+ /// The type discriminator describing a message type.
/// A new instance for mocking.
public static NotificationContent NotificationContent(Guid channelRegistrationId = default, IEnumerable to = null, string kind = null)
{
@@ -260,106 +260,6 @@ public static TemplateNotificationContent TemplateNotificationContent(Guid chann
return new TemplateNotificationContent(channelRegistrationId, to?.ToList(), CommunicationMessageKind.Template, serializedAdditionalRawData: null, template);
}
- /// Initializes a new instance of .
- /// Name of the template.
- /// The template's language, in the ISO 639 format, consist of a two-letter language code followed by an optional two-letter country code, e.g., 'en' or 'en_US'.
- ///
- /// The template values.
- /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
- /// The available derived classes include , , , , and .
- ///
- ///
- /// The binding object to link values to the template specific locations
- /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
- /// The available derived classes include .
- ///
- /// A new instance for mocking.
- public static MessageTemplate MessageTemplate(string name = null, string language = null, IEnumerable values = null, MessageTemplateBindings bindings = null)
- {
- values ??= new List();
-
- return new MessageTemplate(name, language, values?.ToList(), bindings, serializedAdditionalRawData: null);
- }
-
- /// Initializes a new instance of .
- /// Template binding reference name.
- /// The type discriminator describing a template parameter type.
- /// A new instance for mocking.
- public static MessageTemplateValue MessageTemplateValue(string name = null, string kind = null)
- {
- return new UnknownMessageTemplateValue(name, kind == null ? default : new MessageTemplateValueKind(kind), serializedAdditionalRawData: null);
- }
-
- /// Initializes a new instance of .
- /// Template binding reference name.
- /// The text value.
- /// A new instance for mocking.
- public static MessageTemplateText MessageTemplateText(string name = null, string text = null)
- {
- return new MessageTemplateText(name, MessageTemplateValueKind.Text, serializedAdditionalRawData: null, text);
- }
-
- /// Initializes a new instance of .
- /// Template binding reference name.
- /// The (public) URL of the media.
- /// The [optional] caption of the media object.
- /// The [optional] filename of the media file.
- /// A new instance for mocking.
- public static MessageTemplateImage MessageTemplateImage(string name = null, Uri uri = null, string caption = null, string fileName = null)
- {
- return new MessageTemplateImage(
- name,
- MessageTemplateValueKind.Image,
- serializedAdditionalRawData: null,
- uri,
- caption,
- fileName);
- }
-
- /// Initializes a new instance of .
- /// Template binding reference name.
- /// The (public) URL of the media.
- /// The [optional] caption of the media object.
- /// The [optional] filename of the media file.
- /// A new instance for mocking.
- public static MessageTemplateDocument MessageTemplateDocument(string name = null, Uri uri = null, string caption = null, string fileName = null)
- {
- return new MessageTemplateDocument(
- name,
- MessageTemplateValueKind.Document,
- serializedAdditionalRawData: null,
- uri,
- caption,
- fileName);
- }
-
- /// Initializes a new instance of .
- /// Template binding reference name.
- /// The (public) URL of the media.
- /// The [optional] caption of the media object.
- /// The [optional] filename of the media file.
- /// A new instance for mocking.
- public static MessageTemplateVideo MessageTemplateVideo(string name = null, Uri uri = null, string caption = null, string fileName = null)
- {
- return new MessageTemplateVideo(
- name,
- MessageTemplateValueKind.Video,
- serializedAdditionalRawData: null,
- uri,
- caption,
- fileName);
- }
-
- /// Initializes a new instance of .
- /// Template binding reference name.
- /// The [Optional] quick action text.
- /// The [Optional] quick action payload.
- /// A new instance for mocking.
- public static MessageTemplateQuickAction MessageTemplateQuickAction(string name = null, string text = null, string payload = null)
- {
- return new MessageTemplateQuickAction(name, MessageTemplateValueKind.QuickAction, serializedAdditionalRawData: null, text, payload);
- }
-
/// Initializes a new instance of .
/// Receipts of the send message operation.
/// A new instance for mocking.
@@ -406,5 +306,155 @@ public static WhatsAppMessageTemplateItem WhatsAppMessageTemplateItem(string nam
serializedAdditionalRawData: null,
content);
}
+
+ /// Initializes a new instance of .
+ /// The conversation ID.
+ /// The conversation topic.
+ /// List of delivery channel IDs.
+ /// Outbound delivery strategy for the conversation.
+ ///
+ /// List of participants involved in the conversation.
+ /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
+ /// The available derived classes include and .
+ ///
+ /// A new instance for mocking.
+ public static CommunicationConversation CommunicationConversation(string id = null, string topic = null, IEnumerable deliveryChannelIds = null, OutboundDeliveryStrategyKind? outboundDeliveryStrategy = null, IEnumerable participants = null)
+ {
+ deliveryChannelIds ??= new List();
+ participants ??= new List();
+
+ return new CommunicationConversation(
+ id,
+ topic,
+ deliveryChannelIds?.ToList(),
+ outboundDeliveryStrategy,
+ participants?.ToList(),
+ serializedAdditionalRawData: null);
+ }
+
+ /// Initializes a new instance of .
+ /// Participant Identifier.
+ /// Participant display name.
+ /// The type discriminator describing a participant type.
+ /// A new instance for mocking.
+ public static ConversationParticipant ConversationParticipant(string id = null, string displayName = null, string kind = null)
+ {
+ return new UnknownConversationParticipant(id, displayName, kind == null ? default : new ParticipantKind(kind), serializedAdditionalRawData: null);
+ }
+
+ /// Initializes a new instance of .
+ /// Participant Identifier.
+ /// Participant display name.
+ ///
+ /// The internal platform identifiers for the participant.
+ /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
+ /// The available derived classes include , and .
+ ///
+ /// A new instance for mocking.
+ public static InternalConversationParticipant InternalConversationParticipant(string id = null, string displayName = null, ConversationContact contact = null)
+ {
+ return new InternalConversationParticipant(id, displayName, ParticipantKind.Internal, serializedAdditionalRawData: null, contact);
+ }
+
+ /// Initializes a new instance of .
+ /// Participant Identifier.
+ /// Participant display name.
+ ///
+ /// List of external platform identifiers for the participant.
+ /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
+ /// The available derived classes include , and .
+ ///
+ /// A new instance for mocking.
+ public static ExternalConversationParticipant ExternalConversationParticipant(string id = null, string displayName = null, IEnumerable contacts = null)
+ {
+ contacts ??= new List();
+
+ return new ExternalConversationParticipant(id, displayName, ParticipantKind.External, serializedAdditionalRawData: null, contacts?.ToList());
+ }
+
+ /// Initializes a new instance of .
+ /// Message ID.
+ /// Message sequence ID.
+ ///
+ /// Payload of a threaded conversation message.
+ /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
+ /// The available derived classes include , , , , and .
+ ///
+ /// The display name of the message sender.
+ /// The communication identifier of the message sender.
+ /// Timestamp when the message is sent.
+ /// A new instance for mocking.
+ public static ConversationMessageItem ConversationMessageItem(string id = null, long? sequenceId = null, ConversationMessageContent message = null, string senderDisplayName = null, string senderCommunicationIdentifier = null, DateTimeOffset createdOn = default)
+ {
+ return new ConversationMessageItem(
+ id,
+ sequenceId,
+ message,
+ senderDisplayName,
+ senderCommunicationIdentifier,
+ createdOn,
+ serializedAdditionalRawData: null);
+ }
+
+ /// Initializes a new instance of .
+ /// List of Ids with Errors if failed to be added.
+ /// A new instance for mocking.
+ public static AddParticipantsResult AddParticipantsResult(IEnumerable invalidParticipants = null)
+ {
+ invalidParticipants ??= new List();
+
+ return new AddParticipantsResult(invalidParticipants?.ToList(), serializedAdditionalRawData: null);
+ }
+
+ /// Initializes a new instance of .
+ /// Participant User Id.
+ /// Error of the participant operation.
+ /// A new instance for mocking.
+ public static UpdateParticipantsResult UpdateParticipantsResult(string id = null, ResponseError error = null)
+ {
+ return new UpdateParticipantsResult(id, error, serializedAdditionalRawData: null);
+ }
+
+ /// Initializes a new instance of .
+ /// List of Ids with Errors if failed to be added.
+ /// A new instance for mocking.
+ public static RemoveParticipantsResult RemoveParticipantsResult(IEnumerable invalidParticipants = null)
+ {
+ invalidParticipants ??= new List();
+
+ return new RemoveParticipantsResult(invalidParticipants?.ToList(), serializedAdditionalRawData: null);
+ }
+
+ /// Initializes a new instance of .
+ /// The AI summary of the conversation messages.
+ /// A new instance for mocking.
+ public static GetConversationThreadAnalysisResult GetConversationThreadAnalysisResult(string summary = null)
+ {
+ return new GetConversationThreadAnalysisResult(summary, serializedAdditionalRawData: null);
+ }
+
+ /// Initializes a new instance of .
+ ///
+ /// Details of a send conversation message request.
+ /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
+ /// The available derived classes include , , , , and .
+ ///
+ ///
+ /// The options of the outbound delivery strategy for messages sent by participants in a conversation.
+ /// Supports internalOnly, allChannels.
+ ///
+ /// A new instance for mocking.
+ public static SendConversationMessageOptions SendConversationMessageOptions(ConversationMessageContent request = null, OutboundDeliveryStrategyKind? outboundDeliveryStrategy = null)
+ {
+ return new SendConversationMessageOptions(request, outboundDeliveryStrategy, serializedAdditionalRawData: null);
+ }
+
+ /// Initializes a new instance of .
+ /// A server-generated Advanced Messaging conversation message id.
+ /// A new instance for mocking.
+ public static SendConversationMessageResult SendConversationMessageResult(string messageId = null)
+ {
+ return new SendConversationMessageResult(messageId, serializedAdditionalRawData: null);
+ }
}
}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationAdministrationClient.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationAdministrationClient.cs
new file mode 100644
index 000000000000..f11a5132d23b
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationAdministrationClient.cs
@@ -0,0 +1,1216 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using Autorest.CSharp.Core;
+using Azure.Core;
+using Azure.Core.Pipeline;
+
+namespace Azure.Communication.Messages
+{
+ // Data plane generated client.
+ /// The ConversationAdministration service client.
+ public partial class ConversationAdministrationClient
+ {
+ private const string AuthorizationHeader = "Authorization";
+ private readonly AzureKeyCredential _keyCredential;
+ private const string AuthorizationApiKeyPrefix = "Bearer";
+ private static readonly string[] AuthorizationScopes = new string[] { "https://communication.azure.com/.default" };
+ private readonly TokenCredential _tokenCredential;
+ private readonly HttpPipeline _pipeline;
+ private readonly Uri _endpoint;
+ private readonly string _apiVersion;
+
+ /// The ClientDiagnostics is used to provide tracing support for the client library.
+ internal ClientDiagnostics ClientDiagnostics { get; }
+
+ /// The HTTP pipeline for sending and receiving REST requests and responses.
+ public virtual HttpPipeline Pipeline => _pipeline;
+
+ /// Initializes a new instance of ConversationAdministrationClient for mocking.
+ protected ConversationAdministrationClient()
+ {
+ }
+
+ /// Initializes a new instance of ConversationAdministrationClient.
+ /// The communication resource, for example https://my-resource.communication.azure.com.
+ /// A credential used to authenticate to an Azure Service.
+ /// or is null.
+ public ConversationAdministrationClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new CommunicationMessagesClientOptions())
+ {
+ }
+
+ /// Initializes a new instance of ConversationAdministrationClient.
+ /// The communication resource, for example https://my-resource.communication.azure.com.
+ /// A credential used to authenticate to an Azure Service.
+ /// or is null.
+ public ConversationAdministrationClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new CommunicationMessagesClientOptions())
+ {
+ }
+
+ /// Initializes a new instance of ConversationAdministrationClient.
+ /// The communication resource, for example https://my-resource.communication.azure.com.
+ /// A credential used to authenticate to an Azure Service.
+ /// The options for configuring the client.
+ /// or is null.
+ public ConversationAdministrationClient(Uri endpoint, AzureKeyCredential credential, CommunicationMessagesClientOptions options)
+ {
+ Argument.AssertNotNull(endpoint, nameof(endpoint));
+ Argument.AssertNotNull(credential, nameof(credential));
+ options ??= new CommunicationMessagesClientOptions();
+
+ ClientDiagnostics = new ClientDiagnostics(options, true);
+ _keyCredential = credential;
+ _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader, AuthorizationApiKeyPrefix) }, new ResponseClassifier());
+ _endpoint = endpoint;
+ _apiVersion = options.Version;
+ }
+
+ /// Initializes a new instance of ConversationAdministrationClient.
+ /// The communication resource, for example https://my-resource.communication.azure.com.
+ /// A credential used to authenticate to an Azure Service.
+ /// The options for configuring the client.
+ /// or is null.
+ public ConversationAdministrationClient(Uri endpoint, TokenCredential credential, CommunicationMessagesClientOptions options)
+ {
+ Argument.AssertNotNull(endpoint, nameof(endpoint));
+ Argument.AssertNotNull(credential, nameof(credential));
+ options ??= new CommunicationMessagesClientOptions();
+
+ ClientDiagnostics = new ClientDiagnostics(options, true);
+ _tokenCredential = credential;
+ _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier());
+ _endpoint = endpoint;
+ _apiVersion = options.Version;
+ }
+
+ /// Creates a new conversation. This is only for create operation.
+ /// The conversation details.
+ /// An initial message within the conversation.
+ /// The cancellation token to use.
+ /// is null.
+ ///
+ public virtual async Task> CreateConversationAsync(CommunicationConversation conversation, ConversationMessage initialMessage = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(conversation, nameof(conversation));
+
+ CreateConversationRequest1 createConversationRequest1 = new CreateConversationRequest1(conversation, initialMessage, null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await CreateConversationAsync(createConversationRequest1.ToRequestContent(), context).ConfigureAwait(false);
+ return Response.FromValue(CommunicationConversation.FromResponse(response), response);
+ }
+
+ /// Creates a new conversation. This is only for create operation.
+ /// The conversation details.
+ /// An initial message within the conversation.
+ /// The cancellation token to use.
+ /// is null.
+ ///
+ public virtual Response CreateConversation(CommunicationConversation conversation, ConversationMessage initialMessage = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(conversation, nameof(conversation));
+
+ CreateConversationRequest1 createConversationRequest1 = new CreateConversationRequest1(conversation, initialMessage, null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = CreateConversation(createConversationRequest1.ToRequestContent(), context);
+ return Response.FromValue(CommunicationConversation.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Creates a new conversation. This is only for create operation.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task CreateConversationAsync(RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("ConversationAdministrationClient.CreateConversation");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateCreateConversationRequest(content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Creates a new conversation. This is only for create operation.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response CreateConversation(RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("ConversationAdministrationClient.CreateConversation");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateCreateConversationRequest(content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Gets the details of a specific conversation.
+ /// The conversation ID.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> GetConversationAsync(string conversationId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await GetConversationAsync(conversationId, context).ConfigureAwait(false);
+ return Response.FromValue(CommunicationConversation.FromResponse(response), response);
+ }
+
+ /// Gets the details of a specific conversation.
+ /// The conversation ID.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response GetConversation(string conversationId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = GetConversation(conversationId, context);
+ return Response.FromValue(CommunicationConversation.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Gets the details of a specific conversation.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The conversation ID.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task GetConversationAsync(string conversationId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+
+ using var scope = ClientDiagnostics.CreateScope("ConversationAdministrationClient.GetConversation");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetConversationRequest(conversationId, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Gets the details of a specific conversation.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The conversation ID.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response GetConversation(string conversationId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+
+ using var scope = ClientDiagnostics.CreateScope("ConversationAdministrationClient.GetConversation");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetConversationRequest(conversationId, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method
+ ///
+ /// [Protocol Method] Deletes a specific conversation.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// The conversation ID.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task DeleteConversationAsync(string conversationId, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+
+ using var scope = ClientDiagnostics.CreateScope("ConversationAdministrationClient.DeleteConversation");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateDeleteConversationRequest(conversationId, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method
+ ///
+ /// [Protocol Method] Deletes a specific conversation.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// The conversation ID.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response DeleteConversation(string conversationId, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+
+ using var scope = ClientDiagnostics.CreateScope("ConversationAdministrationClient.DeleteConversation");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateDeleteConversationRequest(conversationId, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method
+ ///
+ /// [Protocol Method] Terminates a specific conversation.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// The conversation ID.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task TerminateConversationAsync(string conversationId, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+
+ using var scope = ClientDiagnostics.CreateScope("ConversationAdministrationClient.TerminateConversation");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateTerminateConversationRequest(conversationId, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method
+ ///
+ /// [Protocol Method] Terminates a specific conversation.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// The conversation ID.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response TerminateConversation(string conversationId, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+
+ using var scope = ClientDiagnostics.CreateScope("ConversationAdministrationClient.TerminateConversation");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateTerminateConversationRequest(conversationId, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Adds participants to a specific conversation.
+ /// The conversation ID.
+ /// Details of the payload for adding participants to a conversation.
+ /// The cancellation token to use.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> AddParticipantsAsync(string conversationId, AddParticipantsOptions options, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+ Argument.AssertNotNull(options, nameof(options));
+
+ using RequestContent content = options.ToRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await AddParticipantsAsync(conversationId, content, context).ConfigureAwait(false);
+ return Response.FromValue(AddParticipantsResult.FromResponse(response), response);
+ }
+
+ /// Adds participants to a specific conversation.
+ /// The conversation ID.
+ /// Details of the payload for adding participants to a conversation.
+ /// The cancellation token to use.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response AddParticipants(string conversationId, AddParticipantsOptions options, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+ Argument.AssertNotNull(options, nameof(options));
+
+ using RequestContent content = options.ToRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = AddParticipants(conversationId, content, context);
+ return Response.FromValue(AddParticipantsResult.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Adds participants to a specific conversation.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The conversation ID.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task AddParticipantsAsync(string conversationId, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("ConversationAdministrationClient.AddParticipants");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateAddParticipantsRequest(conversationId, content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Adds participants to a specific conversation.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The conversation ID.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response AddParticipants(string conversationId, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("ConversationAdministrationClient.AddParticipants");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateAddParticipantsRequest(conversationId, content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// remove a participant from a conversation.
+ /// The conversation ID.
+ /// Details of the request body for removing participants from a conversation.
+ /// The cancellation token to use.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> RemoveParticipantsAsync(string conversationId, RemoveParticipantsOptions options, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+ Argument.AssertNotNull(options, nameof(options));
+
+ using RequestContent content = options.ToRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await RemoveParticipantsAsync(conversationId, content, context).ConfigureAwait(false);
+ return Response.FromValue(RemoveParticipantsResult.FromResponse(response), response);
+ }
+
+ /// remove a participant from a conversation.
+ /// The conversation ID.
+ /// Details of the request body for removing participants from a conversation.
+ /// The cancellation token to use.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response RemoveParticipants(string conversationId, RemoveParticipantsOptions options, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+ Argument.AssertNotNull(options, nameof(options));
+
+ using RequestContent content = options.ToRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = RemoveParticipants(conversationId, content, context);
+ return Response.FromValue(RemoveParticipantsResult.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] remove a participant from a conversation
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The conversation ID.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task RemoveParticipantsAsync(string conversationId, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("ConversationAdministrationClient.RemoveParticipants");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateRemoveParticipantsRequest(conversationId, content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] remove a participant from a conversation
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The conversation ID.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response RemoveParticipants(string conversationId, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("ConversationAdministrationClient.RemoveParticipants");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateRemoveParticipantsRequest(conversationId, content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Get AI Analysis of a conversation.
+ /// The conversation ID.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> AnalyzeConversationAsync(string conversationId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await AnalyzeConversationAsync(conversationId, context).ConfigureAwait(false);
+ return Response.FromValue(GetConversationThreadAnalysisResult.FromResponse(response), response);
+ }
+
+ /// Get AI Analysis of a conversation.
+ /// The conversation ID.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response AnalyzeConversation(string conversationId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = AnalyzeConversation(conversationId, context);
+ return Response.FromValue(GetConversationThreadAnalysisResult.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Get AI Analysis of a conversation.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The conversation ID.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task AnalyzeConversationAsync(string conversationId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+
+ using var scope = ClientDiagnostics.CreateScope("ConversationAdministrationClient.AnalyzeConversation");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateAnalyzeConversationRequest(conversationId, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Get AI Analysis of a conversation.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The conversation ID.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response AnalyzeConversation(string conversationId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+
+ using var scope = ClientDiagnostics.CreateScope("ConversationAdministrationClient.AnalyzeConversation");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateAnalyzeConversationRequest(conversationId, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Retrieves list of conversations.
+ /// Number of objects to return per page.
+ /// The participant user ID.
+ /// The id of channel.
+ /// The cancellation token to use.
+ ///
+ public virtual AsyncPageable GetConversationsAsync(int? maxPageSize = null, string participantId = null, Guid? channelId = null, CancellationToken cancellationToken = default)
+ {
+ RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null;
+ HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetConversationsRequest(maxPageSize, participantId, channelId, context);
+ HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetConversationsNextPageRequest(nextLink, maxPageSize, participantId, channelId, context);
+ return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => CommunicationConversation.DeserializeCommunicationConversation(e), ClientDiagnostics, _pipeline, "ConversationAdministrationClient.GetConversations", "value", "nextLink", context);
+ }
+
+ /// Retrieves list of conversations.
+ /// Number of objects to return per page.
+ /// The participant user ID.
+ /// The id of channel.
+ /// The cancellation token to use.
+ ///
+ public virtual Pageable GetConversations(int? maxPageSize = null, string participantId = null, Guid? channelId = null, CancellationToken cancellationToken = default)
+ {
+ RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null;
+ HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetConversationsRequest(maxPageSize, participantId, channelId, context);
+ HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetConversationsNextPageRequest(nextLink, maxPageSize, participantId, channelId, context);
+ return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => CommunicationConversation.DeserializeCommunicationConversation(e), ClientDiagnostics, _pipeline, "ConversationAdministrationClient.GetConversations", "value", "nextLink", context);
+ }
+
+ ///
+ /// [Protocol Method] Retrieves list of conversations.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Number of objects to return per page.
+ /// The participant user ID.
+ /// The id of channel.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// Service returned a non-success status code.
+ /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below.
+ ///
+ public virtual AsyncPageable GetConversationsAsync(int? maxPageSize, string participantId, Guid? channelId, RequestContext context)
+ {
+ HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetConversationsRequest(maxPageSize, participantId, channelId, context);
+ HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetConversationsNextPageRequest(nextLink, maxPageSize, participantId, channelId, context);
+ return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "ConversationAdministrationClient.GetConversations", "value", "nextLink", context);
+ }
+
+ ///
+ /// [Protocol Method] Retrieves list of conversations.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Number of objects to return per page.
+ /// The participant user ID.
+ /// The id of channel.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// Service returned a non-success status code.
+ /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below.
+ ///
+ public virtual Pageable GetConversations(int? maxPageSize, string participantId, Guid? channelId, RequestContext context)
+ {
+ HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetConversationsRequest(maxPageSize, participantId, channelId, context);
+ HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetConversationsNextPageRequest(nextLink, maxPageSize, participantId, channelId, context);
+ return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "ConversationAdministrationClient.GetConversations", "value", "nextLink", context);
+ }
+
+ /// Retrieves list of conversation messages.
+ /// The conversation ID.
+ /// Number of objects to return per page.
+ /// The participant user ID.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual AsyncPageable GetMessagesAsync(string conversationId, int? maxPageSize = null, string participantId = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+
+ RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null;
+ HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMessagesRequest(conversationId, maxPageSize, participantId, context);
+ HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMessagesNextPageRequest(nextLink, conversationId, maxPageSize, participantId, context);
+ return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => ConversationMessageItem.DeserializeConversationMessageItem(e), ClientDiagnostics, _pipeline, "ConversationAdministrationClient.GetMessages", "value", "nextLink", context);
+ }
+
+ /// Retrieves list of conversation messages.
+ /// The conversation ID.
+ /// Number of objects to return per page.
+ /// The participant user ID.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Pageable GetMessages(string conversationId, int? maxPageSize = null, string participantId = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+
+ RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null;
+ HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMessagesRequest(conversationId, maxPageSize, participantId, context);
+ HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMessagesNextPageRequest(nextLink, conversationId, maxPageSize, participantId, context);
+ return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => ConversationMessageItem.DeserializeConversationMessageItem(e), ClientDiagnostics, _pipeline, "ConversationAdministrationClient.GetMessages", "value", "nextLink", context);
+ }
+
+ ///
+ /// [Protocol Method] Retrieves list of conversation messages.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The conversation ID.
+ /// Number of objects to return per page.
+ /// The participant user ID.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below.
+ ///
+ public virtual AsyncPageable GetMessagesAsync(string conversationId, int? maxPageSize, string participantId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+
+ HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMessagesRequest(conversationId, maxPageSize, participantId, context);
+ HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMessagesNextPageRequest(nextLink, conversationId, maxPageSize, participantId, context);
+ return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "ConversationAdministrationClient.GetMessages", "value", "nextLink", context);
+ }
+
+ ///
+ /// [Protocol Method] Retrieves list of conversation messages.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The conversation ID.
+ /// Number of objects to return per page.
+ /// The participant user ID.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below.
+ ///
+ public virtual Pageable GetMessages(string conversationId, int? maxPageSize, string participantId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
+
+ HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMessagesRequest(conversationId, maxPageSize, participantId, context);
+ HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMessagesNextPageRequest(nextLink, conversationId, maxPageSize, participantId, context);
+ return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "ConversationAdministrationClient.GetMessages", "value", "nextLink", context);
+ }
+
+ internal HttpMessage CreateCreateConversationRequest(RequestContent content, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier201);
+ var request = message.Request;
+ request.Method = RequestMethod.Post;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendPath("/messages/conversations", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ request.Headers.Add("Content-Type", "application/json");
+ request.Content = content;
+ return message;
+ }
+
+ internal HttpMessage CreateGetConversationRequest(string conversationId, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier200);
+ var request = message.Request;
+ request.Method = RequestMethod.Get;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendPath("/messages/conversations/", false);
+ uri.AppendPath(conversationId, true);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ return message;
+ }
+
+ internal HttpMessage CreateDeleteConversationRequest(string conversationId, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier204);
+ var request = message.Request;
+ request.Method = RequestMethod.Delete;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendPath("/messages/conversations/", false);
+ uri.AppendPath(conversationId, true);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ request.Headers.Add("Repeatability-Request-ID", Guid.NewGuid());
+ request.Headers.Add("Repeatability-First-Sent", DateTimeOffset.Now, "R");
+ return message;
+ }
+
+ internal HttpMessage CreateTerminateConversationRequest(string conversationId, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier200);
+ var request = message.Request;
+ request.Method = RequestMethod.Post;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendPath("/messages/conversations/", false);
+ uri.AppendPath(conversationId, true);
+ uri.AppendPath(":terminate", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ request.Headers.Add("Repeatability-Request-ID", Guid.NewGuid());
+ request.Headers.Add("Repeatability-First-Sent", DateTimeOffset.Now, "R");
+ return message;
+ }
+
+ internal HttpMessage CreateGetConversationsRequest(int? maxPageSize, string participantId, Guid? channelId, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier200);
+ var request = message.Request;
+ request.Method = RequestMethod.Get;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendPath("/messages/conversations", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ if (maxPageSize != null)
+ {
+ uri.AppendQuery("maxPageSize", maxPageSize.Value, true);
+ }
+ if (participantId != null)
+ {
+ uri.AppendQuery("participantId", participantId, true);
+ }
+ if (channelId != null)
+ {
+ uri.AppendQuery("channelId", channelId.Value, true);
+ }
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ return message;
+ }
+
+ internal HttpMessage CreateGetMessagesRequest(string conversationId, int? maxPageSize, string participantId, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier200);
+ var request = message.Request;
+ request.Method = RequestMethod.Get;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendPath("/messages/conversations/", false);
+ uri.AppendPath(conversationId, true);
+ uri.AppendPath("/messages", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ if (maxPageSize != null)
+ {
+ uri.AppendQuery("maxPageSize", maxPageSize.Value, true);
+ }
+ if (participantId != null)
+ {
+ uri.AppendQuery("participantId", participantId, true);
+ }
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ return message;
+ }
+
+ internal HttpMessage CreateAddParticipantsRequest(string conversationId, RequestContent content, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier207);
+ var request = message.Request;
+ request.Method = RequestMethod.Post;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendPath("/messages/conversations/", false);
+ uri.AppendPath(conversationId, true);
+ uri.AppendPath("/participants:add", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ request.Headers.Add("Repeatability-Request-ID", Guid.NewGuid());
+ request.Headers.Add("Repeatability-First-Sent", DateTimeOffset.Now, "R");
+ request.Headers.Add("Content-Type", "application/json");
+ request.Content = content;
+ return message;
+ }
+
+ internal HttpMessage CreateRemoveParticipantsRequest(string conversationId, RequestContent content, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier207);
+ var request = message.Request;
+ request.Method = RequestMethod.Post;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendPath("/messages/conversations/", false);
+ uri.AppendPath(conversationId, true);
+ uri.AppendPath("/participants:remove", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ request.Headers.Add("Repeatability-Request-ID", Guid.NewGuid());
+ request.Headers.Add("Repeatability-First-Sent", DateTimeOffset.Now, "R");
+ request.Headers.Add("Content-Type", "application/json");
+ request.Content = content;
+ return message;
+ }
+
+ internal HttpMessage CreateAnalyzeConversationRequest(string conversationId, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier200);
+ var request = message.Request;
+ request.Method = RequestMethod.Post;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendPath("/messages/conversations/", false);
+ uri.AppendPath(conversationId, true);
+ uri.AppendPath(":analyze", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ request.Headers.Add("Repeatability-Request-ID", Guid.NewGuid());
+ request.Headers.Add("Repeatability-First-Sent", DateTimeOffset.Now, "R");
+ return message;
+ }
+
+ internal HttpMessage CreateGetConversationsNextPageRequest(string nextLink, int? maxPageSize, string participantId, Guid? channelId, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier200);
+ var request = message.Request;
+ request.Method = RequestMethod.Get;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendRawNextLink(nextLink, false);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ return message;
+ }
+
+ internal HttpMessage CreateGetMessagesNextPageRequest(string nextLink, string conversationId, int? maxPageSize, string participantId, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier200);
+ var request = message.Request;
+ request.Method = RequestMethod.Get;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendRawNextLink(nextLink, false);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ return message;
+ }
+
+ private static RequestContext DefaultRequestContext = new RequestContext();
+ internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default)
+ {
+ if (!cancellationToken.CanBeCanceled)
+ {
+ return DefaultRequestContext;
+ }
+
+ return new RequestContext() { CancellationToken = cancellationToken };
+ }
+
+ private static ResponseClassifier _responseClassifier201;
+ private static ResponseClassifier ResponseClassifier201 => _responseClassifier201 ??= new StatusCodeClassifier(stackalloc ushort[] { 201 });
+ private static ResponseClassifier _responseClassifier200;
+ private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 });
+ private static ResponseClassifier _responseClassifier204;
+ private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 });
+ private static ResponseClassifier _responseClassifier207;
+ private static ResponseClassifier ResponseClassifier207 => _responseClassifier207 ??= new StatusCodeClassifier(stackalloc ushort[] { 207 });
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationContact.Serialization.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationContact.Serialization.cs
new file mode 100644
index 000000000000..93c9e0f28832
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationContact.Serialization.cs
@@ -0,0 +1,137 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.Communication.Messages
+{
+ [PersistableModelProxy(typeof(UnknownConversationContact))]
+ public partial class ConversationContact : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(ConversationContact)} does not support writing '{format}' format.");
+ }
+
+ writer.WritePropertyName("id"u8);
+ writer.WriteStringValue(Id);
+ writer.WritePropertyName("kind"u8);
+ writer.WriteStringValue(Kind.ToString());
+ if (options.Format != "W" && _serializedAdditionalRawData != null)
+ {
+ foreach (var item in _serializedAdditionalRawData)
+ {
+ writer.WritePropertyName(item.Key);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(item.Value);
+#else
+ using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ }
+ }
+
+ ConversationContact IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(ConversationContact)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeConversationContact(document.RootElement, options);
+ }
+
+ internal static ConversationContact DeserializeConversationContact(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ if (element.TryGetProperty("kind", out JsonElement discriminator))
+ {
+ switch (discriminator.GetString())
+ {
+ case "bot": return BotContact.DeserializeBotContact(element, options);
+ case "communication": return CommunicationContact.DeserializeCommunicationContact(element, options);
+ case "whatsApp": return WhatsAppContact.DeserializeWhatsAppContact(element, options);
+ }
+ }
+ return UnknownConversationContact.DeserializeUnknownConversationContact(element, options);
+ }
+
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(ConversationContact)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ ConversationContact IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeConversationContact(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(ConversationContact)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static ConversationContact FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeConversationContact(document.RootElement);
+ }
+
+ /// Convert into a .
+ internal virtual RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions);
+ return content;
+ }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationContact.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationContact.cs
new file mode 100644
index 000000000000..81d3958af8a9
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationContact.cs
@@ -0,0 +1,83 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+
+namespace Azure.Communication.Messages
+{
+ ///
+ /// Details of an external platform contact.
+ /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
+ /// The available derived classes include , and .
+ ///
+ public abstract partial class ConversationContact
+ {
+ ///
+ /// Keeps track of any properties unknown to the library.
+ ///
+ /// To assign an object to the value of this property use .
+ ///
+ ///
+ /// To assign an already formatted json string to this property use .
+ ///
+ ///
+ /// Examples:
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson("foo")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromString("\"foo\"")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson(new { key = "value" })
+ /// Creates a payload of { "key": "value" }.
+ ///
+ /// -
+ /// BinaryData.FromString("{\"key\": \"value\"}")
+ /// Creates a payload of { "key": "value" }.
+ ///
+ ///
+ ///
+ ///
+ private protected IDictionary _serializedAdditionalRawData;
+
+ /// Initializes a new instance of .
+ /// External platform identifier.
+ /// is null.
+ protected ConversationContact(string id)
+ {
+ Argument.AssertNotNull(id, nameof(id));
+
+ Id = id;
+ }
+
+ /// Initializes a new instance of .
+ /// External platform identifier.
+ /// Type of message platform (e.g., WhatsApp).
+ /// Keeps track of any properties unknown to the library.
+ internal ConversationContact(string id, MessagePlatformKind kind, IDictionary serializedAdditionalRawData)
+ {
+ Id = id;
+ Kind = kind;
+ _serializedAdditionalRawData = serializedAdditionalRawData;
+ }
+
+ /// Initializes a new instance of for deserialization.
+ internal ConversationContact()
+ {
+ }
+
+ /// External platform identifier.
+ public string Id { get; set; }
+ /// Type of message platform (e.g., WhatsApp).
+ internal MessagePlatformKind Kind { get; set; }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationMessage.Serialization.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationMessage.Serialization.cs
new file mode 100644
index 000000000000..35608d073f84
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationMessage.Serialization.cs
@@ -0,0 +1,142 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.Communication.Messages
+{
+ public partial class ConversationMessage : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(ConversationMessage)} does not support writing '{format}' format.");
+ }
+
+ writer.WritePropertyName("content"u8);
+ writer.WriteStringValue(Content);
+ if (options.Format != "W" && _serializedAdditionalRawData != null)
+ {
+ foreach (var item in _serializedAdditionalRawData)
+ {
+ writer.WritePropertyName(item.Key);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(item.Value);
+#else
+ using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ }
+ }
+
+ ConversationMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(ConversationMessage)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeConversationMessage(document.RootElement, options);
+ }
+
+ internal static ConversationMessage DeserializeConversationMessage(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ string content = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("content"u8))
+ {
+ content = property.Value.GetString();
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new ConversationMessage(content, serializedAdditionalRawData);
+ }
+
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(ConversationMessage)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ ConversationMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeConversationMessage(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(ConversationMessage)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static ConversationMessage FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeConversationMessage(document.RootElement);
+ }
+
+ /// Convert into a .
+ internal virtual RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions);
+ return content;
+ }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationMessage.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationMessage.cs
new file mode 100644
index 000000000000..a1303fc67bbb
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationMessage.cs
@@ -0,0 +1,75 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+
+namespace Azure.Communication.Messages
+{
+ /// Details of a message.
+ public partial class ConversationMessage
+ {
+ ///
+ /// Keeps track of any properties unknown to the library.
+ ///
+ /// To assign an object to the value of this property use .
+ ///
+ ///
+ /// To assign an already formatted json string to this property use .
+ ///
+ ///
+ /// Examples:
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson("foo")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromString("\"foo\"")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson(new { key = "value" })
+ /// Creates a payload of { "key": "value" }.
+ ///
+ /// -
+ /// BinaryData.FromString("{\"key\": \"value\"}")
+ /// Creates a payload of { "key": "value" }.
+ ///
+ ///
+ ///
+ ///
+ private IDictionary _serializedAdditionalRawData;
+
+ /// Initializes a new instance of .
+ /// Content of the message.
+ /// is null.
+ public ConversationMessage(string content)
+ {
+ Argument.AssertNotNull(content, nameof(content));
+
+ Content = content;
+ }
+
+ /// Initializes a new instance of .
+ /// Content of the message.
+ /// Keeps track of any properties unknown to the library.
+ internal ConversationMessage(string content, IDictionary serializedAdditionalRawData)
+ {
+ Content = content;
+ _serializedAdditionalRawData = serializedAdditionalRawData;
+ }
+
+ /// Initializes a new instance of for deserialization.
+ internal ConversationMessage()
+ {
+ }
+
+ /// Content of the message.
+ public string Content { get; }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationMessageContent.Serialization.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationMessageContent.Serialization.cs
new file mode 100644
index 000000000000..00c7862b9bdc
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationMessageContent.Serialization.cs
@@ -0,0 +1,138 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.Communication.Messages
+{
+ [PersistableModelProxy(typeof(UnknownConversationMessageContent))]
+ public partial class ConversationMessageContent : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(ConversationMessageContent)} does not support writing '{format}' format.");
+ }
+
+ writer.WritePropertyName("kind"u8);
+ writer.WriteStringValue(Kind.ToString());
+ if (options.Format != "W" && _serializedAdditionalRawData != null)
+ {
+ foreach (var item in _serializedAdditionalRawData)
+ {
+ writer.WritePropertyName(item.Key);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(item.Value);
+#else
+ using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ }
+ }
+
+ ConversationMessageContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(ConversationMessageContent)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeConversationMessageContent(document.RootElement, options);
+ }
+
+ internal static ConversationMessageContent DeserializeConversationMessageContent(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ if (element.TryGetProperty("kind", out JsonElement discriminator))
+ {
+ switch (discriminator.GetString())
+ {
+ case "audio": return AudioConversationMessageContent.DeserializeAudioConversationMessageContent(element, options);
+ case "document": return DocumentConversationMessageContent.DeserializeDocumentConversationMessageContent(element, options);
+ case "image": return ImageConversationMessageContent.DeserializeImageConversationMessageContent(element, options);
+ case "template": return TemplateConversationMessageContent.DeserializeTemplateConversationMessageContent(element, options);
+ case "text": return TextConversationMessageContent.DeserializeTextConversationMessageContent(element, options);
+ case "video": return VideoConversationMessageContent.DeserializeVideoConversationMessageContent(element, options);
+ }
+ }
+ return UnknownConversationMessageContent.DeserializeUnknownConversationMessageContent(element, options);
+ }
+
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(ConversationMessageContent)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ ConversationMessageContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeConversationMessageContent(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(ConversationMessageContent)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static ConversationMessageContent FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeConversationMessageContent(document.RootElement);
+ }
+
+ /// Convert into a .
+ internal virtual RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions);
+ return content;
+ }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationMessageContent.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationMessageContent.cs
new file mode 100644
index 000000000000..8f1d32828735
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationMessageContent.cs
@@ -0,0 +1,69 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+
+namespace Azure.Communication.Messages
+{
+ ///
+ /// Details of the conversation message content.
+ /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
+ /// The available derived classes include , , , , and .
+ ///
+ public abstract partial class ConversationMessageContent
+ {
+ ///
+ /// Keeps track of any properties unknown to the library.
+ ///
+ /// To assign an object to the value of this property use .
+ ///
+ ///
+ /// To assign an already formatted json string to this property use .
+ ///
+ ///
+ /// Examples:
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson("foo")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromString("\"foo\"")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson(new { key = "value" })
+ /// Creates a payload of { "key": "value" }.
+ ///
+ /// -
+ /// BinaryData.FromString("{\"key\": \"value\"}")
+ /// Creates a payload of { "key": "value" }.
+ ///
+ ///
+ ///
+ ///
+ private protected IDictionary _serializedAdditionalRawData;
+
+ /// Initializes a new instance of .
+ protected ConversationMessageContent()
+ {
+ }
+
+ /// Initializes a new instance of .
+ /// The type discriminator describing a message type.
+ /// Keeps track of any properties unknown to the library.
+ internal ConversationMessageContent(CommunicationMessageKind kind, IDictionary serializedAdditionalRawData)
+ {
+ Kind = kind;
+ _serializedAdditionalRawData = serializedAdditionalRawData;
+ }
+
+ /// The type discriminator describing a message type.
+ internal CommunicationMessageKind Kind { get; set; }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationMessageItem.Serialization.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationMessageItem.Serialization.cs
new file mode 100644
index 000000000000..de3b463164ce
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationMessageItem.Serialization.cs
@@ -0,0 +1,202 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.Communication.Messages
+{
+ public partial class ConversationMessageItem : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(ConversationMessageItem)} does not support writing '{format}' format.");
+ }
+
+ if (options.Format != "W")
+ {
+ writer.WritePropertyName("id"u8);
+ writer.WriteStringValue(Id);
+ }
+ if (Optional.IsDefined(SequenceId))
+ {
+ writer.WritePropertyName("sequenceId"u8);
+ writer.WriteNumberValue(SequenceId.Value);
+ }
+ writer.WritePropertyName("message"u8);
+ writer.WriteObjectValue(Message, options);
+ if (Optional.IsDefined(SenderDisplayName))
+ {
+ writer.WritePropertyName("senderDisplayName"u8);
+ writer.WriteStringValue(SenderDisplayName);
+ }
+ writer.WritePropertyName("senderCommunicationIdentifier"u8);
+ writer.WriteStringValue(SenderCommunicationIdentifier);
+ writer.WritePropertyName("createdOn"u8);
+ writer.WriteStringValue(CreatedOn, "O");
+ if (options.Format != "W" && _serializedAdditionalRawData != null)
+ {
+ foreach (var item in _serializedAdditionalRawData)
+ {
+ writer.WritePropertyName(item.Key);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(item.Value);
+#else
+ using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ }
+ }
+
+ ConversationMessageItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(ConversationMessageItem)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeConversationMessageItem(document.RootElement, options);
+ }
+
+ internal static ConversationMessageItem DeserializeConversationMessageItem(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ string id = default;
+ long? sequenceId = default;
+ ConversationMessageContent message = default;
+ string senderDisplayName = default;
+ string senderCommunicationIdentifier = default;
+ DateTimeOffset createdOn = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("id"u8))
+ {
+ id = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("sequenceId"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ sequenceId = property.Value.GetInt64();
+ continue;
+ }
+ if (property.NameEquals("message"u8))
+ {
+ message = ConversationMessageContent.DeserializeConversationMessageContent(property.Value, options);
+ continue;
+ }
+ if (property.NameEquals("senderDisplayName"u8))
+ {
+ senderDisplayName = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("senderCommunicationIdentifier"u8))
+ {
+ senderCommunicationIdentifier = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("createdOn"u8))
+ {
+ createdOn = property.Value.GetDateTimeOffset("O");
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new ConversationMessageItem(
+ id,
+ sequenceId,
+ message,
+ senderDisplayName,
+ senderCommunicationIdentifier,
+ createdOn,
+ serializedAdditionalRawData);
+ }
+
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(ConversationMessageItem)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ ConversationMessageItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeConversationMessageItem(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(ConversationMessageItem)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static ConversationMessageItem FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeConversationMessageItem(document.RootElement);
+ }
+
+ /// Convert into a .
+ internal virtual RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions);
+ return content;
+ }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationMessageItem.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationMessageItem.cs
new file mode 100644
index 000000000000..0a263823bc3e
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationMessageItem.cs
@@ -0,0 +1,112 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+
+namespace Azure.Communication.Messages
+{
+ /// The conversation message as returned from the service.
+ public partial class ConversationMessageItem
+ {
+ ///
+ /// Keeps track of any properties unknown to the library.
+ ///
+ /// To assign an object to the value of this property use .
+ ///
+ ///
+ /// To assign an already formatted json string to this property use .
+ ///
+ ///
+ /// Examples:
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson("foo")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromString("\"foo\"")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson(new { key = "value" })
+ /// Creates a payload of { "key": "value" }.
+ ///
+ /// -
+ /// BinaryData.FromString("{\"key\": \"value\"}")
+ /// Creates a payload of { "key": "value" }.
+ ///
+ ///
+ ///
+ ///
+ private IDictionary _serializedAdditionalRawData;
+
+ /// Initializes a new instance of .
+ ///
+ /// Payload of a threaded conversation message.
+ /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
+ /// The available derived classes include , , , , and .
+ ///
+ /// The communication identifier of the message sender.
+ /// Timestamp when the message is sent.
+ /// or is null.
+ internal ConversationMessageItem(ConversationMessageContent message, string senderCommunicationIdentifier, DateTimeOffset createdOn)
+ {
+ Argument.AssertNotNull(message, nameof(message));
+ Argument.AssertNotNull(senderCommunicationIdentifier, nameof(senderCommunicationIdentifier));
+
+ Message = message;
+ SenderCommunicationIdentifier = senderCommunicationIdentifier;
+ CreatedOn = createdOn;
+ }
+
+ /// Initializes a new instance of .
+ /// Message ID.
+ /// Message sequence ID.
+ ///
+ /// Payload of a threaded conversation message.
+ /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
+ /// The available derived classes include , , , , and .
+ ///
+ /// The display name of the message sender.
+ /// The communication identifier of the message sender.
+ /// Timestamp when the message is sent.
+ /// Keeps track of any properties unknown to the library.
+ internal ConversationMessageItem(string id, long? sequenceId, ConversationMessageContent message, string senderDisplayName, string senderCommunicationIdentifier, DateTimeOffset createdOn, IDictionary serializedAdditionalRawData)
+ {
+ Id = id;
+ SequenceId = sequenceId;
+ Message = message;
+ SenderDisplayName = senderDisplayName;
+ SenderCommunicationIdentifier = senderCommunicationIdentifier;
+ CreatedOn = createdOn;
+ _serializedAdditionalRawData = serializedAdditionalRawData;
+ }
+
+ /// Initializes a new instance of for deserialization.
+ internal ConversationMessageItem()
+ {
+ }
+
+ /// Message ID.
+ public string Id { get; }
+ /// Message sequence ID.
+ public long? SequenceId { get; }
+ ///
+ /// Payload of a threaded conversation message.
+ /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
+ /// The available derived classes include , , , , and .
+ ///
+ public ConversationMessageContent Message { get; }
+ /// The display name of the message sender.
+ public string SenderDisplayName { get; }
+ /// The communication identifier of the message sender.
+ public string SenderCommunicationIdentifier { get; }
+ /// Timestamp when the message is sent.
+ public DateTimeOffset CreatedOn { get; }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationParticipant.Serialization.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationParticipant.Serialization.cs
new file mode 100644
index 000000000000..4789c4fda2fb
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/ConversationParticipant.Serialization.cs
@@ -0,0 +1,144 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.Communication.Messages
+{
+ [PersistableModelProxy(typeof(UnknownConversationParticipant))]
+ public partial class ConversationParticipant : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(ConversationParticipant)} does not support writing '{format}' format.");
+ }
+
+ if (options.Format != "W")
+ {
+ writer.WritePropertyName("id"u8);
+ writer.WriteStringValue(Id);
+ }
+ if (Optional.IsDefined(DisplayName))
+ {
+ writer.WritePropertyName("displayName"u8);
+ writer.WriteStringValue(DisplayName);
+ }
+ writer.WritePropertyName("kind"u8);
+ writer.WriteStringValue(Kind.ToString());
+ if (options.Format != "W" && _serializedAdditionalRawData != null)
+ {
+ foreach (var item in _serializedAdditionalRawData)
+ {
+ writer.WritePropertyName(item.Key);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(item.Value);
+#else
+ using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ }
+ }
+
+ ConversationParticipant IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(ConversationParticipant)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeConversationParticipant(document.RootElement, options);
+ }
+
+ internal static ConversationParticipant DeserializeConversationParticipant(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ if (element.TryGetProperty("kind", out JsonElement discriminator))
+ {
+ switch (discriminator.GetString())
+ {
+ case "external": return ExternalConversationParticipant.DeserializeExternalConversationParticipant(element, options);
+ case "internal": return InternalConversationParticipant.DeserializeInternalConversationParticipant(element, options);
+ }
+ }
+ return UnknownConversationParticipant.DeserializeUnknownConversationParticipant(element, options);
+ }
+
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(ConversationParticipant)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ ConversationParticipant IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeConversationParticipant(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(ConversationParticipant)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static ConversationParticipant FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeConversationParticipant(document.RootElement);
+ }
+
+ /// Convert into a