diff --git a/sdk/search/Azure.Search.Documents/CHANGELOG.md b/sdk/search/Azure.Search.Documents/CHANGELOG.md index ffa5bdf4dcea..d7107afc28dd 100644 --- a/sdk/search/Azure.Search.Documents/CHANGELOG.md +++ b/sdk/search/Azure.Search.Documents/CHANGELOG.md @@ -4,6 +4,8 @@ ### Features Added +- Enable the new model serialization using System.ClientModel, refer to this [document](https://aka.ms/azsdk/net/mrw) for more details. + ### Breaking Changes ### Bugs Fixed diff --git a/sdk/search/Azure.Search.Documents/api/Azure.Search.Documents.net8.0.cs b/sdk/search/Azure.Search.Documents/api/Azure.Search.Documents.net8.0.cs index 3e3bab762113..47e0d8122674 100644 --- a/sdk/search/Azure.Search.Documents/api/Azure.Search.Documents.net8.0.cs +++ b/sdk/search/Azure.Search.Documents/api/Azure.Search.Documents.net8.0.cs @@ -1,6 +1,6 @@ namespace Azure.Search.Documents { - public partial class AutocompleteOptions + public partial class AutocompleteOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AutocompleteOptions() { } public string Filter { get { throw null; } set { } } @@ -11,13 +11,18 @@ public AutocompleteOptions() { } public System.Collections.Generic.IList SearchFields { get { throw null; } } public int? Size { get { throw null; } set { } } public bool? UseFuzzyMatching { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.AutocompleteOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.AutocompleteOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public partial class AzureSearchDocumentsContext : System.ClientModel.Primitives.ModelReaderWriterContext { - public AzureSearchDocumentsContext() { } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public Azure.Search.Documents.AzureSearchDocumentsContext Default { get { throw null; } } + internal AzureSearchDocumentsContext() { } + public static Azure.Search.Documents.AzureSearchDocumentsContext Default { get { throw null; } } + protected override bool TryGetTypeBuilderCore(System.Type type, out System.ClientModel.Primitives.ModelReaderWriterTypeBuilder builder) { throw null; } } public partial class GetDocumentOptions { @@ -161,7 +166,7 @@ void System.IDisposable.Dispose() { } public virtual void UploadDocuments(System.Collections.Generic.IEnumerable documents, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { } public virtual System.Threading.Tasks.Task UploadDocumentsAsync(System.Collections.Generic.IEnumerable documents, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } - public partial class SearchOptions + public partial class SearchOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchOptions() { } public System.Collections.Generic.IList Facets { get { throw null; } } @@ -187,8 +192,14 @@ public SearchOptions() { } public int? Size { get { throw null; } set { } } public int? Skip { get { throw null; } set { } } public Azure.Search.Documents.Models.VectorSearchOptions VectorSearch { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.SearchOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.SearchOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SuggestOptions + public partial class SuggestOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SuggestOptions() { } public string Filter { get { throw null; } set { } } @@ -200,6 +211,12 @@ public SuggestOptions() { } public System.Collections.Generic.IList Select { get { throw null; } } public int? Size { get { throw null; } set { } } public bool? UseFuzzyMatching { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.SuggestOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.SuggestOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } } namespace Azure.Search.Documents.Agents @@ -220,18 +237,30 @@ public KnowledgeAgentRetrievalClient(System.Uri endpoint, string agentName, Azur } namespace Azure.Search.Documents.Agents.Models { - public abstract partial class KnowledgeAgentActivityRecord + public abstract partial class KnowledgeAgentActivityRecord : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { protected KnowledgeAgentActivityRecord(int id) { } public int Id { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentActivityRecord System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentActivityRecord System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentAzureSearchDocReference : Azure.Search.Documents.Agents.Models.KnowledgeAgentReference + public partial class KnowledgeAgentAzureSearchDocReference : Azure.Search.Documents.Agents.Models.KnowledgeAgentReference, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal KnowledgeAgentAzureSearchDocReference() : base (default(string), default(int)) { } public string DocKey { get { throw null; } } public System.Collections.Generic.IReadOnlyDictionary SourceData { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentAzureSearchDocReference System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentAzureSearchDocReference System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentIndexParams + public partial class KnowledgeAgentIndexParams : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeAgentIndexParams() { } public string FilterAddOn { get { throw null; } set { } } @@ -239,16 +268,34 @@ public KnowledgeAgentIndexParams() { } public string IndexName { get { throw null; } set { } } public int? MaxDocsForReranker { get { throw null; } set { } } public float? RerankerThreshold { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentIndexParams System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentIndexParams System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentMessage + public partial class KnowledgeAgentMessage : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeAgentMessage(string role, System.Collections.Generic.IEnumerable content) { } public System.Collections.Generic.IList Content { get { throw null; } } public string Role { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentMessage System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentMessage System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public abstract partial class KnowledgeAgentMessageContent + public abstract partial class KnowledgeAgentMessageContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { protected KnowledgeAgentMessageContent() { } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct KnowledgeAgentMessageContentType : System.IEquatable @@ -268,43 +315,79 @@ protected KnowledgeAgentMessageContent() { } public static bool operator !=(Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageContentType left, Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageContentType right) { throw null; } public override string ToString() { throw null; } } - public partial class KnowledgeAgentMessageImageContent : Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageContent + public partial class KnowledgeAgentMessageImageContent : Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageContent, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeAgentMessageImageContent(Azure.Search.Documents.Models.KnowledgeAgentMessageImageContentImage image) { } public Azure.Search.Documents.Models.KnowledgeAgentMessageImageContentImage Image { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageImageContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageImageContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentMessageTextContent : Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageContent + public partial class KnowledgeAgentMessageTextContent : Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageContent, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeAgentMessageTextContent(string text) { } public string Text { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageTextContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageTextContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentModelQueryPlanningActivityRecord : Azure.Search.Documents.Agents.Models.KnowledgeAgentActivityRecord + public partial class KnowledgeAgentModelQueryPlanningActivityRecord : Azure.Search.Documents.Agents.Models.KnowledgeAgentActivityRecord, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal KnowledgeAgentModelQueryPlanningActivityRecord() : base (default(int)) { } public int? ElapsedMs { get { throw null; } } public int? InputTokens { get { throw null; } } public int? OutputTokens { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentModelQueryPlanningActivityRecord System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentModelQueryPlanningActivityRecord System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public abstract partial class KnowledgeAgentReference + public abstract partial class KnowledgeAgentReference : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { protected KnowledgeAgentReference(string id, int activitySource) { } public int ActivitySource { get { throw null; } } public string Id { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentReference System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentReference System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentRetrievalRequest + public partial class KnowledgeAgentRetrievalRequest : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeAgentRetrievalRequest(System.Collections.Generic.IEnumerable messages) { } public System.Collections.Generic.IList Messages { get { throw null; } } public System.Collections.Generic.IList TargetIndexParams { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentRetrievalRequest System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentRetrievalRequest System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentRetrievalResponse + public partial class KnowledgeAgentRetrievalResponse : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal KnowledgeAgentRetrievalResponse() { } public System.Collections.Generic.IReadOnlyList Activity { get { throw null; } } public System.Collections.Generic.IReadOnlyList References { get { throw null; } } public System.Collections.Generic.IReadOnlyList Response { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentRetrievalResponse System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentRetrievalResponse System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentSearchActivityRecord : Azure.Search.Documents.Agents.Models.KnowledgeAgentActivityRecord + public partial class KnowledgeAgentSearchActivityRecord : Azure.Search.Documents.Agents.Models.KnowledgeAgentActivityRecord, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal KnowledgeAgentSearchActivityRecord() : base (default(int)) { } public int? Count { get { throw null; } } @@ -312,12 +395,24 @@ internal KnowledgeAgentSearchActivityRecord() : base (default(int)) { } public Azure.Search.Documents.Models.KnowledgeAgentSearchActivityRecordQuery Query { get { throw null; } } public System.DateTimeOffset? QueryTime { get { throw null; } } public string TargetIndex { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentSearchActivityRecord System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentSearchActivityRecord System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentSemanticRankerActivityRecord : Azure.Search.Documents.Agents.Models.KnowledgeAgentActivityRecord + public partial class KnowledgeAgentSemanticRankerActivityRecord : Azure.Search.Documents.Agents.Models.KnowledgeAgentActivityRecord, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal KnowledgeAgentSemanticRankerActivityRecord() : base (default(int)) { } public int? ElapsedMs { get { throw null; } } public int? InputTokens { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentSemanticRankerActivityRecord System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentSemanticRankerActivityRecord System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } } namespace Azure.Search.Documents.Indexes @@ -545,40 +640,70 @@ namespace Azure.Search.Documents.Indexes.Models public static bool operator !=(Azure.Search.Documents.Indexes.Models.AIFoundryModelCatalogName left, Azure.Search.Documents.Indexes.Models.AIFoundryModelCatalogName right) { throw null; } public override string ToString() { throw null; } } - public partial class AIServicesAccountIdentity : Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount + public partial class AIServicesAccountIdentity : Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AIServicesAccountIdentity(string subdomainUrl) { } public Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity Identity { get { throw null; } set { } } public string SubdomainUrl { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AIServicesAccountIdentity System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AIServicesAccountIdentity System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AIServicesAccountKey : Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount + public partial class AIServicesAccountKey : Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AIServicesAccountKey(string key, string subdomainUrl) { } public string Key { get { throw null; } set { } } public string SubdomainUrl { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AIServicesAccountKey System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AIServicesAccountKey System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AIServicesVisionParameters + public partial class AIServicesVisionParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AIServicesVisionParameters(string modelVersion, System.Uri resourceUri) { } public string ApiKey { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity AuthIdentity { get { throw null; } set { } } public string ModelVersion { get { throw null; } set { } } public System.Uri ResourceUri { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AIServicesVisionParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AIServicesVisionParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AIServicesVisionVectorizer : Azure.Search.Documents.Indexes.Models.VectorSearchVectorizer + public partial class AIServicesVisionVectorizer : Azure.Search.Documents.Indexes.Models.VectorSearchVectorizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AIServicesVisionVectorizer(string vectorizerName) : base (default(string)) { } public Azure.Search.Documents.Indexes.Models.AIServicesVisionParameters AIServicesVisionParameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AIServicesVisionVectorizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AIServicesVisionVectorizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AnalyzedTokenInfo + public partial class AnalyzedTokenInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal AnalyzedTokenInfo() { } public int EndOffset { get { throw null; } } public int Position { get { throw null; } } public int StartOffset { get { throw null; } } public string Token { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AnalyzedTokenInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AnalyzedTokenInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AnalyzeTextOptions + public partial class AnalyzeTextOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AnalyzeTextOptions(string text) { } public AnalyzeTextOptions(string text, Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName analyzerName) { } @@ -590,13 +715,25 @@ public AnalyzeTextOptions(string text, Azure.Search.Documents.Indexes.Models.Lex public string Text { get { throw null; } } public System.Collections.Generic.IList TokenFilters { get { throw null; } } public Azure.Search.Documents.Indexes.Models.LexicalTokenizerName? TokenizerName { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AnalyzeTextOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AnalyzeTextOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AsciiFoldingTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class AsciiFoldingTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AsciiFoldingTokenFilter(string name) { } public bool? PreserveOriginal { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AsciiFoldingTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AsciiFoldingTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AzureMachineLearningParameters + public partial class AzureMachineLearningParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AzureMachineLearningParameters(System.Uri scoringUri) { } public string AuthenticationKey { get { throw null; } set { } } @@ -605,8 +742,14 @@ public AzureMachineLearningParameters(System.Uri scoringUri) { } public string ResourceId { get { throw null; } set { } } public System.Uri ScoringUri { get { throw null; } set { } } public System.TimeSpan? Timeout { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureMachineLearningParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureMachineLearningParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AzureMachineLearningSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class AzureMachineLearningSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AzureMachineLearningSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs, Azure.Core.ResourceIdentifier resourceId, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?)) { } public AzureMachineLearningSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs, System.Uri scoringUri, string authenticationKey = null) { } @@ -616,13 +759,25 @@ public AzureMachineLearningSkill(System.Collections.Generic.IEnumerable.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureMachineLearningSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AzureMachineLearningVectorizer : Azure.Search.Documents.Indexes.Models.VectorSearchVectorizer + public partial class AzureMachineLearningVectorizer : Azure.Search.Documents.Indexes.Models.VectorSearchVectorizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AzureMachineLearningVectorizer(string vectorizerName) : base (default(string)) { } public Azure.Search.Documents.Indexes.Models.AzureMachineLearningParameters AMLParameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureMachineLearningVectorizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureMachineLearningVectorizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AzureOpenAIEmbeddingSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class AzureOpenAIEmbeddingSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AzureOpenAIEmbeddingSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public string ApiKey { get { throw null; } set { } } @@ -631,6 +786,12 @@ public AzureOpenAIEmbeddingSkill(System.Collections.Generic.IEnumerable.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureOpenAIEmbeddingSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct AzureOpenAIModelName : System.IEquatable @@ -656,18 +817,30 @@ public AzureOpenAIEmbeddingSkill(System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public AzureOpenAITokenizerParameters() { } public System.Collections.Generic.IList AllowedSpecialTokens { get { throw null; } } public Azure.Search.Documents.Indexes.Models.SplitSkillEncoderModelName? EncoderModelName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureOpenAITokenizerParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureOpenAITokenizerParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AzureOpenAIVectorizer : Azure.Search.Documents.Indexes.Models.VectorSearchVectorizer + public partial class AzureOpenAIVectorizer : Azure.Search.Documents.Indexes.Models.VectorSearchVectorizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AzureOpenAIVectorizer(string vectorizerName) : base (default(string)) { } public Azure.Search.Documents.Indexes.Models.AzureOpenAIVectorizerParameters Parameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureOpenAIVectorizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureOpenAIVectorizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AzureOpenAIVectorizerParameters + public partial class AzureOpenAIVectorizerParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AzureOpenAIVectorizerParameters() { } public string ApiKey { get { throw null; } set { } } @@ -675,10 +848,22 @@ public AzureOpenAIVectorizerParameters() { } public string DeploymentName { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.AzureOpenAIModelName? ModelName { get { throw null; } set { } } public System.Uri ResourceUri { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureOpenAIVectorizerParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureOpenAIVectorizerParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class BinaryQuantizationCompression : Azure.Search.Documents.Indexes.Models.VectorSearchCompression + public partial class BinaryQuantizationCompression : Azure.Search.Documents.Indexes.Models.VectorSearchCompression, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public BinaryQuantizationCompression(string compressionName) : base (default(string)) { } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.BinaryQuantizationCompression System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.BinaryQuantizationCompression System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct BlobIndexerDataToExtract : System.IEquatable @@ -759,16 +944,28 @@ public BinaryQuantizationCompression(string compressionName) : base (default(str public static bool operator !=(Azure.Search.Documents.Indexes.Models.BlobIndexerPdfTextRotationAlgorithm left, Azure.Search.Documents.Indexes.Models.BlobIndexerPdfTextRotationAlgorithm right) { throw null; } public override string ToString() { throw null; } } - public partial class BM25Similarity : Azure.Search.Documents.Indexes.Models.SimilarityAlgorithm + public partial class BM25Similarity : Azure.Search.Documents.Indexes.Models.SimilarityAlgorithm, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public BM25Similarity() { } public double? B { get { throw null; } set { } } public double? K1 { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.BM25Similarity System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.BM25Similarity System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CharFilter + public partial class CharFilter : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal CharFilter() { } public string Name { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CharFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CharFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct CharFilterName : System.IEquatable @@ -806,21 +1003,33 @@ internal CharFilter() { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.ChatCompletionExtraParametersBehavior left, Azure.Search.Documents.Indexes.Models.ChatCompletionExtraParametersBehavior right) { throw null; } public override string ToString() { throw null; } } - public partial class ChatCompletionResponseFormat + public partial class ChatCompletionResponseFormat : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ChatCompletionResponseFormat() { } public Azure.Search.Documents.Models.ChatCompletionResponseFormatJsonSchemaProperties ChatCompletionSchemaProperties { get { throw null; } set { } } public Azure.Search.Documents.Models.ChatCompletionResponseFormatType? Type { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ChatCompletionResponseFormat System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ChatCompletionResponseFormat System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ChatCompletionSchema + public partial class ChatCompletionSchema : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ChatCompletionSchema() { } public bool? AdditionalProperties { get { throw null; } set { } } public string Properties { get { throw null; } set { } } public System.Collections.Generic.IList Required { get { throw null; } } public string Type { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ChatCompletionSchema System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ChatCompletionSchema System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ChatCompletionSkill : Azure.Search.Documents.Indexes.Models.WebApiSkill + public partial class ChatCompletionSkill : Azure.Search.Documents.Indexes.Models.WebApiSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ChatCompletionSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs, string uri) : base (default(System.Collections.Generic.IEnumerable), default(System.Collections.Generic.IEnumerable), default(string)) { } public string ApiKey { get { throw null; } set { } } @@ -828,12 +1037,24 @@ public partial class ChatCompletionSkill : Azure.Search.Documents.Indexes.Models public System.Collections.Generic.IDictionary ExtraParameters { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.ChatCompletionExtraParametersBehavior? ExtraParametersBehavior { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.ChatCompletionResponseFormat ResponseFormat { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ChatCompletionSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ChatCompletionSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CjkBigramTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class CjkBigramTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CjkBigramTokenFilter(string name) { } public System.Collections.Generic.IList IgnoreScripts { get { throw null; } } public bool? OutputUnigrams { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CjkBigramTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CjkBigramTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum CjkBigramTokenFilterScripts { @@ -842,33 +1063,63 @@ public enum CjkBigramTokenFilterScripts Katakana = 2, Hangul = 3, } - public partial class ClassicSimilarity : Azure.Search.Documents.Indexes.Models.SimilarityAlgorithm + public partial class ClassicSimilarity : Azure.Search.Documents.Indexes.Models.SimilarityAlgorithm, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ClassicSimilarity() { } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ClassicSimilarity System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ClassicSimilarity System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ClassicTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class ClassicTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ClassicTokenizer(string name) { } public int? MaxTokenLength { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ClassicTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ClassicTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CognitiveServicesAccount + public partial class CognitiveServicesAccount : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal CognitiveServicesAccount() { } public string Description { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CognitiveServicesAccountKey : Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount + public partial class CognitiveServicesAccountKey : Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CognitiveServicesAccountKey(string key) { } public string Key { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CognitiveServicesAccountKey System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CognitiveServicesAccountKey System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CommonGramTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class CommonGramTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CommonGramTokenFilter(string name, System.Collections.Generic.IEnumerable commonWords) { } public System.Collections.Generic.IList CommonWords { get { throw null; } } public bool? IgnoreCase { get { throw null; } set { } } public bool? UseQueryMode { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CommonGramTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CommonGramTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CommonModelParameters + public partial class CommonModelParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CommonModelParameters() { } public float? FrequencyPenalty { get { throw null; } set { } } @@ -878,30 +1129,54 @@ public CommonModelParameters() { } public int? Seed { get { throw null; } set { } } public System.Collections.Generic.IList Stop { get { throw null; } set { } } public float? Temperature { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CommonModelParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CommonModelParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class ComplexField : Azure.Search.Documents.Indexes.Models.SearchFieldTemplate { public ComplexField(string name, bool collection = false) { } public System.Collections.Generic.IList Fields { get { throw null; } } } - public partial class ConditionalSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class ConditionalSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ConditionalSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ConditionalSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ConditionalSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CorsOptions + public partial class CorsOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CorsOptions(System.Collections.Generic.IEnumerable allowedOrigins) { } public System.Collections.Generic.IList AllowedOrigins { get { throw null; } } public long? MaxAgeInSeconds { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CorsOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CorsOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CustomAnalyzer : Azure.Search.Documents.Indexes.Models.LexicalAnalyzer + public partial class CustomAnalyzer : Azure.Search.Documents.Indexes.Models.LexicalAnalyzer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CustomAnalyzer(string name, Azure.Search.Documents.Indexes.Models.LexicalTokenizerName tokenizerName) { } public System.Collections.Generic.IList CharFilters { get { throw null; } } public System.Collections.Generic.IList TokenFilters { get { throw null; } } public Azure.Search.Documents.Indexes.Models.LexicalTokenizerName TokenizerName { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CustomAnalyzer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CustomAnalyzer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CustomEntity + public partial class CustomEntity : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CustomEntity(string name) { } public bool? AccentSensitive { get { throw null; } set { } } @@ -916,16 +1191,28 @@ public CustomEntity(string name) { } public string Name { get { throw null; } set { } } public string Subtype { get { throw null; } set { } } public string Type { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CustomEntity System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CustomEntity System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CustomEntityAlias + public partial class CustomEntityAlias : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CustomEntityAlias(string text) { } public bool? AccentSensitive { get { throw null; } set { } } public bool? CaseSensitive { get { throw null; } set { } } public int? FuzzyEditDistance { get { throw null; } set { } } public string Text { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CustomEntityAlias System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CustomEntityAlias System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CustomEntityLookupSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class CustomEntityLookupSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CustomEntityLookupSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public Azure.Search.Documents.Indexes.Models.CustomEntityLookupSkillLanguage? DefaultLanguageCode { get { throw null; } set { } } @@ -934,6 +1221,12 @@ public CustomEntityLookupSkill(System.Collections.Generic.IEnumerable InlineEntitiesDefinition { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CustomEntityLookupSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CustomEntityLookupSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct CustomEntityLookupSkillLanguage : System.IEquatable @@ -960,25 +1253,49 @@ public CustomEntityLookupSkill(System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public CustomNormalizer(string name) : base (default(string)) { } public System.Collections.Generic.IList CharFilters { get { throw null; } } public System.Collections.Generic.IList TokenFilters { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CustomNormalizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CustomNormalizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class DataChangeDetectionPolicy + public partial class DataChangeDetectionPolicy : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal DataChangeDetectionPolicy() { } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DataChangeDetectionPolicy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DataChangeDetectionPolicy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class DataDeletionDetectionPolicy + public partial class DataDeletionDetectionPolicy : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal DataDeletionDetectionPolicy() { } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DataDeletionDetectionPolicy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DataDeletionDetectionPolicy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class DefaultCognitiveServicesAccount : Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount + public partial class DefaultCognitiveServicesAccount : Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public DefaultCognitiveServicesAccount() { } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DefaultCognitiveServicesAccount System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DefaultCognitiveServicesAccount System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class DictionaryDecompounderTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class DictionaryDecompounderTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public DictionaryDecompounderTokenFilter(string name, System.Collections.Generic.IEnumerable wordList) { } public int? MaxSubwordSize { get { throw null; } set { } } @@ -986,26 +1303,50 @@ public DictionaryDecompounderTokenFilter(string name, System.Collections.Generic public int? MinWordSize { get { throw null; } set { } } public bool? OnlyLongestMatch { get { throw null; } set { } } public System.Collections.Generic.IList WordList { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DictionaryDecompounderTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DictionaryDecompounderTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class DistanceScoringFunction : Azure.Search.Documents.Indexes.Models.ScoringFunction + public partial class DistanceScoringFunction : Azure.Search.Documents.Indexes.Models.ScoringFunction, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public DistanceScoringFunction(string fieldName, double boost, Azure.Search.Documents.Indexes.Models.DistanceScoringParameters parameters) { } public Azure.Search.Documents.Indexes.Models.DistanceScoringParameters Parameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DistanceScoringFunction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DistanceScoringFunction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class DistanceScoringParameters + public partial class DistanceScoringParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public DistanceScoringParameters(string referencePointParameter, double boostingDistance) { } public double BoostingDistance { get { throw null; } set { } } public string ReferencePointParameter { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DistanceScoringParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DistanceScoringParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class DocumentExtractionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class DocumentExtractionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public DocumentExtractionSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public System.Collections.Generic.IDictionary Configuration { get { throw null; } } public Azure.Search.Documents.Indexes.Models.BlobIndexerDataToExtract? DataToExtract { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.BlobIndexerParsingMode? ParsingMode { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DocumentExtractionSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DocumentExtractionSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class DocumentIntelligenceLayoutSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class DocumentIntelligenceLayoutSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public DocumentIntelligenceLayoutSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public Azure.Search.Documents.Indexes.Models.DocumentIntelligenceLayoutSkillChunkingProperties ChunkingProperties { get { throw null; } set { } } @@ -1013,13 +1354,25 @@ public DocumentIntelligenceLayoutSkill(System.Collections.Generic.IEnumerable.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DocumentIntelligenceLayoutSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class DocumentIntelligenceLayoutSkillChunkingProperties + public partial class DocumentIntelligenceLayoutSkillChunkingProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public DocumentIntelligenceLayoutSkillChunkingProperties() { } public int? MaximumLength { get { throw null; } set { } } public int? OverlapLength { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.DocumentIntelligenceLayoutSkillChunkingUnit? Unit { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DocumentIntelligenceLayoutSkillChunkingProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DocumentIntelligenceLayoutSkillChunkingProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct DocumentIntelligenceLayoutSkillChunkingUnit : System.IEquatable @@ -1113,29 +1466,47 @@ public DocumentIntelligenceLayoutSkillChunkingProperties() { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.DocumentIntelligenceLayoutSkillOutputMode left, Azure.Search.Documents.Indexes.Models.DocumentIntelligenceLayoutSkillOutputMode right) { throw null; } public override string ToString() { throw null; } } - public partial class EdgeNGramTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class EdgeNGramTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public EdgeNGramTokenFilter(string name) { } public int? MaxGram { get { throw null; } set { } } public int? MinGram { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.EdgeNGramTokenFilterSide? Side { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.EdgeNGramTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.EdgeNGramTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum EdgeNGramTokenFilterSide { Front = 0, Back = 1, } - public partial class EdgeNGramTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class EdgeNGramTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public EdgeNGramTokenizer(string name) { } public int? MaxGram { get { throw null; } set { } } public int? MinGram { get { throw null; } set { } } public System.Collections.Generic.IList TokenChars { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.EdgeNGramTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.EdgeNGramTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ElisionTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class ElisionTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ElisionTokenFilter(string name) { } public System.Collections.Generic.IList Articles { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ElisionTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ElisionTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct EntityCategory : System.IEquatable @@ -1160,14 +1531,20 @@ public ElisionTokenFilter(string name) { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.EntityCategory left, Azure.Search.Documents.Indexes.Models.EntityCategory right) { throw null; } public override string ToString() { throw null; } } - public partial class EntityLinkingSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class EntityLinkingSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public EntityLinkingSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public string DefaultLanguageCode { get { throw null; } set { } } public double? MinimumPrecision { get { throw null; } set { } } public string ModelVersion { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.EntityLinkingSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.EntityLinkingSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class EntityRecognitionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class EntityRecognitionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public EntityRecognitionSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } @@ -1177,6 +1554,12 @@ public EntityRecognitionSkill(System.Collections.Generic.IEnumerable.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.EntityRecognitionSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct SkillVersion : System.IEquatable { @@ -1239,63 +1622,123 @@ public EntityRecognitionSkill(System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public ExhaustiveKnnAlgorithmConfiguration(string name) : base (default(string)) { } public Azure.Search.Documents.Indexes.Models.ExhaustiveKnnParameters Parameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ExhaustiveKnnAlgorithmConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ExhaustiveKnnAlgorithmConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ExhaustiveKnnParameters + public partial class ExhaustiveKnnParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ExhaustiveKnnParameters() { } public Azure.Search.Documents.Indexes.Models.VectorSearchAlgorithmMetric? Metric { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ExhaustiveKnnParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ExhaustiveKnnParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class FieldMapping + public partial class FieldMapping : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public FieldMapping(string sourceFieldName) { } public Azure.Search.Documents.Indexes.Models.FieldMappingFunction MappingFunction { get { throw null; } set { } } public string SourceFieldName { get { throw null; } set { } } public string TargetFieldName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.FieldMapping System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.FieldMapping System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class FieldMappingFunction + public partial class FieldMappingFunction : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public FieldMappingFunction(string name) { } public string Name { get { throw null; } set { } } public System.Collections.Generic.IDictionary Parameters { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.FieldMappingFunction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.FieldMappingFunction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class FreshnessScoringFunction : Azure.Search.Documents.Indexes.Models.ScoringFunction + public partial class FreshnessScoringFunction : Azure.Search.Documents.Indexes.Models.ScoringFunction, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public FreshnessScoringFunction(string fieldName, double boost, Azure.Search.Documents.Indexes.Models.FreshnessScoringParameters parameters) { } public Azure.Search.Documents.Indexes.Models.FreshnessScoringParameters Parameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.FreshnessScoringFunction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.FreshnessScoringFunction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class FreshnessScoringParameters + public partial class FreshnessScoringParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public FreshnessScoringParameters(System.TimeSpan boostingDuration) { } public System.TimeSpan BoostingDuration { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.FreshnessScoringParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.FreshnessScoringParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class HighWaterMarkChangeDetectionPolicy : Azure.Search.Documents.Indexes.Models.DataChangeDetectionPolicy + public partial class HighWaterMarkChangeDetectionPolicy : Azure.Search.Documents.Indexes.Models.DataChangeDetectionPolicy, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public HighWaterMarkChangeDetectionPolicy(string highWaterMarkColumnName) { } public string HighWaterMarkColumnName { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.HighWaterMarkChangeDetectionPolicy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.HighWaterMarkChangeDetectionPolicy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class HnswAlgorithmConfiguration : Azure.Search.Documents.Indexes.Models.VectorSearchAlgorithmConfiguration + public partial class HnswAlgorithmConfiguration : Azure.Search.Documents.Indexes.Models.VectorSearchAlgorithmConfiguration, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public HnswAlgorithmConfiguration(string name) : base (default(string)) { } public Azure.Search.Documents.Indexes.Models.HnswParameters Parameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.HnswAlgorithmConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.HnswAlgorithmConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class HnswParameters + public partial class HnswParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public HnswParameters() { } public int? EfConstruction { get { throw null; } set { } } public int? EfSearch { get { throw null; } set { } } public int? M { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.VectorSearchAlgorithmMetric? Metric { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.HnswParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.HnswParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ImageAnalysisSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class ImageAnalysisSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ImageAnalysisSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public Azure.Search.Documents.Indexes.Models.ImageAnalysisSkillLanguage? DefaultLanguageCode { get { throw null; } set { } } public System.Collections.Generic.IList Details { get { throw null; } } public System.Collections.Generic.IList VisualFeatures { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ImageAnalysisSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ImageAnalysisSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct ImageAnalysisSkillLanguage : System.IEquatable @@ -1409,7 +1852,7 @@ internal IndexerChangeTrackingState() { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.IndexerExecutionEnvironment left, Azure.Search.Documents.Indexes.Models.IndexerExecutionEnvironment right) { throw null; } public override string ToString() { throw null; } } - public partial class IndexerExecutionResult + public partial class IndexerExecutionResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal IndexerExecutionResult() { } public System.DateTimeOffset? EndTime { get { throw null; } } @@ -1424,6 +1867,12 @@ internal IndexerExecutionResult() { } public Azure.Search.Documents.Indexes.Models.IndexerExecutionStatus Status { get { throw null; } } public Azure.Search.Documents.Indexes.Models.IndexerExecutionStatusDetail? StatusDetail { get { throw null; } } public System.Collections.Generic.IReadOnlyList Warnings { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexerExecutionResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexerExecutionResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum IndexerExecutionStatus { @@ -1486,7 +1935,7 @@ public enum IndexerExecutionStatus public static bool operator !=(Azure.Search.Documents.Indexes.Models.IndexerResyncOption left, Azure.Search.Documents.Indexes.Models.IndexerResyncOption right) { throw null; } public override string ToString() { throw null; } } - public partial class IndexerState + public partial class IndexerState : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal IndexerState() { } public string AllDocsFinalTrackingState { get { throw null; } } @@ -1499,6 +1948,12 @@ internal IndexerState() { } public System.Collections.Generic.IReadOnlyList ResetDocumentKeys { get { throw null; } } public string ResyncFinalTrackingState { get { throw null; } } public string ResyncInitialTrackingState { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexerState System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexerState System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum IndexerStatus { @@ -1525,7 +1980,7 @@ public enum IndexerStatus public static bool operator !=(Azure.Search.Documents.Indexes.Models.IndexingMode left, Azure.Search.Documents.Indexes.Models.IndexingMode right) { throw null; } public override string ToString() { throw null; } } - public partial class IndexingParameters + public partial class IndexingParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public IndexingParameters() { } public int? BatchSize { get { throw null; } set { } } @@ -1534,8 +1989,14 @@ public IndexingParameters() { } public Azure.Search.Documents.Indexes.Models.IndexingParametersConfiguration IndexingParametersConfiguration { get { throw null; } set { } } public int? MaxFailedItems { get { throw null; } set { } } public int? MaxFailedItemsPerBatch { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexingParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexingParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class IndexingParametersConfiguration : System.Collections.Generic.ICollection>, System.Collections.Generic.IDictionary, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + public partial class IndexingParametersConfiguration : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel, System.Collections.Generic.ICollection>, System.Collections.Generic.IDictionary, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable { public IndexingParametersConfiguration() { } public bool? AllowSkillsetToReadFileData { get { throw null; } set { } } @@ -1564,7 +2025,13 @@ public IndexingParametersConfiguration() { } public void Add(string key, object value) { } public bool ContainsKey(string key) { throw null; } public System.Collections.Generic.IEnumerator> GetEnumerator() { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } public bool Remove(string key) { throw null; } + Azure.Search.Documents.Indexes.Models.IndexingParametersConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexingParametersConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.Collections.Generic.ICollection>.Add(System.Collections.Generic.KeyValuePair value) { } void System.Collections.Generic.ICollection>.Clear() { } bool System.Collections.Generic.ICollection>.Contains(System.Collections.Generic.KeyValuePair value) { throw null; } @@ -1573,11 +2040,17 @@ public void Add(string key, object value) { } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } public bool TryGetValue(string key, out object value) { throw null; } } - public partial class IndexingSchedule + public partial class IndexingSchedule : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public IndexingSchedule(System.TimeSpan interval) { } public System.TimeSpan Interval { get { throw null; } set { } } public System.DateTimeOffset? StartTime { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexingSchedule System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexingSchedule System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct IndexProjectionMode : System.IEquatable @@ -1597,33 +2070,57 @@ public IndexingSchedule(System.TimeSpan interval) { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.IndexProjectionMode left, Azure.Search.Documents.Indexes.Models.IndexProjectionMode right) { throw null; } public override string ToString() { throw null; } } - public partial class IndexStatisticsSummary + public partial class IndexStatisticsSummary : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal IndexStatisticsSummary() { } public long DocumentCount { get { throw null; } } public string Name { get { throw null; } } public long StorageSize { get { throw null; } } public long VectorIndexSize { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexStatisticsSummary System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexStatisticsSummary System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class InputFieldMappingEntry + public partial class InputFieldMappingEntry : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public InputFieldMappingEntry(string name) { } public System.Collections.Generic.IList Inputs { get { throw null; } } public string Name { get { throw null; } set { } } public string Source { get { throw null; } set { } } public string SourceContext { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.InputFieldMappingEntry System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.InputFieldMappingEntry System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KeepTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class KeepTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KeepTokenFilter(string name, System.Collections.Generic.IEnumerable keepWords) { } public System.Collections.Generic.IList KeepWords { get { throw null; } } public bool? LowerCaseKeepWords { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KeepTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KeepTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KeyPhraseExtractionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class KeyPhraseExtractionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KeyPhraseExtractionSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public Azure.Search.Documents.Indexes.Models.KeyPhraseExtractionSkillLanguage? DefaultLanguageCode { get { throw null; } set { } } public int? MaxKeyPhraseCount { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KeyPhraseExtractionSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KeyPhraseExtractionSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct KeyPhraseExtractionSkillLanguage : System.IEquatable @@ -1657,19 +2154,31 @@ public KeyPhraseExtractionSkill(System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public KeywordMarkerTokenFilter(string name, System.Collections.Generic.IEnumerable keywords) { } public bool? IgnoreCase { get { throw null; } set { } } public System.Collections.Generic.IList Keywords { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KeywordMarkerTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KeywordMarkerTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KeywordTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class KeywordTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KeywordTokenizer(string name) { } public int? BufferSize { get { throw null; } set { } } public int? MaxTokenLength { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KeywordTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KeywordTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgent + public partial class KnowledgeAgent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeAgent(string name, System.Collections.Generic.IEnumerable models, System.Collections.Generic.IEnumerable targetIndexes) { } public string Description { get { throw null; } set { } } @@ -1679,15 +2188,33 @@ public KnowledgeAgent(string name, System.Collections.Generic.IEnumerable TargetIndexes { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeAgent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeAgent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentAzureOpenAIModel : Azure.Search.Documents.Indexes.Models.KnowledgeAgentModel + public partial class KnowledgeAgentAzureOpenAIModel : Azure.Search.Documents.Indexes.Models.KnowledgeAgentModel, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeAgentAzureOpenAIModel(Azure.Search.Documents.Indexes.Models.AzureOpenAIVectorizerParameters azureOpenAIParameters) { } public Azure.Search.Documents.Indexes.Models.AzureOpenAIVectorizerParameters AzureOpenAIParameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeAgentAzureOpenAIModel System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeAgentAzureOpenAIModel System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public abstract partial class KnowledgeAgentModel + public abstract partial class KnowledgeAgentModel : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { protected KnowledgeAgentModel() { } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeAgentModel System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeAgentModel System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct KnowledgeAgentModelKind : System.IEquatable @@ -1706,44 +2233,80 @@ protected KnowledgeAgentModel() { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.KnowledgeAgentModelKind left, Azure.Search.Documents.Indexes.Models.KnowledgeAgentModelKind right) { throw null; } public override string ToString() { throw null; } } - public partial class KnowledgeAgentRequestLimits + public partial class KnowledgeAgentRequestLimits : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeAgentRequestLimits() { } public int? MaxOutputSize { get { throw null; } set { } } public int? MaxRuntimeInSeconds { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeAgentRequestLimits System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeAgentRequestLimits System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentTargetIndex + public partial class KnowledgeAgentTargetIndex : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeAgentTargetIndex(string indexName) { } public bool? DefaultIncludeReferenceSourceData { get { throw null; } set { } } public int? DefaultMaxDocsForReranker { get { throw null; } set { } } public float? DefaultRerankerThreshold { get { throw null; } set { } } public string IndexName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeAgentTargetIndex System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeAgentTargetIndex System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeStore + public partial class KnowledgeStore : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeStore(string storageConnectionString, System.Collections.Generic.IEnumerable projections) { } public Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity Identity { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.SearchIndexerKnowledgeStoreParameters Parameters { get { throw null; } set { } } public System.Collections.Generic.IList Projections { get { throw null; } } public string StorageConnectionString { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStore System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStore System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeStoreFileProjectionSelector : Azure.Search.Documents.Indexes.Models.KnowledgeStoreStorageProjectionSelector + public partial class KnowledgeStoreFileProjectionSelector : Azure.Search.Documents.Indexes.Models.KnowledgeStoreStorageProjectionSelector, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeStoreFileProjectionSelector(string storageContainer) : base (default(string)) { } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreFileProjectionSelector System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreFileProjectionSelector System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeStoreObjectProjectionSelector : Azure.Search.Documents.Indexes.Models.KnowledgeStoreStorageProjectionSelector + public partial class KnowledgeStoreObjectProjectionSelector : Azure.Search.Documents.Indexes.Models.KnowledgeStoreStorageProjectionSelector, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeStoreObjectProjectionSelector(string storageContainer) : base (default(string)) { } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreObjectProjectionSelector System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreObjectProjectionSelector System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeStoreProjection + public partial class KnowledgeStoreProjection : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeStoreProjection() { } public System.Collections.Generic.IList Files { get { throw null; } } public System.Collections.Generic.IList Objects { get { throw null; } } public System.Collections.Generic.IList Tables { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreProjection System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreProjection System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeStoreProjectionSelector + public partial class KnowledgeStoreProjectionSelector : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeStoreProjectionSelector() { } public string GeneratedKeyName { get { throw null; } set { } } @@ -1751,32 +2314,68 @@ public KnowledgeStoreProjectionSelector() { } public string ReferenceKeyName { get { throw null; } set { } } public string Source { get { throw null; } set { } } public string SourceContext { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreProjectionSelector System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreProjectionSelector System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeStoreStorageProjectionSelector : Azure.Search.Documents.Indexes.Models.KnowledgeStoreProjectionSelector + public partial class KnowledgeStoreStorageProjectionSelector : Azure.Search.Documents.Indexes.Models.KnowledgeStoreProjectionSelector, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeStoreStorageProjectionSelector(string storageContainer) { } public string StorageContainer { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreStorageProjectionSelector System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreStorageProjectionSelector System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeStoreTableProjectionSelector : Azure.Search.Documents.Indexes.Models.KnowledgeStoreProjectionSelector + public partial class KnowledgeStoreTableProjectionSelector : Azure.Search.Documents.Indexes.Models.KnowledgeStoreProjectionSelector, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeStoreTableProjectionSelector(string tableName) { } public string TableName { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreTableProjectionSelector System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreTableProjectionSelector System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class LanguageDetectionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class LanguageDetectionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public LanguageDetectionSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public string DefaultCountryHint { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LanguageDetectionSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LanguageDetectionSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class LengthTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class LengthTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public LengthTokenFilter(string name) { } public int? MaxLength { get { throw null; } set { } } public int? MinLength { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LengthTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LengthTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class LexicalAnalyzer + public partial class LexicalAnalyzer : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal LexicalAnalyzer() { } public string Name { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LexicalAnalyzer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LexicalAnalyzer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct LexicalAnalyzerName : System.IEquatable @@ -1983,10 +2582,16 @@ public static partial class Values public const string ZhHantMicrosoft = "zh-Hant.microsoft"; } } - public partial class LexicalNormalizer + public partial class LexicalNormalizer : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public LexicalNormalizer(string name) { } public string Name { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LexicalNormalizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LexicalNormalizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct LexicalNormalizerName : System.IEquatable @@ -2017,10 +2622,16 @@ public static partial class Values public const string Uppercase = "uppercase"; } } - public partial class LexicalTokenizer + public partial class LexicalTokenizer : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal LexicalTokenizer() { } public string Name { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LexicalTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LexicalTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct LexicalTokenizerName : System.IEquatable @@ -2051,44 +2662,86 @@ internal LexicalTokenizer() { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.LexicalTokenizerName left, Azure.Search.Documents.Indexes.Models.LexicalTokenizerName right) { throw null; } public override string ToString() { throw null; } } - public partial class LimitTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class LimitTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public LimitTokenFilter(string name) { } public bool? ConsumeAllTokens { get { throw null; } set { } } public int? MaxTokenCount { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LimitTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LimitTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ListIndexStatsSummary + public partial class ListIndexStatsSummary : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ListIndexStatsSummary() { } public System.Collections.Generic.IReadOnlyList IndexesStatistics { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ListIndexStatsSummary System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ListIndexStatsSummary System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class LuceneStandardAnalyzer : Azure.Search.Documents.Indexes.Models.LexicalAnalyzer + public partial class LuceneStandardAnalyzer : Azure.Search.Documents.Indexes.Models.LexicalAnalyzer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public LuceneStandardAnalyzer(string name) { } public int? MaxTokenLength { get { throw null; } set { } } public System.Collections.Generic.IList Stopwords { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LuceneStandardAnalyzer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LuceneStandardAnalyzer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class LuceneStandardTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class LuceneStandardTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public LuceneStandardTokenizer(string name) { } public int? MaxTokenLength { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LuceneStandardTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LuceneStandardTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class MagnitudeScoringFunction : Azure.Search.Documents.Indexes.Models.ScoringFunction + public partial class MagnitudeScoringFunction : Azure.Search.Documents.Indexes.Models.ScoringFunction, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public MagnitudeScoringFunction(string fieldName, double boost, Azure.Search.Documents.Indexes.Models.MagnitudeScoringParameters parameters) { } public Azure.Search.Documents.Indexes.Models.MagnitudeScoringParameters Parameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MagnitudeScoringFunction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MagnitudeScoringFunction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class MagnitudeScoringParameters + public partial class MagnitudeScoringParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public MagnitudeScoringParameters(double boostingRangeStart, double boostingRangeEnd) { } public double BoostingRangeEnd { get { throw null; } set { } } public double BoostingRangeStart { get { throw null; } set { } } public bool? ShouldBoostBeyondRangeByConstant { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MagnitudeScoringParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MagnitudeScoringParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class MappingCharFilter : Azure.Search.Documents.Indexes.Models.CharFilter + public partial class MappingCharFilter : Azure.Search.Documents.Indexes.Models.CharFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public MappingCharFilter(string name, System.Collections.Generic.IEnumerable mappings) { } public System.Collections.Generic.IList Mappings { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MappingCharFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MappingCharFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct MarkdownHeaderDepth : System.IEquatable @@ -2130,25 +2783,43 @@ public MappingCharFilter(string name, System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public MergeSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public string InsertPostTag { get { throw null; } set { } } public string InsertPreTag { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MergeSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MergeSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class MicrosoftLanguageStemmingTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class MicrosoftLanguageStemmingTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public MicrosoftLanguageStemmingTokenizer(string name) { } public bool? IsSearchTokenizer { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.MicrosoftStemmingTokenizerLanguage? Language { get { throw null; } set { } } public int? MaxTokenLength { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MicrosoftLanguageStemmingTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MicrosoftLanguageStemmingTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class MicrosoftLanguageTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class MicrosoftLanguageTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public MicrosoftLanguageTokenizer(string name) { } public bool? IsSearchTokenizer { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.MicrosoftTokenizerLanguage? Language { get { throw null; } set { } } public int? MaxTokenLength { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MicrosoftLanguageTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MicrosoftLanguageTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum MicrosoftStemmingTokenizerLanguage { @@ -2243,22 +2914,40 @@ public enum MicrosoftTokenizerLanguage Urdu = 40, Vietnamese = 41, } - public partial class NativeBlobSoftDeleteDeletionDetectionPolicy : Azure.Search.Documents.Indexes.Models.DataDeletionDetectionPolicy + public partial class NativeBlobSoftDeleteDeletionDetectionPolicy : Azure.Search.Documents.Indexes.Models.DataDeletionDetectionPolicy, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public NativeBlobSoftDeleteDeletionDetectionPolicy() { } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.NativeBlobSoftDeleteDeletionDetectionPolicy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.NativeBlobSoftDeleteDeletionDetectionPolicy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class NGramTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class NGramTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public NGramTokenFilter(string name) { } public int? MaxGram { get { throw null; } set { } } public int? MinGram { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.NGramTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.NGramTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class NGramTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class NGramTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public NGramTokenizer(string name) { } public int? MaxGram { get { throw null; } set { } } public int? MinGram { get { throw null; } set { } } public System.Collections.Generic.IList TokenChars { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.NGramTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.NGramTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct OcrLineEnding : System.IEquatable @@ -2280,12 +2969,18 @@ public NGramTokenizer(string name) { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.OcrLineEnding left, Azure.Search.Documents.Indexes.Models.OcrLineEnding right) { throw null; } public override string ToString() { throw null; } } - public partial class OcrSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class OcrSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public OcrSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public Azure.Search.Documents.Indexes.Models.OcrSkillLanguage? DefaultLanguageCode { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.OcrLineEnding? LineEnding { get { throw null; } set { } } public bool? ShouldDetectOrientation { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.OcrSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.OcrSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct OcrSkillLanguage : System.IEquatable @@ -2473,13 +3168,19 @@ public OcrSkill(System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public OutputFieldMappingEntry(string name) { } public string Name { get { throw null; } set { } } public string TargetName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.OutputFieldMappingEntry System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.OutputFieldMappingEntry System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class PathHierarchyTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class PathHierarchyTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PathHierarchyTokenizer(string name) { } public char? Delimiter { get { throw null; } set { } } @@ -2487,39 +3188,75 @@ public PathHierarchyTokenizer(string name) { } public int? NumberOfTokensToSkip { get { throw null; } set { } } public char? Replacement { get { throw null; } set { } } public bool? ReverseTokenOrder { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PathHierarchyTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PathHierarchyTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class PatternAnalyzer : Azure.Search.Documents.Indexes.Models.LexicalAnalyzer + public partial class PatternAnalyzer : Azure.Search.Documents.Indexes.Models.LexicalAnalyzer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PatternAnalyzer(string name) { } public System.Collections.Generic.IList Flags { get { throw null; } } public bool? LowerCaseTerms { get { throw null; } set { } } public string Pattern { get { throw null; } set { } } public System.Collections.Generic.IList Stopwords { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PatternAnalyzer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PatternAnalyzer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class PatternCaptureTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class PatternCaptureTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PatternCaptureTokenFilter(string name, System.Collections.Generic.IEnumerable patterns) { } public System.Collections.Generic.IList Patterns { get { throw null; } } public bool? PreserveOriginal { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PatternCaptureTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PatternCaptureTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class PatternReplaceCharFilter : Azure.Search.Documents.Indexes.Models.CharFilter + public partial class PatternReplaceCharFilter : Azure.Search.Documents.Indexes.Models.CharFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PatternReplaceCharFilter(string name, string pattern, string replacement) { } public string Pattern { get { throw null; } set { } } public string Replacement { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PatternReplaceCharFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PatternReplaceCharFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class PatternReplaceTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class PatternReplaceTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PatternReplaceTokenFilter(string name, string pattern, string replacement) { } public string Pattern { get { throw null; } set { } } public string Replacement { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PatternReplaceTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PatternReplaceTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class PatternTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class PatternTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PatternTokenizer(string name) { } public System.Collections.Generic.IList Flags { get { throw null; } } public int? Group { get { throw null; } set { } } public string Pattern { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PatternTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PatternTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct PermissionFilter : System.IEquatable @@ -2560,13 +3297,19 @@ public enum PhoneticEncoder HaasePhonetik = 9, BeiderMorse = 10, } - public partial class PhoneticTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class PhoneticTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PhoneticTokenFilter(string name) { } public Azure.Search.Documents.Indexes.Models.PhoneticEncoder? Encoder { get { throw null; } set { } } public bool? ReplaceOriginalTokens { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PhoneticTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PhoneticTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class PiiDetectionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class PiiDetectionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PiiDetectionSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public string DefaultLanguageCode { get { throw null; } set { } } @@ -2576,6 +3319,12 @@ public PiiDetectionSkill(System.Collections.Generic.IEnumerable PiiCategories { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PiiDetectionSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PiiDetectionSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct PiiDetectionSkillMaskingMode : System.IEquatable @@ -2637,29 +3386,53 @@ public PiiDetectionSkill(System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public RescoringOptions() { } public double? DefaultOversampling { get { throw null; } set { } } public bool? EnableRescoring { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.VectorSearchCompressionRescoreStorageMethod? RescoreStorageMethod { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.RescoringOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.RescoringOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ScalarQuantizationCompression : Azure.Search.Documents.Indexes.Models.VectorSearchCompression + public partial class ScalarQuantizationCompression : Azure.Search.Documents.Indexes.Models.VectorSearchCompression, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ScalarQuantizationCompression(string compressionName) : base (default(string)) { } public Azure.Search.Documents.Indexes.Models.ScalarQuantizationParameters Parameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ScalarQuantizationCompression System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ScalarQuantizationCompression System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ScalarQuantizationParameters + public partial class ScalarQuantizationParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ScalarQuantizationParameters() { } public Azure.Search.Documents.Indexes.Models.VectorSearchCompressionTarget? QuantizedDataType { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ScalarQuantizationParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ScalarQuantizationParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ScoringFunction + public partial class ScoringFunction : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ScoringFunction() { } public double Boost { get { throw null; } set { } } public string FieldName { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.ScoringFunctionInterpolation? Interpolation { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ScoringFunction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ScoringFunction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum ScoringFunctionAggregation { @@ -2676,13 +3449,19 @@ public enum ScoringFunctionInterpolation Quadratic = 2, Logarithmic = 3, } - public partial class ScoringProfile + public partial class ScoringProfile : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ScoringProfile(string name) { } public Azure.Search.Documents.Indexes.Models.ScoringFunctionAggregation? FunctionAggregation { get { throw null; } set { } } public System.Collections.Generic.IList Functions { get { throw null; } } public string Name { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.TextWeights TextWeights { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ScoringProfile System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ScoringProfile System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class SearchableField : Azure.Search.Documents.Indexes.Models.SimpleField { @@ -2692,15 +3471,21 @@ public partial class SearchableField : Azure.Search.Documents.Indexes.Models.Sim public Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName? SearchAnalyzerName { get { throw null; } set { } } public System.Collections.Generic.IList SynonymMapNames { get { throw null; } } } - public partial class SearchAlias + public partial class SearchAlias : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchAlias(string name, System.Collections.Generic.IEnumerable indexes) { } public SearchAlias(string name, string index) { } public Azure.ETag? ETag { get { throw null; } } public System.Collections.Generic.IList Indexes { get { throw null; } } public string Name { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchAlias System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchAlias System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchField + public partial class SearchField : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchField(string name, Azure.Search.Documents.Indexes.Models.SearchFieldDataType type) { } public Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName? AnalyzerName { get { throw null; } set { } } @@ -2722,6 +3507,12 @@ public SearchField(string name, Azure.Search.Documents.Indexes.Models.SearchFiel public Azure.Search.Documents.Indexes.Models.VectorEncodingFormat? VectorEncodingFormat { get { throw null; } set { } } public int? VectorSearchDimensions { get { throw null; } set { } } public string VectorSearchProfileName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchField System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchField System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } public override string ToString() { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] @@ -2762,7 +3553,7 @@ internal SearchFieldTemplate() { } public Azure.Search.Documents.Indexes.Models.SearchFieldDataType Type { get { throw null; } } public static implicit operator Azure.Search.Documents.Indexes.Models.SearchField (Azure.Search.Documents.Indexes.Models.SearchFieldTemplate value) { throw null; } } - public partial class SearchIndex + public partial class SearchIndex : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndex(string name) { } public SearchIndex(string name, System.Collections.Generic.IEnumerable fields) { } @@ -2784,8 +3575,14 @@ public SearchIndex(string name, System.Collections.Generic.IEnumerable TokenFilters { get { throw null; } } public System.Collections.Generic.IList Tokenizers { get { throw null; } } public Azure.Search.Documents.Indexes.Models.VectorSearch VectorSearch { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndex System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndex System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexer + public partial class SearchIndexer : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexer(string name, string dataSourceName, string targetIndexName) { } public Azure.Search.Documents.Indexes.Models.SearchIndexerCache Cache { get { throw null; } set { } } @@ -2801,30 +3598,60 @@ public SearchIndexer(string name, string dataSourceName, string targetIndexName) public Azure.Search.Documents.Indexes.Models.IndexingSchedule Schedule { get { throw null; } set { } } public string SkillsetName { get { throw null; } set { } } public string TargetIndexName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerCache + public partial class SearchIndexerCache : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerCache() { } public bool? EnableReprocessing { get { throw null; } set { } } public string Id { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity Identity { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } public void SetStorageConnectionString(string storageConnectionString) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerCache System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerCache System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerDataContainer + public partial class SearchIndexerDataContainer : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerDataContainer(string name) { } public string Name { get { throw null; } set { } } public string Query { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerDataContainer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerDataContainer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public abstract partial class SearchIndexerDataIdentity + public abstract partial class SearchIndexerDataIdentity : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerDataIdentity() { } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerDataNoneIdentity : Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity + public partial class SearchIndexerDataNoneIdentity : Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerDataNoneIdentity() { } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerDataNoneIdentity System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerDataNoneIdentity System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerDataSourceConnection + public partial class SearchIndexerDataSourceConnection : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerDataSourceConnection(string name, Azure.Search.Documents.Indexes.Models.SearchIndexerDataSourceType type, string connectionString, Azure.Search.Documents.Indexes.Models.SearchIndexerDataContainer container) { } public string ConnectionString { get { throw null; } set { } } @@ -2838,6 +3665,12 @@ public SearchIndexerDataSourceConnection(string name, Azure.Search.Documents.Ind public System.Collections.Generic.IList IndexerPermissionOptions { get { throw null; } } public string Name { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.SearchIndexerDataSourceType Type { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerDataSourceConnection System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerDataSourceConnection System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct SearchIndexerDataSourceType : System.IEquatable @@ -2862,12 +3695,18 @@ public SearchIndexerDataSourceConnection(string name, Azure.Search.Documents.Ind public static bool operator !=(Azure.Search.Documents.Indexes.Models.SearchIndexerDataSourceType left, Azure.Search.Documents.Indexes.Models.SearchIndexerDataSourceType right) { throw null; } public override string ToString() { throw null; } } - public partial class SearchIndexerDataUserAssignedIdentity : Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity + public partial class SearchIndexerDataUserAssignedIdentity : Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerDataUserAssignedIdentity(Azure.Core.ResourceIdentifier userAssignedIdentity) { } public Azure.Core.ResourceIdentifier UserAssignedIdentity { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerDataUserAssignedIdentity System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerDataUserAssignedIdentity System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerError + public partial class SearchIndexerError : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SearchIndexerError() { } public string Details { get { throw null; } } @@ -2876,41 +3715,77 @@ internal SearchIndexerError() { } public string Key { get { throw null; } } public string Name { get { throw null; } } public int StatusCode { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerError System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerError System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerIndexProjection + public partial class SearchIndexerIndexProjection : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerIndexProjection(System.Collections.Generic.IEnumerable selectors) { } public Azure.Search.Documents.Indexes.Models.SearchIndexerIndexProjectionsParameters Parameters { get { throw null; } set { } } public System.Collections.Generic.IList Selectors { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerIndexProjection System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerIndexProjection System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerIndexProjectionSelector + public partial class SearchIndexerIndexProjectionSelector : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerIndexProjectionSelector(string targetIndexName, string parentKeyFieldName, string sourceContext, System.Collections.Generic.IEnumerable mappings) { } public System.Collections.Generic.IList Mappings { get { throw null; } } public string ParentKeyFieldName { get { throw null; } set { } } public string SourceContext { get { throw null; } set { } } public string TargetIndexName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerIndexProjectionSelector System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerIndexProjectionSelector System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerIndexProjectionsParameters + public partial class SearchIndexerIndexProjectionsParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerIndexProjectionsParameters() { } public System.Collections.Generic.IDictionary AdditionalProperties { get { throw null; } } public Azure.Search.Documents.Indexes.Models.IndexProjectionMode? ProjectionMode { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerIndexProjectionsParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerIndexProjectionsParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerKnowledgeStoreParameters + public partial class SearchIndexerKnowledgeStoreParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerKnowledgeStoreParameters() { } public System.Collections.Generic.IDictionary AdditionalProperties { get { throw null; } } public bool? SynthesizeGeneratedKeyName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerKnowledgeStoreParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerKnowledgeStoreParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerLimits + public partial class SearchIndexerLimits : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SearchIndexerLimits() { } public long? MaxDocumentContentCharactersToExtract { get { throw null; } } public long? MaxDocumentExtractionSize { get { throw null; } } public System.TimeSpan? MaxRunTime { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerLimits System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerLimits System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerSkill + public partial class SearchIndexerSkill : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SearchIndexerSkill() { } public string Context { get { throw null; } set { } } @@ -2918,8 +3793,14 @@ internal SearchIndexerSkill() { } public System.Collections.Generic.IList Inputs { get { throw null; } } public string Name { get { throw null; } set { } } public System.Collections.Generic.IList Outputs { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerSkillset + public partial class SearchIndexerSkillset : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerSkillset(string name, System.Collections.Generic.IEnumerable skills) { } public Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount CognitiveServicesAccount { get { throw null; } set { } } @@ -2930,8 +3811,14 @@ public SearchIndexerSkillset(string name, System.Collections.Generic.IEnumerable public Azure.Search.Documents.Indexes.Models.KnowledgeStore KnowledgeStore { get { throw null; } set { } } public string Name { get { throw null; } set { } } public System.Collections.Generic.IList Skills { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerSkillset System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerSkillset System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerStatus + public partial class SearchIndexerStatus : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SearchIndexerStatus() { } public Azure.Search.Documents.Indexes.Models.IndexerState CurrentState { get { throw null; } } @@ -2939,8 +3826,14 @@ internal SearchIndexerStatus() { } public Azure.Search.Documents.Indexes.Models.IndexerExecutionResult LastResult { get { throw null; } } public Azure.Search.Documents.Indexes.Models.SearchIndexerLimits Limits { get { throw null; } } public Azure.Search.Documents.Indexes.Models.IndexerStatus Status { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerStatus System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerStatus System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerWarning + public partial class SearchIndexerWarning : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SearchIndexerWarning() { } public string Details { get { throw null; } } @@ -2948,21 +3841,39 @@ internal SearchIndexerWarning() { } public string Key { get { throw null; } } public string Message { get { throw null; } } public string Name { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerWarning System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerWarning System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexStatistics + public partial class SearchIndexStatistics : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SearchIndexStatistics() { } public long DocumentCount { get { throw null; } } public long StorageSize { get { throw null; } } public long VectorIndexSize { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexStatistics System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexStatistics System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchResourceCounter + public partial class SearchResourceCounter : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SearchResourceCounter() { } public long? Quota { get { throw null; } } public long Usage { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchResourceCounter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchResourceCounter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchResourceEncryptionKey + public partial class SearchResourceEncryptionKey : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchResourceEncryptionKey(System.Uri vaultUri, string keyName, string keyVersion) { } public string ApplicationId { get { throw null; } set { } } @@ -2971,8 +3882,14 @@ public SearchResourceEncryptionKey(System.Uri vaultUri, string keyName, string k public string KeyName { get { throw null; } } public string KeyVersion { get { throw null; } } public System.Uri VaultUri { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchResourceEncryptionKey System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchResourceEncryptionKey System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchServiceCounters + public partial class SearchServiceCounters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SearchServiceCounters() { } public Azure.Search.Documents.Indexes.Models.SearchResourceCounter AliasCounter { get { throw null; } } @@ -2984,8 +3901,14 @@ internal SearchServiceCounters() { } public Azure.Search.Documents.Indexes.Models.SearchResourceCounter StorageSizeCounter { get { throw null; } } public Azure.Search.Documents.Indexes.Models.SearchResourceCounter SynonymMapCounter { get { throw null; } } public Azure.Search.Documents.Indexes.Models.SearchResourceCounter VectorIndexSizeCounter { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchServiceCounters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchServiceCounters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchServiceLimits + public partial class SearchServiceLimits : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SearchServiceLimits() { } public int? MaxComplexCollectionFieldsPerIndex { get { throw null; } } @@ -2993,47 +3916,89 @@ internal SearchServiceLimits() { } public int? MaxFieldNestingDepthPerIndex { get { throw null; } } public int? MaxFieldsPerIndex { get { throw null; } } public long? MaxStoragePerIndexInBytes { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchServiceLimits System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchServiceLimits System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchServiceStatistics + public partial class SearchServiceStatistics : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SearchServiceStatistics() { } public Azure.Search.Documents.Indexes.Models.SearchServiceCounters Counters { get { throw null; } } public Azure.Search.Documents.Indexes.Models.SearchServiceLimits Limits { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchServiceStatistics System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchServiceStatistics System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchSuggester + public partial class SearchSuggester : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchSuggester(string name, System.Collections.Generic.IEnumerable sourceFields) { } public SearchSuggester(string name, params string[] sourceFields) { } public string Name { get { throw null; } set { } } public System.Collections.Generic.IList SourceFields { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchSuggester System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchSuggester System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SemanticConfiguration + public partial class SemanticConfiguration : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SemanticConfiguration(string name, Azure.Search.Documents.Indexes.Models.SemanticPrioritizedFields prioritizedFields) { } public bool? FlightingOptIn { get { throw null; } set { } } public string Name { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.SemanticPrioritizedFields PrioritizedFields { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.RankingOrder? RankingOrder { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SemanticConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SemanticConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SemanticField + public partial class SemanticField : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SemanticField(string fieldName) { } public string FieldName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SemanticField System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SemanticField System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SemanticPrioritizedFields + public partial class SemanticPrioritizedFields : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SemanticPrioritizedFields() { } public System.Collections.Generic.IList ContentFields { get { throw null; } } public System.Collections.Generic.IList KeywordsFields { get { throw null; } } public Azure.Search.Documents.Indexes.Models.SemanticField TitleField { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SemanticPrioritizedFields System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SemanticPrioritizedFields System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SemanticSearch + public partial class SemanticSearch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SemanticSearch() { } public System.Collections.Generic.IList Configurations { get { throw null; } } public string DefaultConfigurationName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SemanticSearch System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SemanticSearch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SentimentSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class SentimentSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public SentimentSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } @@ -3041,6 +4006,12 @@ public SentimentSkill(System.Collections.Generic.IEnumerable.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SentimentSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct SkillVersion : System.IEquatable { @@ -3095,11 +4066,17 @@ public SentimentSkill(System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public ShaperSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ShaperSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ShaperSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ShingleTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class ShingleTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ShingleTokenFilter(string name) { } public string FilterToken { get { throw null; } set { } } @@ -3108,10 +4085,22 @@ public ShingleTokenFilter(string name) { } public bool? OutputUnigrams { get { throw null; } set { } } public bool? OutputUnigramsIfNoShingles { get { throw null; } set { } } public string TokenSeparator { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ShingleTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ShingleTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SimilarityAlgorithm + public partial class SimilarityAlgorithm : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SimilarityAlgorithm() { } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SimilarityAlgorithm System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SimilarityAlgorithm System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class SimpleField : Azure.Search.Documents.Indexes.Models.SearchFieldTemplate { @@ -3124,10 +4113,16 @@ public SimpleField(string name, Azure.Search.Documents.Indexes.Models.SearchFiel public Azure.Search.Documents.Indexes.Models.LexicalNormalizerName? NormalizerName { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.PermissionFilter? PermissionFilter { get { throw null; } set { } } } - public partial class SnowballTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class SnowballTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SnowballTokenFilter(string name, Azure.Search.Documents.Indexes.Models.SnowballTokenFilterLanguage language) { } public Azure.Search.Documents.Indexes.Models.SnowballTokenFilterLanguage Language { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SnowballTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SnowballTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum SnowballTokenFilterLanguage { @@ -3154,13 +4149,19 @@ public enum SnowballTokenFilterLanguage Swedish = 20, Turkish = 21, } - public partial class SoftDeleteColumnDeletionDetectionPolicy : Azure.Search.Documents.Indexes.Models.DataDeletionDetectionPolicy + public partial class SoftDeleteColumnDeletionDetectionPolicy : Azure.Search.Documents.Indexes.Models.DataDeletionDetectionPolicy, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SoftDeleteColumnDeletionDetectionPolicy() { } public string SoftDeleteColumnName { get { throw null; } set { } } public string SoftDeleteMarkerValue { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SoftDeleteColumnDeletionDetectionPolicy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SoftDeleteColumnDeletionDetectionPolicy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SplitSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class SplitSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SplitSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public Azure.Search.Documents.Indexes.Models.AzureOpenAITokenizerParameters AzureOpenAITokenizerParameters { get { throw null; } set { } } @@ -3170,6 +4171,12 @@ public SplitSkill(System.Collections.Generic.IEnumerable.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SplitSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct SplitSkillEncoderModelName : System.IEquatable @@ -3258,19 +4265,37 @@ public SplitSkill(System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public SqlIntegratedChangeTrackingPolicy() { } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SqlIntegratedChangeTrackingPolicy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SqlIntegratedChangeTrackingPolicy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class StemmerOverrideTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class StemmerOverrideTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public StemmerOverrideTokenFilter(string name, System.Collections.Generic.IEnumerable rules) { } public System.Collections.Generic.IList Rules { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.StemmerOverrideTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.StemmerOverrideTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class StemmerTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class StemmerTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public StemmerTokenFilter(string name, Azure.Search.Documents.Indexes.Models.StemmerTokenFilterLanguage language) { } public Azure.Search.Documents.Indexes.Models.StemmerTokenFilterLanguage Language { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.StemmerTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.StemmerTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum StemmerTokenFilterLanguage { @@ -3329,10 +4354,16 @@ public enum StemmerTokenFilterLanguage LightSwedish = 52, Turkish = 53, } - public partial class StopAnalyzer : Azure.Search.Documents.Indexes.Models.LexicalAnalyzer + public partial class StopAnalyzer : Azure.Search.Documents.Indexes.Models.LexicalAnalyzer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public StopAnalyzer(string name) { } public System.Collections.Generic.IList Stopwords { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.StopAnalyzer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.StopAnalyzer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum StopwordsList { @@ -3368,15 +4399,21 @@ public enum StopwordsList Thai = 29, Turkish = 30, } - public partial class StopwordsTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class StopwordsTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public StopwordsTokenFilter(string name) { } public bool? IgnoreCase { get { throw null; } set { } } public bool? RemoveTrailingStopWords { get { throw null; } set { } } public System.Collections.Generic.IList Stopwords { get { throw null; } } public Azure.Search.Documents.Indexes.Models.StopwordsList? StopwordsList { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.StopwordsTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.StopwordsTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SynonymMap + public partial class SynonymMap : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SynonymMap(string name, System.IO.TextReader reader) { } public SynonymMap(string name, string synonyms) { } @@ -3384,23 +4421,47 @@ public SynonymMap(string name, string synonyms) { } public Azure.ETag? ETag { get { throw null; } set { } } public string Name { get { throw null; } set { } } public string Synonyms { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SynonymMap System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SynonymMap System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SynonymTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class SynonymTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SynonymTokenFilter(string name, System.Collections.Generic.IEnumerable synonyms) { } public bool? Expand { get { throw null; } set { } } public bool? IgnoreCase { get { throw null; } set { } } public System.Collections.Generic.IList Synonyms { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SynonymTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SynonymTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class TagScoringFunction : Azure.Search.Documents.Indexes.Models.ScoringFunction + public partial class TagScoringFunction : Azure.Search.Documents.Indexes.Models.ScoringFunction, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TagScoringFunction(string fieldName, double boost, Azure.Search.Documents.Indexes.Models.TagScoringParameters parameters) { } public Azure.Search.Documents.Indexes.Models.TagScoringParameters Parameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TagScoringFunction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TagScoringFunction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class TagScoringParameters + public partial class TagScoringParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TagScoringParameters(string tagsParameter) { } public string TagsParameter { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TagScoringParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TagScoringParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct TextSplitMode : System.IEquatable @@ -3420,12 +4481,18 @@ public TagScoringParameters(string tagsParameter) { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.TextSplitMode left, Azure.Search.Documents.Indexes.Models.TextSplitMode right) { throw null; } public override string ToString() { throw null; } } - public partial class TextTranslationSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class TextTranslationSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TextTranslationSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs, Azure.Search.Documents.Indexes.Models.TextTranslationSkillLanguage defaultToLanguageCode) { } public Azure.Search.Documents.Indexes.Models.TextTranslationSkillLanguage? DefaultFromLanguageCode { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.TextTranslationSkillLanguage DefaultToLanguageCode { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.TextTranslationSkillLanguage? SuggestedFrom { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TextTranslationSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TextTranslationSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct TextTranslationSkillLanguage : System.IEquatable @@ -3515,10 +4582,16 @@ public TextTranslationSkill(System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public TextWeights(System.Collections.Generic.IDictionary weights) { } public System.Collections.Generic.IDictionary Weights { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TextWeights System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TextWeights System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum TokenCharacterKind { @@ -3528,10 +4601,16 @@ public enum TokenCharacterKind Punctuation = 3, Symbol = 4, } - public partial class TokenFilter + public partial class TokenFilter : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal TokenFilter() { } public string Name { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct TokenFilterName : System.IEquatable @@ -3583,20 +4662,38 @@ internal TokenFilter() { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.TokenFilterName left, Azure.Search.Documents.Indexes.Models.TokenFilterName right) { throw null; } public override string ToString() { throw null; } } - public partial class TruncateTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class TruncateTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TruncateTokenFilter(string name) { } public int? Length { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TruncateTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TruncateTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class UaxUrlEmailTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class UaxUrlEmailTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public UaxUrlEmailTokenizer(string name) { } public int? MaxTokenLength { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.UaxUrlEmailTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.UaxUrlEmailTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class UniqueTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class UniqueTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public UniqueTokenFilter(string name) { } public bool? OnlyOnSamePosition { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.UniqueTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.UniqueTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct VectorEncodingFormat : System.IEquatable @@ -3619,18 +4716,30 @@ public static partial class Values public const string PackedBit = "packedBit"; } } - public partial class VectorSearch + public partial class VectorSearch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public VectorSearch() { } public System.Collections.Generic.IList Algorithms { get { throw null; } } public System.Collections.Generic.IList Compressions { get { throw null; } } public System.Collections.Generic.IList Profiles { get { throw null; } } public System.Collections.Generic.IList Vectorizers { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VectorSearch System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VectorSearch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public abstract partial class VectorSearchAlgorithmConfiguration + public abstract partial class VectorSearchAlgorithmConfiguration : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { protected VectorSearchAlgorithmConfiguration(string name) { } public string Name { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VectorSearchAlgorithmConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VectorSearchAlgorithmConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct VectorSearchAlgorithmMetric : System.IEquatable @@ -3652,7 +4761,7 @@ protected VectorSearchAlgorithmConfiguration(string name) { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.VectorSearchAlgorithmMetric left, Azure.Search.Documents.Indexes.Models.VectorSearchAlgorithmMetric right) { throw null; } public override string ToString() { throw null; } } - public abstract partial class VectorSearchCompression + public abstract partial class VectorSearchCompression : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { protected VectorSearchCompression(string compressionName) { } public string CompressionName { get { throw null; } } @@ -3660,6 +4769,12 @@ protected VectorSearchCompression(string compressionName) { } public bool? RerankWithOriginalVectors { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.RescoringOptions RescoringOptions { get { throw null; } set { } } public int? TruncationDimension { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VectorSearchCompression System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VectorSearchCompression System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct VectorSearchCompressionRescoreStorageMethod : System.IEquatable @@ -3705,23 +4820,41 @@ public VectorSearchField(string name, int vectorSearchDimensions, string vectorS public int VectorSearchDimensions { get { throw null; } set { } } public string VectorSearchProfileName { get { throw null; } set { } } } - public partial class VectorSearchProfile + public partial class VectorSearchProfile : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public VectorSearchProfile(string name, string algorithmConfigurationName) { } public string AlgorithmConfigurationName { get { throw null; } set { } } public string CompressionName { get { throw null; } set { } } public string Name { get { throw null; } set { } } public string VectorizerName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VectorSearchProfile System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VectorSearchProfile System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public abstract partial class VectorSearchVectorizer + public abstract partial class VectorSearchVectorizer : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { protected VectorSearchVectorizer(string vectorizerName) { } public string VectorizerName { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VectorSearchVectorizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VectorSearchVectorizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class VisionVectorizeSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class VisionVectorizeSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public VisionVectorizeSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs, string modelVersion) { } public string ModelVersion { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VisionVectorizeSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VisionVectorizeSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct VisualFeature : System.IEquatable @@ -3746,7 +4879,7 @@ public VisionVectorizeSkill(System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public WebApiSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs, string uri) { } public Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity AuthIdentity { get { throw null; } set { } } @@ -3757,13 +4890,25 @@ public WebApiSkill(System.Collections.Generic.IEnumerable.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.WebApiSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class WebApiVectorizer : Azure.Search.Documents.Indexes.Models.VectorSearchVectorizer + public partial class WebApiVectorizer : Azure.Search.Documents.Indexes.Models.VectorSearchVectorizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public WebApiVectorizer(string vectorizerName) : base (default(string)) { } public Azure.Search.Documents.Indexes.Models.WebApiVectorizerParameters Parameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.WebApiVectorizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.WebApiVectorizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class WebApiVectorizerParameters + public partial class WebApiVectorizerParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public WebApiVectorizerParameters() { } public Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity AuthIdentity { get { throw null; } set { } } @@ -3772,8 +4917,14 @@ public WebApiVectorizerParameters() { } public string HttpMethod { get { throw null; } set { } } public System.TimeSpan? Timeout { get { throw null; } set { } } public System.Uri Uri { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.WebApiVectorizerParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.WebApiVectorizerParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class WordDelimiterTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class WordDelimiterTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public WordDelimiterTokenFilter(string name) { } public bool? CatenateAll { get { throw null; } set { } } @@ -3786,15 +4937,27 @@ public WordDelimiterTokenFilter(string name) { } public bool? SplitOnCaseChange { get { throw null; } set { } } public bool? SplitOnNumerics { get { throw null; } set { } } public bool? StemEnglishPossessive { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.WordDelimiterTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.WordDelimiterTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } } namespace Azure.Search.Documents.Models { - public partial class AutocompleteItem + public partial class AutocompleteItem : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal AutocompleteItem() { } public string QueryPlusText { get { throw null; } } public string Text { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.AutocompleteItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.AutocompleteItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum AutocompleteMode { @@ -3802,19 +4965,31 @@ public enum AutocompleteMode TwoTerms = 1, OneTermWithContext = 2, } - public partial class AutocompleteResults + public partial class AutocompleteResults : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal AutocompleteResults() { } public double? Coverage { get { throw null; } } public System.Collections.Generic.IReadOnlyList Results { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.AutocompleteResults System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.AutocompleteResults System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ChatCompletionResponseFormatJsonSchemaProperties + public partial class ChatCompletionResponseFormatJsonSchemaProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ChatCompletionResponseFormatJsonSchemaProperties() { } public string Description { get { throw null; } set { } } public string Name { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.ChatCompletionSchema Schema { get { throw null; } set { } } public bool? Strict { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.ChatCompletionResponseFormatJsonSchemaProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.ChatCompletionResponseFormatJsonSchemaProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct ChatCompletionResponseFormatType : System.IEquatable @@ -3835,19 +5010,31 @@ public ChatCompletionResponseFormatJsonSchemaProperties() { } public static bool operator !=(Azure.Search.Documents.Models.ChatCompletionResponseFormatType left, Azure.Search.Documents.Models.ChatCompletionResponseFormatType right) { throw null; } public override string ToString() { throw null; } } - public partial class DebugInfo + public partial class DebugInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal DebugInfo() { } public Azure.Search.Documents.Models.QueryRewritesDebugInfo QueryRewrites { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.DebugInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.DebugInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class DocumentDebugInfo + public partial class DocumentDebugInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal DocumentDebugInfo() { } public System.Collections.Generic.IReadOnlyDictionary> InnerHits { get { throw null; } } public Azure.Search.Documents.Models.SemanticDebugInfo Semantic { get { throw null; } } public Azure.Search.Documents.Models.VectorsDebugInfo Vectors { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.DocumentDebugInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.DocumentDebugInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class FacetResult : System.Collections.Generic.IEnumerable>, System.Collections.Generic.IReadOnlyCollection>, System.Collections.Generic.IReadOnlyDictionary, System.Collections.IEnumerable + public partial class FacetResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel, System.Collections.Generic.IEnumerable>, System.Collections.Generic.IReadOnlyCollection>, System.Collections.Generic.IReadOnlyDictionary, System.Collections.IEnumerable { internal FacetResult() { } public long? Count { get { throw null; } } @@ -3865,6 +5052,12 @@ internal FacetResult() { } public Azure.Search.Documents.Models.ValueFacetResult AsValueFacetResult() { throw null; } public bool ContainsKey(string key) { throw null; } public System.Collections.Generic.IEnumerator> GetEnumerator() { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.FacetResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.FacetResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } public bool TryGetValue(string key, out object value) { throw null; } } @@ -3891,11 +5084,17 @@ public enum FacetType public static bool operator !=(Azure.Search.Documents.Models.HybridCountAndFacetMode left, Azure.Search.Documents.Models.HybridCountAndFacetMode right) { throw null; } public override string ToString() { throw null; } } - public partial class HybridSearch + public partial class HybridSearch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public HybridSearch() { } public Azure.Search.Documents.Models.HybridCountAndFacetMode? CountAndFacetMode { get { throw null; } set { } } public int? MaxTextRecallSize { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.HybridSearch System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.HybridSearch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class IndexActionCompletedEventArgs : Azure.Search.Documents.Models.IndexActionEventArgs { @@ -3949,34 +5148,64 @@ public partial class IndexDocumentsBatch public IndexDocumentsBatch() { } public System.Collections.Generic.IList> Actions { get { throw null; } } } - public partial class IndexDocumentsResult + public partial class IndexDocumentsResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal IndexDocumentsResult() { } public System.Collections.Generic.IReadOnlyList Results { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.IndexDocumentsResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.IndexDocumentsResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class IndexerResyncBody + public partial class IndexerResyncBody : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public IndexerResyncBody() { } public System.Collections.Generic.IList Options { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.IndexerResyncBody System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.IndexerResyncBody System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class IndexingResult + public partial class IndexingResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal IndexingResult() { } public string ErrorMessage { get { throw null; } } public string Key { get { throw null; } } public int Status { get { throw null; } } public bool Succeeded { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.IndexingResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.IndexingResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentMessageImageContentImage + public partial class KnowledgeAgentMessageImageContentImage : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeAgentMessageImageContentImage(string url) { } public string Url { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.KnowledgeAgentMessageImageContentImage System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.KnowledgeAgentMessageImageContentImage System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentSearchActivityRecordQuery + public partial class KnowledgeAgentSearchActivityRecordQuery : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal KnowledgeAgentSearchActivityRecordQuery() { } public string Filter { get { throw null; } } public string Search { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.KnowledgeAgentSearchActivityRecordQuery System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.KnowledgeAgentSearchActivityRecordQuery System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class QueryAnswer { @@ -3986,7 +5215,7 @@ public QueryAnswer(Azure.Search.Documents.Models.QueryAnswerType answerType) { } public int? MaxCharLength { get { throw null; } set { } } public double? Threshold { get { throw null; } set { } } } - public partial class QueryAnswerResult + public partial class QueryAnswerResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal QueryAnswerResult() { } public System.Collections.Generic.IReadOnlyDictionary AdditionalProperties { get { throw null; } } @@ -3994,6 +5223,12 @@ internal QueryAnswerResult() { } public string Key { get { throw null; } } public double? Score { get { throw null; } } public string Text { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryAnswerResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryAnswerResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct QueryAnswerType : System.IEquatable @@ -4020,12 +5255,18 @@ public QueryCaption(Azure.Search.Documents.Models.QueryCaptionType captionType) public bool HighlightEnabled { get { throw null; } set { } } public int? MaxCharLength { get { throw null; } set { } } } - public partial class QueryCaptionResult + public partial class QueryCaptionResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal QueryCaptionResult() { } public System.Collections.Generic.IReadOnlyDictionary AdditionalProperties { get { throw null; } } public string Highlights { get { throw null; } } public string Text { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryCaptionResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryCaptionResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct QueryCaptionType : System.IEquatable @@ -4155,31 +5396,55 @@ internal QueryCaptionResult() { } public static bool operator !=(Azure.Search.Documents.Models.QueryLanguage left, Azure.Search.Documents.Models.QueryLanguage right) { throw null; } public override string ToString() { throw null; } } - public partial class QueryResultDocumentInnerHit + public partial class QueryResultDocumentInnerHit : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal QueryResultDocumentInnerHit() { } public long? Ordinal { get { throw null; } } public System.Collections.Generic.IReadOnlyList> Vectors { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryResultDocumentInnerHit System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryResultDocumentInnerHit System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class QueryResultDocumentRerankerInput + public partial class QueryResultDocumentRerankerInput : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal QueryResultDocumentRerankerInput() { } public string Content { get { throw null; } } public string Keywords { get { throw null; } } public string Title { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryResultDocumentRerankerInput System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryResultDocumentRerankerInput System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class QueryResultDocumentSemanticField + public partial class QueryResultDocumentSemanticField : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal QueryResultDocumentSemanticField() { } public string Name { get { throw null; } } public Azure.Search.Documents.Models.SemanticFieldState? State { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryResultDocumentSemanticField System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryResultDocumentSemanticField System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class QueryResultDocumentSubscores + public partial class QueryResultDocumentSubscores : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal QueryResultDocumentSubscores() { } public double? DocumentBoost { get { throw null; } } public Azure.Search.Documents.Models.TextResult Text { get { throw null; } } public System.Collections.Generic.IReadOnlyList> Vectors { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryResultDocumentSubscores System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryResultDocumentSubscores System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class QueryRewrites { @@ -4187,11 +5452,17 @@ public QueryRewrites(Azure.Search.Documents.Models.QueryRewritesType rewritesTyp public int? Count { get { throw null; } set { } } public Azure.Search.Documents.Models.QueryRewritesType RewritesType { get { throw null; } } } - public partial class QueryRewritesDebugInfo + public partial class QueryRewritesDebugInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal QueryRewritesDebugInfo() { } public Azure.Search.Documents.Models.QueryRewritesValuesDebugInfo Text { get { throw null; } } public System.Collections.Generic.IReadOnlyList Vectors { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryRewritesDebugInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryRewritesDebugInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct QueryRewritesType : System.IEquatable @@ -4211,11 +5482,17 @@ internal QueryRewritesDebugInfo() { } public static bool operator !=(Azure.Search.Documents.Models.QueryRewritesType left, Azure.Search.Documents.Models.QueryRewritesType right) { throw null; } public override string ToString() { throw null; } } - public partial class QueryRewritesValuesDebugInfo + public partial class QueryRewritesValuesDebugInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal QueryRewritesValuesDebugInfo() { } public string InputQuery { get { throw null; } } public System.Collections.Generic.IReadOnlyList Rewrites { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryRewritesValuesDebugInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryRewritesValuesDebugInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct QuerySpellerType : System.IEquatable @@ -4242,16 +5519,28 @@ public RangeFacetResult(long count, T? from, T? to) { } public T? From { get { throw null; } } public T? To { get { throw null; } } } - public partial class ResetDocumentOptions + public partial class ResetDocumentOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ResetDocumentOptions() { } public System.Collections.Generic.IList DataSourceDocumentIds { get { throw null; } } public System.Collections.Generic.IList DocumentKeys { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.ResetDocumentOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.ResetDocumentOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ResetSkillsOptions + public partial class ResetSkillsOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ResetSkillsOptions() { } public System.Collections.Generic.IList SkillNames { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.ResetSkillsOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.ResetSkillsOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum ScoringStatistics { @@ -4322,6 +5611,7 @@ public enum SearchMode public static partial class SearchModelFactory { public static Azure.Search.Documents.Indexes.Models.AnalyzedTokenInfo AnalyzedTokenInfo(string token, int startOffset, int endOffset, int position) { throw null; } + public static Azure.Search.Documents.Indexes.Models.AnalyzeTextOptions AnalyzeTextOptions(string text = null, Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName? analyzerName = default(Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName?), Azure.Search.Documents.Indexes.Models.LexicalTokenizerName? tokenizerName = default(Azure.Search.Documents.Indexes.Models.LexicalTokenizerName?), Azure.Search.Documents.Indexes.Models.LexicalNormalizerName? normalizerName = default(Azure.Search.Documents.Indexes.Models.LexicalNormalizerName?), System.Collections.Generic.IEnumerable tokenFilters = null, System.Collections.Generic.IEnumerable charFilters = null) { throw null; } public static Azure.Search.Documents.Models.AutocompleteItem AutocompleteItem(string text, string queryPlusText) { throw null; } public static Azure.Search.Documents.Models.AutocompleteResults AutocompleteResults(double? coverage = default(double?), System.Collections.Generic.IEnumerable results = null) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] @@ -4454,10 +5744,16 @@ internal SearchResult() { } public double? Score { get { throw null; } } public Azure.Search.Documents.Models.SemanticSearchResult SemanticSearch { get { throw null; } } } - public partial class SearchScoreThreshold : Azure.Search.Documents.Models.VectorThreshold + public partial class SearchScoreThreshold : Azure.Search.Documents.Models.VectorThreshold, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchScoreThreshold(double value) { } public double Value { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.SearchScoreThreshold System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.SearchScoreThreshold System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class SearchSuggestion { @@ -4465,13 +5761,19 @@ internal SearchSuggestion() { } public T Document { get { throw null; } } public string Text { get { throw null; } } } - public partial class SemanticDebugInfo + public partial class SemanticDebugInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SemanticDebugInfo() { } public System.Collections.Generic.IReadOnlyList ContentFields { get { throw null; } } public System.Collections.Generic.IReadOnlyList KeywordFields { get { throw null; } } public Azure.Search.Documents.Models.QueryResultDocumentRerankerInput RerankerInput { get { throw null; } } public Azure.Search.Documents.Models.QueryResultDocumentSemanticField TitleField { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.SemanticDebugInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.SemanticDebugInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct SemanticErrorMode : System.IEquatable @@ -4592,11 +5894,17 @@ public SemanticSearchResults() { } public static bool operator !=(Azure.Search.Documents.Models.SemanticSearchResultsType left, Azure.Search.Documents.Models.SemanticSearchResultsType right) { throw null; } public override string ToString() { throw null; } } - public partial class SingleVectorFieldResult + public partial class SingleVectorFieldResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SingleVectorFieldResult() { } public double? SearchScore { get { throw null; } } public double? VectorSimilarity { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.SingleVectorFieldResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.SingleVectorFieldResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class SuggestResults { @@ -4604,10 +5912,16 @@ internal SuggestResults() { } public double? Coverage { get { throw null; } } public System.Collections.Generic.IReadOnlyList> Results { get { throw null; } } } - public partial class TextResult + public partial class TextResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal TextResult() { } public double? SearchScore { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.TextResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.TextResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class ValueFacetResult { @@ -4633,28 +5947,52 @@ public ValueFacetResult(long count, T value) { } public static bool operator !=(Azure.Search.Documents.Models.VectorFilterMode left, Azure.Search.Documents.Models.VectorFilterMode right) { throw null; } public override string ToString() { throw null; } } - public partial class VectorizableImageBinaryQuery : Azure.Search.Documents.Models.VectorQuery + public partial class VectorizableImageBinaryQuery : Azure.Search.Documents.Models.VectorQuery, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public VectorizableImageBinaryQuery() { } public string Base64Image { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorizableImageBinaryQuery System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorizableImageBinaryQuery System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class VectorizableImageUrlQuery : Azure.Search.Documents.Models.VectorQuery + public partial class VectorizableImageUrlQuery : Azure.Search.Documents.Models.VectorQuery, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public VectorizableImageUrlQuery() { } public System.Uri Url { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorizableImageUrlQuery System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorizableImageUrlQuery System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class VectorizableTextQuery : Azure.Search.Documents.Models.VectorQuery + public partial class VectorizableTextQuery : Azure.Search.Documents.Models.VectorQuery, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public VectorizableTextQuery(string text) { } public Azure.Search.Documents.Models.QueryRewritesType? QueryRewrites { get { throw null; } set { } } public string Text { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorizableTextQuery System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorizableTextQuery System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class VectorizedQuery : Azure.Search.Documents.Models.VectorQuery + public partial class VectorizedQuery : Azure.Search.Documents.Models.VectorQuery, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public VectorizedQuery(System.ReadOnlyMemory vector) { } public System.ReadOnlyMemory Vector { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorizedQuery System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorizedQuery System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public abstract partial class VectorQuery + public abstract partial class VectorQuery : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { protected VectorQuery() { } public bool? Exhaustive { get { throw null; } set { } } @@ -4665,11 +6003,23 @@ protected VectorQuery() { } public int? PerDocumentVectorLimit { get { throw null; } set { } } public Azure.Search.Documents.Models.VectorThreshold Threshold { get { throw null; } set { } } public float? Weight { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorQuery System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorQuery System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class VectorsDebugInfo + public partial class VectorsDebugInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal VectorsDebugInfo() { } public Azure.Search.Documents.Models.QueryResultDocumentSubscores Subscores { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorsDebugInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorsDebugInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class VectorSearchOptions { @@ -4677,14 +6027,26 @@ public VectorSearchOptions() { } public Azure.Search.Documents.Models.VectorFilterMode? FilterMode { get { throw null; } set { } } public System.Collections.Generic.IList Queries { get { throw null; } } } - public partial class VectorSimilarityThreshold : Azure.Search.Documents.Models.VectorThreshold + public partial class VectorSimilarityThreshold : Azure.Search.Documents.Models.VectorThreshold, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public VectorSimilarityThreshold(double value) { } public double Value { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorSimilarityThreshold System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorSimilarityThreshold System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public abstract partial class VectorThreshold + public abstract partial class VectorThreshold : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { protected VectorThreshold() { } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorThreshold System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorThreshold System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } } namespace Microsoft.Extensions.Azure diff --git a/sdk/search/Azure.Search.Documents/api/Azure.Search.Documents.netstandard2.0.cs b/sdk/search/Azure.Search.Documents/api/Azure.Search.Documents.netstandard2.0.cs index f81ca0c811f6..e8d3eb64aa8d 100644 --- a/sdk/search/Azure.Search.Documents/api/Azure.Search.Documents.netstandard2.0.cs +++ b/sdk/search/Azure.Search.Documents/api/Azure.Search.Documents.netstandard2.0.cs @@ -1,6 +1,6 @@ namespace Azure.Search.Documents { - public partial class AutocompleteOptions + public partial class AutocompleteOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AutocompleteOptions() { } public string Filter { get { throw null; } set { } } @@ -11,13 +11,18 @@ public AutocompleteOptions() { } public System.Collections.Generic.IList SearchFields { get { throw null; } } public int? Size { get { throw null; } set { } } public bool? UseFuzzyMatching { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.AutocompleteOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.AutocompleteOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public partial class AzureSearchDocumentsContext : System.ClientModel.Primitives.ModelReaderWriterContext { - public AzureSearchDocumentsContext() { } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public Azure.Search.Documents.AzureSearchDocumentsContext Default { get { throw null; } } + internal AzureSearchDocumentsContext() { } + public static Azure.Search.Documents.AzureSearchDocumentsContext Default { get { throw null; } } + protected override bool TryGetTypeBuilderCore(System.Type type, out System.ClientModel.Primitives.ModelReaderWriterTypeBuilder builder) { throw null; } } public partial class GetDocumentOptions { @@ -161,7 +166,7 @@ void System.IDisposable.Dispose() { } public virtual void UploadDocuments(System.Collections.Generic.IEnumerable documents, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { } public virtual System.Threading.Tasks.Task UploadDocumentsAsync(System.Collections.Generic.IEnumerable documents, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } - public partial class SearchOptions + public partial class SearchOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchOptions() { } public System.Collections.Generic.IList Facets { get { throw null; } } @@ -187,8 +192,14 @@ public SearchOptions() { } public int? Size { get { throw null; } set { } } public int? Skip { get { throw null; } set { } } public Azure.Search.Documents.Models.VectorSearchOptions VectorSearch { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.SearchOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.SearchOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SuggestOptions + public partial class SuggestOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SuggestOptions() { } public string Filter { get { throw null; } set { } } @@ -200,6 +211,12 @@ public SuggestOptions() { } public System.Collections.Generic.IList Select { get { throw null; } } public int? Size { get { throw null; } set { } } public bool? UseFuzzyMatching { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.SuggestOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.SuggestOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } } namespace Azure.Search.Documents.Agents @@ -220,18 +237,30 @@ public KnowledgeAgentRetrievalClient(System.Uri endpoint, string agentName, Azur } namespace Azure.Search.Documents.Agents.Models { - public abstract partial class KnowledgeAgentActivityRecord + public abstract partial class KnowledgeAgentActivityRecord : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { protected KnowledgeAgentActivityRecord(int id) { } public int Id { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentActivityRecord System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentActivityRecord System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentAzureSearchDocReference : Azure.Search.Documents.Agents.Models.KnowledgeAgentReference + public partial class KnowledgeAgentAzureSearchDocReference : Azure.Search.Documents.Agents.Models.KnowledgeAgentReference, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal KnowledgeAgentAzureSearchDocReference() : base (default(string), default(int)) { } public string DocKey { get { throw null; } } public System.Collections.Generic.IReadOnlyDictionary SourceData { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentAzureSearchDocReference System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentAzureSearchDocReference System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentIndexParams + public partial class KnowledgeAgentIndexParams : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeAgentIndexParams() { } public string FilterAddOn { get { throw null; } set { } } @@ -239,16 +268,34 @@ public KnowledgeAgentIndexParams() { } public string IndexName { get { throw null; } set { } } public int? MaxDocsForReranker { get { throw null; } set { } } public float? RerankerThreshold { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentIndexParams System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentIndexParams System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentMessage + public partial class KnowledgeAgentMessage : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeAgentMessage(string role, System.Collections.Generic.IEnumerable content) { } public System.Collections.Generic.IList Content { get { throw null; } } public string Role { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentMessage System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentMessage System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public abstract partial class KnowledgeAgentMessageContent + public abstract partial class KnowledgeAgentMessageContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { protected KnowledgeAgentMessageContent() { } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct KnowledgeAgentMessageContentType : System.IEquatable @@ -268,43 +315,79 @@ protected KnowledgeAgentMessageContent() { } public static bool operator !=(Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageContentType left, Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageContentType right) { throw null; } public override string ToString() { throw null; } } - public partial class KnowledgeAgentMessageImageContent : Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageContent + public partial class KnowledgeAgentMessageImageContent : Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageContent, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeAgentMessageImageContent(Azure.Search.Documents.Models.KnowledgeAgentMessageImageContentImage image) { } public Azure.Search.Documents.Models.KnowledgeAgentMessageImageContentImage Image { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageImageContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageImageContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentMessageTextContent : Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageContent + public partial class KnowledgeAgentMessageTextContent : Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageContent, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeAgentMessageTextContent(string text) { } public string Text { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageTextContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentMessageTextContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentModelQueryPlanningActivityRecord : Azure.Search.Documents.Agents.Models.KnowledgeAgentActivityRecord + public partial class KnowledgeAgentModelQueryPlanningActivityRecord : Azure.Search.Documents.Agents.Models.KnowledgeAgentActivityRecord, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal KnowledgeAgentModelQueryPlanningActivityRecord() : base (default(int)) { } public int? ElapsedMs { get { throw null; } } public int? InputTokens { get { throw null; } } public int? OutputTokens { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentModelQueryPlanningActivityRecord System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentModelQueryPlanningActivityRecord System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public abstract partial class KnowledgeAgentReference + public abstract partial class KnowledgeAgentReference : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { protected KnowledgeAgentReference(string id, int activitySource) { } public int ActivitySource { get { throw null; } } public string Id { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentReference System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentReference System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentRetrievalRequest + public partial class KnowledgeAgentRetrievalRequest : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeAgentRetrievalRequest(System.Collections.Generic.IEnumerable messages) { } public System.Collections.Generic.IList Messages { get { throw null; } } public System.Collections.Generic.IList TargetIndexParams { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentRetrievalRequest System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentRetrievalRequest System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentRetrievalResponse + public partial class KnowledgeAgentRetrievalResponse : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal KnowledgeAgentRetrievalResponse() { } public System.Collections.Generic.IReadOnlyList Activity { get { throw null; } } public System.Collections.Generic.IReadOnlyList References { get { throw null; } } public System.Collections.Generic.IReadOnlyList Response { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentRetrievalResponse System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentRetrievalResponse System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentSearchActivityRecord : Azure.Search.Documents.Agents.Models.KnowledgeAgentActivityRecord + public partial class KnowledgeAgentSearchActivityRecord : Azure.Search.Documents.Agents.Models.KnowledgeAgentActivityRecord, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal KnowledgeAgentSearchActivityRecord() : base (default(int)) { } public int? Count { get { throw null; } } @@ -312,12 +395,24 @@ internal KnowledgeAgentSearchActivityRecord() : base (default(int)) { } public Azure.Search.Documents.Models.KnowledgeAgentSearchActivityRecordQuery Query { get { throw null; } } public System.DateTimeOffset? QueryTime { get { throw null; } } public string TargetIndex { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentSearchActivityRecord System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentSearchActivityRecord System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentSemanticRankerActivityRecord : Azure.Search.Documents.Agents.Models.KnowledgeAgentActivityRecord + public partial class KnowledgeAgentSemanticRankerActivityRecord : Azure.Search.Documents.Agents.Models.KnowledgeAgentActivityRecord, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal KnowledgeAgentSemanticRankerActivityRecord() : base (default(int)) { } public int? ElapsedMs { get { throw null; } } public int? InputTokens { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentSemanticRankerActivityRecord System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Agents.Models.KnowledgeAgentSemanticRankerActivityRecord System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } } namespace Azure.Search.Documents.Indexes @@ -545,40 +640,70 @@ namespace Azure.Search.Documents.Indexes.Models public static bool operator !=(Azure.Search.Documents.Indexes.Models.AIFoundryModelCatalogName left, Azure.Search.Documents.Indexes.Models.AIFoundryModelCatalogName right) { throw null; } public override string ToString() { throw null; } } - public partial class AIServicesAccountIdentity : Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount + public partial class AIServicesAccountIdentity : Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AIServicesAccountIdentity(string subdomainUrl) { } public Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity Identity { get { throw null; } set { } } public string SubdomainUrl { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AIServicesAccountIdentity System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AIServicesAccountIdentity System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AIServicesAccountKey : Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount + public partial class AIServicesAccountKey : Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AIServicesAccountKey(string key, string subdomainUrl) { } public string Key { get { throw null; } set { } } public string SubdomainUrl { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AIServicesAccountKey System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AIServicesAccountKey System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AIServicesVisionParameters + public partial class AIServicesVisionParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AIServicesVisionParameters(string modelVersion, System.Uri resourceUri) { } public string ApiKey { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity AuthIdentity { get { throw null; } set { } } public string ModelVersion { get { throw null; } set { } } public System.Uri ResourceUri { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AIServicesVisionParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AIServicesVisionParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AIServicesVisionVectorizer : Azure.Search.Documents.Indexes.Models.VectorSearchVectorizer + public partial class AIServicesVisionVectorizer : Azure.Search.Documents.Indexes.Models.VectorSearchVectorizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AIServicesVisionVectorizer(string vectorizerName) : base (default(string)) { } public Azure.Search.Documents.Indexes.Models.AIServicesVisionParameters AIServicesVisionParameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AIServicesVisionVectorizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AIServicesVisionVectorizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AnalyzedTokenInfo + public partial class AnalyzedTokenInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal AnalyzedTokenInfo() { } public int EndOffset { get { throw null; } } public int Position { get { throw null; } } public int StartOffset { get { throw null; } } public string Token { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AnalyzedTokenInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AnalyzedTokenInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AnalyzeTextOptions + public partial class AnalyzeTextOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AnalyzeTextOptions(string text) { } public AnalyzeTextOptions(string text, Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName analyzerName) { } @@ -590,13 +715,25 @@ public AnalyzeTextOptions(string text, Azure.Search.Documents.Indexes.Models.Lex public string Text { get { throw null; } } public System.Collections.Generic.IList TokenFilters { get { throw null; } } public Azure.Search.Documents.Indexes.Models.LexicalTokenizerName? TokenizerName { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AnalyzeTextOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AnalyzeTextOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AsciiFoldingTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class AsciiFoldingTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AsciiFoldingTokenFilter(string name) { } public bool? PreserveOriginal { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AsciiFoldingTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AsciiFoldingTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AzureMachineLearningParameters + public partial class AzureMachineLearningParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AzureMachineLearningParameters(System.Uri scoringUri) { } public string AuthenticationKey { get { throw null; } set { } } @@ -605,8 +742,14 @@ public AzureMachineLearningParameters(System.Uri scoringUri) { } public string ResourceId { get { throw null; } set { } } public System.Uri ScoringUri { get { throw null; } set { } } public System.TimeSpan? Timeout { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureMachineLearningParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureMachineLearningParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AzureMachineLearningSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class AzureMachineLearningSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AzureMachineLearningSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs, Azure.Core.ResourceIdentifier resourceId, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?)) { } public AzureMachineLearningSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs, System.Uri scoringUri, string authenticationKey = null) { } @@ -616,13 +759,25 @@ public AzureMachineLearningSkill(System.Collections.Generic.IEnumerable.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureMachineLearningSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AzureMachineLearningVectorizer : Azure.Search.Documents.Indexes.Models.VectorSearchVectorizer + public partial class AzureMachineLearningVectorizer : Azure.Search.Documents.Indexes.Models.VectorSearchVectorizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AzureMachineLearningVectorizer(string vectorizerName) : base (default(string)) { } public Azure.Search.Documents.Indexes.Models.AzureMachineLearningParameters AMLParameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureMachineLearningVectorizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureMachineLearningVectorizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AzureOpenAIEmbeddingSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class AzureOpenAIEmbeddingSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AzureOpenAIEmbeddingSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public string ApiKey { get { throw null; } set { } } @@ -631,6 +786,12 @@ public AzureOpenAIEmbeddingSkill(System.Collections.Generic.IEnumerable.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureOpenAIEmbeddingSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct AzureOpenAIModelName : System.IEquatable @@ -656,18 +817,30 @@ public AzureOpenAIEmbeddingSkill(System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public AzureOpenAITokenizerParameters() { } public System.Collections.Generic.IList AllowedSpecialTokens { get { throw null; } } public Azure.Search.Documents.Indexes.Models.SplitSkillEncoderModelName? EncoderModelName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureOpenAITokenizerParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureOpenAITokenizerParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AzureOpenAIVectorizer : Azure.Search.Documents.Indexes.Models.VectorSearchVectorizer + public partial class AzureOpenAIVectorizer : Azure.Search.Documents.Indexes.Models.VectorSearchVectorizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AzureOpenAIVectorizer(string vectorizerName) : base (default(string)) { } public Azure.Search.Documents.Indexes.Models.AzureOpenAIVectorizerParameters Parameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureOpenAIVectorizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureOpenAIVectorizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class AzureOpenAIVectorizerParameters + public partial class AzureOpenAIVectorizerParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public AzureOpenAIVectorizerParameters() { } public string ApiKey { get { throw null; } set { } } @@ -675,10 +848,22 @@ public AzureOpenAIVectorizerParameters() { } public string DeploymentName { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.AzureOpenAIModelName? ModelName { get { throw null; } set { } } public System.Uri ResourceUri { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureOpenAIVectorizerParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.AzureOpenAIVectorizerParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class BinaryQuantizationCompression : Azure.Search.Documents.Indexes.Models.VectorSearchCompression + public partial class BinaryQuantizationCompression : Azure.Search.Documents.Indexes.Models.VectorSearchCompression, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public BinaryQuantizationCompression(string compressionName) : base (default(string)) { } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.BinaryQuantizationCompression System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.BinaryQuantizationCompression System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct BlobIndexerDataToExtract : System.IEquatable @@ -759,16 +944,28 @@ public BinaryQuantizationCompression(string compressionName) : base (default(str public static bool operator !=(Azure.Search.Documents.Indexes.Models.BlobIndexerPdfTextRotationAlgorithm left, Azure.Search.Documents.Indexes.Models.BlobIndexerPdfTextRotationAlgorithm right) { throw null; } public override string ToString() { throw null; } } - public partial class BM25Similarity : Azure.Search.Documents.Indexes.Models.SimilarityAlgorithm + public partial class BM25Similarity : Azure.Search.Documents.Indexes.Models.SimilarityAlgorithm, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public BM25Similarity() { } public double? B { get { throw null; } set { } } public double? K1 { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.BM25Similarity System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.BM25Similarity System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CharFilter + public partial class CharFilter : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal CharFilter() { } public string Name { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CharFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CharFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct CharFilterName : System.IEquatable @@ -806,21 +1003,33 @@ internal CharFilter() { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.ChatCompletionExtraParametersBehavior left, Azure.Search.Documents.Indexes.Models.ChatCompletionExtraParametersBehavior right) { throw null; } public override string ToString() { throw null; } } - public partial class ChatCompletionResponseFormat + public partial class ChatCompletionResponseFormat : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ChatCompletionResponseFormat() { } public Azure.Search.Documents.Models.ChatCompletionResponseFormatJsonSchemaProperties ChatCompletionSchemaProperties { get { throw null; } set { } } public Azure.Search.Documents.Models.ChatCompletionResponseFormatType? Type { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ChatCompletionResponseFormat System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ChatCompletionResponseFormat System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ChatCompletionSchema + public partial class ChatCompletionSchema : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ChatCompletionSchema() { } public bool? AdditionalProperties { get { throw null; } set { } } public string Properties { get { throw null; } set { } } public System.Collections.Generic.IList Required { get { throw null; } } public string Type { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ChatCompletionSchema System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ChatCompletionSchema System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ChatCompletionSkill : Azure.Search.Documents.Indexes.Models.WebApiSkill + public partial class ChatCompletionSkill : Azure.Search.Documents.Indexes.Models.WebApiSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ChatCompletionSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs, string uri) : base (default(System.Collections.Generic.IEnumerable), default(System.Collections.Generic.IEnumerable), default(string)) { } public string ApiKey { get { throw null; } set { } } @@ -828,12 +1037,24 @@ public partial class ChatCompletionSkill : Azure.Search.Documents.Indexes.Models public System.Collections.Generic.IDictionary ExtraParameters { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.ChatCompletionExtraParametersBehavior? ExtraParametersBehavior { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.ChatCompletionResponseFormat ResponseFormat { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ChatCompletionSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ChatCompletionSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CjkBigramTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class CjkBigramTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CjkBigramTokenFilter(string name) { } public System.Collections.Generic.IList IgnoreScripts { get { throw null; } } public bool? OutputUnigrams { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CjkBigramTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CjkBigramTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum CjkBigramTokenFilterScripts { @@ -842,33 +1063,63 @@ public enum CjkBigramTokenFilterScripts Katakana = 2, Hangul = 3, } - public partial class ClassicSimilarity : Azure.Search.Documents.Indexes.Models.SimilarityAlgorithm + public partial class ClassicSimilarity : Azure.Search.Documents.Indexes.Models.SimilarityAlgorithm, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ClassicSimilarity() { } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ClassicSimilarity System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ClassicSimilarity System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ClassicTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class ClassicTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ClassicTokenizer(string name) { } public int? MaxTokenLength { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ClassicTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ClassicTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CognitiveServicesAccount + public partial class CognitiveServicesAccount : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal CognitiveServicesAccount() { } public string Description { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CognitiveServicesAccountKey : Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount + public partial class CognitiveServicesAccountKey : Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CognitiveServicesAccountKey(string key) { } public string Key { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CognitiveServicesAccountKey System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CognitiveServicesAccountKey System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CommonGramTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class CommonGramTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CommonGramTokenFilter(string name, System.Collections.Generic.IEnumerable commonWords) { } public System.Collections.Generic.IList CommonWords { get { throw null; } } public bool? IgnoreCase { get { throw null; } set { } } public bool? UseQueryMode { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CommonGramTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CommonGramTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CommonModelParameters + public partial class CommonModelParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CommonModelParameters() { } public float? FrequencyPenalty { get { throw null; } set { } } @@ -878,30 +1129,54 @@ public CommonModelParameters() { } public int? Seed { get { throw null; } set { } } public System.Collections.Generic.IList Stop { get { throw null; } set { } } public float? Temperature { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CommonModelParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CommonModelParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class ComplexField : Azure.Search.Documents.Indexes.Models.SearchFieldTemplate { public ComplexField(string name, bool collection = false) { } public System.Collections.Generic.IList Fields { get { throw null; } } } - public partial class ConditionalSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class ConditionalSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ConditionalSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ConditionalSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ConditionalSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CorsOptions + public partial class CorsOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CorsOptions(System.Collections.Generic.IEnumerable allowedOrigins) { } public System.Collections.Generic.IList AllowedOrigins { get { throw null; } } public long? MaxAgeInSeconds { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CorsOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CorsOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CustomAnalyzer : Azure.Search.Documents.Indexes.Models.LexicalAnalyzer + public partial class CustomAnalyzer : Azure.Search.Documents.Indexes.Models.LexicalAnalyzer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CustomAnalyzer(string name, Azure.Search.Documents.Indexes.Models.LexicalTokenizerName tokenizerName) { } public System.Collections.Generic.IList CharFilters { get { throw null; } } public System.Collections.Generic.IList TokenFilters { get { throw null; } } public Azure.Search.Documents.Indexes.Models.LexicalTokenizerName TokenizerName { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CustomAnalyzer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CustomAnalyzer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CustomEntity + public partial class CustomEntity : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CustomEntity(string name) { } public bool? AccentSensitive { get { throw null; } set { } } @@ -916,16 +1191,28 @@ public CustomEntity(string name) { } public string Name { get { throw null; } set { } } public string Subtype { get { throw null; } set { } } public string Type { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CustomEntity System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CustomEntity System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CustomEntityAlias + public partial class CustomEntityAlias : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CustomEntityAlias(string text) { } public bool? AccentSensitive { get { throw null; } set { } } public bool? CaseSensitive { get { throw null; } set { } } public int? FuzzyEditDistance { get { throw null; } set { } } public string Text { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CustomEntityAlias System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CustomEntityAlias System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class CustomEntityLookupSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class CustomEntityLookupSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CustomEntityLookupSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public Azure.Search.Documents.Indexes.Models.CustomEntityLookupSkillLanguage? DefaultLanguageCode { get { throw null; } set { } } @@ -934,6 +1221,12 @@ public CustomEntityLookupSkill(System.Collections.Generic.IEnumerable InlineEntitiesDefinition { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CustomEntityLookupSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CustomEntityLookupSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct CustomEntityLookupSkillLanguage : System.IEquatable @@ -960,25 +1253,49 @@ public CustomEntityLookupSkill(System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public CustomNormalizer(string name) : base (default(string)) { } public System.Collections.Generic.IList CharFilters { get { throw null; } } public System.Collections.Generic.IList TokenFilters { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CustomNormalizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.CustomNormalizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class DataChangeDetectionPolicy + public partial class DataChangeDetectionPolicy : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal DataChangeDetectionPolicy() { } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DataChangeDetectionPolicy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DataChangeDetectionPolicy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class DataDeletionDetectionPolicy + public partial class DataDeletionDetectionPolicy : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal DataDeletionDetectionPolicy() { } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DataDeletionDetectionPolicy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DataDeletionDetectionPolicy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class DefaultCognitiveServicesAccount : Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount + public partial class DefaultCognitiveServicesAccount : Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public DefaultCognitiveServicesAccount() { } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DefaultCognitiveServicesAccount System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DefaultCognitiveServicesAccount System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class DictionaryDecompounderTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class DictionaryDecompounderTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public DictionaryDecompounderTokenFilter(string name, System.Collections.Generic.IEnumerable wordList) { } public int? MaxSubwordSize { get { throw null; } set { } } @@ -986,26 +1303,50 @@ public DictionaryDecompounderTokenFilter(string name, System.Collections.Generic public int? MinWordSize { get { throw null; } set { } } public bool? OnlyLongestMatch { get { throw null; } set { } } public System.Collections.Generic.IList WordList { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DictionaryDecompounderTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DictionaryDecompounderTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class DistanceScoringFunction : Azure.Search.Documents.Indexes.Models.ScoringFunction + public partial class DistanceScoringFunction : Azure.Search.Documents.Indexes.Models.ScoringFunction, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public DistanceScoringFunction(string fieldName, double boost, Azure.Search.Documents.Indexes.Models.DistanceScoringParameters parameters) { } public Azure.Search.Documents.Indexes.Models.DistanceScoringParameters Parameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DistanceScoringFunction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DistanceScoringFunction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class DistanceScoringParameters + public partial class DistanceScoringParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public DistanceScoringParameters(string referencePointParameter, double boostingDistance) { } public double BoostingDistance { get { throw null; } set { } } public string ReferencePointParameter { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DistanceScoringParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DistanceScoringParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class DocumentExtractionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class DocumentExtractionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public DocumentExtractionSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public System.Collections.Generic.IDictionary Configuration { get { throw null; } } public Azure.Search.Documents.Indexes.Models.BlobIndexerDataToExtract? DataToExtract { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.BlobIndexerParsingMode? ParsingMode { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DocumentExtractionSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DocumentExtractionSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class DocumentIntelligenceLayoutSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class DocumentIntelligenceLayoutSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public DocumentIntelligenceLayoutSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public Azure.Search.Documents.Indexes.Models.DocumentIntelligenceLayoutSkillChunkingProperties ChunkingProperties { get { throw null; } set { } } @@ -1013,13 +1354,25 @@ public DocumentIntelligenceLayoutSkill(System.Collections.Generic.IEnumerable.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DocumentIntelligenceLayoutSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class DocumentIntelligenceLayoutSkillChunkingProperties + public partial class DocumentIntelligenceLayoutSkillChunkingProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public DocumentIntelligenceLayoutSkillChunkingProperties() { } public int? MaximumLength { get { throw null; } set { } } public int? OverlapLength { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.DocumentIntelligenceLayoutSkillChunkingUnit? Unit { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DocumentIntelligenceLayoutSkillChunkingProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.DocumentIntelligenceLayoutSkillChunkingProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct DocumentIntelligenceLayoutSkillChunkingUnit : System.IEquatable @@ -1113,29 +1466,47 @@ public DocumentIntelligenceLayoutSkillChunkingProperties() { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.DocumentIntelligenceLayoutSkillOutputMode left, Azure.Search.Documents.Indexes.Models.DocumentIntelligenceLayoutSkillOutputMode right) { throw null; } public override string ToString() { throw null; } } - public partial class EdgeNGramTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class EdgeNGramTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public EdgeNGramTokenFilter(string name) { } public int? MaxGram { get { throw null; } set { } } public int? MinGram { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.EdgeNGramTokenFilterSide? Side { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.EdgeNGramTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.EdgeNGramTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum EdgeNGramTokenFilterSide { Front = 0, Back = 1, } - public partial class EdgeNGramTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class EdgeNGramTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public EdgeNGramTokenizer(string name) { } public int? MaxGram { get { throw null; } set { } } public int? MinGram { get { throw null; } set { } } public System.Collections.Generic.IList TokenChars { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.EdgeNGramTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.EdgeNGramTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ElisionTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class ElisionTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ElisionTokenFilter(string name) { } public System.Collections.Generic.IList Articles { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ElisionTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ElisionTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct EntityCategory : System.IEquatable @@ -1160,14 +1531,20 @@ public ElisionTokenFilter(string name) { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.EntityCategory left, Azure.Search.Documents.Indexes.Models.EntityCategory right) { throw null; } public override string ToString() { throw null; } } - public partial class EntityLinkingSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class EntityLinkingSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public EntityLinkingSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public string DefaultLanguageCode { get { throw null; } set { } } public double? MinimumPrecision { get { throw null; } set { } } public string ModelVersion { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.EntityLinkingSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.EntityLinkingSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class EntityRecognitionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class EntityRecognitionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public EntityRecognitionSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } @@ -1177,6 +1554,12 @@ public EntityRecognitionSkill(System.Collections.Generic.IEnumerable.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.EntityRecognitionSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct SkillVersion : System.IEquatable { @@ -1239,63 +1622,123 @@ public EntityRecognitionSkill(System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public ExhaustiveKnnAlgorithmConfiguration(string name) : base (default(string)) { } public Azure.Search.Documents.Indexes.Models.ExhaustiveKnnParameters Parameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ExhaustiveKnnAlgorithmConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ExhaustiveKnnAlgorithmConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ExhaustiveKnnParameters + public partial class ExhaustiveKnnParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ExhaustiveKnnParameters() { } public Azure.Search.Documents.Indexes.Models.VectorSearchAlgorithmMetric? Metric { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ExhaustiveKnnParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ExhaustiveKnnParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class FieldMapping + public partial class FieldMapping : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public FieldMapping(string sourceFieldName) { } public Azure.Search.Documents.Indexes.Models.FieldMappingFunction MappingFunction { get { throw null; } set { } } public string SourceFieldName { get { throw null; } set { } } public string TargetFieldName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.FieldMapping System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.FieldMapping System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class FieldMappingFunction + public partial class FieldMappingFunction : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public FieldMappingFunction(string name) { } public string Name { get { throw null; } set { } } public System.Collections.Generic.IDictionary Parameters { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.FieldMappingFunction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.FieldMappingFunction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class FreshnessScoringFunction : Azure.Search.Documents.Indexes.Models.ScoringFunction + public partial class FreshnessScoringFunction : Azure.Search.Documents.Indexes.Models.ScoringFunction, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public FreshnessScoringFunction(string fieldName, double boost, Azure.Search.Documents.Indexes.Models.FreshnessScoringParameters parameters) { } public Azure.Search.Documents.Indexes.Models.FreshnessScoringParameters Parameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.FreshnessScoringFunction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.FreshnessScoringFunction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class FreshnessScoringParameters + public partial class FreshnessScoringParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public FreshnessScoringParameters(System.TimeSpan boostingDuration) { } public System.TimeSpan BoostingDuration { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.FreshnessScoringParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.FreshnessScoringParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class HighWaterMarkChangeDetectionPolicy : Azure.Search.Documents.Indexes.Models.DataChangeDetectionPolicy + public partial class HighWaterMarkChangeDetectionPolicy : Azure.Search.Documents.Indexes.Models.DataChangeDetectionPolicy, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public HighWaterMarkChangeDetectionPolicy(string highWaterMarkColumnName) { } public string HighWaterMarkColumnName { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.HighWaterMarkChangeDetectionPolicy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.HighWaterMarkChangeDetectionPolicy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class HnswAlgorithmConfiguration : Azure.Search.Documents.Indexes.Models.VectorSearchAlgorithmConfiguration + public partial class HnswAlgorithmConfiguration : Azure.Search.Documents.Indexes.Models.VectorSearchAlgorithmConfiguration, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public HnswAlgorithmConfiguration(string name) : base (default(string)) { } public Azure.Search.Documents.Indexes.Models.HnswParameters Parameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.HnswAlgorithmConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.HnswAlgorithmConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class HnswParameters + public partial class HnswParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public HnswParameters() { } public int? EfConstruction { get { throw null; } set { } } public int? EfSearch { get { throw null; } set { } } public int? M { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.VectorSearchAlgorithmMetric? Metric { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.HnswParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.HnswParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ImageAnalysisSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class ImageAnalysisSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ImageAnalysisSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public Azure.Search.Documents.Indexes.Models.ImageAnalysisSkillLanguage? DefaultLanguageCode { get { throw null; } set { } } public System.Collections.Generic.IList Details { get { throw null; } } public System.Collections.Generic.IList VisualFeatures { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ImageAnalysisSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ImageAnalysisSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct ImageAnalysisSkillLanguage : System.IEquatable @@ -1409,7 +1852,7 @@ internal IndexerChangeTrackingState() { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.IndexerExecutionEnvironment left, Azure.Search.Documents.Indexes.Models.IndexerExecutionEnvironment right) { throw null; } public override string ToString() { throw null; } } - public partial class IndexerExecutionResult + public partial class IndexerExecutionResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal IndexerExecutionResult() { } public System.DateTimeOffset? EndTime { get { throw null; } } @@ -1424,6 +1867,12 @@ internal IndexerExecutionResult() { } public Azure.Search.Documents.Indexes.Models.IndexerExecutionStatus Status { get { throw null; } } public Azure.Search.Documents.Indexes.Models.IndexerExecutionStatusDetail? StatusDetail { get { throw null; } } public System.Collections.Generic.IReadOnlyList Warnings { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexerExecutionResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexerExecutionResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum IndexerExecutionStatus { @@ -1486,7 +1935,7 @@ public enum IndexerExecutionStatus public static bool operator !=(Azure.Search.Documents.Indexes.Models.IndexerResyncOption left, Azure.Search.Documents.Indexes.Models.IndexerResyncOption right) { throw null; } public override string ToString() { throw null; } } - public partial class IndexerState + public partial class IndexerState : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal IndexerState() { } public string AllDocsFinalTrackingState { get { throw null; } } @@ -1499,6 +1948,12 @@ internal IndexerState() { } public System.Collections.Generic.IReadOnlyList ResetDocumentKeys { get { throw null; } } public string ResyncFinalTrackingState { get { throw null; } } public string ResyncInitialTrackingState { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexerState System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexerState System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum IndexerStatus { @@ -1525,7 +1980,7 @@ public enum IndexerStatus public static bool operator !=(Azure.Search.Documents.Indexes.Models.IndexingMode left, Azure.Search.Documents.Indexes.Models.IndexingMode right) { throw null; } public override string ToString() { throw null; } } - public partial class IndexingParameters + public partial class IndexingParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public IndexingParameters() { } public int? BatchSize { get { throw null; } set { } } @@ -1534,8 +1989,14 @@ public IndexingParameters() { } public Azure.Search.Documents.Indexes.Models.IndexingParametersConfiguration IndexingParametersConfiguration { get { throw null; } set { } } public int? MaxFailedItems { get { throw null; } set { } } public int? MaxFailedItemsPerBatch { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexingParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexingParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class IndexingParametersConfiguration : System.Collections.Generic.ICollection>, System.Collections.Generic.IDictionary, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + public partial class IndexingParametersConfiguration : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel, System.Collections.Generic.ICollection>, System.Collections.Generic.IDictionary, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable { public IndexingParametersConfiguration() { } public bool? AllowSkillsetToReadFileData { get { throw null; } set { } } @@ -1564,7 +2025,13 @@ public IndexingParametersConfiguration() { } public void Add(string key, object value) { } public bool ContainsKey(string key) { throw null; } public System.Collections.Generic.IEnumerator> GetEnumerator() { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } public bool Remove(string key) { throw null; } + Azure.Search.Documents.Indexes.Models.IndexingParametersConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexingParametersConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.Collections.Generic.ICollection>.Add(System.Collections.Generic.KeyValuePair value) { } void System.Collections.Generic.ICollection>.Clear() { } bool System.Collections.Generic.ICollection>.Contains(System.Collections.Generic.KeyValuePair value) { throw null; } @@ -1573,11 +2040,17 @@ public void Add(string key, object value) { } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } public bool TryGetValue(string key, out object value) { throw null; } } - public partial class IndexingSchedule + public partial class IndexingSchedule : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public IndexingSchedule(System.TimeSpan interval) { } public System.TimeSpan Interval { get { throw null; } set { } } public System.DateTimeOffset? StartTime { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexingSchedule System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexingSchedule System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct IndexProjectionMode : System.IEquatable @@ -1597,33 +2070,57 @@ public IndexingSchedule(System.TimeSpan interval) { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.IndexProjectionMode left, Azure.Search.Documents.Indexes.Models.IndexProjectionMode right) { throw null; } public override string ToString() { throw null; } } - public partial class IndexStatisticsSummary + public partial class IndexStatisticsSummary : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal IndexStatisticsSummary() { } public long DocumentCount { get { throw null; } } public string Name { get { throw null; } } public long StorageSize { get { throw null; } } public long VectorIndexSize { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexStatisticsSummary System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.IndexStatisticsSummary System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class InputFieldMappingEntry + public partial class InputFieldMappingEntry : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public InputFieldMappingEntry(string name) { } public System.Collections.Generic.IList Inputs { get { throw null; } } public string Name { get { throw null; } set { } } public string Source { get { throw null; } set { } } public string SourceContext { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.InputFieldMappingEntry System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.InputFieldMappingEntry System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KeepTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class KeepTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KeepTokenFilter(string name, System.Collections.Generic.IEnumerable keepWords) { } public System.Collections.Generic.IList KeepWords { get { throw null; } } public bool? LowerCaseKeepWords { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KeepTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KeepTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KeyPhraseExtractionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class KeyPhraseExtractionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KeyPhraseExtractionSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public Azure.Search.Documents.Indexes.Models.KeyPhraseExtractionSkillLanguage? DefaultLanguageCode { get { throw null; } set { } } public int? MaxKeyPhraseCount { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KeyPhraseExtractionSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KeyPhraseExtractionSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct KeyPhraseExtractionSkillLanguage : System.IEquatable @@ -1657,19 +2154,31 @@ public KeyPhraseExtractionSkill(System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public KeywordMarkerTokenFilter(string name, System.Collections.Generic.IEnumerable keywords) { } public bool? IgnoreCase { get { throw null; } set { } } public System.Collections.Generic.IList Keywords { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KeywordMarkerTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KeywordMarkerTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KeywordTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class KeywordTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KeywordTokenizer(string name) { } public int? BufferSize { get { throw null; } set { } } public int? MaxTokenLength { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KeywordTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KeywordTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgent + public partial class KnowledgeAgent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeAgent(string name, System.Collections.Generic.IEnumerable models, System.Collections.Generic.IEnumerable targetIndexes) { } public string Description { get { throw null; } set { } } @@ -1679,15 +2188,33 @@ public KnowledgeAgent(string name, System.Collections.Generic.IEnumerable TargetIndexes { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeAgent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeAgent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentAzureOpenAIModel : Azure.Search.Documents.Indexes.Models.KnowledgeAgentModel + public partial class KnowledgeAgentAzureOpenAIModel : Azure.Search.Documents.Indexes.Models.KnowledgeAgentModel, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeAgentAzureOpenAIModel(Azure.Search.Documents.Indexes.Models.AzureOpenAIVectorizerParameters azureOpenAIParameters) { } public Azure.Search.Documents.Indexes.Models.AzureOpenAIVectorizerParameters AzureOpenAIParameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeAgentAzureOpenAIModel System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeAgentAzureOpenAIModel System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public abstract partial class KnowledgeAgentModel + public abstract partial class KnowledgeAgentModel : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { protected KnowledgeAgentModel() { } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeAgentModel System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeAgentModel System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct KnowledgeAgentModelKind : System.IEquatable @@ -1706,44 +2233,80 @@ protected KnowledgeAgentModel() { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.KnowledgeAgentModelKind left, Azure.Search.Documents.Indexes.Models.KnowledgeAgentModelKind right) { throw null; } public override string ToString() { throw null; } } - public partial class KnowledgeAgentRequestLimits + public partial class KnowledgeAgentRequestLimits : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeAgentRequestLimits() { } public int? MaxOutputSize { get { throw null; } set { } } public int? MaxRuntimeInSeconds { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeAgentRequestLimits System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeAgentRequestLimits System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentTargetIndex + public partial class KnowledgeAgentTargetIndex : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeAgentTargetIndex(string indexName) { } public bool? DefaultIncludeReferenceSourceData { get { throw null; } set { } } public int? DefaultMaxDocsForReranker { get { throw null; } set { } } public float? DefaultRerankerThreshold { get { throw null; } set { } } public string IndexName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeAgentTargetIndex System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeAgentTargetIndex System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeStore + public partial class KnowledgeStore : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeStore(string storageConnectionString, System.Collections.Generic.IEnumerable projections) { } public Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity Identity { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.SearchIndexerKnowledgeStoreParameters Parameters { get { throw null; } set { } } public System.Collections.Generic.IList Projections { get { throw null; } } public string StorageConnectionString { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStore System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStore System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeStoreFileProjectionSelector : Azure.Search.Documents.Indexes.Models.KnowledgeStoreStorageProjectionSelector + public partial class KnowledgeStoreFileProjectionSelector : Azure.Search.Documents.Indexes.Models.KnowledgeStoreStorageProjectionSelector, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeStoreFileProjectionSelector(string storageContainer) : base (default(string)) { } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreFileProjectionSelector System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreFileProjectionSelector System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeStoreObjectProjectionSelector : Azure.Search.Documents.Indexes.Models.KnowledgeStoreStorageProjectionSelector + public partial class KnowledgeStoreObjectProjectionSelector : Azure.Search.Documents.Indexes.Models.KnowledgeStoreStorageProjectionSelector, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeStoreObjectProjectionSelector(string storageContainer) : base (default(string)) { } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreObjectProjectionSelector System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreObjectProjectionSelector System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeStoreProjection + public partial class KnowledgeStoreProjection : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeStoreProjection() { } public System.Collections.Generic.IList Files { get { throw null; } } public System.Collections.Generic.IList Objects { get { throw null; } } public System.Collections.Generic.IList Tables { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreProjection System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreProjection System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeStoreProjectionSelector + public partial class KnowledgeStoreProjectionSelector : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeStoreProjectionSelector() { } public string GeneratedKeyName { get { throw null; } set { } } @@ -1751,32 +2314,68 @@ public KnowledgeStoreProjectionSelector() { } public string ReferenceKeyName { get { throw null; } set { } } public string Source { get { throw null; } set { } } public string SourceContext { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreProjectionSelector System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreProjectionSelector System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeStoreStorageProjectionSelector : Azure.Search.Documents.Indexes.Models.KnowledgeStoreProjectionSelector + public partial class KnowledgeStoreStorageProjectionSelector : Azure.Search.Documents.Indexes.Models.KnowledgeStoreProjectionSelector, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeStoreStorageProjectionSelector(string storageContainer) { } public string StorageContainer { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreStorageProjectionSelector System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreStorageProjectionSelector System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeStoreTableProjectionSelector : Azure.Search.Documents.Indexes.Models.KnowledgeStoreProjectionSelector + public partial class KnowledgeStoreTableProjectionSelector : Azure.Search.Documents.Indexes.Models.KnowledgeStoreProjectionSelector, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeStoreTableProjectionSelector(string tableName) { } public string TableName { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreTableProjectionSelector System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.KnowledgeStoreTableProjectionSelector System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class LanguageDetectionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class LanguageDetectionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public LanguageDetectionSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public string DefaultCountryHint { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LanguageDetectionSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LanguageDetectionSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class LengthTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class LengthTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public LengthTokenFilter(string name) { } public int? MaxLength { get { throw null; } set { } } public int? MinLength { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LengthTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LengthTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class LexicalAnalyzer + public partial class LexicalAnalyzer : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal LexicalAnalyzer() { } public string Name { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LexicalAnalyzer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LexicalAnalyzer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct LexicalAnalyzerName : System.IEquatable @@ -1983,10 +2582,16 @@ public static partial class Values public const string ZhHantMicrosoft = "zh-Hant.microsoft"; } } - public partial class LexicalNormalizer + public partial class LexicalNormalizer : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public LexicalNormalizer(string name) { } public string Name { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LexicalNormalizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LexicalNormalizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct LexicalNormalizerName : System.IEquatable @@ -2017,10 +2622,16 @@ public static partial class Values public const string Uppercase = "uppercase"; } } - public partial class LexicalTokenizer + public partial class LexicalTokenizer : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal LexicalTokenizer() { } public string Name { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LexicalTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LexicalTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct LexicalTokenizerName : System.IEquatable @@ -2051,44 +2662,86 @@ internal LexicalTokenizer() { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.LexicalTokenizerName left, Azure.Search.Documents.Indexes.Models.LexicalTokenizerName right) { throw null; } public override string ToString() { throw null; } } - public partial class LimitTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class LimitTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public LimitTokenFilter(string name) { } public bool? ConsumeAllTokens { get { throw null; } set { } } public int? MaxTokenCount { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LimitTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LimitTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ListIndexStatsSummary + public partial class ListIndexStatsSummary : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ListIndexStatsSummary() { } public System.Collections.Generic.IReadOnlyList IndexesStatistics { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ListIndexStatsSummary System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ListIndexStatsSummary System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class LuceneStandardAnalyzer : Azure.Search.Documents.Indexes.Models.LexicalAnalyzer + public partial class LuceneStandardAnalyzer : Azure.Search.Documents.Indexes.Models.LexicalAnalyzer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public LuceneStandardAnalyzer(string name) { } public int? MaxTokenLength { get { throw null; } set { } } public System.Collections.Generic.IList Stopwords { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LuceneStandardAnalyzer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LuceneStandardAnalyzer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class LuceneStandardTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class LuceneStandardTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public LuceneStandardTokenizer(string name) { } public int? MaxTokenLength { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LuceneStandardTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.LuceneStandardTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class MagnitudeScoringFunction : Azure.Search.Documents.Indexes.Models.ScoringFunction + public partial class MagnitudeScoringFunction : Azure.Search.Documents.Indexes.Models.ScoringFunction, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public MagnitudeScoringFunction(string fieldName, double boost, Azure.Search.Documents.Indexes.Models.MagnitudeScoringParameters parameters) { } public Azure.Search.Documents.Indexes.Models.MagnitudeScoringParameters Parameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MagnitudeScoringFunction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MagnitudeScoringFunction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class MagnitudeScoringParameters + public partial class MagnitudeScoringParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public MagnitudeScoringParameters(double boostingRangeStart, double boostingRangeEnd) { } public double BoostingRangeEnd { get { throw null; } set { } } public double BoostingRangeStart { get { throw null; } set { } } public bool? ShouldBoostBeyondRangeByConstant { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MagnitudeScoringParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MagnitudeScoringParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class MappingCharFilter : Azure.Search.Documents.Indexes.Models.CharFilter + public partial class MappingCharFilter : Azure.Search.Documents.Indexes.Models.CharFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public MappingCharFilter(string name, System.Collections.Generic.IEnumerable mappings) { } public System.Collections.Generic.IList Mappings { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MappingCharFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MappingCharFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct MarkdownHeaderDepth : System.IEquatable @@ -2130,25 +2783,43 @@ public MappingCharFilter(string name, System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public MergeSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public string InsertPostTag { get { throw null; } set { } } public string InsertPreTag { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MergeSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MergeSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class MicrosoftLanguageStemmingTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class MicrosoftLanguageStemmingTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public MicrosoftLanguageStemmingTokenizer(string name) { } public bool? IsSearchTokenizer { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.MicrosoftStemmingTokenizerLanguage? Language { get { throw null; } set { } } public int? MaxTokenLength { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MicrosoftLanguageStemmingTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MicrosoftLanguageStemmingTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class MicrosoftLanguageTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class MicrosoftLanguageTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public MicrosoftLanguageTokenizer(string name) { } public bool? IsSearchTokenizer { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.MicrosoftTokenizerLanguage? Language { get { throw null; } set { } } public int? MaxTokenLength { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MicrosoftLanguageTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.MicrosoftLanguageTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum MicrosoftStemmingTokenizerLanguage { @@ -2243,22 +2914,40 @@ public enum MicrosoftTokenizerLanguage Urdu = 40, Vietnamese = 41, } - public partial class NativeBlobSoftDeleteDeletionDetectionPolicy : Azure.Search.Documents.Indexes.Models.DataDeletionDetectionPolicy + public partial class NativeBlobSoftDeleteDeletionDetectionPolicy : Azure.Search.Documents.Indexes.Models.DataDeletionDetectionPolicy, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public NativeBlobSoftDeleteDeletionDetectionPolicy() { } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.NativeBlobSoftDeleteDeletionDetectionPolicy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.NativeBlobSoftDeleteDeletionDetectionPolicy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class NGramTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class NGramTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public NGramTokenFilter(string name) { } public int? MaxGram { get { throw null; } set { } } public int? MinGram { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.NGramTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.NGramTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class NGramTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class NGramTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public NGramTokenizer(string name) { } public int? MaxGram { get { throw null; } set { } } public int? MinGram { get { throw null; } set { } } public System.Collections.Generic.IList TokenChars { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.NGramTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.NGramTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct OcrLineEnding : System.IEquatable @@ -2280,12 +2969,18 @@ public NGramTokenizer(string name) { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.OcrLineEnding left, Azure.Search.Documents.Indexes.Models.OcrLineEnding right) { throw null; } public override string ToString() { throw null; } } - public partial class OcrSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class OcrSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public OcrSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public Azure.Search.Documents.Indexes.Models.OcrSkillLanguage? DefaultLanguageCode { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.OcrLineEnding? LineEnding { get { throw null; } set { } } public bool? ShouldDetectOrientation { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.OcrSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.OcrSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct OcrSkillLanguage : System.IEquatable @@ -2473,13 +3168,19 @@ public OcrSkill(System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public OutputFieldMappingEntry(string name) { } public string Name { get { throw null; } set { } } public string TargetName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.OutputFieldMappingEntry System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.OutputFieldMappingEntry System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class PathHierarchyTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class PathHierarchyTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PathHierarchyTokenizer(string name) { } public char? Delimiter { get { throw null; } set { } } @@ -2487,39 +3188,75 @@ public PathHierarchyTokenizer(string name) { } public int? NumberOfTokensToSkip { get { throw null; } set { } } public char? Replacement { get { throw null; } set { } } public bool? ReverseTokenOrder { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PathHierarchyTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PathHierarchyTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class PatternAnalyzer : Azure.Search.Documents.Indexes.Models.LexicalAnalyzer + public partial class PatternAnalyzer : Azure.Search.Documents.Indexes.Models.LexicalAnalyzer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PatternAnalyzer(string name) { } public System.Collections.Generic.IList Flags { get { throw null; } } public bool? LowerCaseTerms { get { throw null; } set { } } public string Pattern { get { throw null; } set { } } public System.Collections.Generic.IList Stopwords { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PatternAnalyzer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PatternAnalyzer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class PatternCaptureTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class PatternCaptureTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PatternCaptureTokenFilter(string name, System.Collections.Generic.IEnumerable patterns) { } public System.Collections.Generic.IList Patterns { get { throw null; } } public bool? PreserveOriginal { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PatternCaptureTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PatternCaptureTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class PatternReplaceCharFilter : Azure.Search.Documents.Indexes.Models.CharFilter + public partial class PatternReplaceCharFilter : Azure.Search.Documents.Indexes.Models.CharFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PatternReplaceCharFilter(string name, string pattern, string replacement) { } public string Pattern { get { throw null; } set { } } public string Replacement { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PatternReplaceCharFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PatternReplaceCharFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class PatternReplaceTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class PatternReplaceTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PatternReplaceTokenFilter(string name, string pattern, string replacement) { } public string Pattern { get { throw null; } set { } } public string Replacement { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PatternReplaceTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PatternReplaceTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class PatternTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class PatternTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PatternTokenizer(string name) { } public System.Collections.Generic.IList Flags { get { throw null; } } public int? Group { get { throw null; } set { } } public string Pattern { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PatternTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PatternTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct PermissionFilter : System.IEquatable @@ -2560,13 +3297,19 @@ public enum PhoneticEncoder HaasePhonetik = 9, BeiderMorse = 10, } - public partial class PhoneticTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class PhoneticTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PhoneticTokenFilter(string name) { } public Azure.Search.Documents.Indexes.Models.PhoneticEncoder? Encoder { get { throw null; } set { } } public bool? ReplaceOriginalTokens { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PhoneticTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PhoneticTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class PiiDetectionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class PiiDetectionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public PiiDetectionSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public string DefaultLanguageCode { get { throw null; } set { } } @@ -2576,6 +3319,12 @@ public PiiDetectionSkill(System.Collections.Generic.IEnumerable PiiCategories { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PiiDetectionSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.PiiDetectionSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct PiiDetectionSkillMaskingMode : System.IEquatable @@ -2637,29 +3386,53 @@ public PiiDetectionSkill(System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public RescoringOptions() { } public double? DefaultOversampling { get { throw null; } set { } } public bool? EnableRescoring { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.VectorSearchCompressionRescoreStorageMethod? RescoreStorageMethod { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.RescoringOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.RescoringOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ScalarQuantizationCompression : Azure.Search.Documents.Indexes.Models.VectorSearchCompression + public partial class ScalarQuantizationCompression : Azure.Search.Documents.Indexes.Models.VectorSearchCompression, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ScalarQuantizationCompression(string compressionName) : base (default(string)) { } public Azure.Search.Documents.Indexes.Models.ScalarQuantizationParameters Parameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ScalarQuantizationCompression System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ScalarQuantizationCompression System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ScalarQuantizationParameters + public partial class ScalarQuantizationParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ScalarQuantizationParameters() { } public Azure.Search.Documents.Indexes.Models.VectorSearchCompressionTarget? QuantizedDataType { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ScalarQuantizationParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ScalarQuantizationParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ScoringFunction + public partial class ScoringFunction : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ScoringFunction() { } public double Boost { get { throw null; } set { } } public string FieldName { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.ScoringFunctionInterpolation? Interpolation { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ScoringFunction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ScoringFunction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum ScoringFunctionAggregation { @@ -2676,13 +3449,19 @@ public enum ScoringFunctionInterpolation Quadratic = 2, Logarithmic = 3, } - public partial class ScoringProfile + public partial class ScoringProfile : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ScoringProfile(string name) { } public Azure.Search.Documents.Indexes.Models.ScoringFunctionAggregation? FunctionAggregation { get { throw null; } set { } } public System.Collections.Generic.IList Functions { get { throw null; } } public string Name { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.TextWeights TextWeights { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ScoringProfile System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ScoringProfile System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class SearchableField : Azure.Search.Documents.Indexes.Models.SimpleField { @@ -2692,15 +3471,21 @@ public partial class SearchableField : Azure.Search.Documents.Indexes.Models.Sim public Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName? SearchAnalyzerName { get { throw null; } set { } } public System.Collections.Generic.IList SynonymMapNames { get { throw null; } } } - public partial class SearchAlias + public partial class SearchAlias : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchAlias(string name, System.Collections.Generic.IEnumerable indexes) { } public SearchAlias(string name, string index) { } public Azure.ETag? ETag { get { throw null; } } public System.Collections.Generic.IList Indexes { get { throw null; } } public string Name { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchAlias System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchAlias System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchField + public partial class SearchField : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchField(string name, Azure.Search.Documents.Indexes.Models.SearchFieldDataType type) { } public Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName? AnalyzerName { get { throw null; } set { } } @@ -2722,6 +3507,12 @@ public SearchField(string name, Azure.Search.Documents.Indexes.Models.SearchFiel public Azure.Search.Documents.Indexes.Models.VectorEncodingFormat? VectorEncodingFormat { get { throw null; } set { } } public int? VectorSearchDimensions { get { throw null; } set { } } public string VectorSearchProfileName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchField System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchField System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } public override string ToString() { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] @@ -2762,7 +3553,7 @@ internal SearchFieldTemplate() { } public Azure.Search.Documents.Indexes.Models.SearchFieldDataType Type { get { throw null; } } public static implicit operator Azure.Search.Documents.Indexes.Models.SearchField (Azure.Search.Documents.Indexes.Models.SearchFieldTemplate value) { throw null; } } - public partial class SearchIndex + public partial class SearchIndex : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndex(string name) { } public SearchIndex(string name, System.Collections.Generic.IEnumerable fields) { } @@ -2784,8 +3575,14 @@ public SearchIndex(string name, System.Collections.Generic.IEnumerable TokenFilters { get { throw null; } } public System.Collections.Generic.IList Tokenizers { get { throw null; } } public Azure.Search.Documents.Indexes.Models.VectorSearch VectorSearch { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndex System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndex System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexer + public partial class SearchIndexer : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexer(string name, string dataSourceName, string targetIndexName) { } public Azure.Search.Documents.Indexes.Models.SearchIndexerCache Cache { get { throw null; } set { } } @@ -2801,30 +3598,60 @@ public SearchIndexer(string name, string dataSourceName, string targetIndexName) public Azure.Search.Documents.Indexes.Models.IndexingSchedule Schedule { get { throw null; } set { } } public string SkillsetName { get { throw null; } set { } } public string TargetIndexName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerCache + public partial class SearchIndexerCache : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerCache() { } public bool? EnableReprocessing { get { throw null; } set { } } public string Id { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity Identity { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } public void SetStorageConnectionString(string storageConnectionString) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerCache System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerCache System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerDataContainer + public partial class SearchIndexerDataContainer : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerDataContainer(string name) { } public string Name { get { throw null; } set { } } public string Query { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerDataContainer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerDataContainer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public abstract partial class SearchIndexerDataIdentity + public abstract partial class SearchIndexerDataIdentity : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerDataIdentity() { } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerDataNoneIdentity : Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity + public partial class SearchIndexerDataNoneIdentity : Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerDataNoneIdentity() { } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerDataNoneIdentity System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerDataNoneIdentity System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerDataSourceConnection + public partial class SearchIndexerDataSourceConnection : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerDataSourceConnection(string name, Azure.Search.Documents.Indexes.Models.SearchIndexerDataSourceType type, string connectionString, Azure.Search.Documents.Indexes.Models.SearchIndexerDataContainer container) { } public string ConnectionString { get { throw null; } set { } } @@ -2838,6 +3665,12 @@ public SearchIndexerDataSourceConnection(string name, Azure.Search.Documents.Ind public System.Collections.Generic.IList IndexerPermissionOptions { get { throw null; } } public string Name { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.SearchIndexerDataSourceType Type { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerDataSourceConnection System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerDataSourceConnection System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct SearchIndexerDataSourceType : System.IEquatable @@ -2862,12 +3695,18 @@ public SearchIndexerDataSourceConnection(string name, Azure.Search.Documents.Ind public static bool operator !=(Azure.Search.Documents.Indexes.Models.SearchIndexerDataSourceType left, Azure.Search.Documents.Indexes.Models.SearchIndexerDataSourceType right) { throw null; } public override string ToString() { throw null; } } - public partial class SearchIndexerDataUserAssignedIdentity : Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity + public partial class SearchIndexerDataUserAssignedIdentity : Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerDataUserAssignedIdentity(Azure.Core.ResourceIdentifier userAssignedIdentity) { } public Azure.Core.ResourceIdentifier UserAssignedIdentity { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerDataUserAssignedIdentity System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerDataUserAssignedIdentity System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerError + public partial class SearchIndexerError : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SearchIndexerError() { } public string Details { get { throw null; } } @@ -2876,41 +3715,77 @@ internal SearchIndexerError() { } public string Key { get { throw null; } } public string Name { get { throw null; } } public int StatusCode { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerError System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerError System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerIndexProjection + public partial class SearchIndexerIndexProjection : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerIndexProjection(System.Collections.Generic.IEnumerable selectors) { } public Azure.Search.Documents.Indexes.Models.SearchIndexerIndexProjectionsParameters Parameters { get { throw null; } set { } } public System.Collections.Generic.IList Selectors { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerIndexProjection System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerIndexProjection System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerIndexProjectionSelector + public partial class SearchIndexerIndexProjectionSelector : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerIndexProjectionSelector(string targetIndexName, string parentKeyFieldName, string sourceContext, System.Collections.Generic.IEnumerable mappings) { } public System.Collections.Generic.IList Mappings { get { throw null; } } public string ParentKeyFieldName { get { throw null; } set { } } public string SourceContext { get { throw null; } set { } } public string TargetIndexName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerIndexProjectionSelector System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerIndexProjectionSelector System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerIndexProjectionsParameters + public partial class SearchIndexerIndexProjectionsParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerIndexProjectionsParameters() { } public System.Collections.Generic.IDictionary AdditionalProperties { get { throw null; } } public Azure.Search.Documents.Indexes.Models.IndexProjectionMode? ProjectionMode { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerIndexProjectionsParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerIndexProjectionsParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerKnowledgeStoreParameters + public partial class SearchIndexerKnowledgeStoreParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerKnowledgeStoreParameters() { } public System.Collections.Generic.IDictionary AdditionalProperties { get { throw null; } } public bool? SynthesizeGeneratedKeyName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerKnowledgeStoreParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerKnowledgeStoreParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerLimits + public partial class SearchIndexerLimits : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SearchIndexerLimits() { } public long? MaxDocumentContentCharactersToExtract { get { throw null; } } public long? MaxDocumentExtractionSize { get { throw null; } } public System.TimeSpan? MaxRunTime { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerLimits System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerLimits System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerSkill + public partial class SearchIndexerSkill : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SearchIndexerSkill() { } public string Context { get { throw null; } set { } } @@ -2918,8 +3793,14 @@ internal SearchIndexerSkill() { } public System.Collections.Generic.IList Inputs { get { throw null; } } public string Name { get { throw null; } set { } } public System.Collections.Generic.IList Outputs { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerSkillset + public partial class SearchIndexerSkillset : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchIndexerSkillset(string name, System.Collections.Generic.IEnumerable skills) { } public Azure.Search.Documents.Indexes.Models.CognitiveServicesAccount CognitiveServicesAccount { get { throw null; } set { } } @@ -2930,8 +3811,14 @@ public SearchIndexerSkillset(string name, System.Collections.Generic.IEnumerable public Azure.Search.Documents.Indexes.Models.KnowledgeStore KnowledgeStore { get { throw null; } set { } } public string Name { get { throw null; } set { } } public System.Collections.Generic.IList Skills { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerSkillset System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerSkillset System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerStatus + public partial class SearchIndexerStatus : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SearchIndexerStatus() { } public Azure.Search.Documents.Indexes.Models.IndexerState CurrentState { get { throw null; } } @@ -2939,8 +3826,14 @@ internal SearchIndexerStatus() { } public Azure.Search.Documents.Indexes.Models.IndexerExecutionResult LastResult { get { throw null; } } public Azure.Search.Documents.Indexes.Models.SearchIndexerLimits Limits { get { throw null; } } public Azure.Search.Documents.Indexes.Models.IndexerStatus Status { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerStatus System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerStatus System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexerWarning + public partial class SearchIndexerWarning : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SearchIndexerWarning() { } public string Details { get { throw null; } } @@ -2948,21 +3841,39 @@ internal SearchIndexerWarning() { } public string Key { get { throw null; } } public string Message { get { throw null; } } public string Name { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerWarning System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexerWarning System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchIndexStatistics + public partial class SearchIndexStatistics : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SearchIndexStatistics() { } public long DocumentCount { get { throw null; } } public long StorageSize { get { throw null; } } public long VectorIndexSize { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexStatistics System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchIndexStatistics System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchResourceCounter + public partial class SearchResourceCounter : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SearchResourceCounter() { } public long? Quota { get { throw null; } } public long Usage { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchResourceCounter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchResourceCounter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchResourceEncryptionKey + public partial class SearchResourceEncryptionKey : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchResourceEncryptionKey(System.Uri vaultUri, string keyName, string keyVersion) { } public string ApplicationId { get { throw null; } set { } } @@ -2971,8 +3882,14 @@ public SearchResourceEncryptionKey(System.Uri vaultUri, string keyName, string k public string KeyName { get { throw null; } } public string KeyVersion { get { throw null; } } public System.Uri VaultUri { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchResourceEncryptionKey System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchResourceEncryptionKey System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchServiceCounters + public partial class SearchServiceCounters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SearchServiceCounters() { } public Azure.Search.Documents.Indexes.Models.SearchResourceCounter AliasCounter { get { throw null; } } @@ -2984,8 +3901,14 @@ internal SearchServiceCounters() { } public Azure.Search.Documents.Indexes.Models.SearchResourceCounter StorageSizeCounter { get { throw null; } } public Azure.Search.Documents.Indexes.Models.SearchResourceCounter SynonymMapCounter { get { throw null; } } public Azure.Search.Documents.Indexes.Models.SearchResourceCounter VectorIndexSizeCounter { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchServiceCounters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchServiceCounters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchServiceLimits + public partial class SearchServiceLimits : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SearchServiceLimits() { } public int? MaxComplexCollectionFieldsPerIndex { get { throw null; } } @@ -2993,47 +3916,89 @@ internal SearchServiceLimits() { } public int? MaxFieldNestingDepthPerIndex { get { throw null; } } public int? MaxFieldsPerIndex { get { throw null; } } public long? MaxStoragePerIndexInBytes { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchServiceLimits System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchServiceLimits System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchServiceStatistics + public partial class SearchServiceStatistics : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SearchServiceStatistics() { } public Azure.Search.Documents.Indexes.Models.SearchServiceCounters Counters { get { throw null; } } public Azure.Search.Documents.Indexes.Models.SearchServiceLimits Limits { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchServiceStatistics System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchServiceStatistics System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SearchSuggester + public partial class SearchSuggester : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchSuggester(string name, System.Collections.Generic.IEnumerable sourceFields) { } public SearchSuggester(string name, params string[] sourceFields) { } public string Name { get { throw null; } set { } } public System.Collections.Generic.IList SourceFields { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchSuggester System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SearchSuggester System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SemanticConfiguration + public partial class SemanticConfiguration : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SemanticConfiguration(string name, Azure.Search.Documents.Indexes.Models.SemanticPrioritizedFields prioritizedFields) { } public bool? FlightingOptIn { get { throw null; } set { } } public string Name { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.SemanticPrioritizedFields PrioritizedFields { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.RankingOrder? RankingOrder { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SemanticConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SemanticConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SemanticField + public partial class SemanticField : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SemanticField(string fieldName) { } public string FieldName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SemanticField System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SemanticField System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SemanticPrioritizedFields + public partial class SemanticPrioritizedFields : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SemanticPrioritizedFields() { } public System.Collections.Generic.IList ContentFields { get { throw null; } } public System.Collections.Generic.IList KeywordsFields { get { throw null; } } public Azure.Search.Documents.Indexes.Models.SemanticField TitleField { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SemanticPrioritizedFields System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SemanticPrioritizedFields System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SemanticSearch + public partial class SemanticSearch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SemanticSearch() { } public System.Collections.Generic.IList Configurations { get { throw null; } } public string DefaultConfigurationName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SemanticSearch System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SemanticSearch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SentimentSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class SentimentSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public SentimentSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } @@ -3041,6 +4006,12 @@ public SentimentSkill(System.Collections.Generic.IEnumerable.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SentimentSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct SkillVersion : System.IEquatable { @@ -3095,11 +4066,17 @@ public SentimentSkill(System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public ShaperSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ShaperSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ShaperSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ShingleTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class ShingleTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ShingleTokenFilter(string name) { } public string FilterToken { get { throw null; } set { } } @@ -3108,10 +4085,22 @@ public ShingleTokenFilter(string name) { } public bool? OutputUnigrams { get { throw null; } set { } } public bool? OutputUnigramsIfNoShingles { get { throw null; } set { } } public string TokenSeparator { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ShingleTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.ShingleTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SimilarityAlgorithm + public partial class SimilarityAlgorithm : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SimilarityAlgorithm() { } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SimilarityAlgorithm System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SimilarityAlgorithm System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class SimpleField : Azure.Search.Documents.Indexes.Models.SearchFieldTemplate { @@ -3124,10 +4113,16 @@ public SimpleField(string name, Azure.Search.Documents.Indexes.Models.SearchFiel public Azure.Search.Documents.Indexes.Models.LexicalNormalizerName? NormalizerName { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.PermissionFilter? PermissionFilter { get { throw null; } set { } } } - public partial class SnowballTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class SnowballTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SnowballTokenFilter(string name, Azure.Search.Documents.Indexes.Models.SnowballTokenFilterLanguage language) { } public Azure.Search.Documents.Indexes.Models.SnowballTokenFilterLanguage Language { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SnowballTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SnowballTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum SnowballTokenFilterLanguage { @@ -3154,13 +4149,19 @@ public enum SnowballTokenFilterLanguage Swedish = 20, Turkish = 21, } - public partial class SoftDeleteColumnDeletionDetectionPolicy : Azure.Search.Documents.Indexes.Models.DataDeletionDetectionPolicy + public partial class SoftDeleteColumnDeletionDetectionPolicy : Azure.Search.Documents.Indexes.Models.DataDeletionDetectionPolicy, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SoftDeleteColumnDeletionDetectionPolicy() { } public string SoftDeleteColumnName { get { throw null; } set { } } public string SoftDeleteMarkerValue { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SoftDeleteColumnDeletionDetectionPolicy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SoftDeleteColumnDeletionDetectionPolicy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SplitSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class SplitSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SplitSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs) { } public Azure.Search.Documents.Indexes.Models.AzureOpenAITokenizerParameters AzureOpenAITokenizerParameters { get { throw null; } set { } } @@ -3170,6 +4171,12 @@ public SplitSkill(System.Collections.Generic.IEnumerable.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SplitSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct SplitSkillEncoderModelName : System.IEquatable @@ -3258,19 +4265,37 @@ public SplitSkill(System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public SqlIntegratedChangeTrackingPolicy() { } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SqlIntegratedChangeTrackingPolicy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SqlIntegratedChangeTrackingPolicy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class StemmerOverrideTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class StemmerOverrideTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public StemmerOverrideTokenFilter(string name, System.Collections.Generic.IEnumerable rules) { } public System.Collections.Generic.IList Rules { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.StemmerOverrideTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.StemmerOverrideTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class StemmerTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class StemmerTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public StemmerTokenFilter(string name, Azure.Search.Documents.Indexes.Models.StemmerTokenFilterLanguage language) { } public Azure.Search.Documents.Indexes.Models.StemmerTokenFilterLanguage Language { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.StemmerTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.StemmerTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum StemmerTokenFilterLanguage { @@ -3329,10 +4354,16 @@ public enum StemmerTokenFilterLanguage LightSwedish = 52, Turkish = 53, } - public partial class StopAnalyzer : Azure.Search.Documents.Indexes.Models.LexicalAnalyzer + public partial class StopAnalyzer : Azure.Search.Documents.Indexes.Models.LexicalAnalyzer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public StopAnalyzer(string name) { } public System.Collections.Generic.IList Stopwords { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.StopAnalyzer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.StopAnalyzer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum StopwordsList { @@ -3368,15 +4399,21 @@ public enum StopwordsList Thai = 29, Turkish = 30, } - public partial class StopwordsTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class StopwordsTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public StopwordsTokenFilter(string name) { } public bool? IgnoreCase { get { throw null; } set { } } public bool? RemoveTrailingStopWords { get { throw null; } set { } } public System.Collections.Generic.IList Stopwords { get { throw null; } } public Azure.Search.Documents.Indexes.Models.StopwordsList? StopwordsList { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.StopwordsTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.StopwordsTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SynonymMap + public partial class SynonymMap : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SynonymMap(string name, System.IO.TextReader reader) { } public SynonymMap(string name, string synonyms) { } @@ -3384,23 +4421,47 @@ public SynonymMap(string name, string synonyms) { } public Azure.ETag? ETag { get { throw null; } set { } } public string Name { get { throw null; } set { } } public string Synonyms { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SynonymMap System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SynonymMap System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SynonymTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class SynonymTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SynonymTokenFilter(string name, System.Collections.Generic.IEnumerable synonyms) { } public bool? Expand { get { throw null; } set { } } public bool? IgnoreCase { get { throw null; } set { } } public System.Collections.Generic.IList Synonyms { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SynonymTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.SynonymTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class TagScoringFunction : Azure.Search.Documents.Indexes.Models.ScoringFunction + public partial class TagScoringFunction : Azure.Search.Documents.Indexes.Models.ScoringFunction, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TagScoringFunction(string fieldName, double boost, Azure.Search.Documents.Indexes.Models.TagScoringParameters parameters) { } public Azure.Search.Documents.Indexes.Models.TagScoringParameters Parameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TagScoringFunction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TagScoringFunction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class TagScoringParameters + public partial class TagScoringParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TagScoringParameters(string tagsParameter) { } public string TagsParameter { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TagScoringParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TagScoringParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct TextSplitMode : System.IEquatable @@ -3420,12 +4481,18 @@ public TagScoringParameters(string tagsParameter) { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.TextSplitMode left, Azure.Search.Documents.Indexes.Models.TextSplitMode right) { throw null; } public override string ToString() { throw null; } } - public partial class TextTranslationSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class TextTranslationSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TextTranslationSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs, Azure.Search.Documents.Indexes.Models.TextTranslationSkillLanguage defaultToLanguageCode) { } public Azure.Search.Documents.Indexes.Models.TextTranslationSkillLanguage? DefaultFromLanguageCode { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.TextTranslationSkillLanguage DefaultToLanguageCode { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.TextTranslationSkillLanguage? SuggestedFrom { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TextTranslationSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TextTranslationSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct TextTranslationSkillLanguage : System.IEquatable @@ -3515,10 +4582,16 @@ public TextTranslationSkill(System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public TextWeights(System.Collections.Generic.IDictionary weights) { } public System.Collections.Generic.IDictionary Weights { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TextWeights System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TextWeights System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum TokenCharacterKind { @@ -3528,10 +4601,16 @@ public enum TokenCharacterKind Punctuation = 3, Symbol = 4, } - public partial class TokenFilter + public partial class TokenFilter : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal TokenFilter() { } public string Name { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct TokenFilterName : System.IEquatable @@ -3583,20 +4662,38 @@ internal TokenFilter() { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.TokenFilterName left, Azure.Search.Documents.Indexes.Models.TokenFilterName right) { throw null; } public override string ToString() { throw null; } } - public partial class TruncateTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class TruncateTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TruncateTokenFilter(string name) { } public int? Length { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TruncateTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.TruncateTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class UaxUrlEmailTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class UaxUrlEmailTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public UaxUrlEmailTokenizer(string name) { } public int? MaxTokenLength { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.UaxUrlEmailTokenizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.UaxUrlEmailTokenizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class UniqueTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class UniqueTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public UniqueTokenFilter(string name) { } public bool? OnlyOnSamePosition { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.UniqueTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.UniqueTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct VectorEncodingFormat : System.IEquatable @@ -3619,18 +4716,30 @@ public static partial class Values public const string PackedBit = "packedBit"; } } - public partial class VectorSearch + public partial class VectorSearch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public VectorSearch() { } public System.Collections.Generic.IList Algorithms { get { throw null; } } public System.Collections.Generic.IList Compressions { get { throw null; } } public System.Collections.Generic.IList Profiles { get { throw null; } } public System.Collections.Generic.IList Vectorizers { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VectorSearch System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VectorSearch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public abstract partial class VectorSearchAlgorithmConfiguration + public abstract partial class VectorSearchAlgorithmConfiguration : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { protected VectorSearchAlgorithmConfiguration(string name) { } public string Name { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VectorSearchAlgorithmConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VectorSearchAlgorithmConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct VectorSearchAlgorithmMetric : System.IEquatable @@ -3652,7 +4761,7 @@ protected VectorSearchAlgorithmConfiguration(string name) { } public static bool operator !=(Azure.Search.Documents.Indexes.Models.VectorSearchAlgorithmMetric left, Azure.Search.Documents.Indexes.Models.VectorSearchAlgorithmMetric right) { throw null; } public override string ToString() { throw null; } } - public abstract partial class VectorSearchCompression + public abstract partial class VectorSearchCompression : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { protected VectorSearchCompression(string compressionName) { } public string CompressionName { get { throw null; } } @@ -3660,6 +4769,12 @@ protected VectorSearchCompression(string compressionName) { } public bool? RerankWithOriginalVectors { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.RescoringOptions RescoringOptions { get { throw null; } set { } } public int? TruncationDimension { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VectorSearchCompression System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VectorSearchCompression System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct VectorSearchCompressionRescoreStorageMethod : System.IEquatable @@ -3705,23 +4820,41 @@ public VectorSearchField(string name, int vectorSearchDimensions, string vectorS public int VectorSearchDimensions { get { throw null; } set { } } public string VectorSearchProfileName { get { throw null; } set { } } } - public partial class VectorSearchProfile + public partial class VectorSearchProfile : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public VectorSearchProfile(string name, string algorithmConfigurationName) { } public string AlgorithmConfigurationName { get { throw null; } set { } } public string CompressionName { get { throw null; } set { } } public string Name { get { throw null; } set { } } public string VectorizerName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VectorSearchProfile System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VectorSearchProfile System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public abstract partial class VectorSearchVectorizer + public abstract partial class VectorSearchVectorizer : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { protected VectorSearchVectorizer(string vectorizerName) { } public string VectorizerName { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VectorSearchVectorizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VectorSearchVectorizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class VisionVectorizeSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill + public partial class VisionVectorizeSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public VisionVectorizeSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs, string modelVersion) { } public string ModelVersion { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VisionVectorizeSkill System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.VisionVectorizeSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct VisualFeature : System.IEquatable @@ -3746,7 +4879,7 @@ public VisionVectorizeSkill(System.Collections.Generic.IEnumerable, System.ClientModel.Primitives.IPersistableModel { public WebApiSkill(System.Collections.Generic.IEnumerable inputs, System.Collections.Generic.IEnumerable outputs, string uri) { } public Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity AuthIdentity { get { throw null; } set { } } @@ -3757,13 +4890,25 @@ public WebApiSkill(System.Collections.Generic.IEnumerable.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.WebApiSkill System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class WebApiVectorizer : Azure.Search.Documents.Indexes.Models.VectorSearchVectorizer + public partial class WebApiVectorizer : Azure.Search.Documents.Indexes.Models.VectorSearchVectorizer, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public WebApiVectorizer(string vectorizerName) : base (default(string)) { } public Azure.Search.Documents.Indexes.Models.WebApiVectorizerParameters Parameters { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.WebApiVectorizer System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.WebApiVectorizer System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class WebApiVectorizerParameters + public partial class WebApiVectorizerParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public WebApiVectorizerParameters() { } public Azure.Search.Documents.Indexes.Models.SearchIndexerDataIdentity AuthIdentity { get { throw null; } set { } } @@ -3772,8 +4917,14 @@ public WebApiVectorizerParameters() { } public string HttpMethod { get { throw null; } set { } } public System.TimeSpan? Timeout { get { throw null; } set { } } public System.Uri Uri { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.WebApiVectorizerParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.WebApiVectorizerParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class WordDelimiterTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter + public partial class WordDelimiterTokenFilter : Azure.Search.Documents.Indexes.Models.TokenFilter, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public WordDelimiterTokenFilter(string name) { } public bool? CatenateAll { get { throw null; } set { } } @@ -3786,15 +4937,27 @@ public WordDelimiterTokenFilter(string name) { } public bool? SplitOnCaseChange { get { throw null; } set { } } public bool? SplitOnNumerics { get { throw null; } set { } } public bool? StemEnglishPossessive { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.WordDelimiterTokenFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Indexes.Models.WordDelimiterTokenFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } } namespace Azure.Search.Documents.Models { - public partial class AutocompleteItem + public partial class AutocompleteItem : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal AutocompleteItem() { } public string QueryPlusText { get { throw null; } } public string Text { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.AutocompleteItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.AutocompleteItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum AutocompleteMode { @@ -3802,19 +4965,31 @@ public enum AutocompleteMode TwoTerms = 1, OneTermWithContext = 2, } - public partial class AutocompleteResults + public partial class AutocompleteResults : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal AutocompleteResults() { } public double? Coverage { get { throw null; } } public System.Collections.Generic.IReadOnlyList Results { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.AutocompleteResults System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.AutocompleteResults System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ChatCompletionResponseFormatJsonSchemaProperties + public partial class ChatCompletionResponseFormatJsonSchemaProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ChatCompletionResponseFormatJsonSchemaProperties() { } public string Description { get { throw null; } set { } } public string Name { get { throw null; } set { } } public Azure.Search.Documents.Indexes.Models.ChatCompletionSchema Schema { get { throw null; } set { } } public bool? Strict { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.ChatCompletionResponseFormatJsonSchemaProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.ChatCompletionResponseFormatJsonSchemaProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct ChatCompletionResponseFormatType : System.IEquatable @@ -3835,19 +5010,31 @@ public ChatCompletionResponseFormatJsonSchemaProperties() { } public static bool operator !=(Azure.Search.Documents.Models.ChatCompletionResponseFormatType left, Azure.Search.Documents.Models.ChatCompletionResponseFormatType right) { throw null; } public override string ToString() { throw null; } } - public partial class DebugInfo + public partial class DebugInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal DebugInfo() { } public Azure.Search.Documents.Models.QueryRewritesDebugInfo QueryRewrites { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.DebugInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.DebugInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class DocumentDebugInfo + public partial class DocumentDebugInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal DocumentDebugInfo() { } public System.Collections.Generic.IReadOnlyDictionary> InnerHits { get { throw null; } } public Azure.Search.Documents.Models.SemanticDebugInfo Semantic { get { throw null; } } public Azure.Search.Documents.Models.VectorsDebugInfo Vectors { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.DocumentDebugInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.DocumentDebugInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class FacetResult : System.Collections.Generic.IEnumerable>, System.Collections.Generic.IReadOnlyCollection>, System.Collections.Generic.IReadOnlyDictionary, System.Collections.IEnumerable + public partial class FacetResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel, System.Collections.Generic.IEnumerable>, System.Collections.Generic.IReadOnlyCollection>, System.Collections.Generic.IReadOnlyDictionary, System.Collections.IEnumerable { internal FacetResult() { } public long? Count { get { throw null; } } @@ -3865,6 +5052,12 @@ internal FacetResult() { } public Azure.Search.Documents.Models.ValueFacetResult AsValueFacetResult() { throw null; } public bool ContainsKey(string key) { throw null; } public System.Collections.Generic.IEnumerator> GetEnumerator() { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.FacetResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.FacetResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } public bool TryGetValue(string key, out object value) { throw null; } } @@ -3891,11 +5084,17 @@ public enum FacetType public static bool operator !=(Azure.Search.Documents.Models.HybridCountAndFacetMode left, Azure.Search.Documents.Models.HybridCountAndFacetMode right) { throw null; } public override string ToString() { throw null; } } - public partial class HybridSearch + public partial class HybridSearch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public HybridSearch() { } public Azure.Search.Documents.Models.HybridCountAndFacetMode? CountAndFacetMode { get { throw null; } set { } } public int? MaxTextRecallSize { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.HybridSearch System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.HybridSearch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class IndexActionCompletedEventArgs : Azure.Search.Documents.Models.IndexActionEventArgs { @@ -3949,34 +5148,64 @@ public partial class IndexDocumentsBatch public IndexDocumentsBatch() { } public System.Collections.Generic.IList> Actions { get { throw null; } } } - public partial class IndexDocumentsResult + public partial class IndexDocumentsResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal IndexDocumentsResult() { } public System.Collections.Generic.IReadOnlyList Results { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.IndexDocumentsResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.IndexDocumentsResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class IndexerResyncBody + public partial class IndexerResyncBody : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public IndexerResyncBody() { } public System.Collections.Generic.IList Options { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.IndexerResyncBody System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.IndexerResyncBody System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class IndexingResult + public partial class IndexingResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal IndexingResult() { } public string ErrorMessage { get { throw null; } } public string Key { get { throw null; } } public int Status { get { throw null; } } public bool Succeeded { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.IndexingResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.IndexingResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentMessageImageContentImage + public partial class KnowledgeAgentMessageImageContentImage : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public KnowledgeAgentMessageImageContentImage(string url) { } public string Url { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.KnowledgeAgentMessageImageContentImage System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.KnowledgeAgentMessageImageContentImage System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class KnowledgeAgentSearchActivityRecordQuery + public partial class KnowledgeAgentSearchActivityRecordQuery : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal KnowledgeAgentSearchActivityRecordQuery() { } public string Filter { get { throw null; } } public string Search { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.KnowledgeAgentSearchActivityRecordQuery System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.KnowledgeAgentSearchActivityRecordQuery System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class QueryAnswer { @@ -3986,7 +5215,7 @@ public QueryAnswer(Azure.Search.Documents.Models.QueryAnswerType answerType) { } public int? MaxCharLength { get { throw null; } set { } } public double? Threshold { get { throw null; } set { } } } - public partial class QueryAnswerResult + public partial class QueryAnswerResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal QueryAnswerResult() { } public System.Collections.Generic.IReadOnlyDictionary AdditionalProperties { get { throw null; } } @@ -3994,6 +5223,12 @@ internal QueryAnswerResult() { } public string Key { get { throw null; } } public double? Score { get { throw null; } } public string Text { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryAnswerResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryAnswerResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct QueryAnswerType : System.IEquatable @@ -4020,12 +5255,18 @@ public QueryCaption(Azure.Search.Documents.Models.QueryCaptionType captionType) public bool HighlightEnabled { get { throw null; } set { } } public int? MaxCharLength { get { throw null; } set { } } } - public partial class QueryCaptionResult + public partial class QueryCaptionResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal QueryCaptionResult() { } public System.Collections.Generic.IReadOnlyDictionary AdditionalProperties { get { throw null; } } public string Highlights { get { throw null; } } public string Text { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryCaptionResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryCaptionResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct QueryCaptionType : System.IEquatable @@ -4155,31 +5396,55 @@ internal QueryCaptionResult() { } public static bool operator !=(Azure.Search.Documents.Models.QueryLanguage left, Azure.Search.Documents.Models.QueryLanguage right) { throw null; } public override string ToString() { throw null; } } - public partial class QueryResultDocumentInnerHit + public partial class QueryResultDocumentInnerHit : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal QueryResultDocumentInnerHit() { } public long? Ordinal { get { throw null; } } public System.Collections.Generic.IReadOnlyList> Vectors { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryResultDocumentInnerHit System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryResultDocumentInnerHit System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class QueryResultDocumentRerankerInput + public partial class QueryResultDocumentRerankerInput : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal QueryResultDocumentRerankerInput() { } public string Content { get { throw null; } } public string Keywords { get { throw null; } } public string Title { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryResultDocumentRerankerInput System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryResultDocumentRerankerInput System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class QueryResultDocumentSemanticField + public partial class QueryResultDocumentSemanticField : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal QueryResultDocumentSemanticField() { } public string Name { get { throw null; } } public Azure.Search.Documents.Models.SemanticFieldState? State { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryResultDocumentSemanticField System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryResultDocumentSemanticField System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class QueryResultDocumentSubscores + public partial class QueryResultDocumentSubscores : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal QueryResultDocumentSubscores() { } public double? DocumentBoost { get { throw null; } } public Azure.Search.Documents.Models.TextResult Text { get { throw null; } } public System.Collections.Generic.IReadOnlyList> Vectors { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryResultDocumentSubscores System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryResultDocumentSubscores System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class QueryRewrites { @@ -4187,11 +5452,17 @@ public QueryRewrites(Azure.Search.Documents.Models.QueryRewritesType rewritesTyp public int? Count { get { throw null; } set { } } public Azure.Search.Documents.Models.QueryRewritesType RewritesType { get { throw null; } } } - public partial class QueryRewritesDebugInfo + public partial class QueryRewritesDebugInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal QueryRewritesDebugInfo() { } public Azure.Search.Documents.Models.QueryRewritesValuesDebugInfo Text { get { throw null; } } public System.Collections.Generic.IReadOnlyList Vectors { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryRewritesDebugInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryRewritesDebugInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct QueryRewritesType : System.IEquatable @@ -4211,11 +5482,17 @@ internal QueryRewritesDebugInfo() { } public static bool operator !=(Azure.Search.Documents.Models.QueryRewritesType left, Azure.Search.Documents.Models.QueryRewritesType right) { throw null; } public override string ToString() { throw null; } } - public partial class QueryRewritesValuesDebugInfo + public partial class QueryRewritesValuesDebugInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal QueryRewritesValuesDebugInfo() { } public string InputQuery { get { throw null; } } public System.Collections.Generic.IReadOnlyList Rewrites { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryRewritesValuesDebugInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.QueryRewritesValuesDebugInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct QuerySpellerType : System.IEquatable @@ -4242,16 +5519,28 @@ public RangeFacetResult(long count, T? from, T? to) { } public T? From { get { throw null; } } public T? To { get { throw null; } } } - public partial class ResetDocumentOptions + public partial class ResetDocumentOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ResetDocumentOptions() { } public System.Collections.Generic.IList DataSourceDocumentIds { get { throw null; } } public System.Collections.Generic.IList DocumentKeys { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.ResetDocumentOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.ResetDocumentOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ResetSkillsOptions + public partial class ResetSkillsOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ResetSkillsOptions() { } public System.Collections.Generic.IList SkillNames { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.ResetSkillsOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.ResetSkillsOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public enum ScoringStatistics { @@ -4322,6 +5611,7 @@ public enum SearchMode public static partial class SearchModelFactory { public static Azure.Search.Documents.Indexes.Models.AnalyzedTokenInfo AnalyzedTokenInfo(string token, int startOffset, int endOffset, int position) { throw null; } + public static Azure.Search.Documents.Indexes.Models.AnalyzeTextOptions AnalyzeTextOptions(string text = null, Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName? analyzerName = default(Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName?), Azure.Search.Documents.Indexes.Models.LexicalTokenizerName? tokenizerName = default(Azure.Search.Documents.Indexes.Models.LexicalTokenizerName?), Azure.Search.Documents.Indexes.Models.LexicalNormalizerName? normalizerName = default(Azure.Search.Documents.Indexes.Models.LexicalNormalizerName?), System.Collections.Generic.IEnumerable tokenFilters = null, System.Collections.Generic.IEnumerable charFilters = null) { throw null; } public static Azure.Search.Documents.Models.AutocompleteItem AutocompleteItem(string text, string queryPlusText) { throw null; } public static Azure.Search.Documents.Models.AutocompleteResults AutocompleteResults(double? coverage = default(double?), System.Collections.Generic.IEnumerable results = null) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] @@ -4454,10 +5744,16 @@ internal SearchResult() { } public double? Score { get { throw null; } } public Azure.Search.Documents.Models.SemanticSearchResult SemanticSearch { get { throw null; } } } - public partial class SearchScoreThreshold : Azure.Search.Documents.Models.VectorThreshold + public partial class SearchScoreThreshold : Azure.Search.Documents.Models.VectorThreshold, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SearchScoreThreshold(double value) { } public double Value { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.SearchScoreThreshold System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.SearchScoreThreshold System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class SearchSuggestion { @@ -4465,13 +5761,19 @@ internal SearchSuggestion() { } public T Document { get { throw null; } } public string Text { get { throw null; } } } - public partial class SemanticDebugInfo + public partial class SemanticDebugInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SemanticDebugInfo() { } public System.Collections.Generic.IReadOnlyList ContentFields { get { throw null; } } public System.Collections.Generic.IReadOnlyList KeywordFields { get { throw null; } } public Azure.Search.Documents.Models.QueryResultDocumentRerankerInput RerankerInput { get { throw null; } } public Azure.Search.Documents.Models.QueryResultDocumentSemanticField TitleField { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.SemanticDebugInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.SemanticDebugInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct SemanticErrorMode : System.IEquatable @@ -4592,11 +5894,17 @@ public SemanticSearchResults() { } public static bool operator !=(Azure.Search.Documents.Models.SemanticSearchResultsType left, Azure.Search.Documents.Models.SemanticSearchResultsType right) { throw null; } public override string ToString() { throw null; } } - public partial class SingleVectorFieldResult + public partial class SingleVectorFieldResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SingleVectorFieldResult() { } public double? SearchScore { get { throw null; } } public double? VectorSimilarity { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.SingleVectorFieldResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.SingleVectorFieldResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class SuggestResults { @@ -4604,10 +5912,16 @@ internal SuggestResults() { } public double? Coverage { get { throw null; } } public System.Collections.Generic.IReadOnlyList> Results { get { throw null; } } } - public partial class TextResult + public partial class TextResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal TextResult() { } public double? SearchScore { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.TextResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.TextResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class ValueFacetResult { @@ -4633,28 +5947,52 @@ public ValueFacetResult(long count, T value) { } public static bool operator !=(Azure.Search.Documents.Models.VectorFilterMode left, Azure.Search.Documents.Models.VectorFilterMode right) { throw null; } public override string ToString() { throw null; } } - public partial class VectorizableImageBinaryQuery : Azure.Search.Documents.Models.VectorQuery + public partial class VectorizableImageBinaryQuery : Azure.Search.Documents.Models.VectorQuery, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public VectorizableImageBinaryQuery() { } public string Base64Image { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorizableImageBinaryQuery System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorizableImageBinaryQuery System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class VectorizableImageUrlQuery : Azure.Search.Documents.Models.VectorQuery + public partial class VectorizableImageUrlQuery : Azure.Search.Documents.Models.VectorQuery, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public VectorizableImageUrlQuery() { } public System.Uri Url { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorizableImageUrlQuery System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorizableImageUrlQuery System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class VectorizableTextQuery : Azure.Search.Documents.Models.VectorQuery + public partial class VectorizableTextQuery : Azure.Search.Documents.Models.VectorQuery, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public VectorizableTextQuery(string text) { } public Azure.Search.Documents.Models.QueryRewritesType? QueryRewrites { get { throw null; } set { } } public string Text { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorizableTextQuery System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorizableTextQuery System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class VectorizedQuery : Azure.Search.Documents.Models.VectorQuery + public partial class VectorizedQuery : Azure.Search.Documents.Models.VectorQuery, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public VectorizedQuery(System.ReadOnlyMemory vector) { } public System.ReadOnlyMemory Vector { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorizedQuery System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorizedQuery System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public abstract partial class VectorQuery + public abstract partial class VectorQuery : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { protected VectorQuery() { } public bool? Exhaustive { get { throw null; } set { } } @@ -4665,11 +6003,23 @@ protected VectorQuery() { } public int? PerDocumentVectorLimit { get { throw null; } set { } } public Azure.Search.Documents.Models.VectorThreshold Threshold { get { throw null; } set { } } public float? Weight { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorQuery System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorQuery System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class VectorsDebugInfo + public partial class VectorsDebugInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal VectorsDebugInfo() { } public Azure.Search.Documents.Models.QueryResultDocumentSubscores Subscores { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorsDebugInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorsDebugInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class VectorSearchOptions { @@ -4677,14 +6027,26 @@ public VectorSearchOptions() { } public Azure.Search.Documents.Models.VectorFilterMode? FilterMode { get { throw null; } set { } } public System.Collections.Generic.IList Queries { get { throw null; } } } - public partial class VectorSimilarityThreshold : Azure.Search.Documents.Models.VectorThreshold + public partial class VectorSimilarityThreshold : Azure.Search.Documents.Models.VectorThreshold, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public VectorSimilarityThreshold(double value) { } public double Value { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorSimilarityThreshold System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorSimilarityThreshold System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public abstract partial class VectorThreshold + public abstract partial class VectorThreshold : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { protected VectorThreshold() { } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorThreshold System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.Search.Documents.Models.VectorThreshold System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } } namespace Microsoft.Extensions.Azure diff --git a/sdk/search/Azure.Search.Documents/src/Generated/AliasesRestClient.cs b/sdk/search/Azure.Search.Documents/src/Generated/AliasesRestClient.cs index ec780f5f0bf1..655f5bd3c572 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/AliasesRestClient.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/AliasesRestClient.cs @@ -54,7 +54,7 @@ internal HttpMessage CreateCreateRequest(SearchAlias @alias) request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(@alias); + content.JsonWriter.WriteObjectValue(@alias, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } @@ -191,7 +191,7 @@ internal HttpMessage CreateCreateOrUpdateRequest(string aliasName, SearchAlias @ request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(@alias); + content.JsonWriter.WriteObjectValue(@alias, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/DataSourcesRestClient.cs b/sdk/search/Azure.Search.Documents/src/Generated/DataSourcesRestClient.cs index 20bc6f8950ac..94d8316764e5 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/DataSourcesRestClient.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/DataSourcesRestClient.cs @@ -69,7 +69,7 @@ internal HttpMessage CreateCreateOrUpdateRequest(string dataSourceName, SearchIn request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(dataSource); + content.JsonWriter.WriteObjectValue(dataSource, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } @@ -363,7 +363,7 @@ internal HttpMessage CreateCreateRequest(SearchIndexerDataSourceConnection dataS request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(dataSource); + content.JsonWriter.WriteObjectValue(dataSource, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/DocumentsRestClient.cs b/sdk/search/Azure.Search.Documents/src/Generated/DocumentsRestClient.cs index 483078516be9..dfdead7a6ac8 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/DocumentsRestClient.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/DocumentsRestClient.cs @@ -123,7 +123,7 @@ internal HttpMessage CreateSearchPostRequest(SearchOptions searchOptions, string request.Headers.Add("Accept", "application/json; odata.metadata=none"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(searchOptions); + content.JsonWriter.WriteObjectValue(searchOptions, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } @@ -311,7 +311,7 @@ internal HttpMessage CreateSuggestPostRequest(SuggestOptions suggestOptions) request.Headers.Add("Accept", "application/json; odata.metadata=none"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(suggestOptions); + content.JsonWriter.WriteObjectValue(suggestOptions, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } @@ -386,7 +386,7 @@ internal HttpMessage CreateIndexRequest(IndexBatch batch) request.Headers.Add("Accept", "application/json; odata.metadata=none"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(batch); + content.JsonWriter.WriteObjectValue(batch, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } @@ -463,7 +463,7 @@ internal HttpMessage CreateAutocompletePostRequest(AutocompleteOptions autocompl request.Headers.Add("Accept", "application/json; odata.metadata=none"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(autocompleteOptions); + content.JsonWriter.WriteObjectValue(autocompleteOptions, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/IndexersRestClient.cs b/sdk/search/Azure.Search.Documents/src/Generated/IndexersRestClient.cs index 4022d2ba40db..31efac0b76f8 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/IndexersRestClient.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/IndexersRestClient.cs @@ -123,7 +123,7 @@ internal HttpMessage CreateResetDocsRequest(string indexerName, bool? overwrite, { request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(keysOrIds); + content.JsonWriter.WriteObjectValue(keysOrIds, ModelSerializationExtensions.WireOptions); request.Content = content; } return message; @@ -192,7 +192,7 @@ internal HttpMessage CreateResyncRequest(string indexerName, IndexerResyncBody i request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(indexerResync); + content.JsonWriter.WriteObjectValue(indexerResync, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } @@ -343,7 +343,7 @@ internal HttpMessage CreateCreateOrUpdateRequest(string indexerName, SearchIndex request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(indexer); + content.JsonWriter.WriteObjectValue(indexer, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } @@ -639,7 +639,7 @@ internal HttpMessage CreateCreateRequest(SearchIndexer indexer) request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(indexer); + content.JsonWriter.WriteObjectValue(indexer, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/IndexesRestClient.cs b/sdk/search/Azure.Search.Documents/src/Generated/IndexesRestClient.cs index 70116991cd95..ed22bdc8458f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/IndexesRestClient.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/IndexesRestClient.cs @@ -54,7 +54,7 @@ internal HttpMessage CreateCreateRequest(SearchIndex index) request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(index); + content.JsonWriter.WriteObjectValue(index, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } @@ -201,7 +201,7 @@ internal HttpMessage CreateCreateOrUpdateRequest(string indexName, SearchIndex i request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(index); + content.JsonWriter.WriteObjectValue(index, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } @@ -507,7 +507,7 @@ internal HttpMessage CreateAnalyzeRequest(string indexName, AnalyzeTextOptions r request0.Headers.Add("Accept", "application/json; odata.metadata=minimal"); request0.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(request); + content.JsonWriter.WriteObjectValue(request, ModelSerializationExtensions.WireOptions); request0.Content = content; return message; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/search/Azure.Search.Documents/src/Generated/Internal/ModelSerializationExtensions.cs index d20fdaecdbb5..1a7d24e31a85 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Internal/ModelSerializationExtensions.cs @@ -171,13 +171,16 @@ public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset v writer.WriteNumberValue(value.ToUnixTimeSeconds()); } - public static void WriteObjectValue(this Utf8JsonWriter writer, T value) + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) { switch (value) { case null: writer.WriteNullValue(); break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; case IUtf8JsonSerializable serializable: serializable.Write(writer); break; @@ -232,7 +235,7 @@ public static void WriteObjectValue(this Utf8JsonWriter writer, T value) foreach (var pair in enumerable) { writer.WritePropertyName(pair.Key); - writer.WriteObjectValue(pair.Value); + writer.WriteObjectValue(pair.Value, options); } writer.WriteEndObject(); break; @@ -240,7 +243,7 @@ public static void WriteObjectValue(this Utf8JsonWriter writer, T value) writer.WriteStartArray(); foreach (var item in objectEnumerable) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); break; @@ -252,9 +255,9 @@ public static void WriteObjectValue(this Utf8JsonWriter writer, T value) } } - public static void WriteObjectValue(this Utf8JsonWriter writer, object value) + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) { - writer.WriteObjectValue(value); + writer.WriteObjectValue(value, options); } internal static bool IsSentinelValue(BinaryData value) diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Internal/RequestContentHelper.cs b/sdk/search/Azure.Search.Documents/src/Generated/Internal/RequestContentHelper.cs index dac5a6a4e346..717b669dfba8 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Internal/RequestContentHelper.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Internal/RequestContentHelper.cs @@ -21,7 +21,7 @@ public static RequestContent FromEnumerable(IEnumerable enumerable) content.JsonWriter.WriteStartArray(); foreach (var item in enumerable) { - content.JsonWriter.WriteObjectValue(item); + content.JsonWriter.WriteObjectValue(item, ModelSerializationExtensions.WireOptions); } content.JsonWriter.WriteEndArray(); @@ -62,7 +62,7 @@ public static RequestContent FromEnumerable(ReadOnlySpan span) content.JsonWriter.WriteStartArray(); for (int i = 0; i < span.Length; i++) { - content.JsonWriter.WriteObjectValue(span[i]); + content.JsonWriter.WriteObjectValue(span[i], ModelSerializationExtensions.WireOptions); } content.JsonWriter.WriteEndArray(); @@ -77,7 +77,7 @@ public static RequestContent FromDictionary(IDictionary foreach (var item in dictionary) { content.JsonWriter.WritePropertyName(item.Key); - content.JsonWriter.WriteObjectValue(item.Value); + content.JsonWriter.WriteObjectValue(item.Value, ModelSerializationExtensions.WireOptions); } content.JsonWriter.WriteEndObject(); @@ -115,7 +115,7 @@ public static RequestContent FromDictionary(IDictionary dict public static RequestContent FromObject(object value) { Utf8JsonRequestContent content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(value); + content.JsonWriter.WriteObjectValue(value, ModelSerializationExtensions.WireOptions); return content; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/KnowledgeAgentsRestClient.cs b/sdk/search/Azure.Search.Documents/src/Generated/KnowledgeAgentsRestClient.cs index a52eba2cb6ec..0a17953a720a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/KnowledgeAgentsRestClient.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/KnowledgeAgentsRestClient.cs @@ -65,7 +65,7 @@ internal HttpMessage CreateCreateOrUpdateRequest(string agentName, KnowledgeAgen request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(knowledgeAgent); + content.JsonWriter.WriteObjectValue(knowledgeAgent, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } @@ -351,7 +351,7 @@ internal HttpMessage CreateCreateRequest(KnowledgeAgent knowledgeAgent) request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(knowledgeAgent); + content.JsonWriter.WriteObjectValue(knowledgeAgent, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/KnowledgeRetrievalRestClient.cs b/sdk/search/Azure.Search.Documents/src/Generated/KnowledgeRetrievalRestClient.cs index 4afaac30b025..9a2de504184b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/KnowledgeRetrievalRestClient.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/KnowledgeRetrievalRestClient.cs @@ -65,7 +65,7 @@ internal HttpMessage CreateRetrieveRequest(KnowledgeAgentRetrievalRequest retrie request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(retrievalRequest); + content.JsonWriter.WriteObjectValue(retrievalRequest, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesAccountIdentity.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesAccountIdentity.Serialization.cs index e312411cef5b..e6d3aaa43bac 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesAccountIdentity.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesAccountIdentity.Serialization.cs @@ -5,22 +5,42 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class AIServicesAccountIdentity : IUtf8JsonSerializable + public partial class AIServicesAccountIdentity : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(AIServicesAccountIdentity)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Identity)) { if (Identity != null) { writer.WritePropertyName("identity"u8); - writer.WriteObjectValue(Identity); + writer.WriteObjectValue(Identity, options); } else { @@ -29,18 +49,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WritePropertyName("subdomainUrl"u8); writer.WriteStringValue(SubdomainUrl); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Description)) + } + + AIServicesAccountIdentity IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); + throw new FormatException($"The model {nameof(AIServicesAccountIdentity)} does not support reading '{format}' format."); } - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAIServicesAccountIdentity(document.RootElement, options); } - internal static AIServicesAccountIdentity DeserializeAIServicesAccountIdentity(JsonElement element) + internal static AIServicesAccountIdentity DeserializeAIServicesAccountIdentity(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -49,6 +75,8 @@ internal static AIServicesAccountIdentity DeserializeAIServicesAccountIdentity(J string subdomainUrl = default; string odataType = default; string description = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("identity"u8)) @@ -58,7 +86,7 @@ internal static AIServicesAccountIdentity DeserializeAIServicesAccountIdentity(J identity = null; continue; } - identity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value); + identity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value, options); continue; } if (property.NameEquals("subdomainUrl"u8)) @@ -76,10 +104,46 @@ internal static AIServicesAccountIdentity DeserializeAIServicesAccountIdentity(J description = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new AIServicesAccountIdentity(odataType, description, identity, subdomainUrl); + serializedAdditionalRawData = rawDataDictionary; + return new AIServicesAccountIdentity(odataType, description, serializedAdditionalRawData, identity, subdomainUrl); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(AIServicesAccountIdentity)} does not support writing '{options.Format}' format."); + } + } + + AIServicesAccountIdentity 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 DeserializeAIServicesAccountIdentity(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AIServicesAccountIdentity)} 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 AIServicesAccountIdentity FromResponse(Response response) @@ -92,7 +156,7 @@ internal static AIServicesAccountIdentity DeserializeAIServicesAccountIdentity(J internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesAccountIdentity.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesAccountIdentity.cs index 29f8a0bf25e0..345ac9dfcb8e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesAccountIdentity.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesAccountIdentity.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -26,19 +27,25 @@ public AIServicesAccountIdentity(string subdomainUrl) /// Initializes a new instance of . /// A URI fragment specifying the type of Azure AI service resource attached to a skillset. /// Description of the Azure AI service resource attached to a skillset. + /// Keeps track of any properties unknown to the library. /// /// The user-assigned managed identity used for connections to AI Service. If not specified, the system-assigned managed identity is used. On updates to the skillset, if the identity is unspecified, the value remains unchanged. If set to "none", the value of this property is cleared. /// 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 subdomain url for the corresponding AI Service. - internal AIServicesAccountIdentity(string oDataType, string description, SearchIndexerDataIdentity identity, string subdomainUrl) : base(oDataType, description) + internal AIServicesAccountIdentity(string oDataType, string description, IDictionary serializedAdditionalRawData, SearchIndexerDataIdentity identity, string subdomainUrl) : base(oDataType, description, serializedAdditionalRawData) { Identity = identity; SubdomainUrl = subdomainUrl; ODataType = oDataType ?? "#Microsoft.Azure.Search.AIServicesByIdentity"; } + /// Initializes a new instance of for deserialization. + internal AIServicesAccountIdentity() + { + } + /// /// The user-assigned managed identity used for connections to AI Service. If not specified, the system-assigned managed identity is used. On updates to the skillset, if the identity is unspecified, the value remains unchanged. If set to "none", the value of this property is cleared. /// 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. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesAccountKey.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesAccountKey.Serialization.cs index 75ff48392394..976e0fd1ce39 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesAccountKey.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesAccountKey.Serialization.cs @@ -5,32 +5,58 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class AIServicesAccountKey : IUtf8JsonSerializable + public partial class AIServicesAccountKey : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(AIServicesAccountKey)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("key"u8); writer.WriteStringValue(Key); writer.WritePropertyName("subdomainUrl"u8); writer.WriteStringValue(SubdomainUrl); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Description)) + } + + AIServicesAccountKey IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); + throw new FormatException($"The model {nameof(AIServicesAccountKey)} does not support reading '{format}' format."); } - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAIServicesAccountKey(document.RootElement, options); } - internal static AIServicesAccountKey DeserializeAIServicesAccountKey(JsonElement element) + internal static AIServicesAccountKey DeserializeAIServicesAccountKey(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -39,6 +65,8 @@ internal static AIServicesAccountKey DeserializeAIServicesAccountKey(JsonElement string subdomainUrl = default; string odataType = default; string description = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("key"u8)) @@ -61,10 +89,46 @@ internal static AIServicesAccountKey DeserializeAIServicesAccountKey(JsonElement description = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AIServicesAccountKey(odataType, description, serializedAdditionalRawData, key, subdomainUrl); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(AIServicesAccountKey)} does not support writing '{options.Format}' format."); } - return new AIServicesAccountKey(odataType, description, key, subdomainUrl); } + AIServicesAccountKey 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 DeserializeAIServicesAccountKey(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AIServicesAccountKey)} 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 AIServicesAccountKey FromResponse(Response response) @@ -77,7 +141,7 @@ internal static AIServicesAccountKey DeserializeAIServicesAccountKey(JsonElement internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesAccountKey.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesAccountKey.cs index 9fc583eb0fd6..e4d7ce7ae305 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesAccountKey.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesAccountKey.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -29,15 +30,21 @@ public AIServicesAccountKey(string key, string subdomainUrl) /// Initializes a new instance of . /// A URI fragment specifying the type of Azure AI service resource attached to a skillset. /// Description of the Azure AI service resource attached to a skillset. + /// Keeps track of any properties unknown to the library. /// The key used to provision the Azure AI service resource attached to a skillset. /// The subdomain url for the corresponding AI Service. - internal AIServicesAccountKey(string oDataType, string description, string key, string subdomainUrl) : base(oDataType, description) + internal AIServicesAccountKey(string oDataType, string description, IDictionary serializedAdditionalRawData, string key, string subdomainUrl) : base(oDataType, description, serializedAdditionalRawData) { Key = key; SubdomainUrl = subdomainUrl; ODataType = oDataType ?? "#Microsoft.Azure.Search.AIServicesByKey"; } + /// Initializes a new instance of for deserialization. + internal AIServicesAccountKey() + { + } + /// The key used to provision the Azure AI service resource attached to a skillset. public string Key { get; set; } /// The subdomain url for the corresponding AI Service. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesVisionParameters.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesVisionParameters.Serialization.cs index 515a87de17bf..b01d01096981 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesVisionParameters.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesVisionParameters.Serialization.cs @@ -6,16 +6,34 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class AIServicesVisionParameters : IUtf8JsonSerializable + public partial class AIServicesVisionParameters : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(AIServicesVisionParameters)} does not support writing '{format}' format."); + } + if (ModelVersion != null) { writer.WritePropertyName("modelVersion"u8); @@ -37,18 +55,46 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (AuthIdentity != null) { writer.WritePropertyName("authIdentity"u8); - writer.WriteObjectValue(AuthIdentity); + writer.WriteObjectValue(AuthIdentity, options); } else { writer.WriteNull("authIdentity"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static AIServicesVisionParameters DeserializeAIServicesVisionParameters(JsonElement element) + AIServicesVisionParameters 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(AIServicesVisionParameters)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAIServicesVisionParameters(document.RootElement, options); + } + + internal static AIServicesVisionParameters DeserializeAIServicesVisionParameters(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -57,6 +103,8 @@ internal static AIServicesVisionParameters DeserializeAIServicesVisionParameters Uri resourceUri = default; string apiKey = default; SearchIndexerDataIdentity authIdentity = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("modelVersion"u8)) @@ -86,13 +134,49 @@ internal static AIServicesVisionParameters DeserializeAIServicesVisionParameters authIdentity = null; continue; } - authIdentity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value); + authIdentity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AIServicesVisionParameters(modelVersion, resourceUri, apiKey, authIdentity, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(AIServicesVisionParameters)} does not support writing '{options.Format}' format."); } - return new AIServicesVisionParameters(modelVersion, resourceUri, apiKey, authIdentity); } + AIServicesVisionParameters 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 DeserializeAIServicesVisionParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AIServicesVisionParameters)} 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 AIServicesVisionParameters FromResponse(Response response) @@ -105,7 +189,7 @@ internal static AIServicesVisionParameters FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesVisionParameters.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesVisionParameters.cs index 0009bf7e1e56..7c174aeb9fab 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesVisionParameters.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesVisionParameters.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Specifies the AI Services Vision parameters for vectorizing a query image or text. public partial class AIServicesVisionParameters { + /// + /// 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 . /// The version of the model to use when calling the AI Services Vision service. It will default to the latest available when not specified. /// The resource URI of the AI Services resource. @@ -33,12 +66,19 @@ public AIServicesVisionParameters(string modelVersion, Uri resourceUri) /// 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 . /// - internal AIServicesVisionParameters(string modelVersion, Uri resourceUri, string apiKey, SearchIndexerDataIdentity authIdentity) + /// Keeps track of any properties unknown to the library. + internal AIServicesVisionParameters(string modelVersion, Uri resourceUri, string apiKey, SearchIndexerDataIdentity authIdentity, IDictionary serializedAdditionalRawData) { ModelVersion = modelVersion; ResourceUri = resourceUri; ApiKey = apiKey; AuthIdentity = authIdentity; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AIServicesVisionParameters() + { } /// The version of the model to use when calling the AI Services Vision service. It will default to the latest available when not specified. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesVisionVectorizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesVisionVectorizer.Serialization.cs index ebbcd766c121..21201c112cf6 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesVisionVectorizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesVisionVectorizer.Serialization.cs @@ -5,30 +5,59 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class AIServicesVisionVectorizer : IUtf8JsonSerializable + public partial class AIServicesVisionVectorizer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(AIServicesVisionVectorizer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(AIServicesVisionParameters)) { writer.WritePropertyName("aiServicesVisionParameters"u8); - writer.WriteObjectValue(AIServicesVisionParameters); + writer.WriteObjectValue(AIServicesVisionParameters, options); } - writer.WritePropertyName("name"u8); - writer.WriteStringValue(VectorizerName); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); - writer.WriteEndObject(); } - internal static AIServicesVisionVectorizer DeserializeAIServicesVisionVectorizer(JsonElement element) + AIServicesVisionVectorizer 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(AIServicesVisionVectorizer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAIServicesVisionVectorizer(document.RootElement, options); + } + + internal static AIServicesVisionVectorizer DeserializeAIServicesVisionVectorizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -36,6 +65,8 @@ internal static AIServicesVisionVectorizer DeserializeAIServicesVisionVectorizer AIServicesVisionParameters aiServicesVisionParameters = default; string name = default; VectorSearchVectorizerKind kind = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("aiServicesVisionParameters"u8)) @@ -44,7 +75,7 @@ internal static AIServicesVisionVectorizer DeserializeAIServicesVisionVectorizer { continue; } - aiServicesVisionParameters = AIServicesVisionParameters.DeserializeAIServicesVisionParameters(property.Value); + aiServicesVisionParameters = AIServicesVisionParameters.DeserializeAIServicesVisionParameters(property.Value, options); continue; } if (property.NameEquals("name"u8)) @@ -57,10 +88,46 @@ internal static AIServicesVisionVectorizer DeserializeAIServicesVisionVectorizer kind = new VectorSearchVectorizerKind(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AIServicesVisionVectorizer(name, kind, serializedAdditionalRawData, aiServicesVisionParameters); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(AIServicesVisionVectorizer)} does not support writing '{options.Format}' format."); + } + } + + AIServicesVisionVectorizer 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 DeserializeAIServicesVisionVectorizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AIServicesVisionVectorizer)} does not support reading '{options.Format}' format."); } - return new AIServicesVisionVectorizer(name, kind, aiServicesVisionParameters); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new AIServicesVisionVectorizer FromResponse(Response response) @@ -73,7 +140,7 @@ internal static AIServicesVisionVectorizer DeserializeAIServicesVisionVectorizer internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesVisionVectorizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesVisionVectorizer.cs index 8503b68288d0..c3d5a790643b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesVisionVectorizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AIServicesVisionVectorizer.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,13 +26,19 @@ public AIServicesVisionVectorizer(string vectorizerName) : base(vectorizerName) /// Initializes a new instance of . /// The name to associate with this particular vectorization method. /// The name of the kind of vectorization method being configured for use with vector search. + /// Keeps track of any properties unknown to the library. /// Contains the parameters specific to AI Services Vision embedding vectorization. - internal AIServicesVisionVectorizer(string vectorizerName, VectorSearchVectorizerKind kind, AIServicesVisionParameters aiServicesVisionParameters) : base(vectorizerName, kind) + internal AIServicesVisionVectorizer(string vectorizerName, VectorSearchVectorizerKind kind, IDictionary serializedAdditionalRawData, AIServicesVisionParameters aiServicesVisionParameters) : base(vectorizerName, kind, serializedAdditionalRawData) { AIServicesVisionParameters = aiServicesVisionParameters; Kind = kind; } + /// Initializes a new instance of for deserialization. + internal AIServicesVisionVectorizer() + { + } + /// Contains the parameters specific to AI Services Vision embedding vectorization. public AIServicesVisionParameters AIServicesVisionParameters { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzeResult.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzeResult.Serialization.cs index a6eee5e5be98..c89da9e5aa44 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzeResult.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzeResult.Serialization.cs @@ -5,20 +5,82 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - internal partial class AnalyzeResult + internal partial class AnalyzeResult : IUtf8JsonSerializable, IJsonModel { - internal static AnalyzeResult DeserializeAnalyzeResult(JsonElement element) + 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(AnalyzeResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("tokens"u8); + writer.WriteStartArray(); + foreach (var item in Tokens) + { + 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 + } + } + } + + AnalyzeResult 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(AnalyzeResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAnalyzeResult(document.RootElement, options); + } + + internal static AnalyzeResult DeserializeAnalyzeResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } IReadOnlyList tokens = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("tokens"u8)) @@ -26,15 +88,51 @@ internal static AnalyzeResult DeserializeAnalyzeResult(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(AnalyzedTokenInfo.DeserializeAnalyzedTokenInfo(item)); + array.Add(AnalyzedTokenInfo.DeserializeAnalyzedTokenInfo(item, options)); } tokens = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AnalyzeResult(tokens, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(AnalyzeResult)} does not support writing '{options.Format}' format."); + } + } + + AnalyzeResult 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 DeserializeAnalyzeResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AnalyzeResult)} does not support reading '{options.Format}' format."); } - return new AnalyzeResult(tokens); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static AnalyzeResult FromResponse(Response response) @@ -42,5 +140,13 @@ internal static AnalyzeResult FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeAnalyzeResult(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/search/Azure.Search.Documents/src/Generated/Models/AnalyzeResult.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzeResult.cs index cafb6703ca67..089fb844cd22 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzeResult.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzeResult.cs @@ -14,6 +14,38 @@ namespace Azure.Search.Documents.Indexes.Models /// The result of testing an analyzer on text. internal partial class AnalyzeResult { + /// + /// 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 . /// The list of tokens returned by the analyzer specified in the request. /// is null. @@ -26,9 +58,16 @@ internal AnalyzeResult(IEnumerable tokens) /// Initializes a new instance of . /// The list of tokens returned by the analyzer specified in the request. - internal AnalyzeResult(IReadOnlyList tokens) + /// Keeps track of any properties unknown to the library. + internal AnalyzeResult(IReadOnlyList tokens, IDictionary serializedAdditionalRawData) { Tokens = tokens; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AnalyzeResult() + { } /// The list of tokens returned by the analyzer specified in the request. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzeTextOptions.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzeTextOptions.Serialization.cs index f3416858af7f..00f9503d2170 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzeTextOptions.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzeTextOptions.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class AnalyzeTextOptions : IUtf8JsonSerializable + public partial class AnalyzeTextOptions : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(AnalyzeTextOptions)} does not support writing '{format}' format."); + } + writer.WritePropertyName("text"u8); writer.WriteStringValue(Text); if (Optional.IsDefined(AnalyzerName)) @@ -52,14 +71,173 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WriteEndArray(); } - writer.WriteEndObject(); + 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 + } + } + } + + AnalyzeTextOptions 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(AnalyzeTextOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAnalyzeTextOptions(document.RootElement, options); + } + + internal static AnalyzeTextOptions DeserializeAnalyzeTextOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string text = default; + LexicalAnalyzerName? analyzer = default; + LexicalTokenizerName? tokenizer = default; + LexicalNormalizerName? normalizer = default; + IList tokenFilters = default; + IList charFilters = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (property.NameEquals("analyzer"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + analyzer = new LexicalAnalyzerName(property.Value.GetString()); + continue; + } + if (property.NameEquals("tokenizer"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + tokenizer = new LexicalTokenizerName(property.Value.GetString()); + continue; + } + if (property.NameEquals("normalizer"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + normalizer = new LexicalNormalizerName(property.Value.GetString()); + continue; + } + if (property.NameEquals("tokenFilters"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new TokenFilterName(item.GetString())); + } + tokenFilters = array; + continue; + } + if (property.NameEquals("charFilters"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + charFilters = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AnalyzeTextOptions( + text, + analyzer, + tokenizer, + normalizer, + tokenFilters ?? new ChangeTrackingList(), + charFilters ?? 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(AnalyzeTextOptions)} does not support writing '{options.Format}' format."); + } + } + + AnalyzeTextOptions 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 DeserializeAnalyzeTextOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AnalyzeTextOptions)} 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 AnalyzeTextOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAnalyzeTextOptions(document.RootElement); } /// Convert into a . internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzeTextOptions.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzeTextOptions.cs index 64c414f34db5..fa343597266c 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzeTextOptions.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzeTextOptions.cs @@ -13,6 +13,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Specifies some text and analysis components used to break that text into tokens. public partial class AnalyzeTextOptions { + /// + /// 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 . /// The text to break into tokens. /// is null. @@ -32,7 +64,8 @@ public AnalyzeTextOptions(string text) /// The name of the normalizer to use to normalize the given text. /// An optional list of token filters to use when breaking the given text. This parameter can only be set when using the tokenizer parameter. /// An optional list of character filters to use when breaking the given text. This parameter can only be set when using the tokenizer parameter. - internal AnalyzeTextOptions(string text, LexicalAnalyzerName? analyzerName, LexicalTokenizerName? tokenizerName, LexicalNormalizerName? normalizerName, IList tokenFilters, IList charFilters) + /// Keeps track of any properties unknown to the library. + internal AnalyzeTextOptions(string text, LexicalAnalyzerName? analyzerName, LexicalTokenizerName? tokenizerName, LexicalNormalizerName? normalizerName, IList tokenFilters, IList charFilters, IDictionary serializedAdditionalRawData) { Text = text; AnalyzerName = analyzerName; @@ -40,6 +73,12 @@ internal AnalyzeTextOptions(string text, LexicalAnalyzerName? analyzerName, Lexi NormalizerName = normalizerName; TokenFilters = tokenFilters; CharFilters = charFilters; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AnalyzeTextOptions() + { } /// The text to break into tokens. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzedTokenInfo.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzedTokenInfo.Serialization.cs index da83fa8ffcd5..4cb017c5519e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzedTokenInfo.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzedTokenInfo.Serialization.cs @@ -5,14 +5,88 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class AnalyzedTokenInfo + public partial class AnalyzedTokenInfo : IUtf8JsonSerializable, IJsonModel { - internal static AnalyzedTokenInfo DeserializeAnalyzedTokenInfo(JsonElement element) + 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(AnalyzedTokenInfo)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("token"u8); + writer.WriteStringValue(Token); + } + if (options.Format != "W") + { + writer.WritePropertyName("startOffset"u8); + writer.WriteNumberValue(StartOffset); + } + if (options.Format != "W") + { + writer.WritePropertyName("endOffset"u8); + writer.WriteNumberValue(EndOffset); + } + if (options.Format != "W") + { + writer.WritePropertyName("position"u8); + writer.WriteNumberValue(Position); + } + 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 + } + } + } + + AnalyzedTokenInfo 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(AnalyzedTokenInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAnalyzedTokenInfo(document.RootElement, options); + } + + internal static AnalyzedTokenInfo DeserializeAnalyzedTokenInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -21,6 +95,8 @@ internal static AnalyzedTokenInfo DeserializeAnalyzedTokenInfo(JsonElement eleme int startOffset = default; int endOffset = default; int position = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("token"u8)) @@ -43,10 +119,46 @@ internal static AnalyzedTokenInfo DeserializeAnalyzedTokenInfo(JsonElement eleme position = property.Value.GetInt32(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new AnalyzedTokenInfo(token, startOffset, endOffset, position); + serializedAdditionalRawData = rawDataDictionary; + return new AnalyzedTokenInfo(token, startOffset, endOffset, position, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(AnalyzedTokenInfo)} does not support writing '{options.Format}' format."); + } + } + + AnalyzedTokenInfo 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 DeserializeAnalyzedTokenInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AnalyzedTokenInfo)} 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 AnalyzedTokenInfo FromResponse(Response response) @@ -54,5 +166,13 @@ internal static AnalyzedTokenInfo FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeAnalyzedTokenInfo(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/search/Azure.Search.Documents/src/Generated/Models/AnalyzedTokenInfo.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzedTokenInfo.cs index 21bda20820ff..4f22f3f6c5a0 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzedTokenInfo.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AnalyzedTokenInfo.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Information about a token returned by an analyzer. public partial class AnalyzedTokenInfo { + /// + /// 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 . /// The token returned by the analyzer. /// The index of the first character of the token in the input text. @@ -23,6 +58,26 @@ internal AnalyzedTokenInfo(string token, int startOffset, int endOffset, int pos Position = position; } + /// Initializes a new instance of . + /// The token returned by the analyzer. + /// The index of the first character of the token in the input text. + /// The index of the last character of the token in the input text. + /// The position of the token in the input text relative to other tokens. The first token in the input text has position 0, the next has position 1, and so on. Depending on the analyzer used, some tokens might have the same position, for example if they are synonyms of each other. + /// Keeps track of any properties unknown to the library. + internal AnalyzedTokenInfo(string token, int startOffset, int endOffset, int position, IDictionary serializedAdditionalRawData) + { + Token = token; + StartOffset = startOffset; + EndOffset = endOffset; + Position = position; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AnalyzedTokenInfo() + { + } + /// The token returned by the analyzer. public string Token { get; } /// The index of the first character of the token in the input text. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AsciiFoldingTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AsciiFoldingTokenFilter.Serialization.cs index a344d6bff209..ce5d136c556c 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AsciiFoldingTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AsciiFoldingTokenFilter.Serialization.cs @@ -5,30 +5,59 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class AsciiFoldingTokenFilter : IUtf8JsonSerializable + public partial class AsciiFoldingTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(AsciiFoldingTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(PreserveOriginal)) { writer.WritePropertyName("preserveOriginal"u8); writer.WriteBooleanValue(PreserveOriginal.Value); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static AsciiFoldingTokenFilter DeserializeAsciiFoldingTokenFilter(JsonElement element) + AsciiFoldingTokenFilter 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(AsciiFoldingTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAsciiFoldingTokenFilter(document.RootElement, options); + } + + internal static AsciiFoldingTokenFilter DeserializeAsciiFoldingTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -36,6 +65,8 @@ internal static AsciiFoldingTokenFilter DeserializeAsciiFoldingTokenFilter(JsonE bool? preserveOriginal = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("preserveOriginal"u8)) @@ -57,10 +88,46 @@ internal static AsciiFoldingTokenFilter DeserializeAsciiFoldingTokenFilter(JsonE name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AsciiFoldingTokenFilter(odataType, name, serializedAdditionalRawData, preserveOriginal); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(AsciiFoldingTokenFilter)} does not support writing '{options.Format}' format."); + } + } + + AsciiFoldingTokenFilter 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 DeserializeAsciiFoldingTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AsciiFoldingTokenFilter)} does not support reading '{options.Format}' format."); } - return new AsciiFoldingTokenFilter(odataType, name, preserveOriginal); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new AsciiFoldingTokenFilter FromResponse(Response response) @@ -73,7 +140,7 @@ internal static AsciiFoldingTokenFilter DeserializeAsciiFoldingTokenFilter(JsonE internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AsciiFoldingTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AsciiFoldingTokenFilter.cs index eba18808c0d6..2bbc0f5ad591 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AsciiFoldingTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AsciiFoldingTokenFilter.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,13 +26,19 @@ public AsciiFoldingTokenFilter(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// A value indicating whether the original token will be kept. Default is false. - internal AsciiFoldingTokenFilter(string oDataType, string name, bool? preserveOriginal) : base(oDataType, name) + internal AsciiFoldingTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, bool? preserveOriginal) : base(oDataType, name, serializedAdditionalRawData) { PreserveOriginal = preserveOriginal; ODataType = oDataType ?? "#Microsoft.Azure.Search.AsciiFoldingTokenFilter"; } + /// Initializes a new instance of for deserialization. + internal AsciiFoldingTokenFilter() + { + } + /// A value indicating whether the original token will be kept. Default is false. public bool? PreserveOriginal { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteItem.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteItem.Serialization.cs index ad6f5504f2ba..986e7269c9d1 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteItem.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteItem.Serialization.cs @@ -5,20 +5,86 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class AutocompleteItem + public partial class AutocompleteItem : IUtf8JsonSerializable, IJsonModel { - internal static AutocompleteItem DeserializeAutocompleteItem(JsonElement element) + 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(AutocompleteItem)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + if (options.Format != "W") + { + writer.WritePropertyName("queryPlusText"u8); + writer.WriteStringValue(QueryPlusText); + } + 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 + } + } + } + + AutocompleteItem 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(AutocompleteItem)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAutocompleteItem(document.RootElement, options); + } + + internal static AutocompleteItem DeserializeAutocompleteItem(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string text = default; string queryPlusText = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("text"u8)) @@ -31,10 +97,46 @@ internal static AutocompleteItem DeserializeAutocompleteItem(JsonElement element queryPlusText = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AutocompleteItem(text, queryPlusText, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(AutocompleteItem)} does not support writing '{options.Format}' format."); } - return new AutocompleteItem(text, queryPlusText); } + AutocompleteItem 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 DeserializeAutocompleteItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AutocompleteItem)} 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 AutocompleteItem FromResponse(Response response) @@ -42,5 +144,13 @@ internal static AutocompleteItem FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeAutocompleteItem(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/search/Azure.Search.Documents/src/Generated/Models/AutocompleteItem.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteItem.cs index 570232f508bd..8bd5732d2a22 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteItem.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteItem.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Models { /// The result of Autocomplete requests. public partial class AutocompleteItem { + /// + /// 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 . /// The completed term. /// The query along with the completed term. @@ -19,6 +54,22 @@ internal AutocompleteItem(string text, string queryPlusText) QueryPlusText = queryPlusText; } + /// Initializes a new instance of . + /// The completed term. + /// The query along with the completed term. + /// Keeps track of any properties unknown to the library. + internal AutocompleteItem(string text, string queryPlusText, IDictionary serializedAdditionalRawData) + { + Text = text; + QueryPlusText = queryPlusText; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AutocompleteItem() + { + } + /// The completed term. public string Text { get; } /// The query along with the completed term. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteOptions.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteOptions.Serialization.cs index d08830ff9ede..0b87c3d75a0b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteOptions.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteOptions.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents { - public partial class AutocompleteOptions : IUtf8JsonSerializable + public partial class AutocompleteOptions : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(AutocompleteOptions)} does not support writing '{format}' format."); + } + writer.WritePropertyName("search"u8); writer.WriteStringValue(SearchText); if (Optional.IsDefined(Mode)) @@ -60,14 +79,187 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("top"u8); writer.WriteNumberValue(Size.Value); } - writer.WriteEndObject(); + 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 + } + } + } + + AutocompleteOptions 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(AutocompleteOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAutocompleteOptions(document.RootElement, options); + } + + internal static AutocompleteOptions DeserializeAutocompleteOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string search = default; + AutocompleteMode? autocompleteMode = default; + string filter = default; + bool? fuzzy = default; + string highlightPostTag = default; + string highlightPreTag = default; + double? minimumCoverage = default; + string searchFields = default; + string suggesterName = default; + int? top = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("search"u8)) + { + search = property.Value.GetString(); + continue; + } + if (property.NameEquals("autocompleteMode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + autocompleteMode = property.Value.GetString().ToAutocompleteMode(); + continue; + } + if (property.NameEquals("filter"u8)) + { + filter = property.Value.GetString(); + continue; + } + if (property.NameEquals("fuzzy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fuzzy = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("highlightPostTag"u8)) + { + highlightPostTag = property.Value.GetString(); + continue; + } + if (property.NameEquals("highlightPreTag"u8)) + { + highlightPreTag = property.Value.GetString(); + continue; + } + if (property.NameEquals("minimumCoverage"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + minimumCoverage = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("searchFields"u8)) + { + searchFields = property.Value.GetString(); + continue; + } + if (property.NameEquals("suggesterName"u8)) + { + suggesterName = property.Value.GetString(); + continue; + } + if (property.NameEquals("top"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + top = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AutocompleteOptions( + search, + autocompleteMode, + filter, + fuzzy, + highlightPostTag, + highlightPreTag, + minimumCoverage, + searchFields, + suggesterName, + top, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(AutocompleteOptions)} does not support writing '{options.Format}' format."); + } + } + + AutocompleteOptions 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 DeserializeAutocompleteOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AutocompleteOptions)} 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 AutocompleteOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAutocompleteOptions(document.RootElement); } /// Convert into a . internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteOptions.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteOptions.cs index 094faba55211..51079d7575fa 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteOptions.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteOptions.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; using Azure.Search.Documents.Models; namespace Azure.Search.Documents @@ -13,6 +14,38 @@ namespace Azure.Search.Documents /// Parameters for fuzzy matching, and other autocomplete query behaviors. public partial class AutocompleteOptions { + /// + /// 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 . /// The search text on which to base autocomplete results. /// Specifies the mode for Autocomplete. The default is 'oneTerm'. Use 'twoTerms' to get shingles and 'oneTermWithContext' to use the current context while producing auto-completed terms. @@ -24,7 +57,8 @@ public partial class AutocompleteOptions /// The comma-separated list of field names to consider when querying for auto-completed terms. Target fields must be included in the specified suggester. /// The name of the suggester as specified in the suggesters collection that's part of the index definition. /// The number of auto-completed terms to retrieve. This must be a value between 1 and 100. The default is 5. - internal AutocompleteOptions(string searchText, AutocompleteMode? mode, string filter, bool? useFuzzyMatching, string highlightPostTag, string highlightPreTag, double? minimumCoverage, string searchFieldsRaw, string suggesterName, int? size) + /// Keeps track of any properties unknown to the library. + internal AutocompleteOptions(string searchText, AutocompleteMode? mode, string filter, bool? useFuzzyMatching, string highlightPostTag, string highlightPreTag, double? minimumCoverage, string searchFieldsRaw, string suggesterName, int? size, IDictionary serializedAdditionalRawData) { SearchText = searchText; Mode = mode; @@ -36,6 +70,7 @@ internal AutocompleteOptions(string searchText, AutocompleteMode? mode, string f SearchFieldsRaw = searchFieldsRaw; SuggesterName = suggesterName; Size = size; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// A value indicating whether to use fuzzy matching for the autocomplete query. Default is false. When set to true, the query will autocomplete terms even if there's a substituted or missing character in the search text. While this provides a better experience in some scenarios, it comes at a performance cost as fuzzy autocomplete queries are slower and consume more resources. public bool? UseFuzzyMatching { get; set; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteResults.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteResults.Serialization.cs index ebd61028ccee..758a65a3d885 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteResults.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteResults.Serialization.cs @@ -5,21 +5,91 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class AutocompleteResults + public partial class AutocompleteResults : IUtf8JsonSerializable, IJsonModel { - internal static AutocompleteResults DeserializeAutocompleteResults(JsonElement element) + 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(AutocompleteResults)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Coverage)) + { + writer.WritePropertyName("@search.coverage"u8); + writer.WriteNumberValue(Coverage.Value); + } + if (options.Format != "W") + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Results) + { + 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 + } + } + } + + AutocompleteResults 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(AutocompleteResults)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAutocompleteResults(document.RootElement, options); + } + + internal static AutocompleteResults DeserializeAutocompleteResults(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } double? searchCoverage = default; IReadOnlyList value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@search.coverage"u8)) @@ -36,15 +106,51 @@ internal static AutocompleteResults DeserializeAutocompleteResults(JsonElement e List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(AutocompleteItem.DeserializeAutocompleteItem(item)); + array.Add(AutocompleteItem.DeserializeAutocompleteItem(item, options)); } value = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AutocompleteResults(searchCoverage, value, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(AutocompleteResults)} does not support writing '{options.Format}' format."); } - return new AutocompleteResults(searchCoverage, value); } + AutocompleteResults 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 DeserializeAutocompleteResults(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AutocompleteResults)} 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 AutocompleteResults FromResponse(Response response) @@ -52,5 +158,13 @@ internal static AutocompleteResults FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeAutocompleteResults(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/search/Azure.Search.Documents/src/Generated/Models/AutocompleteResults.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteResults.cs index ec145b56ea09..2660f778b775 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteResults.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AutocompleteResults.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using System.Linq; @@ -13,6 +14,38 @@ namespace Azure.Search.Documents.Models /// The result of Autocomplete query. public partial class AutocompleteResults { + /// + /// 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 . /// The list of returned Autocompleted items. internal AutocompleteResults(IEnumerable results) @@ -23,10 +56,17 @@ internal AutocompleteResults(IEnumerable results) /// Initializes a new instance of . /// A value indicating the percentage of the index that was considered by the autocomplete request, or null if minimumCoverage was not specified in the request. /// The list of returned Autocompleted items. - internal AutocompleteResults(double? coverage, IReadOnlyList results) + /// Keeps track of any properties unknown to the library. + internal AutocompleteResults(double? coverage, IReadOnlyList results, IDictionary serializedAdditionalRawData) { Coverage = coverage; Results = results; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AutocompleteResults() + { } /// A value indicating the percentage of the index that was considered by the autocomplete request, or null if minimumCoverage was not specified in the request. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureActiveDirectoryApplicationCredentials.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureActiveDirectoryApplicationCredentials.Serialization.cs index 48d289ea39d2..470731fa7be9 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureActiveDirectoryApplicationCredentials.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureActiveDirectoryApplicationCredentials.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - internal partial class AzureActiveDirectoryApplicationCredentials : IUtf8JsonSerializable + internal partial class AzureActiveDirectoryApplicationCredentials : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(AzureActiveDirectoryApplicationCredentials)} does not support writing '{format}' format."); + } + writer.WritePropertyName("applicationId"u8); writer.WriteStringValue(ApplicationId); if (Optional.IsDefined(ApplicationSecret)) @@ -22,17 +41,47 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("applicationSecret"u8); writer.WriteStringValue(ApplicationSecret); } - writer.WriteEndObject(); + 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 + } + } } - internal static AzureActiveDirectoryApplicationCredentials DeserializeAzureActiveDirectoryApplicationCredentials(JsonElement element) + AzureActiveDirectoryApplicationCredentials 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(AzureActiveDirectoryApplicationCredentials)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureActiveDirectoryApplicationCredentials(document.RootElement, options); + } + + internal static AzureActiveDirectoryApplicationCredentials DeserializeAzureActiveDirectoryApplicationCredentials(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string applicationId = default; string applicationSecret = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("applicationId"u8)) @@ -45,10 +94,46 @@ internal static AzureActiveDirectoryApplicationCredentials DeserializeAzureActiv applicationSecret = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new AzureActiveDirectoryApplicationCredentials(applicationId, applicationSecret); + serializedAdditionalRawData = rawDataDictionary; + return new AzureActiveDirectoryApplicationCredentials(applicationId, applicationSecret, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(AzureActiveDirectoryApplicationCredentials)} does not support writing '{options.Format}' format."); + } + } + + AzureActiveDirectoryApplicationCredentials 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 DeserializeAzureActiveDirectoryApplicationCredentials(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureActiveDirectoryApplicationCredentials)} 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 AzureActiveDirectoryApplicationCredentials FromResponse(Response response) @@ -61,7 +146,7 @@ internal static AzureActiveDirectoryApplicationCredentials FromResponse(Response internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureActiveDirectoryApplicationCredentials.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureActiveDirectoryApplicationCredentials.cs index 51c88660d511..8d1660ab197d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureActiveDirectoryApplicationCredentials.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureActiveDirectoryApplicationCredentials.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Credentials of a registered application created for your search service, used for authenticated access to the encryption keys stored in Azure Key Vault. internal partial class AzureActiveDirectoryApplicationCredentials { + /// + /// 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 . /// An AAD Application ID that was granted the required access permissions to the Azure Key Vault that is to be used when encrypting your data at rest. The Application ID should not be confused with the Object ID for your AAD Application. /// is null. @@ -25,10 +58,17 @@ public AzureActiveDirectoryApplicationCredentials(string applicationId) /// Initializes a new instance of . /// An AAD Application ID that was granted the required access permissions to the Azure Key Vault that is to be used when encrypting your data at rest. The Application ID should not be confused with the Object ID for your AAD Application. /// The authentication key of the specified AAD application. - internal AzureActiveDirectoryApplicationCredentials(string applicationId, string applicationSecret) + /// Keeps track of any properties unknown to the library. + internal AzureActiveDirectoryApplicationCredentials(string applicationId, string applicationSecret, IDictionary serializedAdditionalRawData) { ApplicationId = applicationId; ApplicationSecret = applicationSecret; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AzureActiveDirectoryApplicationCredentials() + { } /// An AAD Application ID that was granted the required access permissions to the Azure Key Vault that is to be used when encrypting your data at rest. The Application ID should not be confused with the Object ID for your AAD Application. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningParameters.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningParameters.Serialization.cs index 1510e243157a..5b34dce2b8e2 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningParameters.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningParameters.Serialization.cs @@ -6,16 +6,34 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class AzureMachineLearningParameters : IUtf8JsonSerializable + public partial class AzureMachineLearningParameters : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(AzureMachineLearningParameters)} does not support writing '{format}' format."); + } + if (ScoringUri != null) { writer.WritePropertyName("uri"u8); @@ -78,11 +96,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("modelName"u8); writer.WriteStringValue(ModelName.Value.ToString()); } - writer.WriteEndObject(); + 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 + } + } } - internal static AzureMachineLearningParameters DeserializeAzureMachineLearningParameters(JsonElement element) + AzureMachineLearningParameters 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(AzureMachineLearningParameters)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureMachineLearningParameters(document.RootElement, options); + } + + internal static AzureMachineLearningParameters DeserializeAzureMachineLearningParameters(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -93,6 +139,8 @@ internal static AzureMachineLearningParameters DeserializeAzureMachineLearningPa TimeSpan? timeout = default; string region = default; AIFoundryModelCatalogName? modelName = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("uri"u8)) @@ -154,16 +202,53 @@ internal static AzureMachineLearningParameters DeserializeAzureMachineLearningPa modelName = new AIFoundryModelCatalogName(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new AzureMachineLearningParameters( uri, key, resourceId, timeout, region, - modelName); + modelName, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(AzureMachineLearningParameters)} does not support writing '{options.Format}' format."); + } } + AzureMachineLearningParameters 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 DeserializeAzureMachineLearningParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureMachineLearningParameters)} 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 AzureMachineLearningParameters FromResponse(Response response) @@ -176,7 +261,7 @@ internal static AzureMachineLearningParameters FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningParameters.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningParameters.cs index 899f99a9246b..97f73c9d7e1f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningParameters.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningParameters.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Specifies the properties for connecting to an AML vectorizer. public partial class AzureMachineLearningParameters { + /// + /// 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 . /// (Required for no authentication or key authentication) The scoring URI of the AML service to which the JSON payload will be sent. Only the https URI scheme is allowed. public AzureMachineLearningParameters(Uri scoringUri) @@ -26,7 +59,8 @@ public AzureMachineLearningParameters(Uri scoringUri) /// (Optional) When specified, indicates the timeout for the http client making the API call. /// (Optional for token authentication). The region the AML service is deployed in. /// The name of the embedding model from the Azure AI Foundry Catalog that is deployed at the provided endpoint. - internal AzureMachineLearningParameters(Uri scoringUri, string authenticationKey, string resourceId, TimeSpan? timeout, string region, AIFoundryModelCatalogName? modelName) + /// Keeps track of any properties unknown to the library. + internal AzureMachineLearningParameters(Uri scoringUri, string authenticationKey, string resourceId, TimeSpan? timeout, string region, AIFoundryModelCatalogName? modelName, IDictionary serializedAdditionalRawData) { ScoringUri = scoringUri; AuthenticationKey = authenticationKey; @@ -34,6 +68,12 @@ internal AzureMachineLearningParameters(Uri scoringUri, string authenticationKey Timeout = timeout; Region = region; ModelName = modelName; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AzureMachineLearningParameters() + { } /// (Required for no authentication or key authentication) The scoring URI of the AML service to which the JSON payload will be sent. Only the https URI scheme is allowed. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningSkill.Serialization.cs index 0de76f2f4ba9..4da885b0af96 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningSkill.Serialization.cs @@ -6,17 +6,35 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class AzureMachineLearningSkill : IUtf8JsonSerializable + public partial class AzureMachineLearningSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(AzureMachineLearningSkill)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(ScoringUri)) { if (ScoringUri != null) @@ -89,42 +107,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("degreeOfParallelism"); } } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + AzureMachineLearningSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(AzureMachineLearningSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureMachineLearningSkill(document.RootElement, options); } - internal static AzureMachineLearningSkill DeserializeAzureMachineLearningSkill(JsonElement element) + internal static AzureMachineLearningSkill DeserializeAzureMachineLearningSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -141,6 +141,8 @@ internal static AzureMachineLearningSkill DeserializeAzureMachineLearningSkill(J string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("uri"u8)) @@ -228,7 +230,7 @@ internal static AzureMachineLearningSkill DeserializeAzureMachineLearningSkill(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -238,12 +240,17 @@ internal static AzureMachineLearningSkill DeserializeAzureMachineLearningSkill(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new AzureMachineLearningSkill( odataType, name, @@ -251,6 +258,7 @@ internal static AzureMachineLearningSkill DeserializeAzureMachineLearningSkill(J context, inputs, outputs, + serializedAdditionalRawData, uri, key, resourceId, @@ -259,6 +267,37 @@ internal static AzureMachineLearningSkill DeserializeAzureMachineLearningSkill(J degreeOfParallelism); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(AzureMachineLearningSkill)} does not support writing '{options.Format}' format."); + } + } + + AzureMachineLearningSkill 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 DeserializeAzureMachineLearningSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureMachineLearningSkill)} 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 AzureMachineLearningSkill FromResponse(Response response) @@ -271,7 +310,7 @@ internal static AzureMachineLearningSkill DeserializeAzureMachineLearningSkill(J internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningSkill.cs index a8485c08910d..0a22bed88301 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningSkill.cs @@ -20,13 +20,14 @@ public partial class AzureMachineLearningSkill : SearchIndexerSkill /// Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// (Required for no authentication or key authentication) The scoring URI of the AML service to which the JSON payload will be sent. Only the https URI scheme is allowed. /// (Required for key authentication) The key for the AML service. /// (Required for token authentication). The Azure Resource Manager resource ID of the AML service. It should be in the format subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.MachineLearningServices/workspaces/{workspace-name}/services/{service_name}. /// (Optional) When specified, indicates the timeout for the http client making the API call. /// (Optional for token authentication). The region the AML service is deployed in. /// (Optional) When specified, indicates the number of calls the indexer will make in parallel to the endpoint you have provided. You can decrease this value if your endpoint is failing under too high of a request load, or raise it if your endpoint is able to accept more requests and you would like an increase in the performance of the indexer. If not set, a default value of 5 is used. The degreeOfParallelism can be set to a maximum of 10 and a minimum of 1. - internal AzureMachineLearningSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, Uri scoringUri, string authenticationKey, string rawResourceId, TimeSpan? timeout, string rawLocation, int? degreeOfParallelism) : base(oDataType, name, description, context, inputs, outputs) + internal AzureMachineLearningSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, Uri scoringUri, string authenticationKey, string rawResourceId, TimeSpan? timeout, string rawLocation, int? degreeOfParallelism) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { ScoringUri = scoringUri; AuthenticationKey = authenticationKey; @@ -36,6 +37,11 @@ internal AzureMachineLearningSkill(string oDataType, string name, string descrip DegreeOfParallelism = degreeOfParallelism; ODataType = oDataType ?? "#Microsoft.Skills.Custom.AmlSkill"; } + + /// Initializes a new instance of for deserialization. + internal AzureMachineLearningSkill() + { + } /// (Optional) When specified, indicates the timeout for the http client making the API call. public TimeSpan? Timeout { get; set; } /// (Optional) When specified, indicates the number of calls the indexer will make in parallel to the endpoint you have provided. You can decrease this value if your endpoint is failing under too high of a request load, or raise it if your endpoint is able to accept more requests and you would like an increase in the performance of the indexer. If not set, a default value of 5 is used. The degreeOfParallelism can be set to a maximum of 10 and a minimum of 1. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningVectorizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningVectorizer.Serialization.cs index c9a2241a090c..758c1bdee48a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningVectorizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningVectorizer.Serialization.cs @@ -5,30 +5,59 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class AzureMachineLearningVectorizer : IUtf8JsonSerializable + public partial class AzureMachineLearningVectorizer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(AzureMachineLearningVectorizer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(AMLParameters)) { writer.WritePropertyName("amlParameters"u8); - writer.WriteObjectValue(AMLParameters); + writer.WriteObjectValue(AMLParameters, options); } - writer.WritePropertyName("name"u8); - writer.WriteStringValue(VectorizerName); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); - writer.WriteEndObject(); } - internal static AzureMachineLearningVectorizer DeserializeAzureMachineLearningVectorizer(JsonElement element) + AzureMachineLearningVectorizer 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(AzureMachineLearningVectorizer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureMachineLearningVectorizer(document.RootElement, options); + } + + internal static AzureMachineLearningVectorizer DeserializeAzureMachineLearningVectorizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -36,6 +65,8 @@ internal static AzureMachineLearningVectorizer DeserializeAzureMachineLearningVe AzureMachineLearningParameters amlParameters = default; string name = default; VectorSearchVectorizerKind kind = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("amlParameters"u8)) @@ -44,7 +75,7 @@ internal static AzureMachineLearningVectorizer DeserializeAzureMachineLearningVe { continue; } - amlParameters = AzureMachineLearningParameters.DeserializeAzureMachineLearningParameters(property.Value); + amlParameters = AzureMachineLearningParameters.DeserializeAzureMachineLearningParameters(property.Value, options); continue; } if (property.NameEquals("name"u8)) @@ -57,10 +88,46 @@ internal static AzureMachineLearningVectorizer DeserializeAzureMachineLearningVe kind = new VectorSearchVectorizerKind(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AzureMachineLearningVectorizer(name, kind, serializedAdditionalRawData, amlParameters); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(AzureMachineLearningVectorizer)} does not support writing '{options.Format}' format."); + } + } + + AzureMachineLearningVectorizer 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 DeserializeAzureMachineLearningVectorizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureMachineLearningVectorizer)} does not support reading '{options.Format}' format."); } - return new AzureMachineLearningVectorizer(name, kind, amlParameters); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new AzureMachineLearningVectorizer FromResponse(Response response) @@ -73,7 +140,7 @@ internal static AzureMachineLearningVectorizer DeserializeAzureMachineLearningVe internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningVectorizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningVectorizer.cs index a459785ad47d..4c12a3400f1a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningVectorizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureMachineLearningVectorizer.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,13 +26,19 @@ public AzureMachineLearningVectorizer(string vectorizerName) : base(vectorizerNa /// Initializes a new instance of . /// The name to associate with this particular vectorization method. /// The name of the kind of vectorization method being configured for use with vector search. + /// Keeps track of any properties unknown to the library. /// Specifies the properties of the AML vectorizer. - internal AzureMachineLearningVectorizer(string vectorizerName, VectorSearchVectorizerKind kind, AzureMachineLearningParameters amlParameters) : base(vectorizerName, kind) + internal AzureMachineLearningVectorizer(string vectorizerName, VectorSearchVectorizerKind kind, IDictionary serializedAdditionalRawData, AzureMachineLearningParameters amlParameters) : base(vectorizerName, kind, serializedAdditionalRawData) { AMLParameters = amlParameters; Kind = kind; } + /// Initializes a new instance of for deserialization. + internal AzureMachineLearningVectorizer() + { + } + /// Specifies the properties of the AML vectorizer. public AzureMachineLearningParameters AMLParameters { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIEmbeddingSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIEmbeddingSkill.Serialization.cs index 61e34001205e..f1032487113e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIEmbeddingSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIEmbeddingSkill.Serialization.cs @@ -6,17 +6,35 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class AzureOpenAIEmbeddingSkill : IUtf8JsonSerializable + public partial class AzureOpenAIEmbeddingSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(AzureOpenAIEmbeddingSkill)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Dimensions)) { if (Dimensions != null) @@ -49,7 +67,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (AuthenticationIdentity != null) { writer.WritePropertyName("authIdentity"u8); - writer.WriteObjectValue(AuthenticationIdentity); + writer.WriteObjectValue(AuthenticationIdentity, options); } else { @@ -61,42 +79,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("modelName"u8); writer.WriteStringValue(ModelName.Value.ToString()); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + AzureOpenAIEmbeddingSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(AzureOpenAIEmbeddingSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureOpenAIEmbeddingSkill(document.RootElement, options); } - internal static AzureOpenAIEmbeddingSkill DeserializeAzureOpenAIEmbeddingSkill(JsonElement element) + internal static AzureOpenAIEmbeddingSkill DeserializeAzureOpenAIEmbeddingSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -113,6 +113,8 @@ internal static AzureOpenAIEmbeddingSkill DeserializeAzureOpenAIEmbeddingSkill(J string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("dimensions"u8)) @@ -151,7 +153,7 @@ internal static AzureOpenAIEmbeddingSkill DeserializeAzureOpenAIEmbeddingSkill(J authIdentity = null; continue; } - authIdentity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value); + authIdentity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value, options); continue; } if (property.NameEquals("modelName"u8)) @@ -188,7 +190,7 @@ internal static AzureOpenAIEmbeddingSkill DeserializeAzureOpenAIEmbeddingSkill(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -198,12 +200,17 @@ internal static AzureOpenAIEmbeddingSkill DeserializeAzureOpenAIEmbeddingSkill(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new AzureOpenAIEmbeddingSkill( odataType, name, @@ -211,6 +218,7 @@ internal static AzureOpenAIEmbeddingSkill DeserializeAzureOpenAIEmbeddingSkill(J context, inputs, outputs, + serializedAdditionalRawData, dimensions, resourceUri, deploymentId, @@ -219,6 +227,37 @@ internal static AzureOpenAIEmbeddingSkill DeserializeAzureOpenAIEmbeddingSkill(J modelName); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(AzureOpenAIEmbeddingSkill)} does not support writing '{options.Format}' format."); + } + } + + AzureOpenAIEmbeddingSkill 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 DeserializeAzureOpenAIEmbeddingSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureOpenAIEmbeddingSkill)} 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 AzureOpenAIEmbeddingSkill FromResponse(Response response) @@ -231,7 +270,7 @@ internal static AzureOpenAIEmbeddingSkill DeserializeAzureOpenAIEmbeddingSkill(J internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIEmbeddingSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIEmbeddingSkill.cs index 0f9de43318f3..37d3320b60d2 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIEmbeddingSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIEmbeddingSkill.cs @@ -32,6 +32,7 @@ public AzureOpenAIEmbeddingSkill(IEnumerable inputs, IEn /// Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// The number of dimensions the resulting output embeddings should have. Only supported in text-embedding-3 and later models. /// The resource URI of the Azure OpenAI resource. /// ID of the Azure OpenAI model deployment on the designated resource. @@ -42,7 +43,7 @@ public AzureOpenAIEmbeddingSkill(IEnumerable inputs, IEn /// The available derived classes include and . /// /// The name of the embedding model that is deployed at the provided deploymentId path. - internal AzureOpenAIEmbeddingSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, int? dimensions, Uri resourceUri, string deploymentName, string apiKey, SearchIndexerDataIdentity authenticationIdentity, AzureOpenAIModelName? modelName) : base(oDataType, name, description, context, inputs, outputs) + internal AzureOpenAIEmbeddingSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, int? dimensions, Uri resourceUri, string deploymentName, string apiKey, SearchIndexerDataIdentity authenticationIdentity, AzureOpenAIModelName? modelName) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { Dimensions = dimensions; ResourceUri = resourceUri; @@ -53,6 +54,11 @@ internal AzureOpenAIEmbeddingSkill(string oDataType, string name, string descrip ODataType = oDataType ?? "#Microsoft.Skills.Text.AzureOpenAIEmbeddingSkill"; } + /// Initializes a new instance of for deserialization. + internal AzureOpenAIEmbeddingSkill() + { + } + /// The number of dimensions the resulting output embeddings should have. Only supported in text-embedding-3 and later models. public int? Dimensions { get; set; } /// The resource URI of the Azure OpenAI resource. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAITokenizerParameters.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAITokenizerParameters.Serialization.cs index 6d94553c7c80..7bcd36b0da13 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAITokenizerParameters.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAITokenizerParameters.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class AzureOpenAITokenizerParameters : IUtf8JsonSerializable + public partial class AzureOpenAITokenizerParameters : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(AzureOpenAITokenizerParameters)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(EncoderModelName)) { if (EncoderModelName != null) @@ -38,17 +56,47 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WriteEndArray(); } - writer.WriteEndObject(); + 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 + } + } } - internal static AzureOpenAITokenizerParameters DeserializeAzureOpenAITokenizerParameters(JsonElement element) + AzureOpenAITokenizerParameters 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(AzureOpenAITokenizerParameters)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureOpenAITokenizerParameters(document.RootElement, options); + } + + internal static AzureOpenAITokenizerParameters DeserializeAzureOpenAITokenizerParameters(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } SplitSkillEncoderModelName? encoderModelName = default; IList allowedSpecialTokens = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("encoderModelName"u8)) @@ -75,10 +123,46 @@ internal static AzureOpenAITokenizerParameters DeserializeAzureOpenAITokenizerPa allowedSpecialTokens = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AzureOpenAITokenizerParameters(encoderModelName, allowedSpecialTokens ?? 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(AzureOpenAITokenizerParameters)} does not support writing '{options.Format}' format."); } - return new AzureOpenAITokenizerParameters(encoderModelName, allowedSpecialTokens ?? new ChangeTrackingList()); } + AzureOpenAITokenizerParameters 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 DeserializeAzureOpenAITokenizerParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureOpenAITokenizerParameters)} 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 AzureOpenAITokenizerParameters FromResponse(Response response) @@ -91,7 +175,7 @@ internal static AzureOpenAITokenizerParameters FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAITokenizerParameters.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAITokenizerParameters.cs index 89b1591b8f24..8e9a835e3ef5 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAITokenizerParameters.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAITokenizerParameters.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models @@ -12,6 +13,38 @@ namespace Azure.Search.Documents.Indexes.Models /// The AzureOpenAITokenizerParameters. public partial class AzureOpenAITokenizerParameters { + /// + /// 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 AzureOpenAITokenizerParameters() { @@ -21,10 +54,12 @@ public AzureOpenAITokenizerParameters() /// Initializes a new instance of . /// Only applies if the unit is set to azureOpenAITokens. Options include 'R50k_base', 'P50k_base', 'P50k_edit' and 'CL100k_base'. The default value is 'CL100k_base'. /// (Optional) Only applies if the unit is set to azureOpenAITokens. This parameter defines a collection of special tokens that are permitted within the tokenization process. - internal AzureOpenAITokenizerParameters(SplitSkillEncoderModelName? encoderModelName, IList allowedSpecialTokens) + /// Keeps track of any properties unknown to the library. + internal AzureOpenAITokenizerParameters(SplitSkillEncoderModelName? encoderModelName, IList allowedSpecialTokens, IDictionary serializedAdditionalRawData) { EncoderModelName = encoderModelName; AllowedSpecialTokens = allowedSpecialTokens; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Only applies if the unit is set to azureOpenAITokens. Options include 'R50k_base', 'P50k_base', 'P50k_edit' and 'CL100k_base'. The default value is 'CL100k_base'. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIVectorizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIVectorizer.Serialization.cs index a8c82dbcad47..47fb88d2fe7d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIVectorizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIVectorizer.Serialization.cs @@ -5,30 +5,59 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class AzureOpenAIVectorizer : IUtf8JsonSerializable + public partial class AzureOpenAIVectorizer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(AzureOpenAIVectorizer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Parameters)) { writer.WritePropertyName("azureOpenAIParameters"u8); - writer.WriteObjectValue(Parameters); + writer.WriteObjectValue(Parameters, options); } - writer.WritePropertyName("name"u8); - writer.WriteStringValue(VectorizerName); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); - writer.WriteEndObject(); } - internal static AzureOpenAIVectorizer DeserializeAzureOpenAIVectorizer(JsonElement element) + AzureOpenAIVectorizer 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(AzureOpenAIVectorizer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureOpenAIVectorizer(document.RootElement, options); + } + + internal static AzureOpenAIVectorizer DeserializeAzureOpenAIVectorizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -36,6 +65,8 @@ internal static AzureOpenAIVectorizer DeserializeAzureOpenAIVectorizer(JsonEleme AzureOpenAIVectorizerParameters azureOpenAIParameters = default; string name = default; VectorSearchVectorizerKind kind = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("azureOpenAIParameters"u8)) @@ -44,7 +75,7 @@ internal static AzureOpenAIVectorizer DeserializeAzureOpenAIVectorizer(JsonEleme { continue; } - azureOpenAIParameters = AzureOpenAIVectorizerParameters.DeserializeAzureOpenAIVectorizerParameters(property.Value); + azureOpenAIParameters = AzureOpenAIVectorizerParameters.DeserializeAzureOpenAIVectorizerParameters(property.Value, options); continue; } if (property.NameEquals("name"u8)) @@ -57,10 +88,46 @@ internal static AzureOpenAIVectorizer DeserializeAzureOpenAIVectorizer(JsonEleme kind = new VectorSearchVectorizerKind(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AzureOpenAIVectorizer(name, kind, serializedAdditionalRawData, azureOpenAIParameters); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(AzureOpenAIVectorizer)} does not support writing '{options.Format}' format."); + } + } + + AzureOpenAIVectorizer 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 DeserializeAzureOpenAIVectorizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureOpenAIVectorizer)} does not support reading '{options.Format}' format."); } - return new AzureOpenAIVectorizer(name, kind, azureOpenAIParameters); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new AzureOpenAIVectorizer FromResponse(Response response) @@ -73,7 +140,7 @@ internal static AzureOpenAIVectorizer DeserializeAzureOpenAIVectorizer(JsonEleme internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIVectorizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIVectorizer.cs index 8e7280613ed0..c5fe1ee3ef8b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIVectorizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIVectorizer.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,13 +26,19 @@ public AzureOpenAIVectorizer(string vectorizerName) : base(vectorizerName) /// Initializes a new instance of . /// The name to associate with this particular vectorization method. /// The name of the kind of vectorization method being configured for use with vector search. + /// Keeps track of any properties unknown to the library. /// Contains the parameters specific to Azure OpenAI embedding vectorization. - internal AzureOpenAIVectorizer(string vectorizerName, VectorSearchVectorizerKind kind, AzureOpenAIVectorizerParameters parameters) : base(vectorizerName, kind) + internal AzureOpenAIVectorizer(string vectorizerName, VectorSearchVectorizerKind kind, IDictionary serializedAdditionalRawData, AzureOpenAIVectorizerParameters parameters) : base(vectorizerName, kind, serializedAdditionalRawData) { Parameters = parameters; Kind = kind; } + /// Initializes a new instance of for deserialization. + internal AzureOpenAIVectorizer() + { + } + /// Contains the parameters specific to Azure OpenAI embedding vectorization. public AzureOpenAIVectorizerParameters Parameters { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIVectorizerParameters.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIVectorizerParameters.Serialization.cs index fb61f808ea3c..f580ec36e8c1 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIVectorizerParameters.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIVectorizerParameters.Serialization.cs @@ -6,16 +6,34 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class AzureOpenAIVectorizerParameters : IUtf8JsonSerializable + public partial class AzureOpenAIVectorizerParameters : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(AzureOpenAIVectorizerParameters)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(ResourceUri)) { writer.WritePropertyName("resourceUri"u8); @@ -36,7 +54,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (AuthenticationIdentity != null) { writer.WritePropertyName("authIdentity"u8); - writer.WriteObjectValue(AuthenticationIdentity); + writer.WriteObjectValue(AuthenticationIdentity, options); } else { @@ -48,11 +66,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("modelName"u8); writer.WriteStringValue(ModelName.Value.ToString()); } - writer.WriteEndObject(); + 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 + } + } } - internal static AzureOpenAIVectorizerParameters DeserializeAzureOpenAIVectorizerParameters(JsonElement element) + AzureOpenAIVectorizerParameters 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(AzureOpenAIVectorizerParameters)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureOpenAIVectorizerParameters(document.RootElement, options); + } + + internal static AzureOpenAIVectorizerParameters DeserializeAzureOpenAIVectorizerParameters(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -62,6 +108,8 @@ internal static AzureOpenAIVectorizerParameters DeserializeAzureOpenAIVectorizer string apiKey = default; SearchIndexerDataIdentity authIdentity = default; AzureOpenAIModelName? modelName = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("resourceUri"u8)) @@ -90,7 +138,7 @@ internal static AzureOpenAIVectorizerParameters DeserializeAzureOpenAIVectorizer authIdentity = null; continue; } - authIdentity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value); + authIdentity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value, options); continue; } if (property.NameEquals("modelName"u8)) @@ -102,10 +150,52 @@ internal static AzureOpenAIVectorizerParameters DeserializeAzureOpenAIVectorizer modelName = new AzureOpenAIModelName(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AzureOpenAIVectorizerParameters( + resourceUri, + deploymentId, + apiKey, + authIdentity, + modelName, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(AzureOpenAIVectorizerParameters)} does not support writing '{options.Format}' format."); } - return new AzureOpenAIVectorizerParameters(resourceUri, deploymentId, apiKey, authIdentity, modelName); } + AzureOpenAIVectorizerParameters 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 DeserializeAzureOpenAIVectorizerParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureOpenAIVectorizerParameters)} 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 AzureOpenAIVectorizerParameters FromResponse(Response response) @@ -118,7 +208,7 @@ internal static AzureOpenAIVectorizerParameters FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIVectorizerParameters.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIVectorizerParameters.cs index 9243c5e40dfc..b6e1cc962392 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIVectorizerParameters.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureOpenAIVectorizerParameters.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Specifies the parameters for connecting to the Azure OpenAI resource. public partial class AzureOpenAIVectorizerParameters { + /// + /// 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 . public AzureOpenAIVectorizerParameters() { @@ -27,13 +60,15 @@ public AzureOpenAIVectorizerParameters() /// The available derived classes include and . /// /// The name of the embedding model that is deployed at the provided deploymentId path. - internal AzureOpenAIVectorizerParameters(Uri resourceUri, string deploymentName, string apiKey, SearchIndexerDataIdentity authenticationIdentity, AzureOpenAIModelName? modelName) + /// Keeps track of any properties unknown to the library. + internal AzureOpenAIVectorizerParameters(Uri resourceUri, string deploymentName, string apiKey, SearchIndexerDataIdentity authenticationIdentity, AzureOpenAIModelName? modelName, IDictionary serializedAdditionalRawData) { ResourceUri = resourceUri; DeploymentName = deploymentName; ApiKey = apiKey; AuthenticationIdentity = authenticationIdentity; ModelName = modelName; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The resource URI of the Azure OpenAI resource. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureSearchDocumentsContext.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureSearchDocumentsContext.cs new file mode 100644 index 000000000000..18fdda5fdc01 --- /dev/null +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/AzureSearchDocumentsContext.cs @@ -0,0 +1,291 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using Azure.Search.Documents.Agents.Models; +using Azure.Search.Documents.Indexes.Models; +using Azure.Search.Documents.Models; + +namespace Azure.Search.Documents +{ + /// + /// Context class which will be filled in by the System.ClientModel.SourceGeneration. + /// For more information see 'https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/src/docs/ModelReaderWriterContext.md' + /// + [ModelReaderWriterBuildable(typeof(AIServicesAccountIdentity))] + [ModelReaderWriterBuildable(typeof(AIServicesAccountKey))] + [ModelReaderWriterBuildable(typeof(AIServicesVisionParameters))] + [ModelReaderWriterBuildable(typeof(AIServicesVisionVectorizer))] + [ModelReaderWriterBuildable(typeof(AnalyzedTokenInfo))] + [ModelReaderWriterBuildable(typeof(AnalyzeResult))] + [ModelReaderWriterBuildable(typeof(AnalyzeTextOptions))] + [ModelReaderWriterBuildable(typeof(AsciiFoldingTokenFilter))] + [ModelReaderWriterBuildable(typeof(AutocompleteItem))] + [ModelReaderWriterBuildable(typeof(AutocompleteOptions))] + [ModelReaderWriterBuildable(typeof(AutocompleteResults))] + [ModelReaderWriterBuildable(typeof(AzureActiveDirectoryApplicationCredentials))] + [ModelReaderWriterBuildable(typeof(AzureMachineLearningParameters))] + [ModelReaderWriterBuildable(typeof(AzureMachineLearningSkill))] + [ModelReaderWriterBuildable(typeof(AzureMachineLearningVectorizer))] + [ModelReaderWriterBuildable(typeof(AzureOpenAIEmbeddingSkill))] + [ModelReaderWriterBuildable(typeof(AzureOpenAITokenizerParameters))] + [ModelReaderWriterBuildable(typeof(AzureOpenAIVectorizer))] + [ModelReaderWriterBuildable(typeof(AzureOpenAIVectorizerParameters))] + [ModelReaderWriterBuildable(typeof(BinaryQuantizationCompression))] + [ModelReaderWriterBuildable(typeof(BM25Similarity))] + [ModelReaderWriterBuildable(typeof(CharFilter))] + [ModelReaderWriterBuildable(typeof(ChatCompletionResponseFormat))] + [ModelReaderWriterBuildable(typeof(ChatCompletionResponseFormatJsonSchemaProperties))] + [ModelReaderWriterBuildable(typeof(ChatCompletionSchema))] + [ModelReaderWriterBuildable(typeof(ChatCompletionSkill))] + [ModelReaderWriterBuildable(typeof(CjkBigramTokenFilter))] + [ModelReaderWriterBuildable(typeof(ClassicSimilarity))] + [ModelReaderWriterBuildable(typeof(ClassicTokenizer))] + [ModelReaderWriterBuildable(typeof(CognitiveServicesAccount))] + [ModelReaderWriterBuildable(typeof(CognitiveServicesAccountKey))] + [ModelReaderWriterBuildable(typeof(CommonGramTokenFilter))] + [ModelReaderWriterBuildable(typeof(CommonModelParameters))] + [ModelReaderWriterBuildable(typeof(ConditionalSkill))] + [ModelReaderWriterBuildable(typeof(CorsOptions))] + [ModelReaderWriterBuildable(typeof(CustomAnalyzer))] + [ModelReaderWriterBuildable(typeof(CustomEntity))] + [ModelReaderWriterBuildable(typeof(CustomEntityAlias))] + [ModelReaderWriterBuildable(typeof(CustomEntityLookupSkill))] + [ModelReaderWriterBuildable(typeof(CustomNormalizer))] + [ModelReaderWriterBuildable(typeof(DataChangeDetectionPolicy))] + [ModelReaderWriterBuildable(typeof(DataDeletionDetectionPolicy))] + [ModelReaderWriterBuildable(typeof(DataSourceCredentials))] + [ModelReaderWriterBuildable(typeof(DebugInfo))] + [ModelReaderWriterBuildable(typeof(DefaultCognitiveServicesAccount))] + [ModelReaderWriterBuildable(typeof(DictionaryDecompounderTokenFilter))] + [ModelReaderWriterBuildable(typeof(DistanceScoringFunction))] + [ModelReaderWriterBuildable(typeof(DistanceScoringParameters))] + [ModelReaderWriterBuildable(typeof(DocumentDebugInfo))] + [ModelReaderWriterBuildable(typeof(DocumentExtractionSkill))] + [ModelReaderWriterBuildable(typeof(DocumentIntelligenceLayoutSkill))] + [ModelReaderWriterBuildable(typeof(DocumentIntelligenceLayoutSkillChunkingProperties))] + [ModelReaderWriterBuildable(typeof(EdgeNGramTokenFilter))] + [ModelReaderWriterBuildable(typeof(EdgeNGramTokenizer))] + [ModelReaderWriterBuildable(typeof(ElisionTokenFilter))] + [ModelReaderWriterBuildable(typeof(EntityLinkingSkill))] + [ModelReaderWriterBuildable(typeof(EntityRecognitionSkill))] + [ModelReaderWriterBuildable(typeof(EntityRecognitionSkillV3))] + [ModelReaderWriterBuildable(typeof(ErrorAdditionalInfo))] + [ModelReaderWriterBuildable(typeof(ErrorDetail))] + [ModelReaderWriterBuildable(typeof(ErrorResponse))] + [ModelReaderWriterBuildable(typeof(ExhaustiveKnnAlgorithmConfiguration))] + [ModelReaderWriterBuildable(typeof(ExhaustiveKnnParameters))] + [ModelReaderWriterBuildable(typeof(FacetResult))] + [ModelReaderWriterBuildable(typeof(FieldMapping))] + [ModelReaderWriterBuildable(typeof(FieldMappingFunction))] + [ModelReaderWriterBuildable(typeof(FreshnessScoringFunction))] + [ModelReaderWriterBuildable(typeof(FreshnessScoringParameters))] + [ModelReaderWriterBuildable(typeof(HighWaterMarkChangeDetectionPolicy))] + [ModelReaderWriterBuildable(typeof(HnswAlgorithmConfiguration))] + [ModelReaderWriterBuildable(typeof(HnswParameters))] + [ModelReaderWriterBuildable(typeof(HybridSearch))] + [ModelReaderWriterBuildable(typeof(ImageAnalysisSkill))] + [ModelReaderWriterBuildable(typeof(IndexAction))] + [ModelReaderWriterBuildable(typeof(IndexBatch))] + [ModelReaderWriterBuildable(typeof(IndexDocumentsResult))] + [ModelReaderWriterBuildable(typeof(IndexerExecutionResult))] + [ModelReaderWriterBuildable(typeof(IndexerResyncBody))] + [ModelReaderWriterBuildable(typeof(IndexerState))] + [ModelReaderWriterBuildable(typeof(IndexingParameters))] + [ModelReaderWriterBuildable(typeof(IndexingParametersConfiguration))] + [ModelReaderWriterBuildable(typeof(IndexingResult))] + [ModelReaderWriterBuildable(typeof(IndexingSchedule))] + [ModelReaderWriterBuildable(typeof(IndexStatisticsSummary))] + [ModelReaderWriterBuildable(typeof(InputFieldMappingEntry))] + [ModelReaderWriterBuildable(typeof(KeepTokenFilter))] + [ModelReaderWriterBuildable(typeof(KeyPhraseExtractionSkill))] + [ModelReaderWriterBuildable(typeof(KeywordMarkerTokenFilter))] + [ModelReaderWriterBuildable(typeof(KeywordTokenizer))] + [ModelReaderWriterBuildable(typeof(KnowledgeAgent))] + [ModelReaderWriterBuildable(typeof(KnowledgeAgentActivityRecord))] + [ModelReaderWriterBuildable(typeof(KnowledgeAgentAzureOpenAIModel))] + [ModelReaderWriterBuildable(typeof(KnowledgeAgentAzureSearchDocReference))] + [ModelReaderWriterBuildable(typeof(KnowledgeAgentIndexParams))] + [ModelReaderWriterBuildable(typeof(KnowledgeAgentMessage))] + [ModelReaderWriterBuildable(typeof(KnowledgeAgentMessageContent))] + [ModelReaderWriterBuildable(typeof(KnowledgeAgentMessageImageContent))] + [ModelReaderWriterBuildable(typeof(KnowledgeAgentMessageImageContentImage))] + [ModelReaderWriterBuildable(typeof(KnowledgeAgentMessageTextContent))] + [ModelReaderWriterBuildable(typeof(KnowledgeAgentModel))] + [ModelReaderWriterBuildable(typeof(KnowledgeAgentModelQueryPlanningActivityRecord))] + [ModelReaderWriterBuildable(typeof(KnowledgeAgentReference))] + [ModelReaderWriterBuildable(typeof(KnowledgeAgentRequestLimits))] + [ModelReaderWriterBuildable(typeof(KnowledgeAgentRetrievalRequest))] + [ModelReaderWriterBuildable(typeof(KnowledgeAgentRetrievalResponse))] + [ModelReaderWriterBuildable(typeof(KnowledgeAgentSearchActivityRecord))] + [ModelReaderWriterBuildable(typeof(KnowledgeAgentSearchActivityRecordQuery))] + [ModelReaderWriterBuildable(typeof(KnowledgeAgentSemanticRankerActivityRecord))] + [ModelReaderWriterBuildable(typeof(KnowledgeAgentTargetIndex))] + [ModelReaderWriterBuildable(typeof(KnowledgeStore))] + [ModelReaderWriterBuildable(typeof(KnowledgeStoreFileProjectionSelector))] + [ModelReaderWriterBuildable(typeof(KnowledgeStoreObjectProjectionSelector))] + [ModelReaderWriterBuildable(typeof(KnowledgeStoreProjection))] + [ModelReaderWriterBuildable(typeof(KnowledgeStoreProjectionSelector))] + [ModelReaderWriterBuildable(typeof(KnowledgeStoreStorageProjectionSelector))] + [ModelReaderWriterBuildable(typeof(KnowledgeStoreTableProjectionSelector))] + [ModelReaderWriterBuildable(typeof(LanguageDetectionSkill))] + [ModelReaderWriterBuildable(typeof(LengthTokenFilter))] + [ModelReaderWriterBuildable(typeof(LexicalAnalyzer))] + [ModelReaderWriterBuildable(typeof(LexicalNormalizer))] + [ModelReaderWriterBuildable(typeof(LexicalTokenizer))] + [ModelReaderWriterBuildable(typeof(LimitTokenFilter))] + [ModelReaderWriterBuildable(typeof(ListAliasesResult))] + [ModelReaderWriterBuildable(typeof(ListDataSourcesResult))] + [ModelReaderWriterBuildable(typeof(ListIndexersResult))] + [ModelReaderWriterBuildable(typeof(ListIndexesResult))] + [ModelReaderWriterBuildable(typeof(ListIndexStatsSummary))] + [ModelReaderWriterBuildable(typeof(ListKnowledgeAgentsResult))] + [ModelReaderWriterBuildable(typeof(ListSkillsetsResult))] + [ModelReaderWriterBuildable(typeof(ListSynonymMapsResult))] + [ModelReaderWriterBuildable(typeof(LuceneStandardAnalyzer))] + [ModelReaderWriterBuildable(typeof(LuceneStandardTokenizer))] + [ModelReaderWriterBuildable(typeof(MagnitudeScoringFunction))] + [ModelReaderWriterBuildable(typeof(MagnitudeScoringParameters))] + [ModelReaderWriterBuildable(typeof(MappingCharFilter))] + [ModelReaderWriterBuildable(typeof(MergeSkill))] + [ModelReaderWriterBuildable(typeof(MicrosoftLanguageStemmingTokenizer))] + [ModelReaderWriterBuildable(typeof(MicrosoftLanguageTokenizer))] + [ModelReaderWriterBuildable(typeof(NativeBlobSoftDeleteDeletionDetectionPolicy))] + [ModelReaderWriterBuildable(typeof(NGramTokenFilter))] + [ModelReaderWriterBuildable(typeof(NGramTokenizer))] + [ModelReaderWriterBuildable(typeof(OcrSkill))] + [ModelReaderWriterBuildable(typeof(OutputFieldMappingEntry))] + [ModelReaderWriterBuildable(typeof(PathHierarchyTokenizer))] + [ModelReaderWriterBuildable(typeof(PatternAnalyzer))] + [ModelReaderWriterBuildable(typeof(PatternCaptureTokenFilter))] + [ModelReaderWriterBuildable(typeof(PatternReplaceCharFilter))] + [ModelReaderWriterBuildable(typeof(PatternReplaceTokenFilter))] + [ModelReaderWriterBuildable(typeof(PatternTokenizer))] + [ModelReaderWriterBuildable(typeof(PhoneticTokenFilter))] + [ModelReaderWriterBuildable(typeof(PiiDetectionSkill))] + [ModelReaderWriterBuildable(typeof(QueryAnswerResult))] + [ModelReaderWriterBuildable(typeof(QueryCaptionResult))] + [ModelReaderWriterBuildable(typeof(QueryResultDocumentInnerHit))] + [ModelReaderWriterBuildable(typeof(QueryResultDocumentRerankerInput))] + [ModelReaderWriterBuildable(typeof(QueryResultDocumentSemanticField))] + [ModelReaderWriterBuildable(typeof(QueryResultDocumentSubscores))] + [ModelReaderWriterBuildable(typeof(QueryRewritesDebugInfo))] + [ModelReaderWriterBuildable(typeof(QueryRewritesValuesDebugInfo))] + [ModelReaderWriterBuildable(typeof(RescoringOptions))] + [ModelReaderWriterBuildable(typeof(ResetDocumentOptions))] + [ModelReaderWriterBuildable(typeof(ResetSkillsOptions))] + [ModelReaderWriterBuildable(typeof(ScalarQuantizationCompression))] + [ModelReaderWriterBuildable(typeof(ScalarQuantizationParameters))] + [ModelReaderWriterBuildable(typeof(ScoringFunction))] + [ModelReaderWriterBuildable(typeof(ScoringProfile))] + [ModelReaderWriterBuildable(typeof(SearchAlias))] + [ModelReaderWriterBuildable(typeof(SearchDocumentsResult))] + [ModelReaderWriterBuildable(typeof(SearchField))] + [ModelReaderWriterBuildable(typeof(SearchIndex))] + [ModelReaderWriterBuildable(typeof(SearchIndexer))] + [ModelReaderWriterBuildable(typeof(SearchIndexerCache))] + [ModelReaderWriterBuildable(typeof(SearchIndexerDataContainer))] + [ModelReaderWriterBuildable(typeof(SearchIndexerDataIdentity))] + [ModelReaderWriterBuildable(typeof(SearchIndexerDataNoneIdentity))] + [ModelReaderWriterBuildable(typeof(SearchIndexerDataSourceConnection))] + [ModelReaderWriterBuildable(typeof(SearchIndexerDataUserAssignedIdentity))] + [ModelReaderWriterBuildable(typeof(SearchIndexerError))] + [ModelReaderWriterBuildable(typeof(SearchIndexerIndexProjection))] + [ModelReaderWriterBuildable(typeof(SearchIndexerIndexProjectionSelector))] + [ModelReaderWriterBuildable(typeof(SearchIndexerIndexProjectionsParameters))] + [ModelReaderWriterBuildable(typeof(SearchIndexerKnowledgeStoreParameters))] + [ModelReaderWriterBuildable(typeof(SearchIndexerLimits))] + [ModelReaderWriterBuildable(typeof(SearchIndexerSkill))] + [ModelReaderWriterBuildable(typeof(SearchIndexerSkillset))] + [ModelReaderWriterBuildable(typeof(SearchIndexerStatus))] + [ModelReaderWriterBuildable(typeof(SearchIndexerWarning))] + [ModelReaderWriterBuildable(typeof(SearchIndexStatistics))] + [ModelReaderWriterBuildable(typeof(SearchOptions))] + [ModelReaderWriterBuildable(typeof(SearchResourceCounter))] + [ModelReaderWriterBuildable(typeof(SearchResourceEncryptionKey))] + [ModelReaderWriterBuildable(typeof(SearchResult))] + [ModelReaderWriterBuildable(typeof(SearchScoreThreshold))] + [ModelReaderWriterBuildable(typeof(SearchServiceCounters))] + [ModelReaderWriterBuildable(typeof(SearchServiceLimits))] + [ModelReaderWriterBuildable(typeof(SearchServiceStatistics))] + [ModelReaderWriterBuildable(typeof(SearchSuggester))] + [ModelReaderWriterBuildable(typeof(SemanticConfiguration))] + [ModelReaderWriterBuildable(typeof(SemanticDebugInfo))] + [ModelReaderWriterBuildable(typeof(SemanticField))] + [ModelReaderWriterBuildable(typeof(SemanticPrioritizedFields))] + [ModelReaderWriterBuildable(typeof(SemanticSearch))] + [ModelReaderWriterBuildable(typeof(SentimentSkill))] + [ModelReaderWriterBuildable(typeof(SentimentSkillV3))] + [ModelReaderWriterBuildable(typeof(ShaperSkill))] + [ModelReaderWriterBuildable(typeof(ShingleTokenFilter))] + [ModelReaderWriterBuildable(typeof(SimilarityAlgorithm))] + [ModelReaderWriterBuildable(typeof(SingleVectorFieldResult))] + [ModelReaderWriterBuildable(typeof(SnowballTokenFilter))] + [ModelReaderWriterBuildable(typeof(SoftDeleteColumnDeletionDetectionPolicy))] + [ModelReaderWriterBuildable(typeof(SplitSkill))] + [ModelReaderWriterBuildable(typeof(SqlIntegratedChangeTrackingPolicy))] + [ModelReaderWriterBuildable(typeof(StemmerOverrideTokenFilter))] + [ModelReaderWriterBuildable(typeof(StemmerTokenFilter))] + [ModelReaderWriterBuildable(typeof(StopAnalyzer))] + [ModelReaderWriterBuildable(typeof(StopwordsTokenFilter))] + [ModelReaderWriterBuildable(typeof(SuggestDocumentsResult))] + [ModelReaderWriterBuildable(typeof(SuggestOptions))] + [ModelReaderWriterBuildable(typeof(SuggestResult))] + [ModelReaderWriterBuildable(typeof(SynonymMap))] + [ModelReaderWriterBuildable(typeof(SynonymTokenFilter))] + [ModelReaderWriterBuildable(typeof(TagScoringFunction))] + [ModelReaderWriterBuildable(typeof(TagScoringParameters))] + [ModelReaderWriterBuildable(typeof(TextResult))] + [ModelReaderWriterBuildable(typeof(TextTranslationSkill))] + [ModelReaderWriterBuildable(typeof(TextWeights))] + [ModelReaderWriterBuildable(typeof(TokenFilter))] + [ModelReaderWriterBuildable(typeof(TruncateTokenFilter))] + [ModelReaderWriterBuildable(typeof(UaxUrlEmailTokenizer))] + [ModelReaderWriterBuildable(typeof(UniqueTokenFilter))] + [ModelReaderWriterBuildable(typeof(UnknownCharFilter))] + [ModelReaderWriterBuildable(typeof(UnknownCognitiveServicesAccount))] + [ModelReaderWriterBuildable(typeof(UnknownDataChangeDetectionPolicy))] + [ModelReaderWriterBuildable(typeof(UnknownDataDeletionDetectionPolicy))] + [ModelReaderWriterBuildable(typeof(UnknownKnowledgeAgentActivityRecord))] + [ModelReaderWriterBuildable(typeof(UnknownKnowledgeAgentMessageContent))] + [ModelReaderWriterBuildable(typeof(UnknownKnowledgeAgentModel))] + [ModelReaderWriterBuildable(typeof(UnknownKnowledgeAgentReference))] + [ModelReaderWriterBuildable(typeof(UnknownLexicalAnalyzer))] + [ModelReaderWriterBuildable(typeof(UnknownLexicalNormalizer))] + [ModelReaderWriterBuildable(typeof(UnknownLexicalTokenizer))] + [ModelReaderWriterBuildable(typeof(UnknownScoringFunction))] + [ModelReaderWriterBuildable(typeof(UnknownSearchIndexerDataIdentity))] + [ModelReaderWriterBuildable(typeof(UnknownSearchIndexerSkill))] + [ModelReaderWriterBuildable(typeof(UnknownSimilarity))] + [ModelReaderWriterBuildable(typeof(UnknownTokenFilter))] + [ModelReaderWriterBuildable(typeof(UnknownVectorQuery))] + [ModelReaderWriterBuildable(typeof(UnknownVectorSearchAlgorithmConfiguration))] + [ModelReaderWriterBuildable(typeof(UnknownVectorSearchCompression))] + [ModelReaderWriterBuildable(typeof(UnknownVectorSearchVectorizer))] + [ModelReaderWriterBuildable(typeof(UnknownVectorThreshold))] + [ModelReaderWriterBuildable(typeof(VectorizableImageBinaryQuery))] + [ModelReaderWriterBuildable(typeof(VectorizableImageUrlQuery))] + [ModelReaderWriterBuildable(typeof(VectorizableTextQuery))] + [ModelReaderWriterBuildable(typeof(VectorizedQuery))] + [ModelReaderWriterBuildable(typeof(VectorQuery))] + [ModelReaderWriterBuildable(typeof(VectorsDebugInfo))] + [ModelReaderWriterBuildable(typeof(VectorSearch))] + [ModelReaderWriterBuildable(typeof(VectorSearchAlgorithmConfiguration))] + [ModelReaderWriterBuildable(typeof(VectorSearchCompression))] + [ModelReaderWriterBuildable(typeof(VectorSearchProfile))] + [ModelReaderWriterBuildable(typeof(VectorSearchVectorizer))] + [ModelReaderWriterBuildable(typeof(VectorSimilarityThreshold))] + [ModelReaderWriterBuildable(typeof(VectorThreshold))] + [ModelReaderWriterBuildable(typeof(VisionVectorizeSkill))] + [ModelReaderWriterBuildable(typeof(WebApiSkill))] + [ModelReaderWriterBuildable(typeof(WebApiVectorizer))] + [ModelReaderWriterBuildable(typeof(WebApiVectorizerParameters))] + [ModelReaderWriterBuildable(typeof(WordDelimiterTokenFilter))] + public partial class AzureSearchDocumentsContext : ModelReaderWriterContext + { + } +} diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/BM25Similarity.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/BM25Similarity.Serialization.cs index f1aa6740169c..bbbfb18bbc14 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/BM25Similarity.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/BM25Similarity.Serialization.cs @@ -5,16 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class BM25Similarity : IUtf8JsonSerializable + public partial class BM25Similarity : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(BM25Similarity)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(K1)) { if (K1 != null) @@ -39,13 +59,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("b"); } } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WriteEndObject(); } - internal static BM25Similarity DeserializeBM25Similarity(JsonElement element) + BM25Similarity 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(BM25Similarity)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBM25Similarity(document.RootElement, options); + } + + internal static BM25Similarity DeserializeBM25Similarity(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -53,6 +84,8 @@ internal static BM25Similarity DeserializeBM25Similarity(JsonElement element) double? k1 = default; double? b = default; string odataType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("k1"u8)) @@ -80,10 +113,46 @@ internal static BM25Similarity DeserializeBM25Similarity(JsonElement element) odataType = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BM25Similarity(odataType, serializedAdditionalRawData, k1, b); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(BM25Similarity)} does not support writing '{options.Format}' format."); + } + } + + BM25Similarity 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 DeserializeBM25Similarity(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BM25Similarity)} does not support reading '{options.Format}' format."); } - return new BM25Similarity(odataType, k1, b); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new BM25Similarity FromResponse(Response response) @@ -96,7 +165,7 @@ internal static BM25Similarity DeserializeBM25Similarity(JsonElement element) internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/BM25Similarity.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/BM25Similarity.cs index c6e8036edf53..7a040475ba24 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/BM25Similarity.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/BM25Similarity.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Ranking function based on the Okapi BM25 similarity algorithm. BM25 is a TF-IDF-like algorithm that includes length normalization (controlled by the 'b' parameter) as well as term frequency saturation (controlled by the 'k1' parameter). @@ -18,9 +21,10 @@ public BM25Similarity() /// Initializes a new instance of . /// + /// Keeps track of any properties unknown to the library. /// This property controls the scaling function between the term frequency of each matching terms and the final relevance score of a document-query pair. By default, a value of 1.2 is used. A value of 0.0 means the score does not scale with an increase in term frequency. /// This property controls how the length of a document affects the relevance score. By default, a value of 0.75 is used. A value of 0.0 means no length normalization is applied, while a value of 1.0 means the score is fully normalized by the length of the document. - internal BM25Similarity(string oDataType, double? k1, double? b) : base(oDataType) + internal BM25Similarity(string oDataType, IDictionary serializedAdditionalRawData, double? k1, double? b) : base(oDataType, serializedAdditionalRawData) { K1 = k1; B = b; diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/BinaryQuantizationCompression.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/BinaryQuantizationCompression.Serialization.cs index 6f3e9bfd4a8a..60c5ce91f39e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/BinaryQuantizationCompression.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/BinaryQuantizationCompression.Serialization.cs @@ -5,73 +5,54 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class BinaryQuantizationCompression : IUtf8JsonSerializable + public partial class BinaryQuantizationCompression : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(CompressionName); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); - if (Optional.IsDefined(RerankWithOriginalVectors)) + 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") { - if (RerankWithOriginalVectors != null) - { - writer.WritePropertyName("rerankWithOriginalVectors"u8); - writer.WriteBooleanValue(RerankWithOriginalVectors.Value); - } - else - { - writer.WriteNull("rerankWithOriginalVectors"); - } + throw new FormatException($"The model {nameof(BinaryQuantizationCompression)} does not support writing '{format}' format."); } - if (Optional.IsDefined(DefaultOversampling)) - { - if (DefaultOversampling != null) - { - writer.WritePropertyName("defaultOversampling"u8); - writer.WriteNumberValue(DefaultOversampling.Value); - } - else - { - writer.WriteNull("defaultOversampling"); - } - } - if (Optional.IsDefined(RescoringOptions)) + + base.JsonModelWriteCore(writer, options); + } + + BinaryQuantizationCompression IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - if (RescoringOptions != null) - { - writer.WritePropertyName("rescoringOptions"u8); - writer.WriteObjectValue(RescoringOptions); - } - else - { - writer.WriteNull("rescoringOptions"); - } + throw new FormatException($"The model {nameof(BinaryQuantizationCompression)} does not support reading '{format}' format."); } - if (Optional.IsDefined(TruncationDimension)) - { - if (TruncationDimension != null) - { - writer.WritePropertyName("truncationDimension"u8); - writer.WriteNumberValue(TruncationDimension.Value); - } - else - { - writer.WriteNull("truncationDimension"); - } - } - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBinaryQuantizationCompression(document.RootElement, options); } - internal static BinaryQuantizationCompression DeserializeBinaryQuantizationCompression(JsonElement element) + internal static BinaryQuantizationCompression DeserializeBinaryQuantizationCompression(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -82,6 +63,8 @@ internal static BinaryQuantizationCompression DeserializeBinaryQuantizationCompr double? defaultOversampling = default; RescoringOptions rescoringOptions = default; int? truncationDimension = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -121,7 +104,7 @@ internal static BinaryQuantizationCompression DeserializeBinaryQuantizationCompr rescoringOptions = null; continue; } - rescoringOptions = RescoringOptions.DeserializeRescoringOptions(property.Value); + rescoringOptions = RescoringOptions.DeserializeRescoringOptions(property.Value, options); continue; } if (property.NameEquals("truncationDimension"u8)) @@ -134,16 +117,53 @@ internal static BinaryQuantizationCompression DeserializeBinaryQuantizationCompr truncationDimension = property.Value.GetInt32(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new BinaryQuantizationCompression( name, kind, rerankWithOriginalVectors, defaultOversampling, rescoringOptions, - truncationDimension); + truncationDimension, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(BinaryQuantizationCompression)} does not support writing '{options.Format}' format."); + } + } + + BinaryQuantizationCompression 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 DeserializeBinaryQuantizationCompression(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BinaryQuantizationCompression)} 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 BinaryQuantizationCompression FromResponse(Response response) @@ -156,7 +176,7 @@ internal static BinaryQuantizationCompression DeserializeBinaryQuantizationCompr internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/BinaryQuantizationCompression.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/BinaryQuantizationCompression.cs index fc8caec0912b..221a09c1c146 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/BinaryQuantizationCompression.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/BinaryQuantizationCompression.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -29,9 +30,15 @@ public BinaryQuantizationCompression(string compressionName) : base(compressionN /// Default oversampling factor. Oversampling will internally request more documents (specified by this multiplier) in the initial search. This increases the set of results that will be reranked using recomputed similarity scores from full-precision vectors. Minimum value is 1, meaning no oversampling (1x). This parameter can only be set when rerankWithOriginalVectors is true. Higher values improve recall at the expense of latency. /// Contains the options for rescoring. /// The number of dimensions to truncate the vectors to. Truncating the vectors reduces the size of the vectors and the amount of data that needs to be transferred during search. This can save storage cost and improve search performance at the expense of recall. It should be only used for embeddings trained with Matryoshka Representation Learning (MRL) such as OpenAI text-embedding-3-large (small). The default value is null, which means no truncation. - internal BinaryQuantizationCompression(string compressionName, VectorSearchCompressionKind kind, bool? rerankWithOriginalVectors, double? defaultOversampling, RescoringOptions rescoringOptions, int? truncationDimension) : base(compressionName, kind, rerankWithOriginalVectors, defaultOversampling, rescoringOptions, truncationDimension) + /// Keeps track of any properties unknown to the library. + internal BinaryQuantizationCompression(string compressionName, VectorSearchCompressionKind kind, bool? rerankWithOriginalVectors, double? defaultOversampling, RescoringOptions rescoringOptions, int? truncationDimension, IDictionary serializedAdditionalRawData) : base(compressionName, kind, rerankWithOriginalVectors, defaultOversampling, rescoringOptions, truncationDimension, serializedAdditionalRawData) { Kind = kind; } + + /// Initializes a new instance of for deserialization. + internal BinaryQuantizationCompression() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CharFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CharFilter.Serialization.cs index 8e2616ac76b0..4725cb91b3bc 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CharFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CharFilter.Serialization.cs @@ -5,26 +5,72 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Indexes.Models { - public partial class CharFilter : IUtf8JsonSerializable + public partial class CharFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(CharFilter)} does not support writing '{format}' format."); + } + writer.WritePropertyName("@odata.type"u8); writer.WriteStringValue(ODataType); writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); - writer.WriteEndObject(); + 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 + } + } } - internal static CharFilter DeserializeCharFilter(JsonElement element) + CharFilter 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(CharFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCharFilter(document.RootElement, options); + } + + internal static CharFilter DeserializeCharFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -33,13 +79,44 @@ internal static CharFilter DeserializeCharFilter(JsonElement element) { switch (discriminator.GetString()) { - case "#Microsoft.Azure.Search.MappingCharFilter": return MappingCharFilter.DeserializeMappingCharFilter(element); - case "#Microsoft.Azure.Search.PatternReplaceCharFilter": return PatternReplaceCharFilter.DeserializePatternReplaceCharFilter(element); + case "#Microsoft.Azure.Search.MappingCharFilter": return MappingCharFilter.DeserializeMappingCharFilter(element, options); + case "#Microsoft.Azure.Search.PatternReplaceCharFilter": return PatternReplaceCharFilter.DeserializePatternReplaceCharFilter(element, options); } } - return UnknownCharFilter.DeserializeUnknownCharFilter(element); + return UnknownCharFilter.DeserializeUnknownCharFilter(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(CharFilter)} does not support writing '{options.Format}' format."); + } + } + + CharFilter 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 DeserializeCharFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CharFilter)} 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 CharFilter FromResponse(Response response) @@ -52,7 +129,7 @@ internal static CharFilter FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CharFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CharFilter.cs index 151e721c598c..159b9017b4b2 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CharFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CharFilter.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -16,13 +17,52 @@ namespace Azure.Search.Documents.Indexes.Models /// public partial class CharFilter { + /// + /// 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 . /// A URI fragment specifying the type of char filter. /// The name of the char filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - internal CharFilter(string oDataType, string name) + /// Keeps track of any properties unknown to the library. + internal CharFilter(string oDataType, string name, IDictionary serializedAdditionalRawData) { ODataType = oDataType; Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CharFilter() + { } /// A URI fragment specifying the type of char filter. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionResponseFormat.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionResponseFormat.Serialization.cs index 9eccc2a587d4..1ee86b8b12cc 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionResponseFormat.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionResponseFormat.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Indexes.Models { - public partial class ChatCompletionResponseFormat : IUtf8JsonSerializable + public partial class ChatCompletionResponseFormat : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(ChatCompletionResponseFormat)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Type)) { writer.WritePropertyName("type"u8); @@ -26,24 +45,54 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (ChatCompletionSchemaProperties != null) { writer.WritePropertyName("jsonSchemaProperties"u8); - writer.WriteObjectValue(ChatCompletionSchemaProperties); + writer.WriteObjectValue(ChatCompletionSchemaProperties, options); } else { writer.WriteNull("jsonSchemaProperties"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static ChatCompletionResponseFormat DeserializeChatCompletionResponseFormat(JsonElement element) + ChatCompletionResponseFormat 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(ChatCompletionResponseFormat)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatCompletionResponseFormat(document.RootElement, options); + } + + internal static ChatCompletionResponseFormat DeserializeChatCompletionResponseFormat(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } ChatCompletionResponseFormatType? type = default; ChatCompletionResponseFormatJsonSchemaProperties jsonSchemaProperties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("type"u8)) @@ -62,13 +111,49 @@ internal static ChatCompletionResponseFormat DeserializeChatCompletionResponseFo jsonSchemaProperties = null; continue; } - jsonSchemaProperties = ChatCompletionResponseFormatJsonSchemaProperties.DeserializeChatCompletionResponseFormatJsonSchemaProperties(property.Value); + jsonSchemaProperties = ChatCompletionResponseFormatJsonSchemaProperties.DeserializeChatCompletionResponseFormatJsonSchemaProperties(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ChatCompletionResponseFormat(type, jsonSchemaProperties, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ChatCompletionResponseFormat)} does not support writing '{options.Format}' format."); } - return new ChatCompletionResponseFormat(type, jsonSchemaProperties); } + ChatCompletionResponseFormat 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 DeserializeChatCompletionResponseFormat(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatCompletionResponseFormat)} 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 ChatCompletionResponseFormat FromResponse(Response response) @@ -81,7 +166,7 @@ internal static ChatCompletionResponseFormat FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionResponseFormat.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionResponseFormat.cs index 69b584b748b0..1e9b55cfdc3f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionResponseFormat.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionResponseFormat.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Indexes.Models @@ -12,6 +14,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Determines how the language model's response should be serialized. Defaults to 'text'. public partial class ChatCompletionResponseFormat { + /// + /// 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 ChatCompletionResponseFormat() { @@ -20,10 +54,12 @@ public ChatCompletionResponseFormat() /// Initializes a new instance of . /// Specifies how the LLM should format the response. Possible values: 'text' (plain string), 'json_object' (arbitrary JSON), or 'json_schema' (adheres to provided schema). /// An open dictionary for extended properties. Required if 'type' == 'json_schema'. - internal ChatCompletionResponseFormat(ChatCompletionResponseFormatType? type, ChatCompletionResponseFormatJsonSchemaProperties chatCompletionSchemaProperties) + /// Keeps track of any properties unknown to the library. + internal ChatCompletionResponseFormat(ChatCompletionResponseFormatType? type, ChatCompletionResponseFormatJsonSchemaProperties chatCompletionSchemaProperties, IDictionary serializedAdditionalRawData) { Type = type; ChatCompletionSchemaProperties = chatCompletionSchemaProperties; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Specifies how the LLM should format the response. Possible values: 'text' (plain string), 'json_object' (arbitrary JSON), or 'json_schema' (adheres to provided schema). diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionResponseFormatJsonSchemaProperties.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionResponseFormatJsonSchemaProperties.Serialization.cs index 9b4cd8bfc4c4..e553c96be4db 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionResponseFormatJsonSchemaProperties.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionResponseFormatJsonSchemaProperties.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models { - public partial class ChatCompletionResponseFormatJsonSchemaProperties : IUtf8JsonSerializable + public partial class ChatCompletionResponseFormatJsonSchemaProperties : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(ChatCompletionResponseFormatJsonSchemaProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Name)) { if (Name != null) @@ -50,18 +69,46 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Schema != null) { writer.WritePropertyName("schema"u8); - writer.WriteObjectValue(Schema); + writer.WriteObjectValue(Schema, options); } else { writer.WriteNull("schema"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static ChatCompletionResponseFormatJsonSchemaProperties DeserializeChatCompletionResponseFormatJsonSchemaProperties(JsonElement element) + ChatCompletionResponseFormatJsonSchemaProperties 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(ChatCompletionResponseFormatJsonSchemaProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatCompletionResponseFormatJsonSchemaProperties(document.RootElement, options); + } + + internal static ChatCompletionResponseFormatJsonSchemaProperties DeserializeChatCompletionResponseFormatJsonSchemaProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -70,6 +117,8 @@ internal static ChatCompletionResponseFormatJsonSchemaProperties DeserializeChat string description = default; bool? strict = default; ChatCompletionSchema schema = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -108,13 +157,49 @@ internal static ChatCompletionResponseFormatJsonSchemaProperties DeserializeChat schema = null; continue; } - schema = ChatCompletionSchema.DeserializeChatCompletionSchema(property.Value); + schema = ChatCompletionSchema.DeserializeChatCompletionSchema(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ChatCompletionResponseFormatJsonSchemaProperties(name, description, strict, schema, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ChatCompletionResponseFormatJsonSchemaProperties)} does not support writing '{options.Format}' format."); } - return new ChatCompletionResponseFormatJsonSchemaProperties(name, description, strict, schema); } + ChatCompletionResponseFormatJsonSchemaProperties 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 DeserializeChatCompletionResponseFormatJsonSchemaProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatCompletionResponseFormatJsonSchemaProperties)} 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 ChatCompletionResponseFormatJsonSchemaProperties FromResponse(Response response) @@ -127,7 +212,7 @@ internal static ChatCompletionResponseFormatJsonSchemaProperties FromResponse(Re internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionResponseFormatJsonSchemaProperties.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionResponseFormatJsonSchemaProperties.cs index ee2a8100b60c..08a49f0c2e4a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionResponseFormatJsonSchemaProperties.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionResponseFormatJsonSchemaProperties.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models @@ -12,6 +14,38 @@ namespace Azure.Search.Documents.Models /// An open dictionary for extended properties. Required if 'type' == 'json_schema'. public partial class ChatCompletionResponseFormatJsonSchemaProperties { + /// + /// 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 ChatCompletionResponseFormatJsonSchemaProperties() { @@ -22,12 +56,14 @@ public ChatCompletionResponseFormatJsonSchemaProperties() /// Description of the json schema the model will adhere to. /// Whether or not the model's response should use structured outputs. Default is true. /// Object defining the custom schema the model will use to structure its output. - internal ChatCompletionResponseFormatJsonSchemaProperties(string name, string description, bool? strict, ChatCompletionSchema schema) + /// Keeps track of any properties unknown to the library. + internal ChatCompletionResponseFormatJsonSchemaProperties(string name, string description, bool? strict, ChatCompletionSchema schema, IDictionary serializedAdditionalRawData) { Name = name; Description = description; Strict = strict; Schema = schema; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Name of the json schema the model will adhere to. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionSchema.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionSchema.Serialization.cs index 9078adc11e52..bd7588c995a0 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionSchema.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionSchema.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class ChatCompletionSchema : IUtf8JsonSerializable + public partial class ChatCompletionSchema : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(ChatCompletionSchema)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Type)) { writer.WritePropertyName("type"u8); @@ -41,11 +59,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("additionalProperties"u8); writer.WriteBooleanValue(AdditionalProperties.Value); } - writer.WriteEndObject(); + 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 + } + } } - internal static ChatCompletionSchema DeserializeChatCompletionSchema(JsonElement element) + ChatCompletionSchema 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(ChatCompletionSchema)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatCompletionSchema(document.RootElement, options); + } + + internal static ChatCompletionSchema DeserializeChatCompletionSchema(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -54,6 +100,8 @@ internal static ChatCompletionSchema DeserializeChatCompletionSchema(JsonElement string properties = default; IList required = default; bool? additionalProperties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("type"u8)) @@ -89,10 +137,46 @@ internal static ChatCompletionSchema DeserializeChatCompletionSchema(JsonElement additionalProperties = property.Value.GetBoolean(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ChatCompletionSchema(type, properties, required ?? new ChangeTrackingList(), additionalProperties, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ChatCompletionSchema)} does not support writing '{options.Format}' format."); } - return new ChatCompletionSchema(type, properties, required ?? new ChangeTrackingList(), additionalProperties); } + ChatCompletionSchema 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 DeserializeChatCompletionSchema(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatCompletionSchema)} 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 ChatCompletionSchema FromResponse(Response response) @@ -105,7 +189,7 @@ internal static ChatCompletionSchema FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionSchema.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionSchema.cs index a5216aa5d7d0..4023ab1d1e85 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionSchema.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionSchema.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models @@ -12,6 +13,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Object defining the custom schema the model will use to structure its output. public partial class ChatCompletionSchema { + /// + /// 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 ChatCompletionSchema() { @@ -23,12 +56,14 @@ public ChatCompletionSchema() /// A JSON-formatted string that defines the output schema's properties and constraints for the model. /// An array of the property names that are required to be part of the model's response. All properties must be included for structured outputs. /// Controls whether it is allowable for an object to contain additional keys / values that were not defined in the JSON Schema. Default is false. - internal ChatCompletionSchema(string type, string properties, IList required, bool? additionalProperties) + /// Keeps track of any properties unknown to the library. + internal ChatCompletionSchema(string type, string properties, IList required, bool? additionalProperties, IDictionary serializedAdditionalRawData) { Type = type; Properties = properties; Required = required; AdditionalProperties = additionalProperties; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Type of schema representation. Usually 'object'. Default is 'object'. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionSkill.Serialization.cs index 712aefac920a..519e6ce80411 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionSkill.Serialization.cs @@ -6,17 +6,35 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class ChatCompletionSkill : IUtf8JsonSerializable + public partial class ChatCompletionSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(ChatCompletionSkill)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(ApiKey)) { writer.WritePropertyName("apiKey"u8); @@ -25,7 +43,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(CommonModelParameters)) { writer.WritePropertyName("commonModelParameters"u8); - writer.WriteObjectValue(CommonModelParameters); + writer.WriteObjectValue(CommonModelParameters, options); } if (Optional.IsCollectionDefined(ExtraParameters)) { @@ -41,7 +59,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNullValue(); continue; } - writer.WriteObjectValue(item.Value); + writer.WriteObjectValue(item.Value, options); } writer.WriteEndObject(); } @@ -58,129 +76,26 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(ResponseFormat)) { writer.WritePropertyName("responseFormat"u8); - writer.WriteObjectValue(ResponseFormat); - } - writer.WritePropertyName("uri"u8); - writer.WriteStringValue(Uri); - if (Optional.IsCollectionDefined(HttpHeaders)) - { - if (HttpHeaders != null) - { - writer.WritePropertyName("httpHeaders"u8); - writer.WriteStartObject(); - foreach (var item in HttpHeaders) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("httpHeaders"); - } - } - if (Optional.IsDefined(HttpMethod)) - { - writer.WritePropertyName("httpMethod"u8); - writer.WriteStringValue(HttpMethod); - } - if (Optional.IsDefined(Timeout)) - { - if (Timeout != null) - { - writer.WritePropertyName("timeout"u8); - writer.WriteStringValue(Timeout.Value, "P"); - } - else - { - writer.WriteNull("timeout"); - } - } - if (Optional.IsDefined(BatchSize)) - { - if (BatchSize != null) - { - writer.WritePropertyName("batchSize"u8); - writer.WriteNumberValue(BatchSize.Value); - } - else - { - writer.WriteNull("batchSize"); - } - } - if (Optional.IsDefined(DegreeOfParallelism)) - { - if (DegreeOfParallelism != null) - { - writer.WritePropertyName("degreeOfParallelism"u8); - writer.WriteNumberValue(DegreeOfParallelism.Value); - } - else - { - writer.WriteNull("degreeOfParallelism"); - } - } - if (Optional.IsDefined(AuthResourceId)) - { - if (AuthResourceId != null) - { - writer.WritePropertyName("authResourceId"u8); - writer.WriteStringValue(AuthResourceId); - } - else - { - writer.WriteNull("authResourceId"); - } - } - if (Optional.IsDefined(AuthIdentity)) - { - if (AuthIdentity != null) - { - writer.WritePropertyName("authIdentity"u8); - writer.WriteObjectValue(AuthIdentity); - } - else - { - writer.WriteNull("authIdentity"); - } - } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); + writer.WriteObjectValue(ResponseFormat, options); } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + ChatCompletionSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(ChatCompletionSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatCompletionSkill(document.RootElement, options); } - internal static ChatCompletionSkill DeserializeChatCompletionSkill(JsonElement element) + internal static ChatCompletionSkill DeserializeChatCompletionSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -204,6 +119,8 @@ internal static ChatCompletionSkill DeserializeChatCompletionSkill(JsonElement e string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("apiKey"u8)) @@ -217,7 +134,7 @@ internal static ChatCompletionSkill DeserializeChatCompletionSkill(JsonElement e { continue; } - commonModelParameters = CommonModelParameters.DeserializeCommonModelParameters(property.Value); + commonModelParameters = CommonModelParameters.DeserializeCommonModelParameters(property.Value, options); continue; } if (property.NameEquals("extraParameters"u8)) @@ -257,7 +174,7 @@ internal static ChatCompletionSkill DeserializeChatCompletionSkill(JsonElement e { continue; } - responseFormat = ChatCompletionResponseFormat.DeserializeChatCompletionResponseFormat(property.Value); + responseFormat = ChatCompletionResponseFormat.DeserializeChatCompletionResponseFormat(property.Value, options); continue; } if (property.NameEquals("uri"u8)) @@ -332,7 +249,7 @@ internal static ChatCompletionSkill DeserializeChatCompletionSkill(JsonElement e authIdentity = null; continue; } - authIdentity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value); + authIdentity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value, options); continue; } if (property.NameEquals("@odata.type"u8)) @@ -360,7 +277,7 @@ internal static ChatCompletionSkill DeserializeChatCompletionSkill(JsonElement e List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -370,12 +287,17 @@ internal static ChatCompletionSkill DeserializeChatCompletionSkill(JsonElement e List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new ChatCompletionSkill( odataType, name, @@ -383,6 +305,7 @@ internal static ChatCompletionSkill DeserializeChatCompletionSkill(JsonElement e context, inputs, outputs, + serializedAdditionalRawData, uri, httpHeaders ?? new ChangeTrackingDictionary(), httpMethod, @@ -398,6 +321,37 @@ internal static ChatCompletionSkill DeserializeChatCompletionSkill(JsonElement e responseFormat); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ChatCompletionSkill)} does not support writing '{options.Format}' format."); + } + } + + ChatCompletionSkill 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 DeserializeChatCompletionSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatCompletionSkill)} 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 ChatCompletionSkill FromResponse(Response response) @@ -410,7 +364,7 @@ internal static ChatCompletionSkill DeserializeChatCompletionSkill(JsonElement e internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionSkill.cs index 2f2d564ac4c0..0358e9545ef5 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionSkill.cs @@ -36,6 +36,7 @@ public ChatCompletionSkill(IEnumerable inputs, IEnumerab /// Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// The url for the Web API. /// The headers required to make the http request. /// The method for the http request. @@ -53,7 +54,7 @@ public ChatCompletionSkill(IEnumerable inputs, IEnumerab /// Open-type dictionary for model-specific parameters that should be appended to the chat completions call. Follows Azure AI Foundry’s extensibility pattern. /// How extra parameters are handled by Azure AI Foundry. Default is 'error'. /// Determines how the LLM should format its response. Defaults to 'text' response type. - internal ChatCompletionSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, string uri, IDictionary httpHeaders, string httpMethod, TimeSpan? timeout, int? batchSize, int? degreeOfParallelism, ResourceIdentifier authResourceId, SearchIndexerDataIdentity authIdentity, string apiKey, CommonModelParameters commonModelParameters, IDictionary extraParameters, ChatCompletionExtraParametersBehavior? extraParametersBehavior, ChatCompletionResponseFormat responseFormat) : base(oDataType, name, description, context, inputs, outputs, uri, httpHeaders, httpMethod, timeout, batchSize, degreeOfParallelism, authResourceId, authIdentity) + internal ChatCompletionSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, string uri, IDictionary httpHeaders, string httpMethod, TimeSpan? timeout, int? batchSize, int? degreeOfParallelism, ResourceIdentifier authResourceId, SearchIndexerDataIdentity authIdentity, string apiKey, CommonModelParameters commonModelParameters, IDictionary extraParameters, ChatCompletionExtraParametersBehavior? extraParametersBehavior, ChatCompletionResponseFormat responseFormat) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData, uri, httpHeaders, httpMethod, timeout, batchSize, degreeOfParallelism, authResourceId, authIdentity) { ApiKey = apiKey; CommonModelParameters = commonModelParameters; @@ -63,6 +64,11 @@ internal ChatCompletionSkill(string oDataType, string name, string description, ODataType = oDataType ?? "#Microsoft.Skills.Custom.ChatCompletionSkill"; } + /// Initializes a new instance of for deserialization. + internal ChatCompletionSkill() + { + } + /// API key for authenticating to the model. Both apiKey and authIdentity cannot be specified at the same time. public string ApiKey { get; set; } /// Common language model parameters that customers can tweak. If omitted, reasonable defaults will be applied. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CjkBigramTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CjkBigramTokenFilter.Serialization.cs index 13637415f7c4..336db2452400 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CjkBigramTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CjkBigramTokenFilter.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class CjkBigramTokenFilter : IUtf8JsonSerializable + public partial class CjkBigramTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(CjkBigramTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsCollectionDefined(IgnoreScripts)) { writer.WritePropertyName("ignoreScripts"u8); @@ -31,15 +50,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("outputUnigrams"u8); writer.WriteBooleanValue(OutputUnigrams.Value); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static CjkBigramTokenFilter DeserializeCjkBigramTokenFilter(JsonElement element) + CjkBigramTokenFilter 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(CjkBigramTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCjkBigramTokenFilter(document.RootElement, options); + } + + internal static CjkBigramTokenFilter DeserializeCjkBigramTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -48,6 +76,8 @@ internal static CjkBigramTokenFilter DeserializeCjkBigramTokenFilter(JsonElement bool? outputUnigrams = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("ignoreScripts"u8)) @@ -83,10 +113,46 @@ internal static CjkBigramTokenFilter DeserializeCjkBigramTokenFilter(JsonElement name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CjkBigramTokenFilter(odataType, name, serializedAdditionalRawData, ignoreScripts ?? new ChangeTrackingList(), outputUnigrams); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(CjkBigramTokenFilter)} does not support writing '{options.Format}' format."); + } + } + + CjkBigramTokenFilter 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 DeserializeCjkBigramTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CjkBigramTokenFilter)} does not support reading '{options.Format}' format."); } - return new CjkBigramTokenFilter(odataType, name, ignoreScripts ?? new ChangeTrackingList(), outputUnigrams); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new CjkBigramTokenFilter FromResponse(Response response) @@ -99,7 +165,7 @@ internal static CjkBigramTokenFilter DeserializeCjkBigramTokenFilter(JsonElement internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CjkBigramTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CjkBigramTokenFilter.cs index 5e1587823f5f..19d4d955d787 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CjkBigramTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CjkBigramTokenFilter.cs @@ -27,14 +27,20 @@ public CjkBigramTokenFilter(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The scripts to ignore. /// A value indicating whether to output both unigrams and bigrams (if true), or just bigrams (if false). Default is false. - internal CjkBigramTokenFilter(string oDataType, string name, IList ignoreScripts, bool? outputUnigrams) : base(oDataType, name) + internal CjkBigramTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, IList ignoreScripts, bool? outputUnigrams) : base(oDataType, name, serializedAdditionalRawData) { IgnoreScripts = ignoreScripts; OutputUnigrams = outputUnigrams; ODataType = oDataType ?? "#Microsoft.Azure.Search.CjkBigramTokenFilter"; } + + /// Initializes a new instance of for deserialization. + internal CjkBigramTokenFilter() + { + } /// A value indicating whether to output both unigrams and bigrams (if true), or just bigrams (if false). Default is false. public bool? OutputUnigrams { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ClassicSimilarity.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ClassicSimilarity.Serialization.cs index ed6b96e3b8b9..602b7205941d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ClassicSimilarity.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ClassicSimilarity.Serialization.cs @@ -5,28 +5,61 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class ClassicSimilarity : IUtf8JsonSerializable + public partial class ClassicSimilarity : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); + JsonModelWriteCore(writer, options); writer.WriteEndObject(); } - internal static ClassicSimilarity DeserializeClassicSimilarity(JsonElement element) + /// 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(ClassicSimilarity)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + ClassicSimilarity 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(ClassicSimilarity)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeClassicSimilarity(document.RootElement, options); + } + + internal static ClassicSimilarity DeserializeClassicSimilarity(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string odataType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@odata.type"u8)) @@ -34,10 +67,46 @@ internal static ClassicSimilarity DeserializeClassicSimilarity(JsonElement eleme odataType = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ClassicSimilarity(odataType, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ClassicSimilarity)} does not support writing '{options.Format}' format."); } - return new ClassicSimilarity(odataType); } + ClassicSimilarity 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 DeserializeClassicSimilarity(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ClassicSimilarity)} 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 ClassicSimilarity FromResponse(Response response) @@ -50,7 +119,7 @@ internal static ClassicSimilarity DeserializeClassicSimilarity(JsonElement eleme internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ClassicSimilarity.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ClassicSimilarity.cs index e89c77cc6d70..980a63721e8e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ClassicSimilarity.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ClassicSimilarity.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Legacy similarity algorithm which uses the Lucene TFIDFSimilarity implementation of TF-IDF. This variation of TF-IDF introduces static document length normalization as well as coordinating factors that penalize documents that only partially match the searched queries. @@ -18,7 +21,8 @@ public ClassicSimilarity() /// Initializes a new instance of . /// - internal ClassicSimilarity(string oDataType) : base(oDataType) + /// Keeps track of any properties unknown to the library. + internal ClassicSimilarity(string oDataType, IDictionary serializedAdditionalRawData) : base(oDataType, serializedAdditionalRawData) { ODataType = oDataType ?? "#Microsoft.Azure.Search.ClassicSimilarity"; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ClassicTokenizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ClassicTokenizer.Serialization.cs index 1ac679c96c94..9dd7372c0171 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ClassicTokenizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ClassicTokenizer.Serialization.cs @@ -5,30 +5,59 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class ClassicTokenizer : IUtf8JsonSerializable + public partial class ClassicTokenizer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(ClassicTokenizer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(MaxTokenLength)) { writer.WritePropertyName("maxTokenLength"u8); writer.WriteNumberValue(MaxTokenLength.Value); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static ClassicTokenizer DeserializeClassicTokenizer(JsonElement element) + ClassicTokenizer 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(ClassicTokenizer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeClassicTokenizer(document.RootElement, options); + } + + internal static ClassicTokenizer DeserializeClassicTokenizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -36,6 +65,8 @@ internal static ClassicTokenizer DeserializeClassicTokenizer(JsonElement element int? maxTokenLength = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("maxTokenLength"u8)) @@ -57,10 +88,46 @@ internal static ClassicTokenizer DeserializeClassicTokenizer(JsonElement element name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ClassicTokenizer(odataType, name, serializedAdditionalRawData, maxTokenLength); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ClassicTokenizer)} does not support writing '{options.Format}' format."); + } + } + + ClassicTokenizer 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 DeserializeClassicTokenizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ClassicTokenizer)} does not support reading '{options.Format}' format."); } - return new ClassicTokenizer(odataType, name, maxTokenLength); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new ClassicTokenizer FromResponse(Response response) @@ -73,7 +140,7 @@ internal static ClassicTokenizer DeserializeClassicTokenizer(JsonElement element internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ClassicTokenizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ClassicTokenizer.cs index 39e3726888a6..103f894c3f07 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ClassicTokenizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ClassicTokenizer.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,13 +26,19 @@ public ClassicTokenizer(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of tokenizer. /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The maximum token length. Default is 255. Tokens longer than the maximum length are split. The maximum token length that can be used is 300 characters. - internal ClassicTokenizer(string oDataType, string name, int? maxTokenLength) : base(oDataType, name) + internal ClassicTokenizer(string oDataType, string name, IDictionary serializedAdditionalRawData, int? maxTokenLength) : base(oDataType, name, serializedAdditionalRawData) { MaxTokenLength = maxTokenLength; ODataType = oDataType ?? "#Microsoft.Azure.Search.ClassicTokenizer"; } + /// Initializes a new instance of for deserialization. + internal ClassicTokenizer() + { + } + /// The maximum token length. Default is 255. Tokens longer than the maximum length are split. The maximum token length that can be used is 300 characters. public int? MaxTokenLength { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CognitiveServicesAccount.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CognitiveServicesAccount.Serialization.cs index 724e47e6e30a..82ec9da9264a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CognitiveServicesAccount.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CognitiveServicesAccount.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Indexes.Models { - public partial class CognitiveServicesAccount : IUtf8JsonSerializable + public partial class CognitiveServicesAccount : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(CognitiveServicesAccount)} does not support writing '{format}' format."); + } + writer.WritePropertyName("@odata.type"u8); writer.WriteStringValue(ODataType); if (Optional.IsDefined(Description)) @@ -23,11 +41,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("description"u8); writer.WriteStringValue(Description); } - writer.WriteEndObject(); + 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 + } + } } - internal static CognitiveServicesAccount DeserializeCognitiveServicesAccount(JsonElement element) + CognitiveServicesAccount 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(CognitiveServicesAccount)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCognitiveServicesAccount(document.RootElement, options); + } + + internal static CognitiveServicesAccount DeserializeCognitiveServicesAccount(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -36,15 +82,46 @@ internal static CognitiveServicesAccount DeserializeCognitiveServicesAccount(Jso { switch (discriminator.GetString()) { - case "#Microsoft.Azure.Search.AIServicesByIdentity": return AIServicesAccountIdentity.DeserializeAIServicesAccountIdentity(element); - case "#Microsoft.Azure.Search.AIServicesByKey": return AIServicesAccountKey.DeserializeAIServicesAccountKey(element); - case "#Microsoft.Azure.Search.CognitiveServicesByKey": return CognitiveServicesAccountKey.DeserializeCognitiveServicesAccountKey(element); - case "#Microsoft.Azure.Search.DefaultCognitiveServices": return DefaultCognitiveServicesAccount.DeserializeDefaultCognitiveServicesAccount(element); + case "#Microsoft.Azure.Search.AIServicesByIdentity": return AIServicesAccountIdentity.DeserializeAIServicesAccountIdentity(element, options); + case "#Microsoft.Azure.Search.AIServicesByKey": return AIServicesAccountKey.DeserializeAIServicesAccountKey(element, options); + case "#Microsoft.Azure.Search.CognitiveServicesByKey": return CognitiveServicesAccountKey.DeserializeCognitiveServicesAccountKey(element, options); + case "#Microsoft.Azure.Search.DefaultCognitiveServices": return DefaultCognitiveServicesAccount.DeserializeDefaultCognitiveServicesAccount(element, options); } } - return UnknownCognitiveServicesAccount.DeserializeUnknownCognitiveServicesAccount(element); + return UnknownCognitiveServicesAccount.DeserializeUnknownCognitiveServicesAccount(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(CognitiveServicesAccount)} does not support writing '{options.Format}' format."); + } + } + + CognitiveServicesAccount 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 DeserializeCognitiveServicesAccount(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CognitiveServicesAccount)} 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 CognitiveServicesAccount FromResponse(Response response) @@ -57,7 +134,7 @@ internal static CognitiveServicesAccount FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CognitiveServicesAccount.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CognitiveServicesAccount.cs index d9a85ae2aab0..7fe3cb1522da 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CognitiveServicesAccount.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CognitiveServicesAccount.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// @@ -14,13 +17,47 @@ namespace Azure.Search.Documents.Indexes.Models /// public partial class CognitiveServicesAccount { + /// + /// 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 . /// A URI fragment specifying the type of Azure AI service resource attached to a skillset. /// Description of the Azure AI service resource attached to a skillset. - internal CognitiveServicesAccount(string oDataType, string description) + /// Keeps track of any properties unknown to the library. + internal CognitiveServicesAccount(string oDataType, string description, IDictionary serializedAdditionalRawData) { ODataType = oDataType; Description = description; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// A URI fragment specifying the type of Azure AI service resource attached to a skillset. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CognitiveServicesAccountKey.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CognitiveServicesAccountKey.Serialization.cs index c9b11e769dbf..fd02315f8bdf 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CognitiveServicesAccountKey.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CognitiveServicesAccountKey.Serialization.cs @@ -5,30 +5,56 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class CognitiveServicesAccountKey : IUtf8JsonSerializable + public partial class CognitiveServicesAccountKey : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(CognitiveServicesAccountKey)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("key"u8); writer.WriteStringValue(Key); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Description)) + } + + CognitiveServicesAccountKey IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); + throw new FormatException($"The model {nameof(CognitiveServicesAccountKey)} does not support reading '{format}' format."); } - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCognitiveServicesAccountKey(document.RootElement, options); } - internal static CognitiveServicesAccountKey DeserializeCognitiveServicesAccountKey(JsonElement element) + internal static CognitiveServicesAccountKey DeserializeCognitiveServicesAccountKey(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -36,6 +62,8 @@ internal static CognitiveServicesAccountKey DeserializeCognitiveServicesAccountK string key = default; string odataType = default; string description = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("key"u8)) @@ -53,10 +81,46 @@ internal static CognitiveServicesAccountKey DeserializeCognitiveServicesAccountK description = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CognitiveServicesAccountKey(odataType, description, serializedAdditionalRawData, key); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(CognitiveServicesAccountKey)} does not support writing '{options.Format}' format."); } - return new CognitiveServicesAccountKey(odataType, description, key); } + CognitiveServicesAccountKey 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 DeserializeCognitiveServicesAccountKey(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CognitiveServicesAccountKey)} 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 CognitiveServicesAccountKey FromResponse(Response response) @@ -69,7 +133,7 @@ internal static CognitiveServicesAccountKey DeserializeCognitiveServicesAccountK internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CognitiveServicesAccountKey.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CognitiveServicesAccountKey.cs index 08f1069d2bc5..f55c787ce839 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CognitiveServicesAccountKey.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CognitiveServicesAccountKey.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -26,13 +27,19 @@ public CognitiveServicesAccountKey(string key) /// Initializes a new instance of . /// A URI fragment specifying the type of Azure AI service resource attached to a skillset. /// Description of the Azure AI service resource attached to a skillset. + /// Keeps track of any properties unknown to the library. /// The key used to provision the Azure AI service resource attached to a skillset. - internal CognitiveServicesAccountKey(string oDataType, string description, string key) : base(oDataType, description) + internal CognitiveServicesAccountKey(string oDataType, string description, IDictionary serializedAdditionalRawData, string key) : base(oDataType, description, serializedAdditionalRawData) { Key = key; ODataType = oDataType ?? "#Microsoft.Azure.Search.CognitiveServicesByKey"; } + /// Initializes a new instance of for deserialization. + internal CognitiveServicesAccountKey() + { + } + /// The key used to provision the Azure AI service resource attached to a skillset. public string Key { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CommonGramTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CommonGramTokenFilter.Serialization.cs index 2805232d5b02..8bef33fd61db 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CommonGramTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CommonGramTokenFilter.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class CommonGramTokenFilter : IUtf8JsonSerializable + public partial class CommonGramTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(CommonGramTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("commonWords"u8); writer.WriteStartArray(); foreach (var item in CommonWords) @@ -33,15 +52,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("queryMode"u8); writer.WriteBooleanValue(UseQueryMode.Value); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static CommonGramTokenFilter DeserializeCommonGramTokenFilter(JsonElement element) + CommonGramTokenFilter 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(CommonGramTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCommonGramTokenFilter(document.RootElement, options); + } + + internal static CommonGramTokenFilter DeserializeCommonGramTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -51,6 +79,8 @@ internal static CommonGramTokenFilter DeserializeCommonGramTokenFilter(JsonEleme bool? queryMode = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("commonWords"u8)) @@ -91,10 +121,52 @@ internal static CommonGramTokenFilter DeserializeCommonGramTokenFilter(JsonEleme name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CommonGramTokenFilter( + odataType, + name, + serializedAdditionalRawData, + commonWords, + ignoreCase, + queryMode); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(CommonGramTokenFilter)} does not support writing '{options.Format}' format."); + } + } + + CommonGramTokenFilter 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 DeserializeCommonGramTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CommonGramTokenFilter)} does not support reading '{options.Format}' format."); } - return new CommonGramTokenFilter(odataType, name, commonWords, ignoreCase, queryMode); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new CommonGramTokenFilter FromResponse(Response response) @@ -107,7 +179,7 @@ internal static CommonGramTokenFilter DeserializeCommonGramTokenFilter(JsonEleme internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CommonGramTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CommonGramTokenFilter.cs index eec757558ebd..3e58c8187427 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CommonGramTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CommonGramTokenFilter.cs @@ -30,16 +30,22 @@ public CommonGramTokenFilter(string name, IEnumerable commonWords) : bas /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The set of common words. /// A value indicating whether common words matching will be case insensitive. Default is false. /// A value that indicates whether the token filter is in query mode. When in query mode, the token filter generates bigrams and then removes common words and single terms followed by a common word. Default is false. - internal CommonGramTokenFilter(string oDataType, string name, IList commonWords, bool? ignoreCase, bool? useQueryMode) : base(oDataType, name) + internal CommonGramTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, IList commonWords, bool? ignoreCase, bool? useQueryMode) : base(oDataType, name, serializedAdditionalRawData) { CommonWords = commonWords; IgnoreCase = ignoreCase; UseQueryMode = useQueryMode; ODataType = oDataType ?? "#Microsoft.Azure.Search.CommonGramTokenFilter"; } + + /// Initializes a new instance of for deserialization. + internal CommonGramTokenFilter() + { + } /// A value indicating whether common words matching will be case insensitive. Default is false. public bool? IgnoreCase { get; set; } /// A value that indicates whether the token filter is in query mode. When in query mode, the token filter generates bigrams and then removes common words and single terms followed by a common word. Default is false. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CommonModelParameters.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CommonModelParameters.Serialization.cs index 6a62321c194a..ccffe4a78c01 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CommonModelParameters.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CommonModelParameters.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class CommonModelParameters : IUtf8JsonSerializable + public partial class CommonModelParameters : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(CommonModelParameters)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Model)) { if (Model != null) @@ -105,11 +123,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("stop"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static CommonModelParameters DeserializeCommonModelParameters(JsonElement element) + CommonModelParameters 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(CommonModelParameters)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCommonModelParameters(document.RootElement, options); + } + + internal static CommonModelParameters DeserializeCommonModelParameters(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -121,6 +167,8 @@ internal static CommonModelParameters DeserializeCommonModelParameters(JsonEleme float? temperature = default; int? seed = default; IList stop = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("model"u8)) @@ -198,7 +246,12 @@ internal static CommonModelParameters DeserializeCommonModelParameters(JsonEleme stop = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new CommonModelParameters( model, frequencyPenalty, @@ -206,9 +259,41 @@ internal static CommonModelParameters DeserializeCommonModelParameters(JsonEleme maxTokens, temperature, seed, - stop ?? new ChangeTrackingList()); + stop ?? 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(CommonModelParameters)} does not support writing '{options.Format}' format."); + } } + CommonModelParameters 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 DeserializeCommonModelParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CommonModelParameters)} 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 CommonModelParameters FromResponse(Response response) @@ -221,7 +306,7 @@ internal static CommonModelParameters FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CommonModelParameters.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CommonModelParameters.cs index 4285af207e3d..24c290708a8d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CommonModelParameters.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CommonModelParameters.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models @@ -12,6 +13,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Common language model parameters for Chat Completions. If omitted, default values are used. public partial class CommonModelParameters { + /// + /// 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 CommonModelParameters() { @@ -26,7 +59,8 @@ public CommonModelParameters() /// Sampling temperature. Default is 0.7. /// Random seed for controlling deterministic outputs. If omitted, randomization is used. /// List of stop sequences that will cut off text generation. Default is none. - internal CommonModelParameters(string model, float? frequencyPenalty, float? presencePenalty, int? maxTokens, float? temperature, int? seed, IList stop) + /// Keeps track of any properties unknown to the library. + internal CommonModelParameters(string model, float? frequencyPenalty, float? presencePenalty, int? maxTokens, float? temperature, int? seed, IList stop, IDictionary serializedAdditionalRawData) { Model = model; FrequencyPenalty = frequencyPenalty; @@ -35,6 +69,7 @@ internal CommonModelParameters(string model, float? frequencyPenalty, float? pre Temperature = temperature; Seed = seed; Stop = stop; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The name of the model to use (e.g., 'gpt-4o', etc.). Default is null if not specified. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ConditionalSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ConditionalSkill.Serialization.cs index 68a8194e6bb0..6f693f23d18b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ConditionalSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ConditionalSkill.Serialization.cs @@ -5,53 +5,54 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class ConditionalSkill : IUtf8JsonSerializable + public partial class ConditionalSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) + 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") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(ConditionalSkill)} does not support writing '{format}' format."); } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + + base.JsonModelWriteCore(writer, options); + } + + ConditionalSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(ConditionalSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeConditionalSkill(document.RootElement, options); } - internal static ConditionalSkill DeserializeConditionalSkill(JsonElement element) + internal static ConditionalSkill DeserializeConditionalSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -62,6 +63,8 @@ internal static ConditionalSkill DeserializeConditionalSkill(JsonElement element string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@odata.type"u8)) @@ -89,7 +92,7 @@ internal static ConditionalSkill DeserializeConditionalSkill(JsonElement element List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -99,21 +102,58 @@ internal static ConditionalSkill DeserializeConditionalSkill(JsonElement element List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new ConditionalSkill( odataType, name, description, context, inputs, - outputs); + outputs, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ConditionalSkill)} does not support writing '{options.Format}' format."); + } + } + + ConditionalSkill 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 DeserializeConditionalSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ConditionalSkill)} 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 ConditionalSkill FromResponse(Response response) @@ -126,7 +166,7 @@ internal static ConditionalSkill DeserializeConditionalSkill(JsonElement element internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ConditionalSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ConditionalSkill.cs index fc95b4fddb38..baac05449df7 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ConditionalSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ConditionalSkill.cs @@ -32,9 +32,15 @@ public ConditionalSkill(IEnumerable inputs, IEnumerable< /// Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. - internal ConditionalSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs) : base(oDataType, name, description, context, inputs, outputs) + /// Keeps track of any properties unknown to the library. + internal ConditionalSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { ODataType = oDataType ?? "#Microsoft.Skills.Util.ConditionalSkill"; } + + /// Initializes a new instance of for deserialization. + internal ConditionalSkill() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CorsOptions.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CorsOptions.Serialization.cs index 8e0912316e23..ff49b006508e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CorsOptions.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CorsOptions.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class CorsOptions : IUtf8JsonSerializable + public partial class CorsOptions : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(CorsOptions)} does not support writing '{format}' format."); + } + writer.WritePropertyName("allowedOrigins"u8); writer.WriteStartArray(); foreach (var item in AllowedOrigins) @@ -35,17 +53,47 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("maxAgeInSeconds"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static CorsOptions DeserializeCorsOptions(JsonElement element) + CorsOptions 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(CorsOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCorsOptions(document.RootElement, options); + } + + internal static CorsOptions DeserializeCorsOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } IList allowedOrigins = default; long? maxAgeInSeconds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("allowedOrigins"u8)) @@ -68,10 +116,46 @@ internal static CorsOptions DeserializeCorsOptions(JsonElement element) maxAgeInSeconds = property.Value.GetInt64(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CorsOptions(allowedOrigins, maxAgeInSeconds, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(CorsOptions)} does not support writing '{options.Format}' format."); } - return new CorsOptions(allowedOrigins, maxAgeInSeconds); } + CorsOptions 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 DeserializeCorsOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CorsOptions)} 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 CorsOptions FromResponse(Response response) @@ -84,7 +168,7 @@ internal static CorsOptions FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CorsOptions.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CorsOptions.cs index a402fabc5fce..b50cf87a6a2f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CorsOptions.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CorsOptions.cs @@ -14,6 +14,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Defines options to control Cross-Origin Resource Sharing (CORS) for an index. public partial class CorsOptions { + /// + /// 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 . /// The list of origins from which JavaScript code will be granted access to your index. Can contain a list of hosts of the form {protocol}://{fully-qualified-domain-name}[:{port#}], or a single '*' to allow all origins (not recommended). /// is null. @@ -27,10 +59,17 @@ public CorsOptions(IEnumerable allowedOrigins) /// Initializes a new instance of . /// The list of origins from which JavaScript code will be granted access to your index. Can contain a list of hosts of the form {protocol}://{fully-qualified-domain-name}[:{port#}], or a single '*' to allow all origins (not recommended). /// The duration for which browsers should cache CORS preflight responses. Defaults to 5 minutes. - internal CorsOptions(IList allowedOrigins, long? maxAgeInSeconds) + /// Keeps track of any properties unknown to the library. + internal CorsOptions(IList allowedOrigins, long? maxAgeInSeconds, IDictionary serializedAdditionalRawData) { AllowedOrigins = allowedOrigins; MaxAgeInSeconds = maxAgeInSeconds; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CorsOptions() + { } /// The duration for which browsers should cache CORS preflight responses. Defaults to 5 minutes. public long? MaxAgeInSeconds { get; set; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomAnalyzer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomAnalyzer.Serialization.cs index 705a8ef44dd7..777d00a9ddf6 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomAnalyzer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomAnalyzer.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class CustomAnalyzer : IUtf8JsonSerializable + public partial class CustomAnalyzer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(CustomAnalyzer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("tokenizer"u8); writer.WriteStringValue(TokenizerName.ToString()); if (Optional.IsCollectionDefined(TokenFilters)) @@ -38,15 +57,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WriteEndArray(); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static CustomAnalyzer DeserializeCustomAnalyzer(JsonElement element) + CustomAnalyzer 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(CustomAnalyzer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCustomAnalyzer(document.RootElement, options); + } + + internal static CustomAnalyzer DeserializeCustomAnalyzer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -56,6 +84,8 @@ internal static CustomAnalyzer DeserializeCustomAnalyzer(JsonElement element) IList charFilters = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("tokenizer"u8)) @@ -101,10 +131,52 @@ internal static CustomAnalyzer DeserializeCustomAnalyzer(JsonElement element) name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CustomAnalyzer( + odataType, + name, + serializedAdditionalRawData, + tokenizer, + tokenFilters ?? new ChangeTrackingList(), + charFilters ?? new ChangeTrackingList()); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(CustomAnalyzer)} does not support writing '{options.Format}' format."); + } + } + + CustomAnalyzer 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 DeserializeCustomAnalyzer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CustomAnalyzer)} does not support reading '{options.Format}' format."); } - return new CustomAnalyzer(odataType, name, tokenizer, tokenFilters ?? new ChangeTrackingList(), charFilters ?? new ChangeTrackingList()); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new CustomAnalyzer FromResponse(Response response) @@ -117,7 +189,7 @@ internal static CustomAnalyzer DeserializeCustomAnalyzer(JsonElement element) internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomAnalyzer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomAnalyzer.cs index 5ee2930397a1..2cc6d4898b58 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomAnalyzer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomAnalyzer.cs @@ -16,15 +16,21 @@ public partial class CustomAnalyzer : LexicalAnalyzer /// Initializes a new instance of . /// A URI fragment specifying the type of analyzer. /// The name of the analyzer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The name of the tokenizer to use to divide continuous text into a sequence of tokens, such as breaking a sentence into words. /// A list of token filters used to filter out or modify the tokens generated by a tokenizer. For example, you can specify a lowercase filter that converts all characters to lowercase. The filters are run in the order in which they are listed. /// A list of character filters used to prepare input text before it is processed by the tokenizer. For instance, they can replace certain characters or symbols. The filters are run in the order in which they are listed. - internal CustomAnalyzer(string oDataType, string name, LexicalTokenizerName tokenizerName, IList tokenFilters, IList charFilters) : base(oDataType, name) + internal CustomAnalyzer(string oDataType, string name, IDictionary serializedAdditionalRawData, LexicalTokenizerName tokenizerName, IList tokenFilters, IList charFilters) : base(oDataType, name, serializedAdditionalRawData) { TokenizerName = tokenizerName; TokenFilters = tokenFilters; CharFilters = charFilters; ODataType = oDataType ?? "#Microsoft.Azure.Search.CustomAnalyzer"; } + + /// Initializes a new instance of for deserialization. + internal CustomAnalyzer() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntity.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntity.Serialization.cs index 8a236bbcb5e2..b76af819f421 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntity.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntity.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class CustomEntity : IUtf8JsonSerializable + public partial class CustomEntity : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(CustomEntity)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); if (Optional.IsDefined(Description)) @@ -146,7 +164,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in Aliases) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } @@ -155,11 +173,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("aliases"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static CustomEntity DeserializeCustomEntity(JsonElement element) + CustomEntity 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(CustomEntity)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCustomEntity(document.RootElement, options); + } + + internal static CustomEntity DeserializeCustomEntity(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -176,6 +222,8 @@ internal static CustomEntity DeserializeCustomEntity(JsonElement element) bool? defaultAccentSensitive = default; int? defaultFuzzyEditDistance = default; IList aliases = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -293,12 +341,17 @@ internal static CustomEntity DeserializeCustomEntity(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(CustomEntityAlias.DeserializeCustomEntityAlias(item)); + array.Add(CustomEntityAlias.DeserializeCustomEntityAlias(item, options)); } aliases = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new CustomEntity( name, description, @@ -311,9 +364,41 @@ internal static CustomEntity DeserializeCustomEntity(JsonElement element) defaultCaseSensitive, defaultAccentSensitive, defaultFuzzyEditDistance, - aliases ?? new ChangeTrackingList()); + aliases ?? 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(CustomEntity)} does not support writing '{options.Format}' format."); + } } + CustomEntity 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 DeserializeCustomEntity(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CustomEntity)} 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 CustomEntity FromResponse(Response response) @@ -326,7 +411,7 @@ internal static CustomEntity FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntity.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntity.cs index b9b0c03bb6ee..a4ac0a8d43ed 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntity.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntity.cs @@ -13,6 +13,38 @@ namespace Azure.Search.Documents.Indexes.Models /// An object that contains information about the matches that were found, and related metadata. public partial class CustomEntity { + /// + /// 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 . /// The top-level entity descriptor. Matches in the skill output will be grouped by this name, and it should represent the "normalized" form of the text being found. /// is null. @@ -37,7 +69,8 @@ public CustomEntity(string name) /// Changes the default accent sensitivity value for this entity. It be used to change the default value of all aliases accentSensitive values. /// Changes the default fuzzy edit distance value for this entity. It can be used to change the default value of all aliases fuzzyEditDistance values. /// An array of complex objects that can be used to specify alternative spellings or synonyms to the root entity name. - internal CustomEntity(string name, string description, string type, string subtype, string id, bool? caseSensitive, bool? accentSensitive, int? fuzzyEditDistance, bool? defaultCaseSensitive, bool? defaultAccentSensitive, int? defaultFuzzyEditDistance, IList aliases) + /// Keeps track of any properties unknown to the library. + internal CustomEntity(string name, string description, string type, string subtype, string id, bool? caseSensitive, bool? accentSensitive, int? fuzzyEditDistance, bool? defaultCaseSensitive, bool? defaultAccentSensitive, int? defaultFuzzyEditDistance, IList aliases, IDictionary serializedAdditionalRawData) { Name = name; Description = description; @@ -51,6 +84,12 @@ internal CustomEntity(string name, string description, string type, string subty DefaultAccentSensitive = defaultAccentSensitive; DefaultFuzzyEditDistance = defaultFuzzyEditDistance; Aliases = aliases; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CustomEntity() + { } /// The top-level entity descriptor. Matches in the skill output will be grouped by this name, and it should represent the "normalized" form of the text being found. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntityAlias.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntityAlias.Serialization.cs index 598308aeda0a..047e87b46a40 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntityAlias.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntityAlias.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class CustomEntityAlias : IUtf8JsonSerializable + public partial class CustomEntityAlias : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(CustomEntityAlias)} does not support writing '{format}' format."); + } + writer.WritePropertyName("text"u8); writer.WriteStringValue(Text); if (Optional.IsDefined(CaseSensitive)) @@ -53,11 +72,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("fuzzyEditDistance"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static CustomEntityAlias DeserializeCustomEntityAlias(JsonElement element) + CustomEntityAlias 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(CustomEntityAlias)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCustomEntityAlias(document.RootElement, options); + } + + internal static CustomEntityAlias DeserializeCustomEntityAlias(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -66,6 +113,8 @@ internal static CustomEntityAlias DeserializeCustomEntityAlias(JsonElement eleme bool? caseSensitive = default; bool? accentSensitive = default; int? fuzzyEditDistance = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("text"u8)) @@ -103,10 +152,46 @@ internal static CustomEntityAlias DeserializeCustomEntityAlias(JsonElement eleme fuzzyEditDistance = property.Value.GetInt32(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CustomEntityAlias(text, caseSensitive, accentSensitive, fuzzyEditDistance, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(CustomEntityAlias)} does not support writing '{options.Format}' format."); } - return new CustomEntityAlias(text, caseSensitive, accentSensitive, fuzzyEditDistance); } + CustomEntityAlias 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 DeserializeCustomEntityAlias(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CustomEntityAlias)} 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 CustomEntityAlias FromResponse(Response response) @@ -119,7 +204,7 @@ internal static CustomEntityAlias FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntityAlias.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntityAlias.cs index d3d232546f11..01511c50111a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntityAlias.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntityAlias.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// A complex object that can be used to specify alternative spellings or synonyms to the root entity name. public partial class CustomEntityAlias { + /// + /// 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 . /// The text of the alias. /// is null. @@ -27,12 +60,19 @@ public CustomEntityAlias(string text) /// Determine if the alias is case sensitive. /// Determine if the alias is accent sensitive. /// Determine the fuzzy edit distance of the alias. - internal CustomEntityAlias(string text, bool? caseSensitive, bool? accentSensitive, int? fuzzyEditDistance) + /// Keeps track of any properties unknown to the library. + internal CustomEntityAlias(string text, bool? caseSensitive, bool? accentSensitive, int? fuzzyEditDistance, IDictionary serializedAdditionalRawData) { Text = text; CaseSensitive = caseSensitive; AccentSensitive = accentSensitive; FuzzyEditDistance = fuzzyEditDistance; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CustomEntityAlias() + { } /// The text of the alias. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntityLookupSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntityLookupSkill.Serialization.cs index b5ffdca4093b..d42d8619eb77 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntityLookupSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntityLookupSkill.Serialization.cs @@ -6,17 +6,35 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class CustomEntityLookupSkill : IUtf8JsonSerializable + public partial class CustomEntityLookupSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(CustomEntityLookupSkill)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(DefaultLanguageCode)) { if (DefaultLanguageCode != null) @@ -49,7 +67,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in InlineEntitiesDefinition) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } @@ -94,42 +112,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("globalDefaultFuzzyEditDistance"); } } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + CustomEntityLookupSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(CustomEntityLookupSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCustomEntityLookupSkill(document.RootElement, options); } - internal static CustomEntityLookupSkill DeserializeCustomEntityLookupSkill(JsonElement element) + internal static CustomEntityLookupSkill DeserializeCustomEntityLookupSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -146,6 +146,8 @@ internal static CustomEntityLookupSkill DeserializeCustomEntityLookupSkill(JsonE string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("defaultLanguageCode"u8)) @@ -178,7 +180,7 @@ internal static CustomEntityLookupSkill DeserializeCustomEntityLookupSkill(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(CustomEntity.DeserializeCustomEntity(item)); + array.Add(CustomEntity.DeserializeCustomEntity(item, options)); } inlineEntitiesDefinition = array; continue; @@ -238,7 +240,7 @@ internal static CustomEntityLookupSkill DeserializeCustomEntityLookupSkill(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -248,12 +250,17 @@ internal static CustomEntityLookupSkill DeserializeCustomEntityLookupSkill(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new CustomEntityLookupSkill( odataType, name, @@ -261,6 +268,7 @@ internal static CustomEntityLookupSkill DeserializeCustomEntityLookupSkill(JsonE context, inputs, outputs, + serializedAdditionalRawData, defaultLanguageCode, entitiesDefinitionUri, inlineEntitiesDefinition ?? new ChangeTrackingList(), @@ -269,6 +277,37 @@ internal static CustomEntityLookupSkill DeserializeCustomEntityLookupSkill(JsonE globalDefaultFuzzyEditDistance); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(CustomEntityLookupSkill)} does not support writing '{options.Format}' format."); + } + } + + CustomEntityLookupSkill 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 DeserializeCustomEntityLookupSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CustomEntityLookupSkill)} 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 CustomEntityLookupSkill FromResponse(Response response) @@ -281,7 +320,7 @@ internal static CustomEntityLookupSkill DeserializeCustomEntityLookupSkill(JsonE internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntityLookupSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntityLookupSkill.cs index 75d2f3d1463d..65f2197a7ae4 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntityLookupSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomEntityLookupSkill.cs @@ -33,13 +33,14 @@ public CustomEntityLookupSkill(IEnumerable inputs, IEnum /// Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// A value indicating which language code to use. Default is `en`. /// Path to a JSON or CSV file containing all the target text to match against. This entity definition is read at the beginning of an indexer run. Any updates to this file during an indexer run will not take effect until subsequent runs. This config must be accessible over HTTPS. /// The inline CustomEntity definition. /// A global flag for CaseSensitive. If CaseSensitive is not set in CustomEntity, this value will be the default value. /// A global flag for AccentSensitive. If AccentSensitive is not set in CustomEntity, this value will be the default value. /// A global flag for FuzzyEditDistance. If FuzzyEditDistance is not set in CustomEntity, this value will be the default value. - internal CustomEntityLookupSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, CustomEntityLookupSkillLanguage? defaultLanguageCode, Uri entitiesDefinitionUri, IList inlineEntitiesDefinition, bool? globalDefaultCaseSensitive, bool? globalDefaultAccentSensitive, int? globalDefaultFuzzyEditDistance) : base(oDataType, name, description, context, inputs, outputs) + internal CustomEntityLookupSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, CustomEntityLookupSkillLanguage? defaultLanguageCode, Uri entitiesDefinitionUri, IList inlineEntitiesDefinition, bool? globalDefaultCaseSensitive, bool? globalDefaultAccentSensitive, int? globalDefaultFuzzyEditDistance) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { DefaultLanguageCode = defaultLanguageCode; EntitiesDefinitionUri = entitiesDefinitionUri; @@ -50,6 +51,11 @@ internal CustomEntityLookupSkill(string oDataType, string name, string descripti ODataType = oDataType ?? "#Microsoft.Skills.Text.CustomEntityLookupSkill"; } + /// Initializes a new instance of for deserialization. + internal CustomEntityLookupSkill() + { + } + /// A value indicating which language code to use. Default is `en`. public CustomEntityLookupSkillLanguage? DefaultLanguageCode { get; set; } /// A global flag for CaseSensitive. If CaseSensitive is not set in CustomEntity, this value will be the default value. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomNormalizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomNormalizer.Serialization.cs index 61b820f527d6..47a0d0c5611c 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomNormalizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomNormalizer.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class CustomNormalizer : IUtf8JsonSerializable + public partial class CustomNormalizer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(CustomNormalizer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsCollectionDefined(TokenFilters)) { writer.WritePropertyName("tokenFilters"u8); @@ -36,15 +55,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WriteEndArray(); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static CustomNormalizer DeserializeCustomNormalizer(JsonElement element) + CustomNormalizer 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(CustomNormalizer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCustomNormalizer(document.RootElement, options); + } + + internal static CustomNormalizer DeserializeCustomNormalizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -53,6 +81,8 @@ internal static CustomNormalizer DeserializeCustomNormalizer(JsonElement element IList charFilters = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("tokenFilters"u8)) @@ -93,10 +123,46 @@ internal static CustomNormalizer DeserializeCustomNormalizer(JsonElement element name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CustomNormalizer(odataType, name, serializedAdditionalRawData, tokenFilters ?? new ChangeTrackingList(), charFilters ?? new ChangeTrackingList()); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(CustomNormalizer)} does not support writing '{options.Format}' format."); + } + } + + CustomNormalizer 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 DeserializeCustomNormalizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CustomNormalizer)} does not support reading '{options.Format}' format."); } - return new CustomNormalizer(odataType, name, tokenFilters ?? new ChangeTrackingList(), charFilters ?? new ChangeTrackingList()); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new CustomNormalizer FromResponse(Response response) @@ -109,7 +175,7 @@ internal static CustomNormalizer DeserializeCustomNormalizer(JsonElement element internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomNormalizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomNormalizer.cs index df041df222cc..e39172931b47 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomNormalizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/CustomNormalizer.cs @@ -28,15 +28,21 @@ public CustomNormalizer(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of normalizer. /// The name of the normalizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. It cannot end in '.microsoft' nor '.lucene', nor be named 'asciifolding', 'standard', 'lowercase', 'uppercase', or 'elision'. + /// Keeps track of any properties unknown to the library. /// A list of token filters used to filter out or modify the input token. For example, you can specify a lowercase filter that converts all characters to lowercase. The filters are run in the order in which they are listed. /// A list of character filters used to prepare input text before it is processed. For instance, they can replace certain characters or symbols. The filters are run in the order in which they are listed. - internal CustomNormalizer(string oDataType, string name, IList tokenFilters, IList charFilters) : base(oDataType, name) + internal CustomNormalizer(string oDataType, string name, IDictionary serializedAdditionalRawData, IList tokenFilters, IList charFilters) : base(oDataType, name, serializedAdditionalRawData) { TokenFilters = tokenFilters; CharFilters = charFilters; ODataType = oDataType ?? "#Microsoft.Azure.Search.CustomNormalizer"; } + /// Initializes a new instance of for deserialization. + internal CustomNormalizer() + { + } + /// A list of token filters used to filter out or modify the input token. For example, you can specify a lowercase filter that converts all characters to lowercase. The filters are run in the order in which they are listed. public IList TokenFilters { get; } /// A list of character filters used to prepare input text before it is processed. For instance, they can replace certain characters or symbols. The filters are run in the order in which they are listed. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DataChangeDetectionPolicy.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DataChangeDetectionPolicy.Serialization.cs index fcac3e6aab57..eee57ee74ac2 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DataChangeDetectionPolicy.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DataChangeDetectionPolicy.Serialization.cs @@ -5,24 +5,70 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Indexes.Models { - public partial class DataChangeDetectionPolicy : IUtf8JsonSerializable + public partial class DataChangeDetectionPolicy : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(DataChangeDetectionPolicy)} does not support writing '{format}' format."); + } + writer.WritePropertyName("@odata.type"u8); writer.WriteStringValue(ODataType); - writer.WriteEndObject(); + 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 + } + } } - internal static DataChangeDetectionPolicy DeserializeDataChangeDetectionPolicy(JsonElement element) + DataChangeDetectionPolicy 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(DataChangeDetectionPolicy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataChangeDetectionPolicy(document.RootElement, options); + } + + internal static DataChangeDetectionPolicy DeserializeDataChangeDetectionPolicy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -31,13 +77,44 @@ internal static DataChangeDetectionPolicy DeserializeDataChangeDetectionPolicy(J { switch (discriminator.GetString()) { - case "#Microsoft.Azure.Search.HighWaterMarkChangeDetectionPolicy": return HighWaterMarkChangeDetectionPolicy.DeserializeHighWaterMarkChangeDetectionPolicy(element); - case "#Microsoft.Azure.Search.SqlIntegratedChangeTrackingPolicy": return SqlIntegratedChangeTrackingPolicy.DeserializeSqlIntegratedChangeTrackingPolicy(element); + case "#Microsoft.Azure.Search.HighWaterMarkChangeDetectionPolicy": return HighWaterMarkChangeDetectionPolicy.DeserializeHighWaterMarkChangeDetectionPolicy(element, options); + case "#Microsoft.Azure.Search.SqlIntegratedChangeTrackingPolicy": return SqlIntegratedChangeTrackingPolicy.DeserializeSqlIntegratedChangeTrackingPolicy(element, options); } } - return UnknownDataChangeDetectionPolicy.DeserializeUnknownDataChangeDetectionPolicy(element); + return UnknownDataChangeDetectionPolicy.DeserializeUnknownDataChangeDetectionPolicy(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(DataChangeDetectionPolicy)} does not support writing '{options.Format}' format."); + } + } + + DataChangeDetectionPolicy 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 DeserializeDataChangeDetectionPolicy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataChangeDetectionPolicy)} 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 DataChangeDetectionPolicy FromResponse(Response response) @@ -50,7 +127,7 @@ internal static DataChangeDetectionPolicy FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DataChangeDetectionPolicy.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DataChangeDetectionPolicy.cs index 553ef79394b1..54bdcb2cc0ca 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DataChangeDetectionPolicy.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DataChangeDetectionPolicy.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// @@ -14,11 +17,45 @@ namespace Azure.Search.Documents.Indexes.Models /// public partial class DataChangeDetectionPolicy { + /// + /// 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 . /// A URI fragment specifying the type of data change detection policy. - internal DataChangeDetectionPolicy(string oDataType) + /// Keeps track of any properties unknown to the library. + internal DataChangeDetectionPolicy(string oDataType, IDictionary serializedAdditionalRawData) { ODataType = oDataType; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// A URI fragment specifying the type of data change detection policy. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DataDeletionDetectionPolicy.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DataDeletionDetectionPolicy.Serialization.cs index 89318fb0f5c4..c1fca3601e76 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DataDeletionDetectionPolicy.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DataDeletionDetectionPolicy.Serialization.cs @@ -5,24 +5,70 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Indexes.Models { - public partial class DataDeletionDetectionPolicy : IUtf8JsonSerializable + public partial class DataDeletionDetectionPolicy : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(DataDeletionDetectionPolicy)} does not support writing '{format}' format."); + } + writer.WritePropertyName("@odata.type"u8); writer.WriteStringValue(ODataType); - writer.WriteEndObject(); + 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 + } + } } - internal static DataDeletionDetectionPolicy DeserializeDataDeletionDetectionPolicy(JsonElement element) + DataDeletionDetectionPolicy 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(DataDeletionDetectionPolicy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataDeletionDetectionPolicy(document.RootElement, options); + } + + internal static DataDeletionDetectionPolicy DeserializeDataDeletionDetectionPolicy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -31,13 +77,44 @@ internal static DataDeletionDetectionPolicy DeserializeDataDeletionDetectionPoli { switch (discriminator.GetString()) { - case "#Microsoft.Azure.Search.NativeBlobSoftDeleteDeletionDetectionPolicy": return NativeBlobSoftDeleteDeletionDetectionPolicy.DeserializeNativeBlobSoftDeleteDeletionDetectionPolicy(element); - case "#Microsoft.Azure.Search.SoftDeleteColumnDeletionDetectionPolicy": return SoftDeleteColumnDeletionDetectionPolicy.DeserializeSoftDeleteColumnDeletionDetectionPolicy(element); + case "#Microsoft.Azure.Search.NativeBlobSoftDeleteDeletionDetectionPolicy": return NativeBlobSoftDeleteDeletionDetectionPolicy.DeserializeNativeBlobSoftDeleteDeletionDetectionPolicy(element, options); + case "#Microsoft.Azure.Search.SoftDeleteColumnDeletionDetectionPolicy": return SoftDeleteColumnDeletionDetectionPolicy.DeserializeSoftDeleteColumnDeletionDetectionPolicy(element, options); } } - return UnknownDataDeletionDetectionPolicy.DeserializeUnknownDataDeletionDetectionPolicy(element); + return UnknownDataDeletionDetectionPolicy.DeserializeUnknownDataDeletionDetectionPolicy(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(DataDeletionDetectionPolicy)} does not support writing '{options.Format}' format."); + } + } + + DataDeletionDetectionPolicy 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 DeserializeDataDeletionDetectionPolicy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataDeletionDetectionPolicy)} 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 DataDeletionDetectionPolicy FromResponse(Response response) @@ -50,7 +127,7 @@ internal static DataDeletionDetectionPolicy FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DataDeletionDetectionPolicy.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DataDeletionDetectionPolicy.cs index b586a85a237e..34c347a323af 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DataDeletionDetectionPolicy.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DataDeletionDetectionPolicy.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// @@ -14,11 +17,45 @@ namespace Azure.Search.Documents.Indexes.Models /// public partial class DataDeletionDetectionPolicy { + /// + /// 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 . /// A URI fragment specifying the type of data deletion detection policy. - internal DataDeletionDetectionPolicy(string oDataType) + /// Keeps track of any properties unknown to the library. + internal DataDeletionDetectionPolicy(string oDataType, IDictionary serializedAdditionalRawData) { ODataType = oDataType; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// A URI fragment specifying the type of data deletion detection policy. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DataSourceCredentials.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DataSourceCredentials.Serialization.cs index 5a6f42b2660c..92a26306dc70 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DataSourceCredentials.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DataSourceCredentials.Serialization.cs @@ -5,31 +5,80 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - internal partial class DataSourceCredentials : IUtf8JsonSerializable + internal partial class DataSourceCredentials : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(DataSourceCredentials)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(ConnectionString)) { writer.WritePropertyName("connectionString"u8); writer.WriteStringValue(ConnectionString); } - writer.WriteEndObject(); + 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 + } + } } - internal static DataSourceCredentials DeserializeDataSourceCredentials(JsonElement element) + DataSourceCredentials 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(DataSourceCredentials)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataSourceCredentials(document.RootElement, options); + } + + internal static DataSourceCredentials DeserializeDataSourceCredentials(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string connectionString = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("connectionString"u8)) @@ -37,10 +86,46 @@ internal static DataSourceCredentials DeserializeDataSourceCredentials(JsonEleme connectionString = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new DataSourceCredentials(connectionString); + serializedAdditionalRawData = rawDataDictionary; + return new DataSourceCredentials(connectionString, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(DataSourceCredentials)} does not support writing '{options.Format}' format."); + } + } + + DataSourceCredentials 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 DeserializeDataSourceCredentials(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataSourceCredentials)} 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 DataSourceCredentials FromResponse(Response response) @@ -53,7 +138,7 @@ internal static DataSourceCredentials FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DataSourceCredentials.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DataSourceCredentials.cs index 62c92b834ab5..1e1dd6ef2aa4 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DataSourceCredentials.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DataSourceCredentials.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Represents credentials that can be used to connect to a datasource. internal partial class DataSourceCredentials { + /// + /// 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 DataSourceCredentials() { @@ -17,9 +52,11 @@ public DataSourceCredentials() /// Initializes a new instance of . /// The connection string for the datasource. Set to `<unchanged>` (with brackets) if you don't want the connection string updated. Set to `<redacted>` if you want to remove the connection string value from the datasource. - internal DataSourceCredentials(string connectionString) + /// Keeps track of any properties unknown to the library. + internal DataSourceCredentials(string connectionString, IDictionary serializedAdditionalRawData) { ConnectionString = connectionString; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The connection string for the datasource. Set to `<unchanged>` (with brackets) if you don't want the connection string updated. Set to `<redacted>` if you want to remove the connection string value from the datasource. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DebugInfo.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DebugInfo.Serialization.cs index 61dde3059701..5a90d2946bc0 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DebugInfo.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DebugInfo.Serialization.cs @@ -5,19 +5,80 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class DebugInfo + public partial class DebugInfo : IUtf8JsonSerializable, IJsonModel { - internal static DebugInfo DeserializeDebugInfo(JsonElement element) + 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(DebugInfo)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(QueryRewrites)) + { + writer.WritePropertyName("queryRewrites"u8); + writer.WriteObjectValue(QueryRewrites, options); + } + 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 + } + } + } + + DebugInfo 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(DebugInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDebugInfo(document.RootElement, options); + } + + internal static DebugInfo DeserializeDebugInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } QueryRewritesDebugInfo queryRewrites = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("queryRewrites"u8)) @@ -26,13 +87,49 @@ internal static DebugInfo DeserializeDebugInfo(JsonElement element) { continue; } - queryRewrites = QueryRewritesDebugInfo.DeserializeQueryRewritesDebugInfo(property.Value); + queryRewrites = QueryRewritesDebugInfo.DeserializeQueryRewritesDebugInfo(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DebugInfo(queryRewrites, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(DebugInfo)} does not support writing '{options.Format}' format."); + } + } + + DebugInfo 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 DeserializeDebugInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DebugInfo)} does not support reading '{options.Format}' format."); } - return new DebugInfo(queryRewrites); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static DebugInfo FromResponse(Response response) @@ -40,5 +137,13 @@ internal static DebugInfo FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDebugInfo(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/search/Azure.Search.Documents/src/Generated/Models/DebugInfo.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DebugInfo.cs index b50ff0c0537f..f551f8ecdcb1 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DebugInfo.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DebugInfo.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Models { /// Contains debugging information that can be used to further explore your search results. public partial class DebugInfo { + /// + /// 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 . internal DebugInfo() { @@ -17,9 +52,11 @@ internal DebugInfo() /// Initializes a new instance of . /// Contains debugging information specific to query rewrites. - internal DebugInfo(QueryRewritesDebugInfo queryRewrites) + /// Keeps track of any properties unknown to the library. + internal DebugInfo(QueryRewritesDebugInfo queryRewrites, IDictionary serializedAdditionalRawData) { QueryRewrites = queryRewrites; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Contains debugging information specific to query rewrites. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DefaultCognitiveServicesAccount.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DefaultCognitiveServicesAccount.Serialization.cs index b9416c718edd..02bee501723b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DefaultCognitiveServicesAccount.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DefaultCognitiveServicesAccount.Serialization.cs @@ -5,34 +5,62 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class DefaultCognitiveServicesAccount : IUtf8JsonSerializable + public partial class DefaultCognitiveServicesAccount : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Description)) + 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") { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); + throw new FormatException($"The model {nameof(DefaultCognitiveServicesAccount)} does not support writing '{format}' format."); } - writer.WriteEndObject(); + + base.JsonModelWriteCore(writer, options); } - internal static DefaultCognitiveServicesAccount DeserializeDefaultCognitiveServicesAccount(JsonElement element) + DefaultCognitiveServicesAccount 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(DefaultCognitiveServicesAccount)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDefaultCognitiveServicesAccount(document.RootElement, options); + } + + internal static DefaultCognitiveServicesAccount DeserializeDefaultCognitiveServicesAccount(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string odataType = default; string description = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@odata.type"u8)) @@ -45,10 +73,46 @@ internal static DefaultCognitiveServicesAccount DeserializeDefaultCognitiveServi description = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DefaultCognitiveServicesAccount(odataType, description, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(DefaultCognitiveServicesAccount)} does not support writing '{options.Format}' format."); } - return new DefaultCognitiveServicesAccount(odataType, description); } + DefaultCognitiveServicesAccount 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 DeserializeDefaultCognitiveServicesAccount(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DefaultCognitiveServicesAccount)} 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 DefaultCognitiveServicesAccount FromResponse(Response response) @@ -61,7 +125,7 @@ internal static DefaultCognitiveServicesAccount DeserializeDefaultCognitiveServi internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DefaultCognitiveServicesAccount.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DefaultCognitiveServicesAccount.cs index 4004250759df..2c4163a512f9 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DefaultCognitiveServicesAccount.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DefaultCognitiveServicesAccount.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// An empty object that represents the default Azure AI service resource for a skillset. @@ -19,7 +22,8 @@ public DefaultCognitiveServicesAccount() /// Initializes a new instance of . /// A URI fragment specifying the type of Azure AI service resource attached to a skillset. /// Description of the Azure AI service resource attached to a skillset. - internal DefaultCognitiveServicesAccount(string oDataType, string description) : base(oDataType, description) + /// Keeps track of any properties unknown to the library. + internal DefaultCognitiveServicesAccount(string oDataType, string description, IDictionary serializedAdditionalRawData) : base(oDataType, description, serializedAdditionalRawData) { ODataType = oDataType ?? "#Microsoft.Azure.Search.DefaultCognitiveServices"; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DictionaryDecompounderTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DictionaryDecompounderTokenFilter.Serialization.cs index 912a886e7b16..123a17c82def 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DictionaryDecompounderTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DictionaryDecompounderTokenFilter.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class DictionaryDecompounderTokenFilter : IUtf8JsonSerializable + public partial class DictionaryDecompounderTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(DictionaryDecompounderTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("wordList"u8); writer.WriteStartArray(); foreach (var item in WordList) @@ -43,15 +62,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("onlyLongestMatch"u8); writer.WriteBooleanValue(OnlyLongestMatch.Value); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static DictionaryDecompounderTokenFilter DeserializeDictionaryDecompounderTokenFilter(JsonElement element) + DictionaryDecompounderTokenFilter 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(DictionaryDecompounderTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDictionaryDecompounderTokenFilter(document.RootElement, options); + } + + internal static DictionaryDecompounderTokenFilter DeserializeDictionaryDecompounderTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -63,6 +91,8 @@ internal static DictionaryDecompounderTokenFilter DeserializeDictionaryDecompoun bool? onlyLongestMatch = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("wordList"u8)) @@ -121,10 +151,16 @@ internal static DictionaryDecompounderTokenFilter DeserializeDictionaryDecompoun name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new DictionaryDecompounderTokenFilter( odataType, name, + serializedAdditionalRawData, wordList, minWordSize, minSubwordSize, @@ -132,6 +168,37 @@ internal static DictionaryDecompounderTokenFilter DeserializeDictionaryDecompoun onlyLongestMatch); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(DictionaryDecompounderTokenFilter)} does not support writing '{options.Format}' format."); + } + } + + DictionaryDecompounderTokenFilter 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 DeserializeDictionaryDecompounderTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DictionaryDecompounderTokenFilter)} 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 DictionaryDecompounderTokenFilter FromResponse(Response response) @@ -144,7 +211,7 @@ internal static DictionaryDecompounderTokenFilter DeserializeDictionaryDecompoun internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DictionaryDecompounderTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DictionaryDecompounderTokenFilter.cs index d8d49736c211..98f2a8b55120 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DictionaryDecompounderTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DictionaryDecompounderTokenFilter.cs @@ -30,12 +30,13 @@ public DictionaryDecompounderTokenFilter(string name, IEnumerable wordLi /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The list of words to match against. /// The minimum word size. Only words longer than this get processed. Default is 5. Maximum is 300. /// The minimum subword size. Only subwords longer than this are outputted. Default is 2. Maximum is 300. /// The maximum subword size. Only subwords shorter than this are outputted. Default is 15. Maximum is 300. /// A value indicating whether to add only the longest matching subword to the output. Default is false. - internal DictionaryDecompounderTokenFilter(string oDataType, string name, IList wordList, int? minWordSize, int? minSubwordSize, int? maxSubwordSize, bool? onlyLongestMatch) : base(oDataType, name) + internal DictionaryDecompounderTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, IList wordList, int? minWordSize, int? minSubwordSize, int? maxSubwordSize, bool? onlyLongestMatch) : base(oDataType, name, serializedAdditionalRawData) { WordList = wordList; MinWordSize = minWordSize; @@ -44,6 +45,11 @@ internal DictionaryDecompounderTokenFilter(string oDataType, string name, IList< OnlyLongestMatch = onlyLongestMatch; ODataType = oDataType ?? "#Microsoft.Azure.Search.DictionaryDecompounderTokenFilter"; } + + /// Initializes a new instance of for deserialization. + internal DictionaryDecompounderTokenFilter() + { + } /// The minimum word size. Only words longer than this get processed. Default is 5. Maximum is 300. public int? MinWordSize { get; set; } /// The minimum subword size. Only subwords longer than this are outputted. Default is 2. Maximum is 300. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DistanceScoringFunction.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DistanceScoringFunction.Serialization.cs index 9db45fd0785e..5256be31c018 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DistanceScoringFunction.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DistanceScoringFunction.Serialization.cs @@ -5,34 +5,56 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class DistanceScoringFunction : IUtf8JsonSerializable + public partial class DistanceScoringFunction : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(DistanceScoringFunction)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("distance"u8); - writer.WriteObjectValue(Parameters); - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - writer.WritePropertyName("fieldName"u8); - writer.WriteStringValue(FieldName); - writer.WritePropertyName("boost"u8); - writer.WriteNumberValue(Boost); - if (Optional.IsDefined(Interpolation)) + writer.WriteObjectValue(Parameters, options); + } + + DistanceScoringFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WritePropertyName("interpolation"u8); - writer.WriteStringValue(Interpolation.Value.ToSerialString()); + throw new FormatException($"The model {nameof(DistanceScoringFunction)} does not support reading '{format}' format."); } - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDistanceScoringFunction(document.RootElement, options); } - internal static DistanceScoringFunction DeserializeDistanceScoringFunction(JsonElement element) + internal static DistanceScoringFunction DeserializeDistanceScoringFunction(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -42,11 +64,13 @@ internal static DistanceScoringFunction DeserializeDistanceScoringFunction(JsonE string fieldName = default; double boost = default; ScoringFunctionInterpolation? interpolation = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("distance"u8)) { - distance = DistanceScoringParameters.DeserializeDistanceScoringParameters(property.Value); + distance = DistanceScoringParameters.DeserializeDistanceScoringParameters(property.Value, options); continue; } if (property.NameEquals("type"u8)) @@ -73,10 +97,52 @@ internal static DistanceScoringFunction DeserializeDistanceScoringFunction(JsonE interpolation = property.Value.GetString().ToScoringFunctionInterpolation(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new DistanceScoringFunction(type, fieldName, boost, interpolation, distance); + serializedAdditionalRawData = rawDataDictionary; + return new DistanceScoringFunction( + type, + fieldName, + boost, + interpolation, + serializedAdditionalRawData, + distance); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(DistanceScoringFunction)} does not support writing '{options.Format}' format."); + } + } + + DistanceScoringFunction 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 DeserializeDistanceScoringFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DistanceScoringFunction)} 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 DistanceScoringFunction FromResponse(Response response) @@ -89,7 +155,7 @@ internal static DistanceScoringFunction DeserializeDistanceScoringFunction(JsonE internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DistanceScoringFunction.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DistanceScoringFunction.cs index 1c6f26b8a4ac..9fa76d85cdfd 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DistanceScoringFunction.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DistanceScoringFunction.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -17,13 +18,19 @@ public partial class DistanceScoringFunction : ScoringFunction /// The name of the field used as input to the scoring function. /// A multiplier for the raw score. Must be a positive number not equal to 1.0. /// A value indicating how boosting will be interpolated across document scores; defaults to "Linear". + /// Keeps track of any properties unknown to the library. /// Parameter values for the distance scoring function. - internal DistanceScoringFunction(string type, string fieldName, double boost, ScoringFunctionInterpolation? interpolation, DistanceScoringParameters parameters) : base(type, fieldName, boost, interpolation) + internal DistanceScoringFunction(string type, string fieldName, double boost, ScoringFunctionInterpolation? interpolation, IDictionary serializedAdditionalRawData, DistanceScoringParameters parameters) : base(type, fieldName, boost, interpolation, serializedAdditionalRawData) { Parameters = parameters; Type = type ?? "distance"; } + /// Initializes a new instance of for deserialization. + internal DistanceScoringFunction() + { + } + /// Parameter values for the distance scoring function. public DistanceScoringParameters Parameters { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DistanceScoringParameters.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DistanceScoringParameters.Serialization.cs index 9eab56fbf6fa..bc97e6f9ebf7 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DistanceScoringParameters.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DistanceScoringParameters.Serialization.cs @@ -5,31 +5,80 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class DistanceScoringParameters : IUtf8JsonSerializable + public partial class DistanceScoringParameters : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(DistanceScoringParameters)} does not support writing '{format}' format."); + } + writer.WritePropertyName("referencePointParameter"u8); writer.WriteStringValue(ReferencePointParameter); writer.WritePropertyName("boostingDistance"u8); writer.WriteNumberValue(BoostingDistance); - writer.WriteEndObject(); + 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 + } + } } - internal static DistanceScoringParameters DeserializeDistanceScoringParameters(JsonElement element) + DistanceScoringParameters 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(DistanceScoringParameters)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDistanceScoringParameters(document.RootElement, options); + } + + internal static DistanceScoringParameters DeserializeDistanceScoringParameters(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string referencePointParameter = default; double boostingDistance = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("referencePointParameter"u8)) @@ -42,10 +91,46 @@ internal static DistanceScoringParameters DeserializeDistanceScoringParameters(J boostingDistance = property.Value.GetDouble(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new DistanceScoringParameters(referencePointParameter, boostingDistance); + serializedAdditionalRawData = rawDataDictionary; + return new DistanceScoringParameters(referencePointParameter, boostingDistance, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(DistanceScoringParameters)} does not support writing '{options.Format}' format."); + } + } + + DistanceScoringParameters 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 DeserializeDistanceScoringParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DistanceScoringParameters)} 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 DistanceScoringParameters FromResponse(Response response) @@ -58,7 +143,7 @@ internal static DistanceScoringParameters FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DistanceScoringParameters.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DistanceScoringParameters.cs index 9269044aa6fd..c8fbb6d0bfee 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DistanceScoringParameters.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DistanceScoringParameters.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Provides parameter values to a distance scoring function. public partial class DistanceScoringParameters { + /// + /// 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 . /// The name of the parameter passed in search queries to specify the reference location. /// The distance in kilometers from the reference location where the boosting range ends. @@ -24,6 +57,22 @@ public DistanceScoringParameters(string referencePointParameter, double boosting BoostingDistance = boostingDistance; } + /// Initializes a new instance of . + /// The name of the parameter passed in search queries to specify the reference location. + /// The distance in kilometers from the reference location where the boosting range ends. + /// Keeps track of any properties unknown to the library. + internal DistanceScoringParameters(string referencePointParameter, double boostingDistance, IDictionary serializedAdditionalRawData) + { + ReferencePointParameter = referencePointParameter; + BoostingDistance = boostingDistance; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DistanceScoringParameters() + { + } + /// The name of the parameter passed in search queries to specify the reference location. public string ReferencePointParameter { get; set; } /// The distance in kilometers from the reference location where the boosting range ends. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentDebugInfo.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentDebugInfo.Serialization.cs index 44fd64673c2a..79940079a00f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentDebugInfo.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentDebugInfo.Serialization.cs @@ -5,15 +5,99 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class DocumentDebugInfo + public partial class DocumentDebugInfo : IUtf8JsonSerializable, IJsonModel { - internal static DocumentDebugInfo DeserializeDocumentDebugInfo(JsonElement element) + 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(DocumentDebugInfo)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Semantic)) + { + writer.WritePropertyName("semantic"u8); + writer.WriteObjectValue(Semantic, options); + } + if (options.Format != "W" && Optional.IsDefined(Vectors)) + { + writer.WritePropertyName("vectors"u8); + writer.WriteObjectValue(Vectors, options); + } + if (options.Format != "W" && Optional.IsCollectionDefined(InnerHits)) + { + writer.WritePropertyName("innerHits"u8); + writer.WriteStartObject(); + foreach (var item in InnerHits) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStartArray(); + foreach (var item0 in item.Value) + { + writer.WriteObjectValue(item0, options); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + 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 + } + } + } + + DocumentDebugInfo 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(DocumentDebugInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDocumentDebugInfo(document.RootElement, options); + } + + internal static DocumentDebugInfo DeserializeDocumentDebugInfo(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -21,6 +105,8 @@ internal static DocumentDebugInfo DeserializeDocumentDebugInfo(JsonElement eleme SemanticDebugInfo semantic = default; VectorsDebugInfo vectors = default; IReadOnlyDictionary> innerHits = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("semantic"u8)) @@ -29,7 +115,7 @@ internal static DocumentDebugInfo DeserializeDocumentDebugInfo(JsonElement eleme { continue; } - semantic = SemanticDebugInfo.DeserializeSemanticDebugInfo(property.Value); + semantic = SemanticDebugInfo.DeserializeSemanticDebugInfo(property.Value, options); continue; } if (property.NameEquals("vectors"u8)) @@ -38,7 +124,7 @@ internal static DocumentDebugInfo DeserializeDocumentDebugInfo(JsonElement eleme { continue; } - vectors = VectorsDebugInfo.DeserializeVectorsDebugInfo(property.Value); + vectors = VectorsDebugInfo.DeserializeVectorsDebugInfo(property.Value, options); continue; } if (property.NameEquals("innerHits"u8)) @@ -59,7 +145,7 @@ internal static DocumentDebugInfo DeserializeDocumentDebugInfo(JsonElement eleme List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(QueryResultDocumentInnerHit.DeserializeQueryResultDocumentInnerHit(item)); + array.Add(QueryResultDocumentInnerHit.DeserializeQueryResultDocumentInnerHit(item, options)); } dictionary.Add(property0.Name, array); } @@ -67,10 +153,46 @@ internal static DocumentDebugInfo DeserializeDocumentDebugInfo(JsonElement eleme innerHits = dictionary; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DocumentDebugInfo(semantic, vectors, innerHits ?? new ChangeTrackingDictionary>(), 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(DocumentDebugInfo)} does not support writing '{options.Format}' format."); + } + } + + DocumentDebugInfo 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 DeserializeDocumentDebugInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DocumentDebugInfo)} does not support reading '{options.Format}' format."); } - return new DocumentDebugInfo(semantic, vectors, innerHits ?? new ChangeTrackingDictionary>()); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static DocumentDebugInfo FromResponse(Response response) @@ -78,5 +200,13 @@ internal static DocumentDebugInfo FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDocumentDebugInfo(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/search/Azure.Search.Documents/src/Generated/Models/DocumentDebugInfo.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentDebugInfo.cs index aab3ce66c7e1..b0db9b83686c 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentDebugInfo.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentDebugInfo.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.Search.Documents.Models @@ -12,6 +13,38 @@ namespace Azure.Search.Documents.Models /// Contains debugging information that can be used to further explore your search results. public partial class DocumentDebugInfo { + /// + /// 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 . internal DocumentDebugInfo() { @@ -22,11 +55,13 @@ internal DocumentDebugInfo() /// Contains debugging information specific to semantic ranking requests. /// Contains debugging information specific to vector and hybrid search. /// Contains debugging information specific to vectors matched within a collection of complex types. - internal DocumentDebugInfo(SemanticDebugInfo semantic, VectorsDebugInfo vectors, IReadOnlyDictionary> innerHits) + /// Keeps track of any properties unknown to the library. + internal DocumentDebugInfo(SemanticDebugInfo semantic, VectorsDebugInfo vectors, IReadOnlyDictionary> innerHits, IDictionary serializedAdditionalRawData) { Semantic = semantic; Vectors = vectors; InnerHits = innerHits; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Contains debugging information specific to semantic ranking requests. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentExtractionSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentExtractionSkill.Serialization.cs index 231d8b13ea9b..3ee83aa4cb8d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentExtractionSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentExtractionSkill.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class DocumentExtractionSkill : IUtf8JsonSerializable + public partial class DocumentExtractionSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(DocumentExtractionSkill)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(ParsingMode)) { if (ParsingMode != null) @@ -54,7 +73,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNullValue(); continue; } - writer.WriteObjectValue(item.Value); + writer.WriteObjectValue(item.Value, options); } writer.WriteEndObject(); } @@ -63,42 +82,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("configuration"); } } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + DocumentExtractionSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(DocumentExtractionSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDocumentExtractionSkill(document.RootElement, options); } - internal static DocumentExtractionSkill DeserializeDocumentExtractionSkill(JsonElement element) + internal static DocumentExtractionSkill DeserializeDocumentExtractionSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -112,6 +113,8 @@ internal static DocumentExtractionSkill DeserializeDocumentExtractionSkill(JsonE string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("parsingMode"u8)) @@ -181,7 +184,7 @@ internal static DocumentExtractionSkill DeserializeDocumentExtractionSkill(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -191,12 +194,17 @@ internal static DocumentExtractionSkill DeserializeDocumentExtractionSkill(JsonE List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new DocumentExtractionSkill( odataType, name, @@ -204,11 +212,43 @@ internal static DocumentExtractionSkill DeserializeDocumentExtractionSkill(JsonE context, inputs, outputs, + serializedAdditionalRawData, parsingMode, dataToExtract, configuration ?? new ChangeTrackingDictionary()); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(DocumentExtractionSkill)} does not support writing '{options.Format}' format."); + } + } + + DocumentExtractionSkill 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 DeserializeDocumentExtractionSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DocumentExtractionSkill)} 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 DocumentExtractionSkill FromResponse(Response response) @@ -221,7 +261,7 @@ internal static DocumentExtractionSkill DeserializeDocumentExtractionSkill(JsonE internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentExtractionSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentExtractionSkill.cs index 089347fe6255..39a93751bbec 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentExtractionSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentExtractionSkill.cs @@ -33,15 +33,21 @@ public DocumentExtractionSkill(IEnumerable inputs, IEnum /// Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// The parsingMode for the skill. Will be set to 'default' if not defined. /// The type of data to be extracted for the skill. Will be set to 'contentAndMetadata' if not defined. /// A dictionary of configurations for the skill. - internal DocumentExtractionSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, BlobIndexerParsingMode? parsingMode, BlobIndexerDataToExtract? dataToExtract, IDictionary configuration) : base(oDataType, name, description, context, inputs, outputs) + internal DocumentExtractionSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, BlobIndexerParsingMode? parsingMode, BlobIndexerDataToExtract? dataToExtract, IDictionary configuration) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { ParsingMode = parsingMode; DataToExtract = dataToExtract; Configuration = configuration; ODataType = oDataType ?? "#Microsoft.Skills.Util.DocumentExtractionSkill"; } + + /// Initializes a new instance of for deserialization. + internal DocumentExtractionSkill() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentIntelligenceLayoutSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentIntelligenceLayoutSkill.Serialization.cs index 4611eb4fe308..42b989175800 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentIntelligenceLayoutSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentIntelligenceLayoutSkill.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class DocumentIntelligenceLayoutSkill : IUtf8JsonSerializable + public partial class DocumentIntelligenceLayoutSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(DocumentIntelligenceLayoutSkill)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(OutputFormat)) { if (OutputFormat != null) @@ -74,49 +93,31 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (ChunkingProperties != null) { writer.WritePropertyName("chunkingProperties"u8); - writer.WriteObjectValue(ChunkingProperties); + writer.WriteObjectValue(ChunkingProperties, options); } else { writer.WriteNull("chunkingProperties"); } } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + DocumentIntelligenceLayoutSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(DocumentIntelligenceLayoutSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDocumentIntelligenceLayoutSkill(document.RootElement, options); } - internal static DocumentIntelligenceLayoutSkill DeserializeDocumentIntelligenceLayoutSkill(JsonElement element) + internal static DocumentIntelligenceLayoutSkill DeserializeDocumentIntelligenceLayoutSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -132,6 +133,8 @@ internal static DocumentIntelligenceLayoutSkill DeserializeDocumentIntelligenceL string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("outputFormat"u8)) @@ -186,7 +189,7 @@ internal static DocumentIntelligenceLayoutSkill DeserializeDocumentIntelligenceL chunkingProperties = null; continue; } - chunkingProperties = DocumentIntelligenceLayoutSkillChunkingProperties.DeserializeDocumentIntelligenceLayoutSkillChunkingProperties(property.Value); + chunkingProperties = DocumentIntelligenceLayoutSkillChunkingProperties.DeserializeDocumentIntelligenceLayoutSkillChunkingProperties(property.Value, options); continue; } if (property.NameEquals("@odata.type"u8)) @@ -214,7 +217,7 @@ internal static DocumentIntelligenceLayoutSkill DeserializeDocumentIntelligenceL List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -224,12 +227,17 @@ internal static DocumentIntelligenceLayoutSkill DeserializeDocumentIntelligenceL List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new DocumentIntelligenceLayoutSkill( odataType, name, @@ -237,6 +245,7 @@ internal static DocumentIntelligenceLayoutSkill DeserializeDocumentIntelligenceL context, inputs, outputs, + serializedAdditionalRawData, outputFormat, outputMode, markdownHeaderDepth, @@ -244,6 +253,37 @@ internal static DocumentIntelligenceLayoutSkill DeserializeDocumentIntelligenceL chunkingProperties); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(DocumentIntelligenceLayoutSkill)} does not support writing '{options.Format}' format."); + } + } + + DocumentIntelligenceLayoutSkill 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 DeserializeDocumentIntelligenceLayoutSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DocumentIntelligenceLayoutSkill)} 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 DocumentIntelligenceLayoutSkill FromResponse(Response response) @@ -256,7 +296,7 @@ internal static DocumentIntelligenceLayoutSkill DeserializeDocumentIntelligenceL internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentIntelligenceLayoutSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentIntelligenceLayoutSkill.cs index 2a491c492f5b..fb81cbf54a22 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentIntelligenceLayoutSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentIntelligenceLayoutSkill.cs @@ -33,12 +33,13 @@ public DocumentIntelligenceLayoutSkill(IEnumerable input /// Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// Controls the cardinality of the output format. Default is 'markdown'. /// Controls the cardinality of the output produced by the skill. Default is 'oneToMany'. /// The depth of headers in the markdown output. Default is h6. /// Controls the cardinality of the content extracted from the document by the skill. /// Controls the cardinality for chunking the content. - internal DocumentIntelligenceLayoutSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, DocumentIntelligenceLayoutSkillOutputFormat? outputFormat, DocumentIntelligenceLayoutSkillOutputMode? outputMode, DocumentIntelligenceLayoutSkillMarkdownHeaderDepth? markdownHeaderDepth, IList extractionOptions, DocumentIntelligenceLayoutSkillChunkingProperties chunkingProperties) : base(oDataType, name, description, context, inputs, outputs) + internal DocumentIntelligenceLayoutSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, DocumentIntelligenceLayoutSkillOutputFormat? outputFormat, DocumentIntelligenceLayoutSkillOutputMode? outputMode, DocumentIntelligenceLayoutSkillMarkdownHeaderDepth? markdownHeaderDepth, IList extractionOptions, DocumentIntelligenceLayoutSkillChunkingProperties chunkingProperties) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { OutputFormat = outputFormat; OutputMode = outputMode; @@ -48,6 +49,11 @@ internal DocumentIntelligenceLayoutSkill(string oDataType, string name, string d ODataType = oDataType ?? "#Microsoft.Skills.Util.DocumentIntelligenceLayoutSkill"; } + /// Initializes a new instance of for deserialization. + internal DocumentIntelligenceLayoutSkill() + { + } + /// Controls the cardinality of the output format. Default is 'markdown'. public DocumentIntelligenceLayoutSkillOutputFormat? OutputFormat { get; set; } /// Controls the cardinality of the output produced by the skill. Default is 'oneToMany'. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentIntelligenceLayoutSkillChunkingProperties.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentIntelligenceLayoutSkillChunkingProperties.Serialization.cs index 62f50c8ccfd5..0b49f65e8bda 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentIntelligenceLayoutSkillChunkingProperties.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentIntelligenceLayoutSkillChunkingProperties.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class DocumentIntelligenceLayoutSkillChunkingProperties : IUtf8JsonSerializable + public partial class DocumentIntelligenceLayoutSkillChunkingProperties : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(DocumentIntelligenceLayoutSkillChunkingProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Unit)) { if (Unit != null) @@ -51,11 +70,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("overlapLength"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static DocumentIntelligenceLayoutSkillChunkingProperties DeserializeDocumentIntelligenceLayoutSkillChunkingProperties(JsonElement element) + DocumentIntelligenceLayoutSkillChunkingProperties 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(DocumentIntelligenceLayoutSkillChunkingProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDocumentIntelligenceLayoutSkillChunkingProperties(document.RootElement, options); + } + + internal static DocumentIntelligenceLayoutSkillChunkingProperties DeserializeDocumentIntelligenceLayoutSkillChunkingProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -63,6 +110,8 @@ internal static DocumentIntelligenceLayoutSkillChunkingProperties DeserializeDoc DocumentIntelligenceLayoutSkillChunkingUnit? unit = default; int? maximumLength = default; int? overlapLength = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("unit"u8)) @@ -95,10 +144,46 @@ internal static DocumentIntelligenceLayoutSkillChunkingProperties DeserializeDoc overlapLength = property.Value.GetInt32(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DocumentIntelligenceLayoutSkillChunkingProperties(unit, maximumLength, overlapLength, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(DocumentIntelligenceLayoutSkillChunkingProperties)} does not support writing '{options.Format}' format."); } - return new DocumentIntelligenceLayoutSkillChunkingProperties(unit, maximumLength, overlapLength); } + DocumentIntelligenceLayoutSkillChunkingProperties 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 DeserializeDocumentIntelligenceLayoutSkillChunkingProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DocumentIntelligenceLayoutSkillChunkingProperties)} 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 DocumentIntelligenceLayoutSkillChunkingProperties FromResponse(Response response) @@ -111,7 +196,7 @@ internal static DocumentIntelligenceLayoutSkillChunkingProperties FromResponse(R internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentIntelligenceLayoutSkillChunkingProperties.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentIntelligenceLayoutSkillChunkingProperties.cs index d87cfc89a2a7..d0d2cb0161b7 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentIntelligenceLayoutSkillChunkingProperties.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/DocumentIntelligenceLayoutSkillChunkingProperties.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Controls the cardinality for chunking the content. public partial class DocumentIntelligenceLayoutSkillChunkingProperties { + /// + /// 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 DocumentIntelligenceLayoutSkillChunkingProperties() { @@ -19,11 +54,13 @@ public DocumentIntelligenceLayoutSkillChunkingProperties() /// The unit of the chunk. /// The maximum chunk length in characters. Default is 500. /// The length of overlap provided between two text chunks. Default is 0. - internal DocumentIntelligenceLayoutSkillChunkingProperties(DocumentIntelligenceLayoutSkillChunkingUnit? unit, int? maximumLength, int? overlapLength) + /// Keeps track of any properties unknown to the library. + internal DocumentIntelligenceLayoutSkillChunkingProperties(DocumentIntelligenceLayoutSkillChunkingUnit? unit, int? maximumLength, int? overlapLength, IDictionary serializedAdditionalRawData) { Unit = unit; MaximumLength = maximumLength; OverlapLength = overlapLength; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The unit of the chunk. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilter.Serialization.cs index cfcac905fb74..e3ed3b3d0c88 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilter.Serialization.cs @@ -5,13 +5,163 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class EdgeNGramTokenFilter : IUtf8JsonSerializable + public partial class EdgeNGramTokenFilter : IUtf8JsonSerializable, IJsonModel { + 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(EdgeNGramTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(MinGram)) + { + writer.WritePropertyName("minGram"u8); + writer.WriteNumberValue(MinGram.Value); + } + if (Optional.IsDefined(MaxGram)) + { + writer.WritePropertyName("maxGram"u8); + writer.WriteNumberValue(MaxGram.Value); + } + if (Optional.IsDefined(Side)) + { + writer.WritePropertyName("side"u8); + writer.WriteStringValue(Side.Value.ToSerialString()); + } + } + + EdgeNGramTokenFilter 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(EdgeNGramTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEdgeNGramTokenFilter(document.RootElement, options); + } + + internal static EdgeNGramTokenFilter DeserializeEdgeNGramTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? minGram = default; + int? maxGram = default; + EdgeNGramTokenFilterSide? side = default; + string odataType = default; + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("minGram"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + minGram = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("maxGram"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxGram = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("side"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + side = property.Value.GetString().ToEdgeNGramTokenFilterSide(); + continue; + } + if (property.NameEquals("@odata.type"u8)) + { + odataType = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EdgeNGramTokenFilter( + odataType, + name, + serializedAdditionalRawData, + minGram, + maxGram, + side); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(EdgeNGramTokenFilter)} does not support writing '{options.Format}' format."); + } + } + + EdgeNGramTokenFilter 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 DeserializeEdgeNGramTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EdgeNGramTokenFilter)} 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 EdgeNGramTokenFilter FromResponse(Response response) @@ -24,7 +174,7 @@ public partial class EdgeNGramTokenFilter : IUtf8JsonSerializable internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilter.cs index 72465c201465..8e4a322f95fc 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilter.cs @@ -6,11 +6,31 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Generates n-grams of the given size(s) starting from the front or the back of an input token. This token filter is implemented using Apache Lucene. public partial class EdgeNGramTokenFilter : TokenFilter { + /// Initializes a new instance of . + /// A URI fragment specifying the type of token filter. + /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. + /// The minimum n-gram length. Default is 1. Maximum is 300. Must be less than the value of maxGram. + /// The maximum n-gram length. Default is 2. Maximum is 300. + /// Specifies which side of the input the n-gram should be generated from. Default is "front". + internal EdgeNGramTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, int? minGram, int? maxGram, EdgeNGramTokenFilterSide? side) : base(oDataType, name, serializedAdditionalRawData) + { + MinGram = minGram; + MaxGram = maxGram; + Side = side; + ODataType = oDataType ?? "#Microsoft.Azure.Search.EdgeNGramTokenFilterV2"; + } + + /// Initializes a new instance of for deserialization. + internal EdgeNGramTokenFilter() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenizer.Serialization.cs index 68ef5c425c2d..55ae83d4c50c 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenizer.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class EdgeNGramTokenizer : IUtf8JsonSerializable + public partial class EdgeNGramTokenizer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(EdgeNGramTokenizer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(MinGram)) { writer.WritePropertyName("minGram"u8); @@ -36,15 +55,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WriteEndArray(); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static EdgeNGramTokenizer DeserializeEdgeNGramTokenizer(JsonElement element) + EdgeNGramTokenizer 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(EdgeNGramTokenizer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEdgeNGramTokenizer(document.RootElement, options); + } + + internal static EdgeNGramTokenizer DeserializeEdgeNGramTokenizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -54,6 +82,8 @@ internal static EdgeNGramTokenizer DeserializeEdgeNGramTokenizer(JsonElement ele IList tokenChars = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("minGram"u8)) @@ -98,10 +128,52 @@ internal static EdgeNGramTokenizer DeserializeEdgeNGramTokenizer(JsonElement ele name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EdgeNGramTokenizer( + odataType, + name, + serializedAdditionalRawData, + minGram, + maxGram, + tokenChars ?? new ChangeTrackingList()); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(EdgeNGramTokenizer)} does not support writing '{options.Format}' format."); + } + } + + EdgeNGramTokenizer 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 DeserializeEdgeNGramTokenizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EdgeNGramTokenizer)} does not support reading '{options.Format}' format."); } - return new EdgeNGramTokenizer(odataType, name, minGram, maxGram, tokenChars ?? new ChangeTrackingList()); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new EdgeNGramTokenizer FromResponse(Response response) @@ -114,7 +186,7 @@ internal static EdgeNGramTokenizer DeserializeEdgeNGramTokenizer(JsonElement ele internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenizer.cs index b3472769bca9..6be55513cca6 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenizer.cs @@ -27,10 +27,11 @@ public EdgeNGramTokenizer(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of tokenizer. /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The minimum n-gram length. Default is 1. Maximum is 300. Must be less than the value of maxGram. /// The maximum n-gram length. Default is 2. Maximum is 300. /// Character classes to keep in the tokens. - internal EdgeNGramTokenizer(string oDataType, string name, int? minGram, int? maxGram, IList tokenChars) : base(oDataType, name) + internal EdgeNGramTokenizer(string oDataType, string name, IDictionary serializedAdditionalRawData, int? minGram, int? maxGram, IList tokenChars) : base(oDataType, name, serializedAdditionalRawData) { MinGram = minGram; MaxGram = maxGram; @@ -38,6 +39,11 @@ internal EdgeNGramTokenizer(string oDataType, string name, int? minGram, int? ma ODataType = oDataType ?? "#Microsoft.Azure.Search.EdgeNGramTokenizer"; } + /// Initializes a new instance of for deserialization. + internal EdgeNGramTokenizer() + { + } + /// The minimum n-gram length. Default is 1. Maximum is 300. Must be less than the value of maxGram. public int? MinGram { get; set; } /// The maximum n-gram length. Default is 2. Maximum is 300. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ElisionTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ElisionTokenFilter.Serialization.cs index d35e656d79f8..66efbad17f33 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ElisionTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ElisionTokenFilter.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class ElisionTokenFilter : IUtf8JsonSerializable + public partial class ElisionTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(ElisionTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsCollectionDefined(Articles)) { writer.WritePropertyName("articles"u8); @@ -26,15 +45,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WriteEndArray(); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static ElisionTokenFilter DeserializeElisionTokenFilter(JsonElement element) + ElisionTokenFilter 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(ElisionTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeElisionTokenFilter(document.RootElement, options); + } + + internal static ElisionTokenFilter DeserializeElisionTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -42,6 +70,8 @@ internal static ElisionTokenFilter DeserializeElisionTokenFilter(JsonElement ele IList articles = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("articles"u8)) @@ -68,10 +98,46 @@ internal static ElisionTokenFilter DeserializeElisionTokenFilter(JsonElement ele name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ElisionTokenFilter(odataType, name, serializedAdditionalRawData, articles ?? new ChangeTrackingList()); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ElisionTokenFilter)} does not support writing '{options.Format}' format."); + } + } + + ElisionTokenFilter 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 DeserializeElisionTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ElisionTokenFilter)} does not support reading '{options.Format}' format."); } - return new ElisionTokenFilter(odataType, name, articles ?? new ChangeTrackingList()); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new ElisionTokenFilter FromResponse(Response response) @@ -84,7 +150,7 @@ internal static ElisionTokenFilter DeserializeElisionTokenFilter(JsonElement ele internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ElisionTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ElisionTokenFilter.cs index 3379a97d3022..67f69f4405cc 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ElisionTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ElisionTokenFilter.cs @@ -27,11 +27,17 @@ public ElisionTokenFilter(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The set of articles to remove. - internal ElisionTokenFilter(string oDataType, string name, IList articles) : base(oDataType, name) + internal ElisionTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, IList articles) : base(oDataType, name, serializedAdditionalRawData) { Articles = articles; ODataType = oDataType ?? "#Microsoft.Azure.Search.ElisionTokenFilter"; } + + /// Initializes a new instance of for deserialization. + internal ElisionTokenFilter() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityLinkingSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityLinkingSkill.Serialization.cs index 222c241adc31..5aa64cb09170 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityLinkingSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityLinkingSkill.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class EntityLinkingSkill : IUtf8JsonSerializable + public partial class EntityLinkingSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(EntityLinkingSkill)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(DefaultLanguageCode)) { if (DefaultLanguageCode != null) @@ -52,42 +71,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("modelVersion"); } } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + EntityLinkingSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(EntityLinkingSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEntityLinkingSkill(document.RootElement, options); } - internal static EntityLinkingSkill DeserializeEntityLinkingSkill(JsonElement element) + internal static EntityLinkingSkill DeserializeEntityLinkingSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -101,6 +102,8 @@ internal static EntityLinkingSkill DeserializeEntityLinkingSkill(JsonElement ele string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("defaultLanguageCode"u8)) @@ -158,7 +161,7 @@ internal static EntityLinkingSkill DeserializeEntityLinkingSkill(JsonElement ele List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -168,12 +171,17 @@ internal static EntityLinkingSkill DeserializeEntityLinkingSkill(JsonElement ele List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new EntityLinkingSkill( odataType, name, @@ -181,11 +189,43 @@ internal static EntityLinkingSkill DeserializeEntityLinkingSkill(JsonElement ele context, inputs, outputs, + serializedAdditionalRawData, defaultLanguageCode, minimumPrecision, modelVersion); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(EntityLinkingSkill)} does not support writing '{options.Format}' format."); + } + } + + EntityLinkingSkill 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 DeserializeEntityLinkingSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EntityLinkingSkill)} 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 EntityLinkingSkill FromResponse(Response response) @@ -198,7 +238,7 @@ internal static EntityLinkingSkill DeserializeEntityLinkingSkill(JsonElement ele internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityLinkingSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityLinkingSkill.cs index e0d3093a29bf..eb01c063b2f3 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityLinkingSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityLinkingSkill.cs @@ -32,10 +32,11 @@ public EntityLinkingSkill(IEnumerable inputs, IEnumerabl /// Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// A value indicating which language code to use. Default is `en`. /// A value between 0 and 1 that be used to only include entities whose confidence score is greater than the value specified. If not set (default), or if explicitly set to null, all entities will be included. /// The version of the model to use when calling the Text Analytics service. It will default to the latest available when not specified. We recommend you do not specify this value unless absolutely necessary. - internal EntityLinkingSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, string defaultLanguageCode, double? minimumPrecision, string modelVersion) : base(oDataType, name, description, context, inputs, outputs) + internal EntityLinkingSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, string defaultLanguageCode, double? minimumPrecision, string modelVersion) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { DefaultLanguageCode = defaultLanguageCode; MinimumPrecision = minimumPrecision; @@ -43,6 +44,11 @@ internal EntityLinkingSkill(string oDataType, string name, string description, s ODataType = oDataType ?? "#Microsoft.Skills.Text.V3.EntityLinkingSkill"; } + /// Initializes a new instance of for deserialization. + internal EntityLinkingSkill() + { + } + /// A value indicating which language code to use. Default is `en`. public string DefaultLanguageCode { get; set; } /// A value between 0 and 1 that be used to only include entities whose confidence score is greater than the value specified. If not set (default), or if explicitly set to null, all entities will be included. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityRecognitionSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityRecognitionSkill.Serialization.cs index 58b19d6f8530..177b9b5a279d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityRecognitionSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityRecognitionSkill.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class EntityRecognitionSkill : IUtf8JsonSerializable + public partial class EntityRecognitionSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(EntityRecognitionSkill)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsCollectionDefined(Categories)) { writer.WritePropertyName("categories"u8); @@ -62,42 +81,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("minimumPrecision"); } } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + EntityRecognitionSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(EntityRecognitionSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEntityRecognitionSkill(document.RootElement, options); } - internal static EntityRecognitionSkill DeserializeEntityRecognitionSkill(JsonElement element) + internal static EntityRecognitionSkill DeserializeEntityRecognitionSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -112,6 +113,8 @@ internal static EntityRecognitionSkill DeserializeEntityRecognitionSkill(JsonEle string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("categories"u8)) @@ -183,7 +186,7 @@ internal static EntityRecognitionSkill DeserializeEntityRecognitionSkill(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -193,12 +196,17 @@ internal static EntityRecognitionSkill DeserializeEntityRecognitionSkill(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new EntityRecognitionSkill( odataType, name, @@ -206,12 +214,44 @@ internal static EntityRecognitionSkill DeserializeEntityRecognitionSkill(JsonEle context, inputs, outputs, + serializedAdditionalRawData, categories ?? new ChangeTrackingList(), defaultLanguageCode, includeTypelessEntities, minimumPrecision); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(EntityRecognitionSkill)} does not support writing '{options.Format}' format."); + } + } + + EntityRecognitionSkill 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 DeserializeEntityRecognitionSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EntityRecognitionSkill)} 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 EntityRecognitionSkill FromResponse(Response response) @@ -224,7 +264,7 @@ internal static EntityRecognitionSkill DeserializeEntityRecognitionSkill(JsonEle internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityRecognitionSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityRecognitionSkill.cs index 958483cd4a8c..0530e9eb5c41 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityRecognitionSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityRecognitionSkill.cs @@ -20,11 +20,12 @@ public partial class EntityRecognitionSkill : SearchIndexerSkill /// Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// A list of entity categories that should be extracted. /// A value indicating which language code to use. Default is `en`. /// Determines whether or not to include entities which are well known but don't conform to a pre-defined type. If this configuration is not set (default), set to null or set to false, entities which don't conform to one of the pre-defined types will not be surfaced. /// A value between 0 and 1 that be used to only include entities whose confidence score is greater than the value specified. If not set (default), or if explicitly set to null, all entities will be included. - internal EntityRecognitionSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IList categories, EntityRecognitionSkillLanguage? defaultLanguageCode, bool? includeTypelessEntities, double? minimumPrecision) : base(oDataType, name, description, context, inputs, outputs) + internal EntityRecognitionSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, IList categories, EntityRecognitionSkillLanguage? defaultLanguageCode, bool? includeTypelessEntities, double? minimumPrecision) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { Categories = categories; DefaultLanguageCode = defaultLanguageCode; @@ -32,6 +33,11 @@ internal EntityRecognitionSkill(string oDataType, string name, string descriptio MinimumPrecision = minimumPrecision; ODataType = oDataType ?? "#Microsoft.Skills.Text.EntityRecognitionSkill"; } + + /// Initializes a new instance of for deserialization. + internal EntityRecognitionSkill() + { + } /// A value indicating which language code to use. Default is `en`. public EntityRecognitionSkillLanguage? DefaultLanguageCode { get; set; } /// A value between 0 and 1 that be used to only include entities whose confidence score is greater than the value specified. If not set (default), or if explicitly set to null, all entities will be included. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityRecognitionSkillV3.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityRecognitionSkillV3.Serialization.cs index 786ee4af269a..9699c8c6bcf7 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityRecognitionSkillV3.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityRecognitionSkillV3.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - internal partial class EntityRecognitionSkillV3 : IUtf8JsonSerializable + internal partial class EntityRecognitionSkillV3 : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(EntityRecognitionSkillV3)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsCollectionDefined(Categories)) { writer.WritePropertyName("categories"u8); @@ -62,42 +81,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("modelVersion"); } } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + EntityRecognitionSkillV3 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(EntityRecognitionSkillV3)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEntityRecognitionSkillV3(document.RootElement, options); } - internal static EntityRecognitionSkillV3 DeserializeEntityRecognitionSkillV3(JsonElement element) + internal static EntityRecognitionSkillV3 DeserializeEntityRecognitionSkillV3(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -112,6 +113,8 @@ internal static EntityRecognitionSkillV3 DeserializeEntityRecognitionSkillV3(Jso string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("categories"u8)) @@ -183,7 +186,7 @@ internal static EntityRecognitionSkillV3 DeserializeEntityRecognitionSkillV3(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -193,12 +196,17 @@ internal static EntityRecognitionSkillV3 DeserializeEntityRecognitionSkillV3(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new EntityRecognitionSkillV3( odataType, name, @@ -206,12 +214,44 @@ internal static EntityRecognitionSkillV3 DeserializeEntityRecognitionSkillV3(Jso context, inputs, outputs, + serializedAdditionalRawData, categories ?? new ChangeTrackingList(), defaultLanguageCode, minimumPrecision, modelVersion); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(EntityRecognitionSkillV3)} does not support writing '{options.Format}' format."); + } + } + + EntityRecognitionSkillV3 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 DeserializeEntityRecognitionSkillV3(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EntityRecognitionSkillV3)} 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 EntityRecognitionSkillV3 FromResponse(Response response) @@ -224,7 +264,7 @@ internal static EntityRecognitionSkillV3 DeserializeEntityRecognitionSkillV3(Jso internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityRecognitionSkillV3.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityRecognitionSkillV3.cs index aea88cab205a..4d4f71654dba 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityRecognitionSkillV3.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/EntityRecognitionSkillV3.cs @@ -33,11 +33,12 @@ public EntityRecognitionSkillV3(IEnumerable inputs, IEnu /// Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// A list of entity categories that should be extracted. /// A value indicating which language code to use. Default is `en`. /// A value between 0 and 1 that be used to only include entities whose confidence score is greater than the value specified. If not set (default), or if explicitly set to null, all entities will be included. /// The version of the model to use when calling the Text Analytics API. It will default to the latest available when not specified. We recommend you do not specify this value unless absolutely necessary. - internal EntityRecognitionSkillV3(string oDataType, string name, string description, string context, IList inputs, IList outputs, IList categories, string defaultLanguageCode, double? minimumPrecision, string modelVersion) : base(oDataType, name, description, context, inputs, outputs) + internal EntityRecognitionSkillV3(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, IList categories, string defaultLanguageCode, double? minimumPrecision, string modelVersion) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { Categories = categories; DefaultLanguageCode = defaultLanguageCode; @@ -46,6 +47,11 @@ internal EntityRecognitionSkillV3(string oDataType, string name, string descript ODataType = oDataType ?? "#Microsoft.Skills.Text.V3.EntityRecognitionSkill"; } + /// Initializes a new instance of for deserialization. + internal EntityRecognitionSkillV3() + { + } + /// A list of entity categories that should be extracted. public IList Categories { get; } /// A value indicating which language code to use. Default is `en`. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorAdditionalInfo.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorAdditionalInfo.Serialization.cs index 79d308cd886a..b067fbfee993 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorAdditionalInfo.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorAdditionalInfo.Serialization.cs @@ -5,20 +5,86 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - internal partial class ErrorAdditionalInfo + internal partial class ErrorAdditionalInfo : IUtf8JsonSerializable, IJsonModel { - internal static ErrorAdditionalInfo DeserializeErrorAdditionalInfo(JsonElement element) + 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(ErrorAdditionalInfo)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (options.Format != "W" && Optional.IsDefined(Info)) + { + writer.WritePropertyName("info"u8); + writer.WriteObjectValue(Info, options); + } + 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 + } + } + } + + ErrorAdditionalInfo 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(ErrorAdditionalInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeErrorAdditionalInfo(document.RootElement, options); + } + + internal static ErrorAdditionalInfo DeserializeErrorAdditionalInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string type = default; object info = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("type"u8)) @@ -35,10 +101,46 @@ internal static ErrorAdditionalInfo DeserializeErrorAdditionalInfo(JsonElement e info = property.Value.GetObject(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ErrorAdditionalInfo(type, info, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ErrorAdditionalInfo)} does not support writing '{options.Format}' format."); } - return new ErrorAdditionalInfo(type, info); } + ErrorAdditionalInfo 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 DeserializeErrorAdditionalInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ErrorAdditionalInfo)} 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 ErrorAdditionalInfo FromResponse(Response response) @@ -46,5 +148,13 @@ internal static ErrorAdditionalInfo FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeErrorAdditionalInfo(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/search/Azure.Search.Documents/src/Generated/Models/ErrorAdditionalInfo.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorAdditionalInfo.cs index b8f219dc1c82..a94981f75bc1 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorAdditionalInfo.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorAdditionalInfo.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Models { /// The resource management error additional info. internal partial class ErrorAdditionalInfo { + /// + /// 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 . internal ErrorAdditionalInfo() { @@ -18,10 +53,12 @@ internal ErrorAdditionalInfo() /// Initializes a new instance of . /// The additional info type. /// The additional info. - internal ErrorAdditionalInfo(string type, object info) + /// Keeps track of any properties unknown to the library. + internal ErrorAdditionalInfo(string type, object info, IDictionary serializedAdditionalRawData) { Type = type; Info = info; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The additional info type. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorDetail.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorDetail.Serialization.cs index 0ad29ada29cd..5443d30643a6 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorDetail.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorDetail.Serialization.cs @@ -5,15 +5,103 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - internal partial class ErrorDetail + internal partial class ErrorDetail : IUtf8JsonSerializable, IJsonModel { - internal static ErrorDetail DeserializeErrorDetail(JsonElement element) + 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(ErrorDetail)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Code)) + { + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + } + if (options.Format != "W" && Optional.IsDefined(Message)) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + if (options.Format != "W" && Optional.IsDefined(Target)) + { + writer.WritePropertyName("target"u8); + writer.WriteStringValue(Target); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Details)) + { + writer.WritePropertyName("details"u8); + writer.WriteStartArray(); + foreach (var item in Details) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(AdditionalInfo)) + { + writer.WritePropertyName("additionalInfo"u8); + writer.WriteStartArray(); + foreach (var item in AdditionalInfo) + { + 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 + } + } + } + + ErrorDetail 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(ErrorDetail)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeErrorDetail(document.RootElement, options); + } + + internal static ErrorDetail DeserializeErrorDetail(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -23,6 +111,8 @@ internal static ErrorDetail DeserializeErrorDetail(JsonElement element) string target = default; IReadOnlyList details = default; IReadOnlyList additionalInfo = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("code"u8)) @@ -49,7 +139,7 @@ internal static ErrorDetail DeserializeErrorDetail(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DeserializeErrorDetail(item)); + array.Add(DeserializeErrorDetail(item, options)); } details = array; continue; @@ -63,15 +153,57 @@ internal static ErrorDetail DeserializeErrorDetail(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ErrorAdditionalInfo.DeserializeErrorAdditionalInfo(item)); + array.Add(ErrorAdditionalInfo.DeserializeErrorAdditionalInfo(item, options)); } additionalInfo = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ErrorDetail( + code, + message, + target, + details ?? new ChangeTrackingList(), + additionalInfo ?? 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ErrorDetail)} does not support writing '{options.Format}' format."); + } + } + + ErrorDetail 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 DeserializeErrorDetail(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ErrorDetail)} does not support reading '{options.Format}' format."); } - return new ErrorDetail(code, message, target, details ?? new ChangeTrackingList(), additionalInfo ?? new ChangeTrackingList()); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static ErrorDetail FromResponse(Response response) @@ -79,5 +211,13 @@ internal static ErrorDetail FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeErrorDetail(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/search/Azure.Search.Documents/src/Generated/Models/ErrorDetail.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorDetail.cs index 9f804b9ebdab..5f0c3e6a7a31 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorDetail.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorDetail.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.Search.Documents.Models @@ -12,6 +13,38 @@ namespace Azure.Search.Documents.Models /// The error detail. internal partial class ErrorDetail { + /// + /// 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 . internal ErrorDetail() { @@ -25,13 +58,15 @@ internal ErrorDetail() /// The error target. /// The error details. /// The error additional info. - internal ErrorDetail(string code, string message, string target, IReadOnlyList details, IReadOnlyList additionalInfo) + /// Keeps track of any properties unknown to the library. + internal ErrorDetail(string code, string message, string target, IReadOnlyList details, IReadOnlyList additionalInfo, IDictionary serializedAdditionalRawData) { Code = code; Message = message; Target = target; Details = details; AdditionalInfo = additionalInfo; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The error code. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorResponse.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorResponse.Serialization.cs index c145daf329a3..ca75605e1911 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorResponse.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorResponse.Serialization.cs @@ -5,19 +5,80 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - internal partial class ErrorResponse + internal partial class ErrorResponse : IUtf8JsonSerializable, IJsonModel { - internal static ErrorResponse DeserializeErrorResponse(JsonElement element) + 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(ErrorResponse)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Error)) + { + writer.WritePropertyName("error"u8); + writer.WriteObjectValue(Error, options); + } + 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 + } + } + } + + ErrorResponse 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(ErrorResponse)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeErrorResponse(document.RootElement, options); + } + + internal static ErrorResponse DeserializeErrorResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } ErrorDetail error = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("error"u8)) @@ -26,13 +87,49 @@ internal static ErrorResponse DeserializeErrorResponse(JsonElement element) { continue; } - error = ErrorDetail.DeserializeErrorDetail(property.Value); + error = ErrorDetail.DeserializeErrorDetail(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ErrorResponse(error, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ErrorResponse)} does not support writing '{options.Format}' format."); + } + } + + ErrorResponse 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 DeserializeErrorResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ErrorResponse)} does not support reading '{options.Format}' format."); } - return new ErrorResponse(error); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static ErrorResponse FromResponse(Response response) @@ -40,5 +137,13 @@ internal static ErrorResponse FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeErrorResponse(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/search/Azure.Search.Documents/src/Generated/Models/ErrorResponse.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorResponse.cs index b7e178bb8942..b974746d731d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorResponse.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ErrorResponse.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Models { /// Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). internal partial class ErrorResponse { + /// + /// 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 . internal ErrorResponse() { @@ -17,9 +52,11 @@ internal ErrorResponse() /// Initializes a new instance of . /// The error object. - internal ErrorResponse(ErrorDetail error) + /// Keeps track of any properties unknown to the library. + internal ErrorResponse(ErrorDetail error, IDictionary serializedAdditionalRawData) { Error = error; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The error object. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ExhaustiveKnnAlgorithmConfiguration.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ExhaustiveKnnAlgorithmConfiguration.Serialization.cs index c6e1f533bb8a..4490a288e374 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ExhaustiveKnnAlgorithmConfiguration.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ExhaustiveKnnAlgorithmConfiguration.Serialization.cs @@ -5,30 +5,59 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class ExhaustiveKnnAlgorithmConfiguration : IUtf8JsonSerializable + public partial class ExhaustiveKnnAlgorithmConfiguration : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(ExhaustiveKnnAlgorithmConfiguration)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Parameters)) { writer.WritePropertyName("exhaustiveKnnParameters"u8); - writer.WriteObjectValue(Parameters); + writer.WriteObjectValue(Parameters, options); } - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); - writer.WriteEndObject(); } - internal static ExhaustiveKnnAlgorithmConfiguration DeserializeExhaustiveKnnAlgorithmConfiguration(JsonElement element) + ExhaustiveKnnAlgorithmConfiguration 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(ExhaustiveKnnAlgorithmConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeExhaustiveKnnAlgorithmConfiguration(document.RootElement, options); + } + + internal static ExhaustiveKnnAlgorithmConfiguration DeserializeExhaustiveKnnAlgorithmConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -36,6 +65,8 @@ internal static ExhaustiveKnnAlgorithmConfiguration DeserializeExhaustiveKnnAlgo ExhaustiveKnnParameters exhaustiveKnnParameters = default; string name = default; VectorSearchAlgorithmKind kind = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("exhaustiveKnnParameters"u8)) @@ -44,7 +75,7 @@ internal static ExhaustiveKnnAlgorithmConfiguration DeserializeExhaustiveKnnAlgo { continue; } - exhaustiveKnnParameters = ExhaustiveKnnParameters.DeserializeExhaustiveKnnParameters(property.Value); + exhaustiveKnnParameters = ExhaustiveKnnParameters.DeserializeExhaustiveKnnParameters(property.Value, options); continue; } if (property.NameEquals("name"u8)) @@ -57,10 +88,46 @@ internal static ExhaustiveKnnAlgorithmConfiguration DeserializeExhaustiveKnnAlgo kind = new VectorSearchAlgorithmKind(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ExhaustiveKnnAlgorithmConfiguration(name, kind, serializedAdditionalRawData, exhaustiveKnnParameters); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ExhaustiveKnnAlgorithmConfiguration)} does not support writing '{options.Format}' format."); + } + } + + ExhaustiveKnnAlgorithmConfiguration 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 DeserializeExhaustiveKnnAlgorithmConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ExhaustiveKnnAlgorithmConfiguration)} does not support reading '{options.Format}' format."); } - return new ExhaustiveKnnAlgorithmConfiguration(name, kind, exhaustiveKnnParameters); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new ExhaustiveKnnAlgorithmConfiguration FromResponse(Response response) @@ -73,7 +140,7 @@ internal static ExhaustiveKnnAlgorithmConfiguration DeserializeExhaustiveKnnAlgo internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ExhaustiveKnnAlgorithmConfiguration.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ExhaustiveKnnAlgorithmConfiguration.cs index 4cc2710a1980..b5adb3e04bab 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ExhaustiveKnnAlgorithmConfiguration.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ExhaustiveKnnAlgorithmConfiguration.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,13 +26,19 @@ public ExhaustiveKnnAlgorithmConfiguration(string name) : base(name) /// Initializes a new instance of . /// The name to associate with this particular configuration. /// The name of the kind of algorithm being configured for use with vector search. + /// Keeps track of any properties unknown to the library. /// Contains the parameters specific to exhaustive KNN algorithm. - internal ExhaustiveKnnAlgorithmConfiguration(string name, VectorSearchAlgorithmKind kind, ExhaustiveKnnParameters parameters) : base(name, kind) + internal ExhaustiveKnnAlgorithmConfiguration(string name, VectorSearchAlgorithmKind kind, IDictionary serializedAdditionalRawData, ExhaustiveKnnParameters parameters) : base(name, kind, serializedAdditionalRawData) { Parameters = parameters; Kind = kind; } + /// Initializes a new instance of for deserialization. + internal ExhaustiveKnnAlgorithmConfiguration() + { + } + /// Contains the parameters specific to exhaustive KNN algorithm. public ExhaustiveKnnParameters Parameters { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ExhaustiveKnnParameters.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ExhaustiveKnnParameters.Serialization.cs index a70600ccdedf..402808731029 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ExhaustiveKnnParameters.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ExhaustiveKnnParameters.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class ExhaustiveKnnParameters : IUtf8JsonSerializable + public partial class ExhaustiveKnnParameters : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(ExhaustiveKnnParameters)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Metric)) { if (Metric != null) @@ -27,16 +46,46 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("metric"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static ExhaustiveKnnParameters DeserializeExhaustiveKnnParameters(JsonElement element) + ExhaustiveKnnParameters 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(ExhaustiveKnnParameters)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeExhaustiveKnnParameters(document.RootElement, options); + } + + internal static ExhaustiveKnnParameters DeserializeExhaustiveKnnParameters(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } VectorSearchAlgorithmMetric? metric = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("metric"u8)) @@ -49,10 +98,46 @@ internal static ExhaustiveKnnParameters DeserializeExhaustiveKnnParameters(JsonE metric = new VectorSearchAlgorithmMetric(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ExhaustiveKnnParameters(metric, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ExhaustiveKnnParameters)} does not support writing '{options.Format}' format."); } - return new ExhaustiveKnnParameters(metric); } + ExhaustiveKnnParameters 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 DeserializeExhaustiveKnnParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ExhaustiveKnnParameters)} 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 ExhaustiveKnnParameters FromResponse(Response response) @@ -65,7 +150,7 @@ internal static ExhaustiveKnnParameters FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ExhaustiveKnnParameters.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ExhaustiveKnnParameters.cs index a8d59ff3d16a..820a22488809 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ExhaustiveKnnParameters.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ExhaustiveKnnParameters.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Contains the parameters specific to exhaustive KNN algorithm. public partial class ExhaustiveKnnParameters { + /// + /// 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 ExhaustiveKnnParameters() { @@ -17,9 +52,11 @@ public ExhaustiveKnnParameters() /// Initializes a new instance of . /// The similarity metric to use for vector comparisons. - internal ExhaustiveKnnParameters(VectorSearchAlgorithmMetric? metric) + /// Keeps track of any properties unknown to the library. + internal ExhaustiveKnnParameters(VectorSearchAlgorithmMetric? metric, IDictionary serializedAdditionalRawData) { Metric = metric; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The similarity metric to use for vector comparisons. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/FacetResult.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/FacetResult.Serialization.cs index 8cb54a984259..429fa87cf2c0 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/FacetResult.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/FacetResult.Serialization.cs @@ -5,15 +5,89 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class FacetResult + public partial class FacetResult : IUtf8JsonSerializable, IJsonModel { - internal static FacetResult DeserializeFacetResult(JsonElement element) + 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(FacetResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Count)) + { + writer.WritePropertyName("count"u8); + writer.WriteNumberValue(Count.Value); + } + if (options.Format != "W" && Optional.IsDefined(Sum)) + { + writer.WritePropertyName("sum"u8); + writer.WriteNumberValue(Sum.Value); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Facets)) + { + writer.WritePropertyName("@search.facets"u8); + writer.WriteStartObject(); + foreach (var item in Facets) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStartArray(); + foreach (var item0 in item.Value) + { + writer.WriteObjectValue(item0, options); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + foreach (var item in AdditionalProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + } + + FacetResult 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(FacetResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFacetResult(document.RootElement, options); + } + + internal static FacetResult DeserializeFacetResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -61,7 +135,7 @@ internal static FacetResult DeserializeFacetResult(JsonElement element) List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(DeserializeFacetResult(item)); + array.Add(DeserializeFacetResult(item, options)); } dictionary.Add(property0.Name, array); } @@ -75,6 +149,37 @@ internal static FacetResult DeserializeFacetResult(JsonElement element) return new FacetResult(count, sum, searchFacets ?? new ChangeTrackingDictionary>(), additionalProperties); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(FacetResult)} does not support writing '{options.Format}' format."); + } + } + + FacetResult 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 DeserializeFacetResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FacetResult)} 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 FacetResult FromResponse(Response response) @@ -82,5 +187,13 @@ internal static FacetResult FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeFacetResult(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/search/Azure.Search.Documents/src/Generated/Models/FieldMapping.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/FieldMapping.Serialization.cs index ee00cb0d2229..bbe238a3b9c6 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/FieldMapping.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/FieldMapping.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class FieldMapping : IUtf8JsonSerializable + public partial class FieldMapping : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(FieldMapping)} does not support writing '{format}' format."); + } + writer.WritePropertyName("sourceFieldName"u8); writer.WriteStringValue(SourceFieldName); if (Optional.IsDefined(TargetFieldName)) @@ -27,18 +46,46 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (MappingFunction != null) { writer.WritePropertyName("mappingFunction"u8); - writer.WriteObjectValue(MappingFunction); + writer.WriteObjectValue(MappingFunction, options); } else { writer.WriteNull("mappingFunction"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static FieldMapping DeserializeFieldMapping(JsonElement element) + FieldMapping 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(FieldMapping)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFieldMapping(document.RootElement, options); + } + + internal static FieldMapping DeserializeFieldMapping(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -46,6 +93,8 @@ internal static FieldMapping DeserializeFieldMapping(JsonElement element) string sourceFieldName = default; string targetFieldName = default; FieldMappingFunction mappingFunction = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("sourceFieldName"u8)) @@ -65,13 +114,49 @@ internal static FieldMapping DeserializeFieldMapping(JsonElement element) mappingFunction = null; continue; } - mappingFunction = FieldMappingFunction.DeserializeFieldMappingFunction(property.Value); + mappingFunction = FieldMappingFunction.DeserializeFieldMappingFunction(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FieldMapping(sourceFieldName, targetFieldName, mappingFunction, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(FieldMapping)} does not support writing '{options.Format}' format."); } - return new FieldMapping(sourceFieldName, targetFieldName, mappingFunction); } + FieldMapping 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 DeserializeFieldMapping(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FieldMapping)} 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 FieldMapping FromResponse(Response response) @@ -84,7 +169,7 @@ internal static FieldMapping FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/FieldMapping.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/FieldMapping.cs index ca65fd52d1be..728cd0cede4b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/FieldMapping.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/FieldMapping.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Defines a mapping between a field in a data source and a target field in an index. public partial class FieldMapping { + /// + /// 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 . /// The name of the field in the data source. /// is null. @@ -26,11 +59,18 @@ public FieldMapping(string sourceFieldName) /// The name of the field in the data source. /// The name of the target field in the index. Same as the source field name by default. /// A function to apply to each source field value before indexing. - internal FieldMapping(string sourceFieldName, string targetFieldName, FieldMappingFunction mappingFunction) + /// Keeps track of any properties unknown to the library. + internal FieldMapping(string sourceFieldName, string targetFieldName, FieldMappingFunction mappingFunction, IDictionary serializedAdditionalRawData) { SourceFieldName = sourceFieldName; TargetFieldName = targetFieldName; MappingFunction = mappingFunction; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FieldMapping() + { } /// The name of the field in the data source. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/FieldMappingFunction.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/FieldMappingFunction.Serialization.cs index b92548ccc926..8e725267a90b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/FieldMappingFunction.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/FieldMappingFunction.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class FieldMappingFunction : IUtf8JsonSerializable + public partial class FieldMappingFunction : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(FieldMappingFunction)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); if (Optional.IsCollectionDefined(Parameters)) @@ -32,7 +50,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNullValue(); continue; } - writer.WriteObjectValue(item.Value); + writer.WriteObjectValue(item.Value, options); } writer.WriteEndObject(); } @@ -41,17 +59,47 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("parameters"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static FieldMappingFunction DeserializeFieldMappingFunction(JsonElement element) + FieldMappingFunction 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(FieldMappingFunction)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFieldMappingFunction(document.RootElement, options); + } + + internal static FieldMappingFunction DeserializeFieldMappingFunction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string name = default; IDictionary parameters = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -81,10 +129,46 @@ internal static FieldMappingFunction DeserializeFieldMappingFunction(JsonElement parameters = dictionary; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FieldMappingFunction(name, parameters ?? new ChangeTrackingDictionary(), 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(FieldMappingFunction)} does not support writing '{options.Format}' format."); } - return new FieldMappingFunction(name, parameters ?? new ChangeTrackingDictionary()); } + FieldMappingFunction 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 DeserializeFieldMappingFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FieldMappingFunction)} 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 FieldMappingFunction FromResponse(Response response) @@ -97,7 +181,7 @@ internal static FieldMappingFunction FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/FieldMappingFunction.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/FieldMappingFunction.cs index c9a14812ac0c..9d1f8242b3ea 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/FieldMappingFunction.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/FieldMappingFunction.cs @@ -13,6 +13,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Represents a function that transforms a value from a data source before indexing. public partial class FieldMappingFunction { + /// + /// 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 . /// The name of the field mapping function. /// is null. @@ -27,10 +59,17 @@ public FieldMappingFunction(string name) /// Initializes a new instance of . /// The name of the field mapping function. /// A dictionary of parameter name/value pairs to pass to the function. Each value must be of a primitive type. - internal FieldMappingFunction(string name, IDictionary parameters) + /// Keeps track of any properties unknown to the library. + internal FieldMappingFunction(string name, IDictionary parameters, IDictionary serializedAdditionalRawData) { Name = name; Parameters = parameters; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FieldMappingFunction() + { } /// The name of the field mapping function. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/FreshnessScoringFunction.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/FreshnessScoringFunction.Serialization.cs index 49f28ed5089d..8e0b4d1bf727 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/FreshnessScoringFunction.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/FreshnessScoringFunction.Serialization.cs @@ -5,34 +5,56 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class FreshnessScoringFunction : IUtf8JsonSerializable + public partial class FreshnessScoringFunction : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(FreshnessScoringFunction)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("freshness"u8); - writer.WriteObjectValue(Parameters); - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - writer.WritePropertyName("fieldName"u8); - writer.WriteStringValue(FieldName); - writer.WritePropertyName("boost"u8); - writer.WriteNumberValue(Boost); - if (Optional.IsDefined(Interpolation)) + writer.WriteObjectValue(Parameters, options); + } + + FreshnessScoringFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WritePropertyName("interpolation"u8); - writer.WriteStringValue(Interpolation.Value.ToSerialString()); + throw new FormatException($"The model {nameof(FreshnessScoringFunction)} does not support reading '{format}' format."); } - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFreshnessScoringFunction(document.RootElement, options); } - internal static FreshnessScoringFunction DeserializeFreshnessScoringFunction(JsonElement element) + internal static FreshnessScoringFunction DeserializeFreshnessScoringFunction(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -42,11 +64,13 @@ internal static FreshnessScoringFunction DeserializeFreshnessScoringFunction(Jso string fieldName = default; double boost = default; ScoringFunctionInterpolation? interpolation = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("freshness"u8)) { - freshness = FreshnessScoringParameters.DeserializeFreshnessScoringParameters(property.Value); + freshness = FreshnessScoringParameters.DeserializeFreshnessScoringParameters(property.Value, options); continue; } if (property.NameEquals("type"u8)) @@ -73,10 +97,52 @@ internal static FreshnessScoringFunction DeserializeFreshnessScoringFunction(Jso interpolation = property.Value.GetString().ToScoringFunctionInterpolation(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new FreshnessScoringFunction(type, fieldName, boost, interpolation, freshness); + serializedAdditionalRawData = rawDataDictionary; + return new FreshnessScoringFunction( + type, + fieldName, + boost, + interpolation, + serializedAdditionalRawData, + freshness); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(FreshnessScoringFunction)} does not support writing '{options.Format}' format."); + } + } + + FreshnessScoringFunction 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 DeserializeFreshnessScoringFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FreshnessScoringFunction)} 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 FreshnessScoringFunction FromResponse(Response response) @@ -89,7 +155,7 @@ internal static FreshnessScoringFunction DeserializeFreshnessScoringFunction(Jso internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/FreshnessScoringFunction.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/FreshnessScoringFunction.cs index d6f7f137659f..30e7918748ee 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/FreshnessScoringFunction.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/FreshnessScoringFunction.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -17,13 +18,19 @@ public partial class FreshnessScoringFunction : ScoringFunction /// The name of the field used as input to the scoring function. /// A multiplier for the raw score. Must be a positive number not equal to 1.0. /// A value indicating how boosting will be interpolated across document scores; defaults to "Linear". + /// Keeps track of any properties unknown to the library. /// Parameter values for the freshness scoring function. - internal FreshnessScoringFunction(string type, string fieldName, double boost, ScoringFunctionInterpolation? interpolation, FreshnessScoringParameters parameters) : base(type, fieldName, boost, interpolation) + internal FreshnessScoringFunction(string type, string fieldName, double boost, ScoringFunctionInterpolation? interpolation, IDictionary serializedAdditionalRawData, FreshnessScoringParameters parameters) : base(type, fieldName, boost, interpolation, serializedAdditionalRawData) { Parameters = parameters; Type = type ?? "freshness"; } + /// Initializes a new instance of for deserialization. + internal FreshnessScoringFunction() + { + } + /// Parameter values for the freshness scoring function. public FreshnessScoringParameters Parameters { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/FreshnessScoringParameters.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/FreshnessScoringParameters.Serialization.cs index 5842580d72be..fc15dcc1bbfc 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/FreshnessScoringParameters.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/FreshnessScoringParameters.Serialization.cs @@ -6,28 +6,76 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class FreshnessScoringParameters : IUtf8JsonSerializable + public partial class FreshnessScoringParameters : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(FreshnessScoringParameters)} does not support writing '{format}' format."); + } + writer.WritePropertyName("boostingDuration"u8); writer.WriteStringValue(BoostingDuration, "P"); - writer.WriteEndObject(); + 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 + } + } } - internal static FreshnessScoringParameters DeserializeFreshnessScoringParameters(JsonElement element) + FreshnessScoringParameters 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(FreshnessScoringParameters)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFreshnessScoringParameters(document.RootElement, options); + } + + internal static FreshnessScoringParameters DeserializeFreshnessScoringParameters(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } TimeSpan boostingDuration = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("boostingDuration"u8)) @@ -35,10 +83,46 @@ internal static FreshnessScoringParameters DeserializeFreshnessScoringParameters boostingDuration = property.Value.GetTimeSpan("P"); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new FreshnessScoringParameters(boostingDuration); + serializedAdditionalRawData = rawDataDictionary; + return new FreshnessScoringParameters(boostingDuration, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(FreshnessScoringParameters)} does not support writing '{options.Format}' format."); + } + } + + FreshnessScoringParameters 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 DeserializeFreshnessScoringParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FreshnessScoringParameters)} 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 FreshnessScoringParameters FromResponse(Response response) @@ -51,7 +135,7 @@ internal static FreshnessScoringParameters FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/FreshnessScoringParameters.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/FreshnessScoringParameters.cs index 721a5a41f499..f27f74d8461e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/FreshnessScoringParameters.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/FreshnessScoringParameters.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Provides parameter values to a freshness scoring function. public partial class FreshnessScoringParameters { + /// + /// 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 . /// The expiration period after which boosting will stop for a particular document. public FreshnessScoringParameters(TimeSpan boostingDuration) @@ -19,6 +52,20 @@ public FreshnessScoringParameters(TimeSpan boostingDuration) BoostingDuration = boostingDuration; } + /// Initializes a new instance of . + /// The expiration period after which boosting will stop for a particular document. + /// Keeps track of any properties unknown to the library. + internal FreshnessScoringParameters(TimeSpan boostingDuration, IDictionary serializedAdditionalRawData) + { + BoostingDuration = boostingDuration; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FreshnessScoringParameters() + { + } + /// The expiration period after which boosting will stop for a particular document. public TimeSpan BoostingDuration { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/HighWaterMarkChangeDetectionPolicy.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/HighWaterMarkChangeDetectionPolicy.Serialization.cs index 1dc2bfd5cc64..a282869219db 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/HighWaterMarkChangeDetectionPolicy.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/HighWaterMarkChangeDetectionPolicy.Serialization.cs @@ -5,31 +5,64 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class HighWaterMarkChangeDetectionPolicy : IUtf8JsonSerializable + public partial class HighWaterMarkChangeDetectionPolicy : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(HighWaterMarkChangeDetectionPolicy)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("highWaterMarkColumnName"u8); writer.WriteStringValue(HighWaterMarkColumnName); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WriteEndObject(); } - internal static HighWaterMarkChangeDetectionPolicy DeserializeHighWaterMarkChangeDetectionPolicy(JsonElement element) + HighWaterMarkChangeDetectionPolicy 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(HighWaterMarkChangeDetectionPolicy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHighWaterMarkChangeDetectionPolicy(document.RootElement, options); + } + + internal static HighWaterMarkChangeDetectionPolicy DeserializeHighWaterMarkChangeDetectionPolicy(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string highWaterMarkColumnName = default; string odataType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("highWaterMarkColumnName"u8)) @@ -42,10 +75,46 @@ internal static HighWaterMarkChangeDetectionPolicy DeserializeHighWaterMarkChang odataType = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new HighWaterMarkChangeDetectionPolicy(odataType, serializedAdditionalRawData, highWaterMarkColumnName); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(HighWaterMarkChangeDetectionPolicy)} does not support writing '{options.Format}' format."); } - return new HighWaterMarkChangeDetectionPolicy(odataType, highWaterMarkColumnName); } + HighWaterMarkChangeDetectionPolicy 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 DeserializeHighWaterMarkChangeDetectionPolicy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HighWaterMarkChangeDetectionPolicy)} 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 HighWaterMarkChangeDetectionPolicy FromResponse(Response response) @@ -58,7 +127,7 @@ internal static HighWaterMarkChangeDetectionPolicy DeserializeHighWaterMarkChang internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/HighWaterMarkChangeDetectionPolicy.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/HighWaterMarkChangeDetectionPolicy.cs index 2e0e3f66f9ce..08b3cda7c883 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/HighWaterMarkChangeDetectionPolicy.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/HighWaterMarkChangeDetectionPolicy.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,13 +26,19 @@ public HighWaterMarkChangeDetectionPolicy(string highWaterMarkColumnName) /// Initializes a new instance of . /// A URI fragment specifying the type of data change detection policy. + /// Keeps track of any properties unknown to the library. /// The name of the high water mark column. - internal HighWaterMarkChangeDetectionPolicy(string oDataType, string highWaterMarkColumnName) : base(oDataType) + internal HighWaterMarkChangeDetectionPolicy(string oDataType, IDictionary serializedAdditionalRawData, string highWaterMarkColumnName) : base(oDataType, serializedAdditionalRawData) { HighWaterMarkColumnName = highWaterMarkColumnName; ODataType = oDataType ?? "#Microsoft.Azure.Search.HighWaterMarkChangeDetectionPolicy"; } + /// Initializes a new instance of for deserialization. + internal HighWaterMarkChangeDetectionPolicy() + { + } + /// The name of the high water mark column. public string HighWaterMarkColumnName { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/HnswAlgorithmConfiguration.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/HnswAlgorithmConfiguration.Serialization.cs index 2c63b205606d..61e7995757ea 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/HnswAlgorithmConfiguration.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/HnswAlgorithmConfiguration.Serialization.cs @@ -5,30 +5,59 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class HnswAlgorithmConfiguration : IUtf8JsonSerializable + public partial class HnswAlgorithmConfiguration : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(HnswAlgorithmConfiguration)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Parameters)) { writer.WritePropertyName("hnswParameters"u8); - writer.WriteObjectValue(Parameters); + writer.WriteObjectValue(Parameters, options); } - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); - writer.WriteEndObject(); } - internal static HnswAlgorithmConfiguration DeserializeHnswAlgorithmConfiguration(JsonElement element) + HnswAlgorithmConfiguration 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(HnswAlgorithmConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHnswAlgorithmConfiguration(document.RootElement, options); + } + + internal static HnswAlgorithmConfiguration DeserializeHnswAlgorithmConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -36,6 +65,8 @@ internal static HnswAlgorithmConfiguration DeserializeHnswAlgorithmConfiguration HnswParameters hnswParameters = default; string name = default; VectorSearchAlgorithmKind kind = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("hnswParameters"u8)) @@ -44,7 +75,7 @@ internal static HnswAlgorithmConfiguration DeserializeHnswAlgorithmConfiguration { continue; } - hnswParameters = HnswParameters.DeserializeHnswParameters(property.Value); + hnswParameters = HnswParameters.DeserializeHnswParameters(property.Value, options); continue; } if (property.NameEquals("name"u8)) @@ -57,10 +88,46 @@ internal static HnswAlgorithmConfiguration DeserializeHnswAlgorithmConfiguration kind = new VectorSearchAlgorithmKind(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new HnswAlgorithmConfiguration(name, kind, serializedAdditionalRawData, hnswParameters); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(HnswAlgorithmConfiguration)} does not support writing '{options.Format}' format."); + } + } + + HnswAlgorithmConfiguration 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 DeserializeHnswAlgorithmConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HnswAlgorithmConfiguration)} does not support reading '{options.Format}' format."); } - return new HnswAlgorithmConfiguration(name, kind, hnswParameters); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new HnswAlgorithmConfiguration FromResponse(Response response) @@ -73,7 +140,7 @@ internal static HnswAlgorithmConfiguration DeserializeHnswAlgorithmConfiguration internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/HnswAlgorithmConfiguration.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/HnswAlgorithmConfiguration.cs index 59aeb87cc763..df5542b7652c 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/HnswAlgorithmConfiguration.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/HnswAlgorithmConfiguration.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,13 +26,19 @@ public HnswAlgorithmConfiguration(string name) : base(name) /// Initializes a new instance of . /// The name to associate with this particular configuration. /// The name of the kind of algorithm being configured for use with vector search. + /// Keeps track of any properties unknown to the library. /// Contains the parameters specific to HNSW algorithm. - internal HnswAlgorithmConfiguration(string name, VectorSearchAlgorithmKind kind, HnswParameters parameters) : base(name, kind) + internal HnswAlgorithmConfiguration(string name, VectorSearchAlgorithmKind kind, IDictionary serializedAdditionalRawData, HnswParameters parameters) : base(name, kind, serializedAdditionalRawData) { Parameters = parameters; Kind = kind; } + /// Initializes a new instance of for deserialization. + internal HnswAlgorithmConfiguration() + { + } + /// Contains the parameters specific to HNSW algorithm. public HnswParameters Parameters { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/HnswParameters.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/HnswParameters.Serialization.cs index 1b2627741861..508c42d0dedf 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/HnswParameters.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/HnswParameters.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class HnswParameters : IUtf8JsonSerializable + public partial class HnswParameters : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(HnswParameters)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(M)) { if (M != null) @@ -63,11 +82,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("metric"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static HnswParameters DeserializeHnswParameters(JsonElement element) + HnswParameters 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(HnswParameters)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHnswParameters(document.RootElement, options); + } + + internal static HnswParameters DeserializeHnswParameters(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -76,6 +123,8 @@ internal static HnswParameters DeserializeHnswParameters(JsonElement element) int? efConstruction = default; int? efSearch = default; VectorSearchAlgorithmMetric? metric = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("m"u8)) @@ -118,10 +167,46 @@ internal static HnswParameters DeserializeHnswParameters(JsonElement element) metric = new VectorSearchAlgorithmMetric(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new HnswParameters(m, efConstruction, efSearch, metric, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(HnswParameters)} does not support writing '{options.Format}' format."); } - return new HnswParameters(m, efConstruction, efSearch, metric); } + HnswParameters 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 DeserializeHnswParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HnswParameters)} 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 HnswParameters FromResponse(Response response) @@ -134,7 +219,7 @@ internal static HnswParameters FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/HnswParameters.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/HnswParameters.cs index 835c29c56e1f..bf690da82ef9 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/HnswParameters.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/HnswParameters.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Contains the parameters specific to the HNSW algorithm. public partial class HnswParameters { + /// + /// 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 HnswParameters() { @@ -20,12 +55,14 @@ public HnswParameters() /// The size of the dynamic list containing the nearest neighbors, which is used during index time. Increasing this parameter may improve index quality, at the expense of increased indexing time. At a certain point, increasing this parameter leads to diminishing returns. /// The size of the dynamic list containing the nearest neighbors, which is used during search time. Increasing this parameter may improve search results, at the expense of slower search. At a certain point, increasing this parameter leads to diminishing returns. /// The similarity metric to use for vector comparisons. - internal HnswParameters(int? m, int? efConstruction, int? efSearch, VectorSearchAlgorithmMetric? metric) + /// Keeps track of any properties unknown to the library. + internal HnswParameters(int? m, int? efConstruction, int? efSearch, VectorSearchAlgorithmMetric? metric, IDictionary serializedAdditionalRawData) { M = m; EfConstruction = efConstruction; EfSearch = efSearch; Metric = metric; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The number of bi-directional links created for every new element during construction. Increasing this parameter value may improve recall and reduce retrieval times for datasets with high intrinsic dimensionality at the expense of increased memory consumption and longer indexing time. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/HybridSearch.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/HybridSearch.Serialization.cs index cc92bae08693..345ad1b8da35 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/HybridSearch.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/HybridSearch.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class HybridSearch : IUtf8JsonSerializable + public partial class HybridSearch : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(HybridSearch)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(MaxTextRecallSize)) { writer.WritePropertyName("maxTextRecallSize"u8); @@ -25,17 +44,47 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("countAndFacetMode"u8); writer.WriteStringValue(CountAndFacetMode.Value.ToString()); } - writer.WriteEndObject(); + 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 + } + } } - internal static HybridSearch DeserializeHybridSearch(JsonElement element) + HybridSearch 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(HybridSearch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHybridSearch(document.RootElement, options); + } + + internal static HybridSearch DeserializeHybridSearch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } int? maxTextRecallSize = default; HybridCountAndFacetMode? countAndFacetMode = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("maxTextRecallSize"u8)) @@ -56,10 +105,46 @@ internal static HybridSearch DeserializeHybridSearch(JsonElement element) countAndFacetMode = new HybridCountAndFacetMode(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new HybridSearch(maxTextRecallSize, countAndFacetMode, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(HybridSearch)} does not support writing '{options.Format}' format."); } - return new HybridSearch(maxTextRecallSize, countAndFacetMode); } + HybridSearch 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 DeserializeHybridSearch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HybridSearch)} 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 HybridSearch FromResponse(Response response) @@ -72,7 +157,7 @@ internal static HybridSearch FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/HybridSearch.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/HybridSearch.cs index 94476d175956..eeccfc9e1eb3 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/HybridSearch.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/HybridSearch.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Models { /// TThe query parameters to configure hybrid search behaviors. public partial class HybridSearch { + /// + /// 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 HybridSearch() { @@ -18,10 +53,12 @@ public HybridSearch() /// Initializes a new instance of . /// Determines the maximum number of documents to be retrieved by the text query portion of a hybrid search request. Those documents will be combined with the documents matching the vector queries to produce a single final list of results. Choosing a larger maxTextRecallSize value will allow retrieving and paging through more documents (using the top and skip parameters), at the cost of higher resource utilization and higher latency. The value needs to be between 1 and 10,000. Default is 1000. /// Determines whether the count and facets should includes all documents that matched the search query, or only the documents that are retrieved within the 'maxTextRecallSize' window. - internal HybridSearch(int? maxTextRecallSize, HybridCountAndFacetMode? countAndFacetMode) + /// Keeps track of any properties unknown to the library. + internal HybridSearch(int? maxTextRecallSize, HybridCountAndFacetMode? countAndFacetMode, IDictionary serializedAdditionalRawData) { MaxTextRecallSize = maxTextRecallSize; CountAndFacetMode = countAndFacetMode; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Determines the maximum number of documents to be retrieved by the text query portion of a hybrid search request. Those documents will be combined with the documents matching the vector queries to produce a single final list of results. Choosing a larger maxTextRecallSize value will allow retrieving and paging through more documents (using the top and skip parameters), at the cost of higher resource utilization and higher latency. The value needs to be between 1 and 10,000. Default is 1000. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ImageAnalysisSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ImageAnalysisSkill.Serialization.cs index 69d45d2636c6..32fbda9e01a8 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ImageAnalysisSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ImageAnalysisSkill.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class ImageAnalysisSkill : IUtf8JsonSerializable + public partial class ImageAnalysisSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(ImageAnalysisSkill)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(DefaultLanguageCode)) { if (DefaultLanguageCode != null) @@ -48,42 +67,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WriteEndArray(); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + ImageAnalysisSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(ImageAnalysisSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeImageAnalysisSkill(document.RootElement, options); } - internal static ImageAnalysisSkill DeserializeImageAnalysisSkill(JsonElement element) + internal static ImageAnalysisSkill DeserializeImageAnalysisSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -97,6 +98,8 @@ internal static ImageAnalysisSkill DeserializeImageAnalysisSkill(JsonElement ele string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("defaultLanguageCode"u8)) @@ -162,7 +165,7 @@ internal static ImageAnalysisSkill DeserializeImageAnalysisSkill(JsonElement ele List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -172,12 +175,17 @@ internal static ImageAnalysisSkill DeserializeImageAnalysisSkill(JsonElement ele List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new ImageAnalysisSkill( odataType, name, @@ -185,11 +193,43 @@ internal static ImageAnalysisSkill DeserializeImageAnalysisSkill(JsonElement ele context, inputs, outputs, + serializedAdditionalRawData, defaultLanguageCode, visualFeatures ?? new ChangeTrackingList(), details ?? new ChangeTrackingList()); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ImageAnalysisSkill)} does not support writing '{options.Format}' format."); + } + } + + ImageAnalysisSkill 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 DeserializeImageAnalysisSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ImageAnalysisSkill)} 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 ImageAnalysisSkill FromResponse(Response response) @@ -202,7 +242,7 @@ internal static ImageAnalysisSkill DeserializeImageAnalysisSkill(JsonElement ele internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ImageAnalysisSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ImageAnalysisSkill.cs index 8e1cfa6bedfb..afeabc3551ac 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ImageAnalysisSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ImageAnalysisSkill.cs @@ -34,10 +34,11 @@ public ImageAnalysisSkill(IEnumerable inputs, IEnumerabl /// Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// A value indicating which language code to use. Default is `en`. /// A list of visual features. /// A string indicating which domain-specific details to return. - internal ImageAnalysisSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, ImageAnalysisSkillLanguage? defaultLanguageCode, IList visualFeatures, IList details) : base(oDataType, name, description, context, inputs, outputs) + internal ImageAnalysisSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, ImageAnalysisSkillLanguage? defaultLanguageCode, IList visualFeatures, IList details) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { DefaultLanguageCode = defaultLanguageCode; VisualFeatures = visualFeatures; @@ -45,6 +46,11 @@ internal ImageAnalysisSkill(string oDataType, string name, string description, s ODataType = oDataType ?? "#Microsoft.Skills.Vision.ImageAnalysisSkill"; } + /// Initializes a new instance of for deserialization. + internal ImageAnalysisSkill() + { + } + /// A value indicating which language code to use. Default is `en`. public ImageAnalysisSkillLanguage? DefaultLanguageCode { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexAction.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexAction.Serialization.cs index 12598dc14baf..c6b1002b3a0d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexAction.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexAction.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Models { - internal partial class IndexAction : IUtf8JsonSerializable + internal partial class IndexAction : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(IndexAction)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(ActionType)) { writer.WritePropertyName("@search.action"u8); @@ -23,16 +42,94 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) foreach (var item in AdditionalProperties) { writer.WritePropertyName(item.Key); - writer.WriteObjectValue(item.Value); + writer.WriteObjectValue(item.Value, options); } - writer.WriteEndObject(); + } + + IndexAction 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(IndexAction)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIndexAction(document.RootElement, options); + } + + internal static IndexAction DeserializeIndexAction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IndexActionType? searchAction = default; + IDictionary additionalProperties = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("@search.action"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + searchAction = property.Value.GetString().ToIndexActionType(); + continue; + } + additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject()); + } + additionalProperties = additionalPropertiesDictionary; + return new IndexAction(searchAction, additionalProperties); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(IndexAction)} does not support writing '{options.Format}' format."); + } + } + + IndexAction 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 DeserializeIndexAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IndexAction)} 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 IndexAction FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeIndexAction(document.RootElement); } /// Convert into a . internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexBatch.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexBatch.Serialization.cs index fa6a91e9f6ee..ba3cc99d8c49 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexBatch.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexBatch.Serialization.cs @@ -5,31 +5,147 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Models { - internal partial class IndexBatch : IUtf8JsonSerializable + internal partial class IndexBatch : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(IndexBatch)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); writer.WriteStartArray(); foreach (var item in Actions) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); - writer.WriteEndObject(); + 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 + } + } + } + + IndexBatch 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(IndexBatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIndexBatch(document.RootElement, options); + } + + internal static IndexBatch DeserializeIndexBatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(IndexAction.DeserializeIndexAction(item, options)); + } + value = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new IndexBatch(value, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(IndexBatch)} does not support writing '{options.Format}' format."); + } + } + + IndexBatch 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 DeserializeIndexBatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IndexBatch)} 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 IndexBatch FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeIndexBatch(document.RootElement); } /// Convert into a . internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexBatch.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexBatch.cs index 8266fc227191..17d8ab665e8b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexBatch.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexBatch.cs @@ -14,6 +14,38 @@ namespace Azure.Search.Documents.Models /// Contains a batch of document write actions to send to the index. internal partial class IndexBatch { + /// + /// 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 . /// The actions in the batch. /// is null. @@ -26,9 +58,16 @@ public IndexBatch(IEnumerable actions) /// Initializes a new instance of . /// The actions in the batch. - internal IndexBatch(IList actions) + /// Keeps track of any properties unknown to the library. + internal IndexBatch(IList actions, IDictionary serializedAdditionalRawData) { Actions = actions; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IndexBatch() + { } /// The actions in the batch. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexDocumentsResult.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexDocumentsResult.Serialization.cs index 3adf877a7766..c8c05c1cacc8 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexDocumentsResult.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexDocumentsResult.Serialization.cs @@ -5,20 +5,85 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class IndexDocumentsResult + public partial class IndexDocumentsResult : IUtf8JsonSerializable, IJsonModel { - internal static IndexDocumentsResult DeserializeIndexDocumentsResult(JsonElement element) + 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(IndexDocumentsResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Results) + { + 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 + } + } + } + + IndexDocumentsResult 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(IndexDocumentsResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIndexDocumentsResult(document.RootElement, options); + } + + internal static IndexDocumentsResult DeserializeIndexDocumentsResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } IReadOnlyList value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value"u8)) @@ -26,15 +91,51 @@ internal static IndexDocumentsResult DeserializeIndexDocumentsResult(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(IndexingResult.DeserializeIndexingResult(item)); + array.Add(IndexingResult.DeserializeIndexingResult(item, options)); } value = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new IndexDocumentsResult(value, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(IndexDocumentsResult)} does not support writing '{options.Format}' format."); } - return new IndexDocumentsResult(value); } + IndexDocumentsResult 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 DeserializeIndexDocumentsResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IndexDocumentsResult)} 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 IndexDocumentsResult FromResponse(Response response) @@ -42,5 +143,13 @@ internal static IndexDocumentsResult FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeIndexDocumentsResult(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/search/Azure.Search.Documents/src/Generated/Models/IndexDocumentsResult.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexDocumentsResult.cs index a8201d3039da..6611e536e582 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexDocumentsResult.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexDocumentsResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using System.Linq; @@ -13,6 +14,38 @@ namespace Azure.Search.Documents.Models /// Response containing the status of operations for all documents in the indexing request. public partial class IndexDocumentsResult { + /// + /// 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 . /// The list of status information for each document in the indexing request. internal IndexDocumentsResult(IEnumerable results) @@ -22,9 +55,16 @@ internal IndexDocumentsResult(IEnumerable results) /// Initializes a new instance of . /// The list of status information for each document in the indexing request. - internal IndexDocumentsResult(IReadOnlyList results) + /// Keeps track of any properties unknown to the library. + internal IndexDocumentsResult(IReadOnlyList results, IDictionary serializedAdditionalRawData) { Results = results; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IndexDocumentsResult() + { } /// The list of status information for each document in the indexing request. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexStatisticsSummary.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexStatisticsSummary.Serialization.cs index 8c7fb7c0c87a..99095a4cd6da 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexStatisticsSummary.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexStatisticsSummary.Serialization.cs @@ -5,14 +5,85 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class IndexStatisticsSummary + public partial class IndexStatisticsSummary : IUtf8JsonSerializable, IJsonModel { - internal static IndexStatisticsSummary DeserializeIndexStatisticsSummary(JsonElement element) + 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(IndexStatisticsSummary)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (options.Format != "W") + { + writer.WritePropertyName("documentCount"u8); + writer.WriteNumberValue(DocumentCount); + } + if (options.Format != "W") + { + writer.WritePropertyName("storageSize"u8); + writer.WriteNumberValue(StorageSize); + } + if (options.Format != "W") + { + writer.WritePropertyName("vectorIndexSize"u8); + writer.WriteNumberValue(VectorIndexSize); + } + 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 + } + } + } + + IndexStatisticsSummary 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(IndexStatisticsSummary)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIndexStatisticsSummary(document.RootElement, options); + } + + internal static IndexStatisticsSummary DeserializeIndexStatisticsSummary(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -21,6 +92,8 @@ internal static IndexStatisticsSummary DeserializeIndexStatisticsSummary(JsonEle long documentCount = default; long storageSize = default; long vectorIndexSize = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -43,10 +116,46 @@ internal static IndexStatisticsSummary DeserializeIndexStatisticsSummary(JsonEle vectorIndexSize = property.Value.GetInt64(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new IndexStatisticsSummary(name, documentCount, storageSize, vectorIndexSize, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(IndexStatisticsSummary)} does not support writing '{options.Format}' format."); } - return new IndexStatisticsSummary(name, documentCount, storageSize, vectorIndexSize); } + IndexStatisticsSummary 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 DeserializeIndexStatisticsSummary(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IndexStatisticsSummary)} 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 IndexStatisticsSummary FromResponse(Response response) @@ -54,5 +163,13 @@ internal static IndexStatisticsSummary FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeIndexStatisticsSummary(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/search/Azure.Search.Documents/src/Generated/Models/IndexStatisticsSummary.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexStatisticsSummary.cs index 4f178cffee0d..512ffb0547f6 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexStatisticsSummary.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexStatisticsSummary.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Statistics for a given index. Statistics are collected periodically and are not guaranteed to always be up-to-date. public partial class IndexStatisticsSummary { + /// + /// 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 . /// The name of the index. /// The number of documents in the index. @@ -28,6 +61,26 @@ internal IndexStatisticsSummary(string name, long documentCount, long storageSiz VectorIndexSize = vectorIndexSize; } + /// Initializes a new instance of . + /// The name of the index. + /// The number of documents in the index. + /// The amount of storage in bytes consumed by the index. + /// The amount of memory in bytes consumed by vectors in the index. + /// Keeps track of any properties unknown to the library. + internal IndexStatisticsSummary(string name, long documentCount, long storageSize, long vectorIndexSize, IDictionary serializedAdditionalRawData) + { + Name = name; + DocumentCount = documentCount; + StorageSize = storageSize; + VectorIndexSize = vectorIndexSize; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IndexStatisticsSummary() + { + } + /// The name of the index. public string Name { get; } /// The number of documents in the index. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerExecutionResult.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerExecutionResult.Serialization.cs index 97365b663f5e..ff21e3ca5f9f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerExecutionResult.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerExecutionResult.Serialization.cs @@ -6,15 +6,151 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class IndexerExecutionResult + public partial class IndexerExecutionResult : IUtf8JsonSerializable, IJsonModel { - internal static IndexerExecutionResult DeserializeIndexerExecutionResult(JsonElement element) + 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(IndexerExecutionResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToSerialString()); + } + if (options.Format != "W" && Optional.IsDefined(StatusDetail)) + { + if (StatusDetail != null) + { + writer.WritePropertyName("statusDetail"u8); + writer.WriteStringValue(StatusDetail.Value.ToString()); + } + else + { + writer.WriteNull("statusDetail"); + } + } + if (options.Format != "W" && Optional.IsDefined(Mode)) + { + writer.WritePropertyName("mode"u8); + writer.WriteStringValue(Mode.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(ErrorMessage)) + { + writer.WritePropertyName("errorMessage"u8); + writer.WriteStringValue(ErrorMessage); + } + if (options.Format != "W" && Optional.IsDefined(StartTime)) + { + writer.WritePropertyName("startTime"u8); + writer.WriteStringValue(StartTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(EndTime)) + { + if (EndTime != null) + { + writer.WritePropertyName("endTime"u8); + writer.WriteStringValue(EndTime.Value, "O"); + } + else + { + writer.WriteNull("endTime"); + } + } + if (options.Format != "W") + { + writer.WritePropertyName("errors"u8); + writer.WriteStartArray(); + foreach (var item in Errors) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W") + { + writer.WritePropertyName("warnings"u8); + writer.WriteStartArray(); + foreach (var item in Warnings) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W") + { + writer.WritePropertyName("itemsProcessed"u8); + writer.WriteNumberValue(ItemCount); + } + if (options.Format != "W") + { + writer.WritePropertyName("itemsFailed"u8); + writer.WriteNumberValue(FailedItemCount); + } + if (options.Format != "W" && Optional.IsDefined(InitialTrackingState)) + { + writer.WritePropertyName("initialTrackingState"u8); + writer.WriteStringValue(InitialTrackingState); + } + if (options.Format != "W" && Optional.IsDefined(FinalTrackingState)) + { + writer.WritePropertyName("finalTrackingState"u8); + writer.WriteStringValue(FinalTrackingState); + } + 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 + } + } + } + + IndexerExecutionResult 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(IndexerExecutionResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIndexerExecutionResult(document.RootElement, options); + } + + internal static IndexerExecutionResult DeserializeIndexerExecutionResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -31,6 +167,8 @@ internal static IndexerExecutionResult DeserializeIndexerExecutionResult(JsonEle int itemsFailed = default; string initialTrackingState = default; string finalTrackingState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("status"u8)) @@ -86,7 +224,7 @@ internal static IndexerExecutionResult DeserializeIndexerExecutionResult(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SearchIndexerError.DeserializeSearchIndexerError(item)); + array.Add(SearchIndexerError.DeserializeSearchIndexerError(item, options)); } errors = array; continue; @@ -96,7 +234,7 @@ internal static IndexerExecutionResult DeserializeIndexerExecutionResult(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SearchIndexerWarning.DeserializeSearchIndexerWarning(item)); + array.Add(SearchIndexerWarning.DeserializeSearchIndexerWarning(item, options)); } warnings = array; continue; @@ -121,7 +259,12 @@ internal static IndexerExecutionResult DeserializeIndexerExecutionResult(JsonEle finalTrackingState = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new IndexerExecutionResult( status, statusDetail, @@ -134,9 +277,41 @@ internal static IndexerExecutionResult DeserializeIndexerExecutionResult(JsonEle itemsProcessed, itemsFailed, initialTrackingState, - finalTrackingState); + finalTrackingState, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(IndexerExecutionResult)} does not support writing '{options.Format}' format."); + } } + IndexerExecutionResult 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 DeserializeIndexerExecutionResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IndexerExecutionResult)} 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 IndexerExecutionResult FromResponse(Response response) @@ -144,5 +319,13 @@ internal static IndexerExecutionResult FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeIndexerExecutionResult(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/search/Azure.Search.Documents/src/Generated/Models/IndexerExecutionResult.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerExecutionResult.cs index d56dae6ba704..480ea7ba4f67 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerExecutionResult.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerExecutionResult.cs @@ -14,6 +14,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Represents the result of an individual indexer execution. public partial class IndexerExecutionResult { + /// + /// 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 . /// The outcome of this indexer execution. /// The item-level indexing errors. @@ -42,7 +74,8 @@ internal IndexerExecutionResult(IndexerExecutionStatus status, IEnumerable The number of items that failed to be indexed during this indexer execution. /// Change tracking state with which an indexer execution started. /// Change tracking state with which an indexer execution finished. - internal IndexerExecutionResult(IndexerExecutionStatus status, IndexerExecutionStatusDetail? statusDetail, IndexingMode? mode, string errorMessage, DateTimeOffset? startTime, DateTimeOffset? endTime, IReadOnlyList errors, IReadOnlyList warnings, int itemCount, int failedItemCount, string initialTrackingState, string finalTrackingState) + /// Keeps track of any properties unknown to the library. + internal IndexerExecutionResult(IndexerExecutionStatus status, IndexerExecutionStatusDetail? statusDetail, IndexingMode? mode, string errorMessage, DateTimeOffset? startTime, DateTimeOffset? endTime, IReadOnlyList errors, IReadOnlyList warnings, int itemCount, int failedItemCount, string initialTrackingState, string finalTrackingState, IDictionary serializedAdditionalRawData) { Status = status; StatusDetail = statusDetail; @@ -56,6 +89,12 @@ internal IndexerExecutionResult(IndexerExecutionStatus status, IndexerExecutionS FailedItemCount = failedItemCount; InitialTrackingState = initialTrackingState; FinalTrackingState = finalTrackingState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IndexerExecutionResult() + { } /// The outcome of this indexer execution. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerResyncBody.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerResyncBody.Serialization.cs index 2dde11b541c7..cf8909e12f14 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerResyncBody.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerResyncBody.Serialization.cs @@ -5,16 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models { - public partial class IndexerResyncBody : IUtf8JsonSerializable + public partial class IndexerResyncBody : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(IndexerResyncBody)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Options)) { if (Options != null) @@ -32,14 +52,116 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("options"); } } - writer.WriteEndObject(); + 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 + } + } + } + + IndexerResyncBody 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(IndexerResyncBody)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIndexerResyncBody(document.RootElement, options); + } + + internal static IndexerResyncBody DeserializeIndexerResyncBody(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList options0 = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("options"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + options0 = null; + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new IndexerResyncOption(item.GetString())); + } + options0 = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new IndexerResyncBody(options0 ?? 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(IndexerResyncBody)} does not support writing '{options.Format}' format."); + } + } + + IndexerResyncBody 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 DeserializeIndexerResyncBody(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IndexerResyncBody)} 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 IndexerResyncBody FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeIndexerResyncBody(document.RootElement); } /// Convert into a . internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerResyncBody.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerResyncBody.cs index 74fd00e15f9e..a2a74ca06738 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerResyncBody.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerResyncBody.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Search.Documents.Indexes.Models; @@ -13,6 +14,38 @@ namespace Azure.Search.Documents.Models /// The IndexerResyncBody. public partial class IndexerResyncBody { + /// + /// 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 IndexerResyncBody() { @@ -21,9 +54,11 @@ public IndexerResyncBody() /// Initializes a new instance of . /// Re-sync options that have been pre-defined from data source. - internal IndexerResyncBody(IList options) + /// Keeps track of any properties unknown to the library. + internal IndexerResyncBody(IList options, IDictionary serializedAdditionalRawData) { Options = options; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Re-sync options that have been pre-defined from data source. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerState.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerState.Serialization.cs index 561f28ed5854..8bee72d33b25 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerState.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerState.Serialization.cs @@ -5,15 +5,123 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class IndexerState + public partial class IndexerState : IUtf8JsonSerializable, IJsonModel { - internal static IndexerState DeserializeIndexerState(JsonElement element) + 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(IndexerState)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Mode)) + { + writer.WritePropertyName("mode"u8); + writer.WriteStringValue(Mode.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(AllDocsInitialTrackingState)) + { + writer.WritePropertyName("allDocsInitialTrackingState"u8); + writer.WriteStringValue(AllDocsInitialTrackingState); + } + if (options.Format != "W" && Optional.IsDefined(AllDocsFinalTrackingState)) + { + writer.WritePropertyName("allDocsFinalTrackingState"u8); + writer.WriteStringValue(AllDocsFinalTrackingState); + } + if (options.Format != "W" && Optional.IsDefined(ResetDocsInitialTrackingState)) + { + writer.WritePropertyName("resetDocsInitialTrackingState"u8); + writer.WriteStringValue(ResetDocsInitialTrackingState); + } + if (options.Format != "W" && Optional.IsDefined(ResetDocsFinalTrackingState)) + { + writer.WritePropertyName("resetDocsFinalTrackingState"u8); + writer.WriteStringValue(ResetDocsFinalTrackingState); + } + if (options.Format != "W" && Optional.IsCollectionDefined(ResetDocumentKeys)) + { + writer.WritePropertyName("resetDocumentKeys"u8); + writer.WriteStartArray(); + foreach (var item in ResetDocumentKeys) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(ResetDataSourceDocumentIds)) + { + writer.WritePropertyName("resetDatasourceDocumentIds"u8); + writer.WriteStartArray(); + foreach (var item in ResetDataSourceDocumentIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(ResyncInitialTrackingState)) + { + writer.WritePropertyName("resyncInitialTrackingState"u8); + writer.WriteStringValue(ResyncInitialTrackingState); + } + if (options.Format != "W" && Optional.IsDefined(ResyncFinalTrackingState)) + { + writer.WritePropertyName("resyncFinalTrackingState"u8); + writer.WriteStringValue(ResyncFinalTrackingState); + } + 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 + } + } + } + + IndexerState 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(IndexerState)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIndexerState(document.RootElement, options); + } + + internal static IndexerState DeserializeIndexerState(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -27,6 +135,8 @@ internal static IndexerState DeserializeIndexerState(JsonElement element) IReadOnlyList resetDatasourceDocumentIds = default; string resyncInitialTrackingState = default; string resyncFinalTrackingState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("mode"u8)) @@ -96,7 +206,12 @@ internal static IndexerState DeserializeIndexerState(JsonElement element) resyncFinalTrackingState = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new IndexerState( mode, allDocsInitialTrackingState, @@ -106,9 +221,41 @@ internal static IndexerState DeserializeIndexerState(JsonElement element) resetDocumentKeys ?? new ChangeTrackingList(), resetDatasourceDocumentIds ?? new ChangeTrackingList(), resyncInitialTrackingState, - resyncFinalTrackingState); + resyncFinalTrackingState, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(IndexerState)} does not support writing '{options.Format}' format."); + } + } + + IndexerState 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 DeserializeIndexerState(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IndexerState)} 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 IndexerState FromResponse(Response response) @@ -116,5 +263,13 @@ internal static IndexerState FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeIndexerState(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/search/Azure.Search.Documents/src/Generated/Models/IndexerState.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerState.cs index 6678d5f11c6b..b90a34f1b8fe 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerState.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexerState.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models @@ -12,6 +13,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Represents all of the state that defines and dictates the indexer's current execution. public partial class IndexerState { + /// + /// 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 . internal IndexerState() { @@ -29,7 +62,8 @@ internal IndexerState() /// The list of datasource document ids that have been reset. The datasource document id is the unique identifier for the data in the datasource. The indexer will prioritize selectively re-ingesting these ids. /// Change tracking state used when indexing starts on selective options from the datasource. /// Change tracking state value when indexing finishes on selective options from the datasource. - internal IndexerState(IndexingMode? mode, string allDocsInitialTrackingState, string allDocsFinalTrackingState, string resetDocsInitialTrackingState, string resetDocsFinalTrackingState, IReadOnlyList resetDocumentKeys, IReadOnlyList resetDataSourceDocumentIds, string resyncInitialTrackingState, string resyncFinalTrackingState) + /// Keeps track of any properties unknown to the library. + internal IndexerState(IndexingMode? mode, string allDocsInitialTrackingState, string allDocsFinalTrackingState, string resetDocsInitialTrackingState, string resetDocsFinalTrackingState, IReadOnlyList resetDocumentKeys, IReadOnlyList resetDataSourceDocumentIds, string resyncInitialTrackingState, string resyncFinalTrackingState, IDictionary serializedAdditionalRawData) { Mode = mode; AllDocsInitialTrackingState = allDocsInitialTrackingState; @@ -40,6 +74,7 @@ internal IndexerState(IndexingMode? mode, string allDocsInitialTrackingState, st ResetDataSourceDocumentIds = resetDataSourceDocumentIds; ResyncInitialTrackingState = resyncInitialTrackingState; ResyncFinalTrackingState = resyncFinalTrackingState; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The mode the indexer is running in. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingParameters.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingParameters.Serialization.cs index 9f0398068bb5..052637984fce 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingParameters.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingParameters.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class IndexingParameters : IUtf8JsonSerializable + public partial class IndexingParameters : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(IndexingParameters)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(BatchSize)) { if (BatchSize != null) @@ -54,13 +73,41 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(IndexingParametersConfiguration)) { writer.WritePropertyName("configuration"u8); - writer.WriteObjectValue(IndexingParametersConfiguration); + writer.WriteObjectValue(IndexingParametersConfiguration, options); + } + 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 + } } - writer.WriteEndObject(); } - internal static IndexingParameters DeserializeIndexingParameters(JsonElement element) + IndexingParameters 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(IndexingParameters)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIndexingParameters(document.RootElement, options); + } + + internal static IndexingParameters DeserializeIndexingParameters(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -69,6 +116,8 @@ internal static IndexingParameters DeserializeIndexingParameters(JsonElement ele int? maxFailedItems = default; int? maxFailedItemsPerBatch = default; IndexingParametersConfiguration configuration = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("batchSize"u8)) @@ -107,13 +156,49 @@ internal static IndexingParameters DeserializeIndexingParameters(JsonElement ele { continue; } - configuration = Models.IndexingParametersConfiguration.DeserializeIndexingParametersConfiguration(property.Value); + configuration = Models.IndexingParametersConfiguration.DeserializeIndexingParametersConfiguration(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new IndexingParameters(batchSize, maxFailedItems, maxFailedItemsPerBatch, configuration, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(IndexingParameters)} does not support writing '{options.Format}' format."); } - return new IndexingParameters(batchSize, maxFailedItems, maxFailedItemsPerBatch, configuration); } + IndexingParameters 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 DeserializeIndexingParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IndexingParameters)} 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 IndexingParameters FromResponse(Response response) @@ -126,7 +211,7 @@ internal static IndexingParameters FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingParameters.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingParameters.cs index fab204e67262..15e412423284 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingParameters.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingParameters.cs @@ -5,22 +5,59 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Represents parameters for indexer execution. public partial class IndexingParameters { + /// + /// 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 . /// The number of items that are read from the data source and indexed as a single batch in order to improve performance. The default depends on the data source type. /// The maximum number of items that can fail indexing for indexer execution to still be considered successful. -1 means no limit. Default is 0. /// The maximum number of items in a single batch that can fail indexing for the batch to still be considered successful. -1 means no limit. Default is 0. /// A dictionary of indexer-specific configuration properties. Each name is the name of a specific property. Each value must be of a primitive type. - internal IndexingParameters(int? batchSize, int? maxFailedItems, int? maxFailedItemsPerBatch, IndexingParametersConfiguration indexingParametersConfiguration) + /// Keeps track of any properties unknown to the library. + internal IndexingParameters(int? batchSize, int? maxFailedItems, int? maxFailedItemsPerBatch, IndexingParametersConfiguration indexingParametersConfiguration, IDictionary serializedAdditionalRawData) { BatchSize = batchSize; MaxFailedItems = maxFailedItems; MaxFailedItemsPerBatch = maxFailedItemsPerBatch; IndexingParametersConfiguration = indexingParametersConfiguration; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The number of items that are read from the data source and indexed as a single batch in order to improve performance. The default depends on the data source type. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingParametersConfiguration.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingParametersConfiguration.Serialization.cs index aed6a2d77bef..df7f9696eb3a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingParametersConfiguration.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingParametersConfiguration.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class IndexingParametersConfiguration : IUtf8JsonSerializable + public partial class IndexingParametersConfiguration : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(IndexingParametersConfiguration)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(ParsingMode)) { writer.WritePropertyName("parsingMode"u8); @@ -123,13 +141,26 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) foreach (var item in AdditionalProperties) { writer.WritePropertyName(item.Key); - writer.WriteObjectValue(item.Value); + writer.WriteObjectValue(item.Value, options); } - writer.WriteEndObject(); } - internal static IndexingParametersConfiguration DeserializeIndexingParametersConfiguration(JsonElement element) + IndexingParametersConfiguration 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(IndexingParametersConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIndexingParametersConfiguration(document.RootElement, options); + } + + internal static IndexingParametersConfiguration DeserializeIndexingParametersConfiguration(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -321,6 +352,37 @@ internal static IndexingParametersConfiguration DeserializeIndexingParametersCon additionalProperties); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(IndexingParametersConfiguration)} does not support writing '{options.Format}' format."); + } + } + + IndexingParametersConfiguration 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 DeserializeIndexingParametersConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IndexingParametersConfiguration)} 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 IndexingParametersConfiguration FromResponse(Response response) @@ -333,7 +395,7 @@ internal static IndexingParametersConfiguration FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingResult.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingResult.Serialization.cs index 877ddf72a4ba..81230a32ece3 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingResult.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingResult.Serialization.cs @@ -5,14 +5,88 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class IndexingResult + public partial class IndexingResult : IUtf8JsonSerializable, IJsonModel { - internal static IndexingResult DeserializeIndexingResult(JsonElement element) + 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(IndexingResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("key"u8); + writer.WriteStringValue(Key); + } + if (options.Format != "W" && Optional.IsDefined(ErrorMessage)) + { + writer.WritePropertyName("errorMessage"u8); + writer.WriteStringValue(ErrorMessage); + } + if (options.Format != "W") + { + writer.WritePropertyName("status"u8); + writer.WriteBooleanValue(Succeeded); + } + if (options.Format != "W") + { + writer.WritePropertyName("statusCode"u8); + writer.WriteNumberValue(Status); + } + 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 + } + } + } + + IndexingResult 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(IndexingResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIndexingResult(document.RootElement, options); + } + + internal static IndexingResult DeserializeIndexingResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -21,6 +95,8 @@ internal static IndexingResult DeserializeIndexingResult(JsonElement element) string errorMessage = default; bool status = default; int statusCode = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("key"u8)) @@ -43,10 +119,46 @@ internal static IndexingResult DeserializeIndexingResult(JsonElement element) statusCode = property.Value.GetInt32(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new IndexingResult(key, errorMessage, status, statusCode); + serializedAdditionalRawData = rawDataDictionary; + return new IndexingResult(key, errorMessage, status, statusCode, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(IndexingResult)} does not support writing '{options.Format}' format."); + } + } + + IndexingResult 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 DeserializeIndexingResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IndexingResult)} 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 IndexingResult FromResponse(Response response) @@ -54,5 +166,13 @@ internal static IndexingResult FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeIndexingResult(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/search/Azure.Search.Documents/src/Generated/Models/IndexingResult.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingResult.cs index bf84934bc27c..4f60f3c4c118 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingResult.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingResult.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Models { /// Status of an indexing operation for a single document. public partial class IndexingResult { + /// + /// 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 . /// The key of a document that was in the indexing request. /// A value indicating whether the indexing operation succeeded for the document identified by the key. @@ -26,12 +61,19 @@ internal IndexingResult(string key, bool succeeded, int status) /// The error message explaining why the indexing operation failed for the document identified by the key; null if indexing succeeded. /// A value indicating whether the indexing operation succeeded for the document identified by the key. /// The status code of the indexing operation. Possible values include: 200 for a successful update or delete, 201 for successful document creation, 400 for a malformed input document, 404 for document not found, 409 for a version conflict, 422 when the index is temporarily unavailable, or 503 for when the service is too busy. - internal IndexingResult(string key, string errorMessage, bool succeeded, int status) + /// Keeps track of any properties unknown to the library. + internal IndexingResult(string key, string errorMessage, bool succeeded, int status, IDictionary serializedAdditionalRawData) { Key = key; ErrorMessage = errorMessage; Succeeded = succeeded; Status = status; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IndexingResult() + { } /// The key of a document that was in the indexing request. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingSchedule.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingSchedule.Serialization.cs index b34e062b1cca..b3e3d90925aa 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingSchedule.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingSchedule.Serialization.cs @@ -6,16 +6,34 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class IndexingSchedule : IUtf8JsonSerializable + public partial class IndexingSchedule : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(IndexingSchedule)} does not support writing '{format}' format."); + } + writer.WritePropertyName("interval"u8); writer.WriteStringValue(Interval, "P"); if (Optional.IsDefined(StartTime)) @@ -23,17 +41,47 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("startTime"u8); writer.WriteStringValue(StartTime.Value, "O"); } - writer.WriteEndObject(); + 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 + } + } } - internal static IndexingSchedule DeserializeIndexingSchedule(JsonElement element) + IndexingSchedule 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(IndexingSchedule)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIndexingSchedule(document.RootElement, options); + } + + internal static IndexingSchedule DeserializeIndexingSchedule(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } TimeSpan interval = default; DateTimeOffset? startTime = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("interval"u8)) @@ -50,10 +98,46 @@ internal static IndexingSchedule DeserializeIndexingSchedule(JsonElement element startTime = property.Value.GetDateTimeOffset("O"); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new IndexingSchedule(interval, startTime, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(IndexingSchedule)} does not support writing '{options.Format}' format."); } - return new IndexingSchedule(interval, startTime); } + IndexingSchedule 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 DeserializeIndexingSchedule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IndexingSchedule)} 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 IndexingSchedule FromResponse(Response response) @@ -66,7 +150,7 @@ internal static IndexingSchedule FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingSchedule.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingSchedule.cs index 186014638b39..4ada1d5b817a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingSchedule.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/IndexingSchedule.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Represents a schedule for indexer execution. public partial class IndexingSchedule { + /// + /// 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 . /// The interval of time between indexer executions. public IndexingSchedule(TimeSpan interval) @@ -22,10 +55,17 @@ public IndexingSchedule(TimeSpan interval) /// Initializes a new instance of . /// The interval of time between indexer executions. /// The time when an indexer should start running. - internal IndexingSchedule(TimeSpan interval, DateTimeOffset? startTime) + /// Keeps track of any properties unknown to the library. + internal IndexingSchedule(TimeSpan interval, DateTimeOffset? startTime, IDictionary serializedAdditionalRawData) { Interval = interval; StartTime = startTime; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IndexingSchedule() + { } /// The interval of time between indexer executions. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/InputFieldMappingEntry.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/InputFieldMappingEntry.Serialization.cs index 0ec8ec09983f..564a07a92ed9 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/InputFieldMappingEntry.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/InputFieldMappingEntry.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class InputFieldMappingEntry : IUtf8JsonSerializable + public partial class InputFieldMappingEntry : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(InputFieldMappingEntry)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); if (Optional.IsDefined(Source)) @@ -34,15 +52,43 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in Inputs) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - writer.WriteEndObject(); + 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 + } + } } - internal static InputFieldMappingEntry DeserializeInputFieldMappingEntry(JsonElement element) + InputFieldMappingEntry 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(InputFieldMappingEntry)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInputFieldMappingEntry(document.RootElement, options); + } + + internal static InputFieldMappingEntry DeserializeInputFieldMappingEntry(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -51,6 +97,8 @@ internal static InputFieldMappingEntry DeserializeInputFieldMappingEntry(JsonEle string source = default; string sourceContext = default; IList inputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -77,15 +125,51 @@ internal static InputFieldMappingEntry DeserializeInputFieldMappingEntry(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DeserializeInputFieldMappingEntry(item)); + array.Add(DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InputFieldMappingEntry(name, source, sourceContext, inputs ?? 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(InputFieldMappingEntry)} does not support writing '{options.Format}' format."); } - return new InputFieldMappingEntry(name, source, sourceContext, inputs ?? new ChangeTrackingList()); } + InputFieldMappingEntry 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 DeserializeInputFieldMappingEntry(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InputFieldMappingEntry)} 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 InputFieldMappingEntry FromResponse(Response response) @@ -98,7 +182,7 @@ internal static InputFieldMappingEntry FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/InputFieldMappingEntry.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/InputFieldMappingEntry.cs index 763b79ac9e92..52bf423987c3 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/InputFieldMappingEntry.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/InputFieldMappingEntry.cs @@ -13,6 +13,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Input field mapping for a skill. public partial class InputFieldMappingEntry { + /// + /// 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 . /// The name of the input. /// is null. @@ -29,12 +61,19 @@ public InputFieldMappingEntry(string name) /// The source of the input. /// The source context used for selecting recursive inputs. /// The recursive inputs used when creating a complex type. - internal InputFieldMappingEntry(string name, string source, string sourceContext, IList inputs) + /// Keeps track of any properties unknown to the library. + internal InputFieldMappingEntry(string name, string source, string sourceContext, IList inputs, IDictionary serializedAdditionalRawData) { Name = name; Source = source; SourceContext = sourceContext; Inputs = inputs; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InputFieldMappingEntry() + { } /// The name of the input. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeepTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeepTokenFilter.Serialization.cs index fc931f7e5541..882179fed11e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeepTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeepTokenFilter.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class KeepTokenFilter : IUtf8JsonSerializable + public partial class KeepTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(KeepTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("keepWords"u8); writer.WriteStartArray(); foreach (var item in KeepWords) @@ -28,15 +47,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("keepWordsCase"u8); writer.WriteBooleanValue(LowerCaseKeepWords.Value); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static KeepTokenFilter DeserializeKeepTokenFilter(JsonElement element) + KeepTokenFilter 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(KeepTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKeepTokenFilter(document.RootElement, options); + } + + internal static KeepTokenFilter DeserializeKeepTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -45,6 +73,8 @@ internal static KeepTokenFilter DeserializeKeepTokenFilter(JsonElement element) bool? keepWordsCase = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("keepWords"u8)) @@ -76,10 +106,46 @@ internal static KeepTokenFilter DeserializeKeepTokenFilter(JsonElement element) name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KeepTokenFilter(odataType, name, serializedAdditionalRawData, keepWords, keepWordsCase); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KeepTokenFilter)} does not support writing '{options.Format}' format."); + } + } + + KeepTokenFilter 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 DeserializeKeepTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KeepTokenFilter)} does not support reading '{options.Format}' format."); } - return new KeepTokenFilter(odataType, name, keepWords, keepWordsCase); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new KeepTokenFilter FromResponse(Response response) @@ -92,7 +158,7 @@ internal static KeepTokenFilter DeserializeKeepTokenFilter(JsonElement element) internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeepTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeepTokenFilter.cs index a4429a1ea475..463288219f6a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeepTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeepTokenFilter.cs @@ -30,14 +30,20 @@ public KeepTokenFilter(string name, IEnumerable keepWords) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The list of words to keep. /// A value indicating whether to lower case all words first. Default is false. - internal KeepTokenFilter(string oDataType, string name, IList keepWords, bool? lowerCaseKeepWords) : base(oDataType, name) + internal KeepTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, IList keepWords, bool? lowerCaseKeepWords) : base(oDataType, name, serializedAdditionalRawData) { KeepWords = keepWords; LowerCaseKeepWords = lowerCaseKeepWords; ODataType = oDataType ?? "#Microsoft.Azure.Search.KeepTokenFilter"; } + + /// Initializes a new instance of for deserialization. + internal KeepTokenFilter() + { + } /// A value indicating whether to lower case all words first. Default is false. public bool? LowerCaseKeepWords { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeyPhraseExtractionSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeyPhraseExtractionSkill.Serialization.cs index 91ea38df0309..a05a390a7592 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeyPhraseExtractionSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeyPhraseExtractionSkill.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class KeyPhraseExtractionSkill : IUtf8JsonSerializable + public partial class KeyPhraseExtractionSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(KeyPhraseExtractionSkill)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(DefaultLanguageCode)) { if (DefaultLanguageCode != null) @@ -52,42 +71,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("modelVersion"); } } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + KeyPhraseExtractionSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(KeyPhraseExtractionSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKeyPhraseExtractionSkill(document.RootElement, options); } - internal static KeyPhraseExtractionSkill DeserializeKeyPhraseExtractionSkill(JsonElement element) + internal static KeyPhraseExtractionSkill DeserializeKeyPhraseExtractionSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -101,6 +102,8 @@ internal static KeyPhraseExtractionSkill DeserializeKeyPhraseExtractionSkill(Jso string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("defaultLanguageCode"u8)) @@ -158,7 +161,7 @@ internal static KeyPhraseExtractionSkill DeserializeKeyPhraseExtractionSkill(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -168,12 +171,17 @@ internal static KeyPhraseExtractionSkill DeserializeKeyPhraseExtractionSkill(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new KeyPhraseExtractionSkill( odataType, name, @@ -181,11 +189,43 @@ internal static KeyPhraseExtractionSkill DeserializeKeyPhraseExtractionSkill(Jso context, inputs, outputs, + serializedAdditionalRawData, defaultLanguageCode, maxKeyPhraseCount, modelVersion); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KeyPhraseExtractionSkill)} does not support writing '{options.Format}' format."); + } + } + + KeyPhraseExtractionSkill 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 DeserializeKeyPhraseExtractionSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KeyPhraseExtractionSkill)} 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 KeyPhraseExtractionSkill FromResponse(Response response) @@ -198,7 +238,7 @@ internal static KeyPhraseExtractionSkill DeserializeKeyPhraseExtractionSkill(Jso internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeyPhraseExtractionSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeyPhraseExtractionSkill.cs index e99f474f8e93..7e1627bf2785 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeyPhraseExtractionSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeyPhraseExtractionSkill.cs @@ -32,10 +32,11 @@ public KeyPhraseExtractionSkill(IEnumerable inputs, IEnu /// Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// A value indicating which language code to use. Default is `en`. /// A number indicating how many key phrases to return. If absent, all identified key phrases will be returned. /// The version of the model to use when calling the Text Analytics service. It will default to the latest available when not specified. We recommend you do not specify this value unless absolutely necessary. - internal KeyPhraseExtractionSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, KeyPhraseExtractionSkillLanguage? defaultLanguageCode, int? maxKeyPhraseCount, string modelVersion) : base(oDataType, name, description, context, inputs, outputs) + internal KeyPhraseExtractionSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, KeyPhraseExtractionSkillLanguage? defaultLanguageCode, int? maxKeyPhraseCount, string modelVersion) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { DefaultLanguageCode = defaultLanguageCode; MaxKeyPhraseCount = maxKeyPhraseCount; @@ -43,6 +44,11 @@ internal KeyPhraseExtractionSkill(string oDataType, string name, string descript ODataType = oDataType ?? "#Microsoft.Skills.Text.KeyPhraseExtractionSkill"; } + /// Initializes a new instance of for deserialization. + internal KeyPhraseExtractionSkill() + { + } + /// A value indicating which language code to use. Default is `en`. public KeyPhraseExtractionSkillLanguage? DefaultLanguageCode { get; set; } /// A number indicating how many key phrases to return. If absent, all identified key phrases will be returned. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordMarkerTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordMarkerTokenFilter.Serialization.cs index 2c1ac7aace23..d3aacc248ca2 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordMarkerTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordMarkerTokenFilter.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class KeywordMarkerTokenFilter : IUtf8JsonSerializable + public partial class KeywordMarkerTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(KeywordMarkerTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("keywords"u8); writer.WriteStartArray(); foreach (var item in Keywords) @@ -28,15 +47,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("ignoreCase"u8); writer.WriteBooleanValue(IgnoreCase.Value); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static KeywordMarkerTokenFilter DeserializeKeywordMarkerTokenFilter(JsonElement element) + KeywordMarkerTokenFilter 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(KeywordMarkerTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKeywordMarkerTokenFilter(document.RootElement, options); + } + + internal static KeywordMarkerTokenFilter DeserializeKeywordMarkerTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -45,6 +73,8 @@ internal static KeywordMarkerTokenFilter DeserializeKeywordMarkerTokenFilter(Jso bool? ignoreCase = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("keywords"u8)) @@ -76,10 +106,46 @@ internal static KeywordMarkerTokenFilter DeserializeKeywordMarkerTokenFilter(Jso name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KeywordMarkerTokenFilter(odataType, name, serializedAdditionalRawData, keywords, ignoreCase); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KeywordMarkerTokenFilter)} does not support writing '{options.Format}' format."); + } + } + + KeywordMarkerTokenFilter 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 DeserializeKeywordMarkerTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KeywordMarkerTokenFilter)} does not support reading '{options.Format}' format."); } - return new KeywordMarkerTokenFilter(odataType, name, keywords, ignoreCase); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new KeywordMarkerTokenFilter FromResponse(Response response) @@ -92,7 +158,7 @@ internal static KeywordMarkerTokenFilter DeserializeKeywordMarkerTokenFilter(Jso internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordMarkerTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordMarkerTokenFilter.cs index 5ed7f96e3de2..4d62a37d4ed2 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordMarkerTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordMarkerTokenFilter.cs @@ -30,14 +30,20 @@ public KeywordMarkerTokenFilter(string name, IEnumerable keywords) : bas /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// A list of words to mark as keywords. /// A value indicating whether to ignore case. If true, all words are converted to lower case first. Default is false. - internal KeywordMarkerTokenFilter(string oDataType, string name, IList keywords, bool? ignoreCase) : base(oDataType, name) + internal KeywordMarkerTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, IList keywords, bool? ignoreCase) : base(oDataType, name, serializedAdditionalRawData) { Keywords = keywords; IgnoreCase = ignoreCase; ODataType = oDataType ?? "#Microsoft.Azure.Search.KeywordMarkerTokenFilter"; } + + /// Initializes a new instance of for deserialization. + internal KeywordMarkerTokenFilter() + { + } /// A value indicating whether to ignore case. If true, all words are converted to lower case first. Default is false. public bool? IgnoreCase { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizer.Serialization.cs index 390f73702826..fe7949cd9017 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizer.Serialization.cs @@ -5,13 +5,150 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class KeywordTokenizer : IUtf8JsonSerializable + public partial class KeywordTokenizer : IUtf8JsonSerializable, IJsonModel { + 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(KeywordTokenizer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(MaxTokenLength)) + { + writer.WritePropertyName("maxTokenLength"u8); + writer.WriteNumberValue(MaxTokenLength.Value); + } + if (Optional.IsDefined(BufferSize)) + { + if (BufferSize != null) + { + writer.WritePropertyName("bufferSize"u8); + writer.WriteNumberValue(BufferSize.Value); + } + else + { + writer.WriteNull("bufferSize"); + } + } + } + + KeywordTokenizer 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(KeywordTokenizer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKeywordTokenizer(document.RootElement, options); + } + + internal static KeywordTokenizer DeserializeKeywordTokenizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? maxTokenLength = default; + int? bufferSize = default; + string odataType = default; + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("maxTokenLength"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxTokenLength = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("bufferSize"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + bufferSize = null; + continue; + } + bufferSize = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("@odata.type"u8)) + { + odataType = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KeywordTokenizer(odataType, name, serializedAdditionalRawData, maxTokenLength, bufferSize); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KeywordTokenizer)} does not support writing '{options.Format}' format."); + } + } + + KeywordTokenizer 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 DeserializeKeywordTokenizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KeywordTokenizer)} 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 KeywordTokenizer FromResponse(Response response) @@ -24,7 +161,7 @@ public partial class KeywordTokenizer : IUtf8JsonSerializable internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizer.cs index a7c9f087b376..9275c98c0945 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizer.cs @@ -6,11 +6,29 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Emits the entire input as a single token. This tokenizer is implemented using Apache Lucene. public partial class KeywordTokenizer : LexicalTokenizer { + /// Initializes a new instance of . + /// A URI fragment specifying the type of tokenizer. + /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. + /// The maximum token length. Default is 256. Tokens longer than the maximum length are split. The maximum token length that can be used is 300 characters. + /// + internal KeywordTokenizer(string oDataType, string name, IDictionary serializedAdditionalRawData, int? maxTokenLength, int? bufferSize) : base(oDataType, name, serializedAdditionalRawData) + { + MaxTokenLength = maxTokenLength; + BufferSize = bufferSize; + ODataType = oDataType ?? "#Microsoft.Azure.Search.KeywordTokenizerV2"; + } + + /// Initializes a new instance of for deserialization. + internal KeywordTokenizer() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgent.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgent.Serialization.cs index 6f1be5a83d72..0d95111cdd24 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgent.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgent.Serialization.cs @@ -5,37 +5,55 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class KnowledgeAgent : IUtf8JsonSerializable + public partial class KnowledgeAgent : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(KnowledgeAgent)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); writer.WritePropertyName("models"u8); writer.WriteStartArray(); foreach (var item in Models) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); writer.WritePropertyName("targetIndexes"u8); writer.WriteStartArray(); foreach (var item in TargetIndexes) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); if (Optional.IsDefined(RequestLimits)) { writer.WritePropertyName("requestLimits"u8); - writer.WriteObjectValue(RequestLimits); + writer.WriteObjectValue(RequestLimits, options); } if (Optional.IsDefined(_eTag)) { @@ -47,7 +65,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (EncryptionKey != null) { writer.WritePropertyName("encryptionKey"u8); - writer.WriteObjectValue(EncryptionKey); + writer.WriteObjectValue(EncryptionKey, options); } else { @@ -59,11 +77,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("description"u8); writer.WriteStringValue(Description); } - writer.WriteEndObject(); + 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 + } + } } - internal static KnowledgeAgent DeserializeKnowledgeAgent(JsonElement element) + KnowledgeAgent 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(KnowledgeAgent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgent(document.RootElement, options); + } + + internal static KnowledgeAgent DeserializeKnowledgeAgent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -75,6 +121,8 @@ internal static KnowledgeAgent DeserializeKnowledgeAgent(JsonElement element) string odataEtag = default; SearchResourceEncryptionKey encryptionKey = default; string description = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -87,7 +135,7 @@ internal static KnowledgeAgent DeserializeKnowledgeAgent(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KnowledgeAgentModel.DeserializeKnowledgeAgentModel(item)); + array.Add(KnowledgeAgentModel.DeserializeKnowledgeAgentModel(item, options)); } models = array; continue; @@ -97,7 +145,7 @@ internal static KnowledgeAgent DeserializeKnowledgeAgent(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KnowledgeAgentTargetIndex.DeserializeKnowledgeAgentTargetIndex(item)); + array.Add(KnowledgeAgentTargetIndex.DeserializeKnowledgeAgentTargetIndex(item, options)); } targetIndexes = array; continue; @@ -108,7 +156,7 @@ internal static KnowledgeAgent DeserializeKnowledgeAgent(JsonElement element) { continue; } - requestLimits = KnowledgeAgentRequestLimits.DeserializeKnowledgeAgentRequestLimits(property.Value); + requestLimits = KnowledgeAgentRequestLimits.DeserializeKnowledgeAgentRequestLimits(property.Value, options); continue; } if (property.NameEquals("@odata.etag"u8)) @@ -123,7 +171,7 @@ internal static KnowledgeAgent DeserializeKnowledgeAgent(JsonElement element) encryptionKey = null; continue; } - encryptionKey = SearchResourceEncryptionKey.DeserializeSearchResourceEncryptionKey(property.Value); + encryptionKey = SearchResourceEncryptionKey.DeserializeSearchResourceEncryptionKey(property.Value, options); continue; } if (property.NameEquals("description"u8)) @@ -131,7 +179,12 @@ internal static KnowledgeAgent DeserializeKnowledgeAgent(JsonElement element) description = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new KnowledgeAgent( name, models, @@ -139,9 +192,41 @@ internal static KnowledgeAgent DeserializeKnowledgeAgent(JsonElement element) requestLimits, odataEtag, encryptionKey, - description); + description, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgent)} does not support writing '{options.Format}' format."); + } } + KnowledgeAgent 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 DeserializeKnowledgeAgent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgent)} 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 KnowledgeAgent FromResponse(Response response) @@ -154,7 +239,7 @@ internal static KnowledgeAgent FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgent.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgent.cs index 4c2fcc41022d..9c9d1bafc23c 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgent.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgent.cs @@ -14,6 +14,38 @@ namespace Azure.Search.Documents.Indexes.Models /// The KnowledgeAgent. public partial class KnowledgeAgent { + /// + /// 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 . /// The name of the knowledge agent. /// @@ -46,7 +78,8 @@ public KnowledgeAgent(string name, IEnumerable models, IEnu /// The ETag of the agent. /// A description of an encryption key that you create in Azure Key Vault. This key is used to provide an additional level of encryption-at-rest for your agent definition when you want full assurance that no one, not even Microsoft, can decrypt them. Once you have encrypted your agent definition, it will always remain encrypted. The search service will ignore attempts to set this property to null. You can change this property as needed if you want to rotate your encryption key; Your agent definition will be unaffected. Encryption with customer-managed keys is not available for free search services, and is only available for paid services created on or after January 1, 2019. /// The description of the agent. - internal KnowledgeAgent(string name, IList models, IList targetIndexes, KnowledgeAgentRequestLimits requestLimits, string eTag, SearchResourceEncryptionKey encryptionKey, string description) + /// Keeps track of any properties unknown to the library. + internal KnowledgeAgent(string name, IList models, IList targetIndexes, KnowledgeAgentRequestLimits requestLimits, string eTag, SearchResourceEncryptionKey encryptionKey, string description, IDictionary serializedAdditionalRawData) { Name = name; Models = models; @@ -55,6 +88,12 @@ internal KnowledgeAgent(string name, IList models, IList Initializes a new instance of for deserialization. + internal KnowledgeAgent() + { } /// The name of the knowledge agent. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentActivityRecord.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentActivityRecord.Serialization.cs index cb25308ce549..497b7fc503d7 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentActivityRecord.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentActivityRecord.Serialization.cs @@ -5,15 +5,73 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; +using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Agents.Models { - public partial class KnowledgeAgentActivityRecord + [PersistableModelProxy(typeof(UnknownKnowledgeAgentActivityRecord))] + public partial class KnowledgeAgentActivityRecord : IUtf8JsonSerializable, IJsonModel { - internal static KnowledgeAgentActivityRecord DeserializeKnowledgeAgentActivityRecord(JsonElement element) + 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(KnowledgeAgentActivityRecord)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteNumberValue(Id); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + 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 + } + } + } + + KnowledgeAgentActivityRecord 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(KnowledgeAgentActivityRecord)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentActivityRecord(document.RootElement, options); + } + + internal static KnowledgeAgentActivityRecord DeserializeKnowledgeAgentActivityRecord(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -22,14 +80,45 @@ internal static KnowledgeAgentActivityRecord DeserializeKnowledgeAgentActivityRe { switch (discriminator.GetString()) { - case "AzureSearchQuery": return KnowledgeAgentSearchActivityRecord.DeserializeKnowledgeAgentSearchActivityRecord(element); - case "AzureSearchSemanticRanker": return KnowledgeAgentSemanticRankerActivityRecord.DeserializeKnowledgeAgentSemanticRankerActivityRecord(element); - case "ModelQueryPlanning": return KnowledgeAgentModelQueryPlanningActivityRecord.DeserializeKnowledgeAgentModelQueryPlanningActivityRecord(element); + case "AzureSearchQuery": return KnowledgeAgentSearchActivityRecord.DeserializeKnowledgeAgentSearchActivityRecord(element, options); + case "AzureSearchSemanticRanker": return KnowledgeAgentSemanticRankerActivityRecord.DeserializeKnowledgeAgentSemanticRankerActivityRecord(element, options); + case "ModelQueryPlanning": return KnowledgeAgentModelQueryPlanningActivityRecord.DeserializeKnowledgeAgentModelQueryPlanningActivityRecord(element, options); } } - return UnknownKnowledgeAgentActivityRecord.DeserializeUnknownKnowledgeAgentActivityRecord(element); + return UnknownKnowledgeAgentActivityRecord.DeserializeUnknownKnowledgeAgentActivityRecord(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentActivityRecord)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeAgentActivityRecord 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 DeserializeKnowledgeAgentActivityRecord(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentActivityRecord)} 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 KnowledgeAgentActivityRecord FromResponse(Response response) @@ -37,5 +126,13 @@ internal static KnowledgeAgentActivityRecord FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeKnowledgeAgentActivityRecord(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/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentActivityRecord.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentActivityRecord.cs index 325559b9edaf..264702a58397 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentActivityRecord.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentActivityRecord.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Agents.Models { /// @@ -14,6 +17,38 @@ namespace Azure.Search.Documents.Agents.Models /// public abstract partial class KnowledgeAgentActivityRecord { + /// + /// 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 . /// The ID of the activity record. protected KnowledgeAgentActivityRecord(int id) @@ -24,10 +59,17 @@ protected KnowledgeAgentActivityRecord(int id) /// Initializes a new instance of . /// The ID of the activity record. /// The type of the activity record. - internal KnowledgeAgentActivityRecord(int id, string type) + /// Keeps track of any properties unknown to the library. + internal KnowledgeAgentActivityRecord(int id, string type, IDictionary serializedAdditionalRawData) { Id = id; Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal KnowledgeAgentActivityRecord() + { } /// The ID of the activity record. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentAzureOpenAIModel.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentAzureOpenAIModel.Serialization.cs index 2bbd56492835..b6bf28d82bcc 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentAzureOpenAIModel.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentAzureOpenAIModel.Serialization.cs @@ -5,36 +5,69 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class KnowledgeAgentAzureOpenAIModel : IUtf8JsonSerializable + public partial class KnowledgeAgentAzureOpenAIModel : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("azureOpenAIParameters"u8); - writer.WriteObjectValue(AzureOpenAIParameters); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); + JsonModelWriteCore(writer, options); writer.WriteEndObject(); } - internal static KnowledgeAgentAzureOpenAIModel DeserializeKnowledgeAgentAzureOpenAIModel(JsonElement element) + /// 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(KnowledgeAgentAzureOpenAIModel)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("azureOpenAIParameters"u8); + writer.WriteObjectValue(AzureOpenAIParameters, options); + } + + KnowledgeAgentAzureOpenAIModel 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(KnowledgeAgentAzureOpenAIModel)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentAzureOpenAIModel(document.RootElement, options); + } + + internal static KnowledgeAgentAzureOpenAIModel DeserializeKnowledgeAgentAzureOpenAIModel(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } AzureOpenAIVectorizerParameters azureOpenAIParameters = default; KnowledgeAgentModelKind kind = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("azureOpenAIParameters"u8)) { - azureOpenAIParameters = AzureOpenAIVectorizerParameters.DeserializeAzureOpenAIVectorizerParameters(property.Value); + azureOpenAIParameters = AzureOpenAIVectorizerParameters.DeserializeAzureOpenAIVectorizerParameters(property.Value, options); continue; } if (property.NameEquals("kind"u8)) @@ -42,10 +75,46 @@ internal static KnowledgeAgentAzureOpenAIModel DeserializeKnowledgeAgentAzureOpe kind = new KnowledgeAgentModelKind(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeAgentAzureOpenAIModel(kind, serializedAdditionalRawData, azureOpenAIParameters); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentAzureOpenAIModel)} does not support writing '{options.Format}' format."); } - return new KnowledgeAgentAzureOpenAIModel(kind, azureOpenAIParameters); } + KnowledgeAgentAzureOpenAIModel 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 DeserializeKnowledgeAgentAzureOpenAIModel(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentAzureOpenAIModel)} 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 KnowledgeAgentAzureOpenAIModel FromResponse(Response response) @@ -58,7 +127,7 @@ internal static KnowledgeAgentAzureOpenAIModel DeserializeKnowledgeAgentAzureOpe internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentAzureOpenAIModel.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentAzureOpenAIModel.cs index dbb8dafc79d0..65ee5e9e5b46 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentAzureOpenAIModel.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentAzureOpenAIModel.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,13 +26,19 @@ public KnowledgeAgentAzureOpenAIModel(AzureOpenAIVectorizerParameters azureOpenA /// Initializes a new instance of . /// The type of AI model. + /// Keeps track of any properties unknown to the library. /// Contains the parameters specific to Azure OpenAI model endpoint. - internal KnowledgeAgentAzureOpenAIModel(KnowledgeAgentModelKind kind, AzureOpenAIVectorizerParameters azureOpenAIParameters) : base(kind) + internal KnowledgeAgentAzureOpenAIModel(KnowledgeAgentModelKind kind, IDictionary serializedAdditionalRawData, AzureOpenAIVectorizerParameters azureOpenAIParameters) : base(kind, serializedAdditionalRawData) { AzureOpenAIParameters = azureOpenAIParameters; Kind = kind; } + /// Initializes a new instance of for deserialization. + internal KnowledgeAgentAzureOpenAIModel() + { + } + /// Contains the parameters specific to Azure OpenAI model endpoint. public AzureOpenAIVectorizerParameters AzureOpenAIParameters { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentAzureSearchDocReference.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentAzureSearchDocReference.Serialization.cs index c38f7245790a..71a40897d218 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentAzureSearchDocReference.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentAzureSearchDocReference.Serialization.cs @@ -5,15 +5,75 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Agents.Models { - public partial class KnowledgeAgentAzureSearchDocReference + public partial class KnowledgeAgentAzureSearchDocReference : IUtf8JsonSerializable, IJsonModel { - internal static KnowledgeAgentAzureSearchDocReference DeserializeKnowledgeAgentAzureSearchDocReference(JsonElement element) + 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(KnowledgeAgentAzureSearchDocReference)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(DocKey)) + { + writer.WritePropertyName("docKey"u8); + writer.WriteStringValue(DocKey); + } + if (Optional.IsCollectionDefined(SourceData)) + { + writer.WritePropertyName("sourceData"u8); + writer.WriteStartObject(); + foreach (var item in SourceData) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + } + + KnowledgeAgentAzureSearchDocReference 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(KnowledgeAgentAzureSearchDocReference)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentAzureSearchDocReference(document.RootElement, options); + } + + internal static KnowledgeAgentAzureSearchDocReference DeserializeKnowledgeAgentAzureSearchDocReference(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -23,6 +83,8 @@ internal static KnowledgeAgentAzureSearchDocReference DeserializeKnowledgeAgentA string type = default; string id = default; int activitySource = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("docKey"u8)) @@ -66,10 +128,52 @@ internal static KnowledgeAgentAzureSearchDocReference DeserializeKnowledgeAgentA activitySource = property.Value.GetInt32(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeAgentAzureSearchDocReference( + type, + id, + activitySource, + serializedAdditionalRawData, + docKey, + sourceData ?? new ChangeTrackingDictionary()); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentAzureSearchDocReference)} does not support writing '{options.Format}' format."); } - return new KnowledgeAgentAzureSearchDocReference(type, id, activitySource, docKey, sourceData ?? new ChangeTrackingDictionary()); } + KnowledgeAgentAzureSearchDocReference 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 DeserializeKnowledgeAgentAzureSearchDocReference(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentAzureSearchDocReference)} 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 KnowledgeAgentAzureSearchDocReference FromResponse(Response response) @@ -77,5 +181,13 @@ internal static KnowledgeAgentAzureSearchDocReference DeserializeKnowledgeAgentA using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeKnowledgeAgentAzureSearchDocReference(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/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentAzureSearchDocReference.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentAzureSearchDocReference.cs index b9ae6cf71e89..1fabb6789fbf 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentAzureSearchDocReference.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentAzureSearchDocReference.cs @@ -29,15 +29,21 @@ internal KnowledgeAgentAzureSearchDocReference(string id, int activitySource) : /// The type of the reference. /// The ID of the reference. /// The source activity ID for the reference. + /// Keeps track of any properties unknown to the library. /// The document key for the reference. /// Dictionary of <any>. - internal KnowledgeAgentAzureSearchDocReference(string type, string id, int activitySource, string docKey, IReadOnlyDictionary sourceData) : base(type, id, activitySource) + internal KnowledgeAgentAzureSearchDocReference(string type, string id, int activitySource, IDictionary serializedAdditionalRawData, string docKey, IReadOnlyDictionary sourceData) : base(type, id, activitySource, serializedAdditionalRawData) { DocKey = docKey; SourceData = sourceData; Type = type ?? "AzureSearchDoc"; } + /// Initializes a new instance of for deserialization. + internal KnowledgeAgentAzureSearchDocReference() + { + } + /// The document key for the reference. public string DocKey { get; } /// Dictionary of <any>. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentIndexParams.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentIndexParams.Serialization.cs index 0d47ea5ff8a3..00c2d234c78d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentIndexParams.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentIndexParams.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Agents.Models { - public partial class KnowledgeAgentIndexParams : IUtf8JsonSerializable + public partial class KnowledgeAgentIndexParams : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(KnowledgeAgentIndexParams)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(IndexName)) { writer.WritePropertyName("indexName"u8); @@ -40,14 +59,148 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("includeReferenceSourceData"u8); writer.WriteBooleanValue(IncludeReferenceSourceData.Value); } - writer.WriteEndObject(); + 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 + } + } + } + + KnowledgeAgentIndexParams 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(KnowledgeAgentIndexParams)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentIndexParams(document.RootElement, options); + } + + internal static KnowledgeAgentIndexParams DeserializeKnowledgeAgentIndexParams(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string indexName = default; + string filterAddOn = default; + int? maxDocsForReranker = default; + float? rerankerThreshold = default; + bool? includeReferenceSourceData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("indexName"u8)) + { + indexName = property.Value.GetString(); + continue; + } + if (property.NameEquals("filterAddOn"u8)) + { + filterAddOn = property.Value.GetString(); + continue; + } + if (property.NameEquals("maxDocsForReranker"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxDocsForReranker = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("rerankerThreshold"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + rerankerThreshold = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("includeReferenceSourceData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + includeReferenceSourceData = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeAgentIndexParams( + indexName, + filterAddOn, + maxDocsForReranker, + rerankerThreshold, + includeReferenceSourceData, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentIndexParams)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeAgentIndexParams 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 DeserializeKnowledgeAgentIndexParams(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentIndexParams)} 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 KnowledgeAgentIndexParams FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeKnowledgeAgentIndexParams(document.RootElement); } /// Convert into a . internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentIndexParams.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentIndexParams.cs index 0a8932bd36a3..888544f89286 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentIndexParams.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentIndexParams.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Agents.Models { /// The KnowledgeAgentIndexParams. public partial class KnowledgeAgentIndexParams { + /// + /// 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 KnowledgeAgentIndexParams() { @@ -21,13 +56,15 @@ public KnowledgeAgentIndexParams() /// Limits the number of documents considered for ranking. /// A threshold for reranking results (range: 0-4). /// Indicates whether reference source data should be included. - internal KnowledgeAgentIndexParams(string indexName, string filterAddOn, int? maxDocsForReranker, float? rerankerThreshold, bool? includeReferenceSourceData) + /// Keeps track of any properties unknown to the library. + internal KnowledgeAgentIndexParams(string indexName, string filterAddOn, int? maxDocsForReranker, float? rerankerThreshold, bool? includeReferenceSourceData, IDictionary serializedAdditionalRawData) { IndexName = indexName; FilterAddOn = filterAddOn; MaxDocsForReranker = maxDocsForReranker; RerankerThreshold = rerankerThreshold; IncludeReferenceSourceData = includeReferenceSourceData; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The name of the index the params apply to. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessage.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessage.Serialization.cs index d7d1f9a1f004..86498c637e71 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessage.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessage.Serialization.cs @@ -5,37 +5,85 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Agents.Models { - public partial class KnowledgeAgentMessage : IUtf8JsonSerializable + public partial class KnowledgeAgentMessage : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(KnowledgeAgentMessage)} does not support writing '{format}' format."); + } + writer.WritePropertyName("role"u8); writer.WriteStringValue(Role); writer.WritePropertyName("content"u8); writer.WriteStartArray(); foreach (var item in Content) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); - writer.WriteEndObject(); + 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 + } + } } - internal static KnowledgeAgentMessage DeserializeKnowledgeAgentMessage(JsonElement element) + KnowledgeAgentMessage 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(KnowledgeAgentMessage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentMessage(document.RootElement, options); + } + + internal static KnowledgeAgentMessage DeserializeKnowledgeAgentMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string role = default; IList content = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("role"u8)) @@ -48,15 +96,51 @@ internal static KnowledgeAgentMessage DeserializeKnowledgeAgentMessage(JsonEleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KnowledgeAgentMessageContent.DeserializeKnowledgeAgentMessageContent(item)); + array.Add(KnowledgeAgentMessageContent.DeserializeKnowledgeAgentMessageContent(item, options)); } content = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeAgentMessage(role, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentMessage)} does not support writing '{options.Format}' format."); } - return new KnowledgeAgentMessage(role, content); } + KnowledgeAgentMessage 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 DeserializeKnowledgeAgentMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentMessage)} 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 KnowledgeAgentMessage FromResponse(Response response) @@ -69,7 +153,7 @@ internal static KnowledgeAgentMessage FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessage.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessage.cs index fd4139aff8d5..0182a85ab9cb 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessage.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessage.cs @@ -14,6 +14,38 @@ namespace Azure.Search.Documents.Agents.Models /// The natural language message style object. public partial class KnowledgeAgentMessage { + /// + /// 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 . /// The role of the tool response. /// @@ -36,10 +68,17 @@ public KnowledgeAgentMessage(string role, IEnumerable 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 . /// - internal KnowledgeAgentMessage(string role, IList content) + /// Keeps track of any properties unknown to the library. + internal KnowledgeAgentMessage(string role, IList content, IDictionary serializedAdditionalRawData) { Role = role; Content = content; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal KnowledgeAgentMessage() + { } /// The role of the tool response. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageContent.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageContent.Serialization.cs index 905520d5af84..aa7e1a317f7b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageContent.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageContent.Serialization.cs @@ -5,24 +5,71 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Agents.Models { - public partial class KnowledgeAgentMessageContent : IUtf8JsonSerializable + [PersistableModelProxy(typeof(UnknownKnowledgeAgentMessageContent))] + public partial class KnowledgeAgentMessageContent : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(KnowledgeAgentMessageContent)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); writer.WriteStringValue(Type.ToString()); - writer.WriteEndObject(); + 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 + } + } } - internal static KnowledgeAgentMessageContent DeserializeKnowledgeAgentMessageContent(JsonElement element) + KnowledgeAgentMessageContent 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(KnowledgeAgentMessageContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentMessageContent(document.RootElement, options); + } + + internal static KnowledgeAgentMessageContent DeserializeKnowledgeAgentMessageContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -31,13 +78,44 @@ internal static KnowledgeAgentMessageContent DeserializeKnowledgeAgentMessageCon { switch (discriminator.GetString()) { - case "image": return KnowledgeAgentMessageImageContent.DeserializeKnowledgeAgentMessageImageContent(element); - case "text": return KnowledgeAgentMessageTextContent.DeserializeKnowledgeAgentMessageTextContent(element); + case "image": return KnowledgeAgentMessageImageContent.DeserializeKnowledgeAgentMessageImageContent(element, options); + case "text": return KnowledgeAgentMessageTextContent.DeserializeKnowledgeAgentMessageTextContent(element, options); } } - return UnknownKnowledgeAgentMessageContent.DeserializeUnknownKnowledgeAgentMessageContent(element); + return UnknownKnowledgeAgentMessageContent.DeserializeUnknownKnowledgeAgentMessageContent(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentMessageContent)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeAgentMessageContent 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 DeserializeKnowledgeAgentMessageContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentMessageContent)} 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 KnowledgeAgentMessageContent FromResponse(Response response) @@ -50,7 +128,7 @@ internal static KnowledgeAgentMessageContent FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageContent.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageContent.cs index f56a0c4647bf..5e5f38514f1a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageContent.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageContent.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Agents.Models { /// @@ -14,6 +17,38 @@ namespace Azure.Search.Documents.Agents.Models /// public abstract partial class KnowledgeAgentMessageContent { + /// + /// 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 KnowledgeAgentMessageContent() { @@ -21,9 +56,11 @@ protected KnowledgeAgentMessageContent() /// Initializes a new instance of . /// The type of the message. - internal KnowledgeAgentMessageContent(KnowledgeAgentMessageContentType type) + /// Keeps track of any properties unknown to the library. + internal KnowledgeAgentMessageContent(KnowledgeAgentMessageContentType type, IDictionary serializedAdditionalRawData) { Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The type of the message. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageImageContent.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageImageContent.Serialization.cs index b4611e80f498..fe8aeedc2b34 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageImageContent.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageImageContent.Serialization.cs @@ -5,37 +5,70 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Agents.Models { - public partial class KnowledgeAgentMessageImageContent : IUtf8JsonSerializable + public partial class KnowledgeAgentMessageImageContent : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("image"u8); - writer.WriteObjectValue(Image); - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type.ToString()); + JsonModelWriteCore(writer, options); writer.WriteEndObject(); } - internal static KnowledgeAgentMessageImageContent DeserializeKnowledgeAgentMessageImageContent(JsonElement element) + /// 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(KnowledgeAgentMessageImageContent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("image"u8); + writer.WriteObjectValue(Image, options); + } + + KnowledgeAgentMessageImageContent 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(KnowledgeAgentMessageImageContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentMessageImageContent(document.RootElement, options); + } + + internal static KnowledgeAgentMessageImageContent DeserializeKnowledgeAgentMessageImageContent(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } KnowledgeAgentMessageImageContentImage image = default; KnowledgeAgentMessageContentType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("image"u8)) { - image = KnowledgeAgentMessageImageContentImage.DeserializeKnowledgeAgentMessageImageContentImage(property.Value); + image = KnowledgeAgentMessageImageContentImage.DeserializeKnowledgeAgentMessageImageContentImage(property.Value, options); continue; } if (property.NameEquals("type"u8)) @@ -43,10 +76,46 @@ internal static KnowledgeAgentMessageImageContent DeserializeKnowledgeAgentMessa type = new KnowledgeAgentMessageContentType(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeAgentMessageImageContent(type, serializedAdditionalRawData, image); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentMessageImageContent)} does not support writing '{options.Format}' format."); } - return new KnowledgeAgentMessageImageContent(type, image); } + KnowledgeAgentMessageImageContent 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 DeserializeKnowledgeAgentMessageImageContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentMessageImageContent)} 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 KnowledgeAgentMessageImageContent FromResponse(Response response) @@ -59,7 +128,7 @@ internal static KnowledgeAgentMessageImageContent DeserializeKnowledgeAgentMessa internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageImageContent.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageImageContent.cs index 1f166c47adcf..30aef63ab16e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageImageContent.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageImageContent.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Agents.Models @@ -26,13 +27,19 @@ public KnowledgeAgentMessageImageContent(KnowledgeAgentMessageImageContentImage /// Initializes a new instance of . /// The type of the message. + /// Keeps track of any properties unknown to the library. /// - internal KnowledgeAgentMessageImageContent(KnowledgeAgentMessageContentType type, KnowledgeAgentMessageImageContentImage image) : base(type) + internal KnowledgeAgentMessageImageContent(KnowledgeAgentMessageContentType type, IDictionary serializedAdditionalRawData, KnowledgeAgentMessageImageContentImage image) : base(type, serializedAdditionalRawData) { Image = image; Type = type; } + /// Initializes a new instance of for deserialization. + internal KnowledgeAgentMessageImageContent() + { + } + /// Gets or sets the image. public KnowledgeAgentMessageImageContentImage Image { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageImageContentImage.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageImageContentImage.Serialization.cs index d1261a203fb1..c3d8a7a1c2f5 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageImageContentImage.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageImageContentImage.Serialization.cs @@ -5,28 +5,77 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class KnowledgeAgentMessageImageContentImage : IUtf8JsonSerializable + public partial class KnowledgeAgentMessageImageContentImage : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(KnowledgeAgentMessageImageContentImage)} does not support writing '{format}' format."); + } + writer.WritePropertyName("url"u8); writer.WriteStringValue(Url); - writer.WriteEndObject(); + 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 + } + } } - internal static KnowledgeAgentMessageImageContentImage DeserializeKnowledgeAgentMessageImageContentImage(JsonElement element) + KnowledgeAgentMessageImageContentImage 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(KnowledgeAgentMessageImageContentImage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentMessageImageContentImage(document.RootElement, options); + } + + internal static KnowledgeAgentMessageImageContentImage DeserializeKnowledgeAgentMessageImageContentImage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string url = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("url"u8)) @@ -34,10 +83,46 @@ internal static KnowledgeAgentMessageImageContentImage DeserializeKnowledgeAgent url = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new KnowledgeAgentMessageImageContentImage(url); + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeAgentMessageImageContentImage(url, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentMessageImageContentImage)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeAgentMessageImageContentImage 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 DeserializeKnowledgeAgentMessageImageContentImage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentMessageImageContentImage)} 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 KnowledgeAgentMessageImageContentImage FromResponse(Response response) @@ -50,7 +135,7 @@ internal static KnowledgeAgentMessageImageContentImage FromResponse(Response res internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageImageContentImage.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageImageContentImage.cs index ffdddfb52ad2..f6b531f6fad3 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageImageContentImage.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageImageContentImage.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Models { /// The KnowledgeAgentMessageImageContentImage. public partial class KnowledgeAgentMessageImageContentImage { + /// + /// 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 . /// The url of the image. /// is null. @@ -22,6 +55,20 @@ public KnowledgeAgentMessageImageContentImage(string url) Url = url; } + /// Initializes a new instance of . + /// The url of the image. + /// Keeps track of any properties unknown to the library. + internal KnowledgeAgentMessageImageContentImage(string url, IDictionary serializedAdditionalRawData) + { + Url = url; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal KnowledgeAgentMessageImageContentImage() + { + } + /// The url of the image. public string Url { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageTextContent.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageTextContent.Serialization.cs index fd3cd315c255..10407c7c3e03 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageTextContent.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageTextContent.Serialization.cs @@ -5,31 +5,64 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Agents.Models { - public partial class KnowledgeAgentMessageTextContent : IUtf8JsonSerializable + public partial class KnowledgeAgentMessageTextContent : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(KnowledgeAgentMessageTextContent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("text"u8); writer.WriteStringValue(Text); - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type.ToString()); - writer.WriteEndObject(); } - internal static KnowledgeAgentMessageTextContent DeserializeKnowledgeAgentMessageTextContent(JsonElement element) + KnowledgeAgentMessageTextContent 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(KnowledgeAgentMessageTextContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentMessageTextContent(document.RootElement, options); + } + + internal static KnowledgeAgentMessageTextContent DeserializeKnowledgeAgentMessageTextContent(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string text = default; KnowledgeAgentMessageContentType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("text"u8)) @@ -42,10 +75,46 @@ internal static KnowledgeAgentMessageTextContent DeserializeKnowledgeAgentMessag type = new KnowledgeAgentMessageContentType(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeAgentMessageTextContent(type, serializedAdditionalRawData, text); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentMessageTextContent)} does not support writing '{options.Format}' format."); } - return new KnowledgeAgentMessageTextContent(type, text); } + KnowledgeAgentMessageTextContent 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 DeserializeKnowledgeAgentMessageTextContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentMessageTextContent)} 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 KnowledgeAgentMessageTextContent FromResponse(Response response) @@ -58,7 +127,7 @@ internal static KnowledgeAgentMessageTextContent DeserializeKnowledgeAgentMessag internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageTextContent.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageTextContent.cs index de36565521d1..87a49ecebe8b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageTextContent.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentMessageTextContent.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Agents.Models { @@ -25,13 +26,19 @@ public KnowledgeAgentMessageTextContent(string text) /// Initializes a new instance of . /// The type of the message. + /// Keeps track of any properties unknown to the library. /// - internal KnowledgeAgentMessageTextContent(KnowledgeAgentMessageContentType type, string text) : base(type) + internal KnowledgeAgentMessageTextContent(KnowledgeAgentMessageContentType type, IDictionary serializedAdditionalRawData, string text) : base(type, serializedAdditionalRawData) { Text = text; Type = type; } + /// Initializes a new instance of for deserialization. + internal KnowledgeAgentMessageTextContent() + { + } + /// Gets or sets the text. public string Text { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentModel.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentModel.Serialization.cs index ad6ba573114a..121e7e4df3ea 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentModel.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentModel.Serialization.cs @@ -5,24 +5,71 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Indexes.Models { - public partial class KnowledgeAgentModel : IUtf8JsonSerializable + [PersistableModelProxy(typeof(UnknownKnowledgeAgentModel))] + public partial class KnowledgeAgentModel : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(KnowledgeAgentModel)} does not support writing '{format}' format."); + } + writer.WritePropertyName("kind"u8); writer.WriteStringValue(Kind.ToString()); - writer.WriteEndObject(); + 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 + } + } } - internal static KnowledgeAgentModel DeserializeKnowledgeAgentModel(JsonElement element) + KnowledgeAgentModel 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(KnowledgeAgentModel)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentModel(document.RootElement, options); + } + + internal static KnowledgeAgentModel DeserializeKnowledgeAgentModel(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -31,12 +78,43 @@ internal static KnowledgeAgentModel DeserializeKnowledgeAgentModel(JsonElement e { switch (discriminator.GetString()) { - case "azureOpenAI": return KnowledgeAgentAzureOpenAIModel.DeserializeKnowledgeAgentAzureOpenAIModel(element); + case "azureOpenAI": return KnowledgeAgentAzureOpenAIModel.DeserializeKnowledgeAgentAzureOpenAIModel(element, options); } } - return UnknownKnowledgeAgentModel.DeserializeUnknownKnowledgeAgentModel(element); + return UnknownKnowledgeAgentModel.DeserializeUnknownKnowledgeAgentModel(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentModel)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeAgentModel 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 DeserializeKnowledgeAgentModel(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentModel)} 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 KnowledgeAgentModel FromResponse(Response response) @@ -49,7 +127,7 @@ internal static KnowledgeAgentModel FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentModel.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentModel.cs index 4fac0859d0c8..c31a4703beba 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentModel.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentModel.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// @@ -14,6 +17,38 @@ namespace Azure.Search.Documents.Indexes.Models /// public abstract partial class KnowledgeAgentModel { + /// + /// 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 KnowledgeAgentModel() { @@ -21,9 +56,11 @@ protected KnowledgeAgentModel() /// Initializes a new instance of . /// The type of AI model. - internal KnowledgeAgentModel(KnowledgeAgentModelKind kind) + /// Keeps track of any properties unknown to the library. + internal KnowledgeAgentModel(KnowledgeAgentModelKind kind, IDictionary serializedAdditionalRawData) { Kind = kind; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The type of AI model. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentModelQueryPlanningActivityRecord.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentModelQueryPlanningActivityRecord.Serialization.cs index 8b9bd4b57d50..3e04986d4dec 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentModelQueryPlanningActivityRecord.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentModelQueryPlanningActivityRecord.Serialization.cs @@ -5,14 +5,69 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Agents.Models { - public partial class KnowledgeAgentModelQueryPlanningActivityRecord + public partial class KnowledgeAgentModelQueryPlanningActivityRecord : IUtf8JsonSerializable, IJsonModel { - internal static KnowledgeAgentModelQueryPlanningActivityRecord DeserializeKnowledgeAgentModelQueryPlanningActivityRecord(JsonElement element) + 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(KnowledgeAgentModelQueryPlanningActivityRecord)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(InputTokens)) + { + writer.WritePropertyName("inputTokens"u8); + writer.WriteNumberValue(InputTokens.Value); + } + if (Optional.IsDefined(OutputTokens)) + { + writer.WritePropertyName("outputTokens"u8); + writer.WriteNumberValue(OutputTokens.Value); + } + if (Optional.IsDefined(ElapsedMs)) + { + writer.WritePropertyName("elapsedMs"u8); + writer.WriteNumberValue(ElapsedMs.Value); + } + } + + KnowledgeAgentModelQueryPlanningActivityRecord 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(KnowledgeAgentModelQueryPlanningActivityRecord)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentModelQueryPlanningActivityRecord(document.RootElement, options); + } + + internal static KnowledgeAgentModelQueryPlanningActivityRecord DeserializeKnowledgeAgentModelQueryPlanningActivityRecord(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -22,6 +77,8 @@ internal static KnowledgeAgentModelQueryPlanningActivityRecord DeserializeKnowle int? elapsedMs = default; int id = default; string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("inputTokens"u8)) @@ -61,10 +118,52 @@ internal static KnowledgeAgentModelQueryPlanningActivityRecord DeserializeKnowle type = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new KnowledgeAgentModelQueryPlanningActivityRecord(id, type, inputTokens, outputTokens, elapsedMs); + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeAgentModelQueryPlanningActivityRecord( + id, + type, + serializedAdditionalRawData, + inputTokens, + outputTokens, + elapsedMs); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentModelQueryPlanningActivityRecord)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeAgentModelQueryPlanningActivityRecord 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 DeserializeKnowledgeAgentModelQueryPlanningActivityRecord(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentModelQueryPlanningActivityRecord)} 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 KnowledgeAgentModelQueryPlanningActivityRecord FromResponse(Response response) @@ -72,5 +171,13 @@ internal static KnowledgeAgentModelQueryPlanningActivityRecord DeserializeKnowle using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeKnowledgeAgentModelQueryPlanningActivityRecord(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/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentModelQueryPlanningActivityRecord.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentModelQueryPlanningActivityRecord.cs index dfd8afb4c465..f48fb0ce817e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentModelQueryPlanningActivityRecord.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentModelQueryPlanningActivityRecord.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Agents.Models { /// Represents an LLM query planning activity record. @@ -20,10 +23,11 @@ internal KnowledgeAgentModelQueryPlanningActivityRecord(int id) : base(id) /// Initializes a new instance of . /// The ID of the activity record. /// The type of the activity record. + /// Keeps track of any properties unknown to the library. /// The number of input tokens for the LLM query planning activity. /// The number of output tokens for the LLM query planning activity. /// The elapsed time in milliseconds for the model activity. - internal KnowledgeAgentModelQueryPlanningActivityRecord(int id, string type, int? inputTokens, int? outputTokens, int? elapsedMs) : base(id, type) + internal KnowledgeAgentModelQueryPlanningActivityRecord(int id, string type, IDictionary serializedAdditionalRawData, int? inputTokens, int? outputTokens, int? elapsedMs) : base(id, type, serializedAdditionalRawData) { InputTokens = inputTokens; OutputTokens = outputTokens; @@ -31,6 +35,11 @@ internal KnowledgeAgentModelQueryPlanningActivityRecord(int id, string type, int Type = type ?? "ModelQueryPlanning"; } + /// Initializes a new instance of for deserialization. + internal KnowledgeAgentModelQueryPlanningActivityRecord() + { + } + /// The number of input tokens for the LLM query planning activity. public int? InputTokens { get; } /// The number of output tokens for the LLM query planning activity. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentReference.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentReference.Serialization.cs index 47c9fe95c28f..c9a4dd28cadd 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentReference.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentReference.Serialization.cs @@ -5,15 +5,75 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; +using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Agents.Models { - public partial class KnowledgeAgentReference + [PersistableModelProxy(typeof(UnknownKnowledgeAgentReference))] + public partial class KnowledgeAgentReference : IUtf8JsonSerializable, IJsonModel { - internal static KnowledgeAgentReference DeserializeKnowledgeAgentReference(JsonElement element) + 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(KnowledgeAgentReference)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("activitySource"u8); + writer.WriteNumberValue(ActivitySource); + 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 + } + } + } + + KnowledgeAgentReference 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(KnowledgeAgentReference)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentReference(document.RootElement, options); + } + + internal static KnowledgeAgentReference DeserializeKnowledgeAgentReference(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -22,12 +82,43 @@ internal static KnowledgeAgentReference DeserializeKnowledgeAgentReference(JsonE { switch (discriminator.GetString()) { - case "AzureSearchDoc": return KnowledgeAgentAzureSearchDocReference.DeserializeKnowledgeAgentAzureSearchDocReference(element); + case "AzureSearchDoc": return KnowledgeAgentAzureSearchDocReference.DeserializeKnowledgeAgentAzureSearchDocReference(element, options); } } - return UnknownKnowledgeAgentReference.DeserializeUnknownKnowledgeAgentReference(element); + return UnknownKnowledgeAgentReference.DeserializeUnknownKnowledgeAgentReference(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentReference)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeAgentReference 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 DeserializeKnowledgeAgentReference(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentReference)} 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 KnowledgeAgentReference FromResponse(Response response) @@ -35,5 +126,13 @@ internal static KnowledgeAgentReference FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeKnowledgeAgentReference(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/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentReference.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentReference.cs index 85117dd5da5f..40f2aeff9e27 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentReference.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentReference.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Agents.Models { @@ -16,6 +17,38 @@ namespace Azure.Search.Documents.Agents.Models /// public abstract partial class KnowledgeAgentReference { + /// + /// 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 . /// The ID of the reference. /// The source activity ID for the reference. @@ -32,11 +65,18 @@ protected KnowledgeAgentReference(string id, int activitySource) /// The type of the reference. /// The ID of the reference. /// The source activity ID for the reference. - internal KnowledgeAgentReference(string type, string id, int activitySource) + /// Keeps track of any properties unknown to the library. + internal KnowledgeAgentReference(string type, string id, int activitySource, IDictionary serializedAdditionalRawData) { Type = type; Id = id; ActivitySource = activitySource; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal KnowledgeAgentReference() + { } /// The type of the reference. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRequestLimits.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRequestLimits.Serialization.cs index 583082a52b4e..25ae9e8b6c69 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRequestLimits.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRequestLimits.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class KnowledgeAgentRequestLimits : IUtf8JsonSerializable + public partial class KnowledgeAgentRequestLimits : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(KnowledgeAgentRequestLimits)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(MaxRuntimeInSeconds)) { writer.WritePropertyName("maxRuntimeInSeconds"u8); @@ -25,17 +44,47 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("maxOutputSize"u8); writer.WriteNumberValue(MaxOutputSize.Value); } - writer.WriteEndObject(); + 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 + } + } } - internal static KnowledgeAgentRequestLimits DeserializeKnowledgeAgentRequestLimits(JsonElement element) + KnowledgeAgentRequestLimits 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(KnowledgeAgentRequestLimits)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentRequestLimits(document.RootElement, options); + } + + internal static KnowledgeAgentRequestLimits DeserializeKnowledgeAgentRequestLimits(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } int? maxRuntimeInSeconds = default; int? maxOutputSize = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("maxRuntimeInSeconds"u8)) @@ -56,10 +105,46 @@ internal static KnowledgeAgentRequestLimits DeserializeKnowledgeAgentRequestLimi maxOutputSize = property.Value.GetInt32(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeAgentRequestLimits(maxRuntimeInSeconds, maxOutputSize, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentRequestLimits)} does not support writing '{options.Format}' format."); } - return new KnowledgeAgentRequestLimits(maxRuntimeInSeconds, maxOutputSize); } + KnowledgeAgentRequestLimits 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 DeserializeKnowledgeAgentRequestLimits(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentRequestLimits)} 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 KnowledgeAgentRequestLimits FromResponse(Response response) @@ -72,7 +157,7 @@ internal static KnowledgeAgentRequestLimits FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRequestLimits.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRequestLimits.cs index 2806f1d859f5..ca19d04159e8 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRequestLimits.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRequestLimits.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Guardrails to limit how much resources are utilized for a single agent retrieval request. public partial class KnowledgeAgentRequestLimits { + /// + /// 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 KnowledgeAgentRequestLimits() { @@ -18,10 +53,12 @@ public KnowledgeAgentRequestLimits() /// Initializes a new instance of . /// The maximum runtime in seconds. /// Limits the maximum size of the content in the output. - internal KnowledgeAgentRequestLimits(int? maxRuntimeInSeconds, int? maxOutputSize) + /// Keeps track of any properties unknown to the library. + internal KnowledgeAgentRequestLimits(int? maxRuntimeInSeconds, int? maxOutputSize, IDictionary serializedAdditionalRawData) { MaxRuntimeInSeconds = maxRuntimeInSeconds; MaxOutputSize = maxOutputSize; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The maximum runtime in seconds. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRetrievalRequest.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRetrievalRequest.Serialization.cs index bc868831ab3c..498d1b435689 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRetrievalRequest.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRetrievalRequest.Serialization.cs @@ -5,21 +5,40 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Agents.Models { - public partial class KnowledgeAgentRetrievalRequest : IUtf8JsonSerializable + public partial class KnowledgeAgentRetrievalRequest : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(KnowledgeAgentRetrievalRequest)} does not support writing '{format}' format."); + } + writer.WritePropertyName("messages"u8); writer.WriteStartArray(); foreach (var item in Messages) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); if (Optional.IsCollectionDefined(TargetIndexParams)) @@ -28,18 +47,130 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in TargetIndexParams) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - writer.WriteEndObject(); + 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 + } + } + } + + KnowledgeAgentRetrievalRequest 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(KnowledgeAgentRetrievalRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentRetrievalRequest(document.RootElement, options); + } + + internal static KnowledgeAgentRetrievalRequest DeserializeKnowledgeAgentRetrievalRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList messages = default; + IList targetIndexParams = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("messages"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(KnowledgeAgentMessage.DeserializeKnowledgeAgentMessage(item, options)); + } + messages = array; + continue; + } + if (property.NameEquals("targetIndexParams"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(KnowledgeAgentIndexParams.DeserializeKnowledgeAgentIndexParams(item, options)); + } + targetIndexParams = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeAgentRetrievalRequest(messages, targetIndexParams ?? 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentRetrievalRequest)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeAgentRetrievalRequest 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 DeserializeKnowledgeAgentRetrievalRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentRetrievalRequest)} 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 KnowledgeAgentRetrievalRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeKnowledgeAgentRetrievalRequest(document.RootElement); } /// Convert into a . internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRetrievalRequest.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRetrievalRequest.cs index 61c12da71cf3..ac9d3b7d59ff 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRetrievalRequest.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRetrievalRequest.cs @@ -14,6 +14,38 @@ namespace Azure.Search.Documents.Agents.Models /// The input contract for the retrieval request. public partial class KnowledgeAgentRetrievalRequest { + /// + /// 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 . /// /// is null. @@ -28,10 +60,17 @@ public KnowledgeAgentRetrievalRequest(IEnumerable message /// Initializes a new instance of . /// /// - internal KnowledgeAgentRetrievalRequest(IList messages, IList targetIndexParams) + /// Keeps track of any properties unknown to the library. + internal KnowledgeAgentRetrievalRequest(IList messages, IList targetIndexParams, IDictionary serializedAdditionalRawData) { Messages = messages; TargetIndexParams = targetIndexParams; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal KnowledgeAgentRetrievalRequest() + { } /// Gets the messages. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRetrievalResponse.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRetrievalResponse.Serialization.cs index e8730a91c75a..428d573d8b1a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRetrievalResponse.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRetrievalResponse.Serialization.cs @@ -5,15 +5,98 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Agents.Models { - public partial class KnowledgeAgentRetrievalResponse + public partial class KnowledgeAgentRetrievalResponse : IUtf8JsonSerializable, IJsonModel { - internal static KnowledgeAgentRetrievalResponse DeserializeKnowledgeAgentRetrievalResponse(JsonElement element) + 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(KnowledgeAgentRetrievalResponse)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Response)) + { + writer.WritePropertyName("response"u8); + writer.WriteStartArray(); + foreach (var item in Response) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Activity)) + { + writer.WritePropertyName("activity"u8); + writer.WriteStartArray(); + foreach (var item in Activity) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(References)) + { + writer.WritePropertyName("references"u8); + writer.WriteStartArray(); + foreach (var item in References) + { + 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 + } + } + } + + KnowledgeAgentRetrievalResponse 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(KnowledgeAgentRetrievalResponse)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentRetrievalResponse(document.RootElement, options); + } + + internal static KnowledgeAgentRetrievalResponse DeserializeKnowledgeAgentRetrievalResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -21,6 +104,8 @@ internal static KnowledgeAgentRetrievalResponse DeserializeKnowledgeAgentRetriev IReadOnlyList response = default; IReadOnlyList activity = default; IReadOnlyList references = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("response"u8)) @@ -32,7 +117,7 @@ internal static KnowledgeAgentRetrievalResponse DeserializeKnowledgeAgentRetriev List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KnowledgeAgentMessage.DeserializeKnowledgeAgentMessage(item)); + array.Add(KnowledgeAgentMessage.DeserializeKnowledgeAgentMessage(item, options)); } response = array; continue; @@ -46,7 +131,7 @@ internal static KnowledgeAgentRetrievalResponse DeserializeKnowledgeAgentRetriev List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KnowledgeAgentActivityRecord.DeserializeKnowledgeAgentActivityRecord(item)); + array.Add(KnowledgeAgentActivityRecord.DeserializeKnowledgeAgentActivityRecord(item, options)); } activity = array; continue; @@ -60,15 +145,51 @@ internal static KnowledgeAgentRetrievalResponse DeserializeKnowledgeAgentRetriev List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KnowledgeAgentReference.DeserializeKnowledgeAgentReference(item)); + array.Add(KnowledgeAgentReference.DeserializeKnowledgeAgentReference(item, options)); } references = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new KnowledgeAgentRetrievalResponse(response ?? new ChangeTrackingList(), activity ?? new ChangeTrackingList(), references ?? new ChangeTrackingList()); + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeAgentRetrievalResponse(response ?? new ChangeTrackingList(), activity ?? new ChangeTrackingList(), references ?? 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentRetrievalResponse)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeAgentRetrievalResponse 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 DeserializeKnowledgeAgentRetrievalResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentRetrievalResponse)} 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 KnowledgeAgentRetrievalResponse FromResponse(Response response) @@ -76,5 +197,13 @@ internal static KnowledgeAgentRetrievalResponse FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeKnowledgeAgentRetrievalResponse(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/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRetrievalResponse.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRetrievalResponse.cs index 5dfc42000900..eefbbc56cf3f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRetrievalResponse.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentRetrievalResponse.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.Search.Documents.Agents.Models @@ -12,6 +13,38 @@ namespace Azure.Search.Documents.Agents.Models /// The output contract for the retrieval response. public partial class KnowledgeAgentRetrievalResponse { + /// + /// 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 . internal KnowledgeAgentRetrievalResponse() { @@ -32,11 +65,13 @@ internal KnowledgeAgentRetrievalResponse() /// 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 . /// - internal KnowledgeAgentRetrievalResponse(IReadOnlyList response, IReadOnlyList activity, IReadOnlyList references) + /// Keeps track of any properties unknown to the library. + internal KnowledgeAgentRetrievalResponse(IReadOnlyList response, IReadOnlyList activity, IReadOnlyList references, IDictionary serializedAdditionalRawData) { Response = response; Activity = activity; References = references; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Gets the response. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSearchActivityRecord.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSearchActivityRecord.Serialization.cs index 508754202082..92704826b438 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSearchActivityRecord.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSearchActivityRecord.Serialization.cs @@ -6,15 +6,79 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Agents.Models { - public partial class KnowledgeAgentSearchActivityRecord + public partial class KnowledgeAgentSearchActivityRecord : IUtf8JsonSerializable, IJsonModel { - internal static KnowledgeAgentSearchActivityRecord DeserializeKnowledgeAgentSearchActivityRecord(JsonElement element) + 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(KnowledgeAgentSearchActivityRecord)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(TargetIndex)) + { + writer.WritePropertyName("targetIndex"u8); + writer.WriteStringValue(TargetIndex); + } + if (Optional.IsDefined(Query)) + { + writer.WritePropertyName("query"u8); + writer.WriteObjectValue(Query, options); + } + if (Optional.IsDefined(QueryTime)) + { + writer.WritePropertyName("queryTime"u8); + writer.WriteStringValue(QueryTime.Value, "O"); + } + if (Optional.IsDefined(Count)) + { + writer.WritePropertyName("count"u8); + writer.WriteNumberValue(Count.Value); + } + if (Optional.IsDefined(ElapsedMs)) + { + writer.WritePropertyName("elapsedMs"u8); + writer.WriteNumberValue(ElapsedMs.Value); + } + } + + KnowledgeAgentSearchActivityRecord 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(KnowledgeAgentSearchActivityRecord)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentSearchActivityRecord(document.RootElement, options); + } + + internal static KnowledgeAgentSearchActivityRecord DeserializeKnowledgeAgentSearchActivityRecord(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -26,6 +90,8 @@ internal static KnowledgeAgentSearchActivityRecord DeserializeKnowledgeAgentSear int? elapsedMs = default; int id = default; string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("targetIndex"u8)) @@ -39,7 +105,7 @@ internal static KnowledgeAgentSearchActivityRecord DeserializeKnowledgeAgentSear { continue; } - query = KnowledgeAgentSearchActivityRecordQuery.DeserializeKnowledgeAgentSearchActivityRecordQuery(property.Value); + query = KnowledgeAgentSearchActivityRecordQuery.DeserializeKnowledgeAgentSearchActivityRecordQuery(property.Value, options); continue; } if (property.NameEquals("queryTime"u8)) @@ -79,10 +145,16 @@ internal static KnowledgeAgentSearchActivityRecord DeserializeKnowledgeAgentSear type = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new KnowledgeAgentSearchActivityRecord( id, type, + serializedAdditionalRawData, targetIndex, query, queryTime, @@ -90,6 +162,37 @@ internal static KnowledgeAgentSearchActivityRecord DeserializeKnowledgeAgentSear elapsedMs); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentSearchActivityRecord)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeAgentSearchActivityRecord 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 DeserializeKnowledgeAgentSearchActivityRecord(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentSearchActivityRecord)} 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 KnowledgeAgentSearchActivityRecord FromResponse(Response response) @@ -97,5 +200,13 @@ internal static KnowledgeAgentSearchActivityRecord DeserializeKnowledgeAgentSear using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeKnowledgeAgentSearchActivityRecord(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/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSearchActivityRecord.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSearchActivityRecord.cs index 0175f2e5fd3e..d85820607b63 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSearchActivityRecord.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSearchActivityRecord.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Agents.Models @@ -23,12 +24,13 @@ internal KnowledgeAgentSearchActivityRecord(int id) : base(id) /// Initializes a new instance of . /// The ID of the activity record. /// The type of the activity record. + /// Keeps track of any properties unknown to the library. /// The target index for the retrieval activity. /// The query details for the retrieval activity. /// The query time for this retrieval activity. /// The count of documents retrieved. /// The elapsed time in milliseconds for the retrieval activity. - internal KnowledgeAgentSearchActivityRecord(int id, string type, string targetIndex, KnowledgeAgentSearchActivityRecordQuery query, DateTimeOffset? queryTime, int? count, int? elapsedMs) : base(id, type) + internal KnowledgeAgentSearchActivityRecord(int id, string type, IDictionary serializedAdditionalRawData, string targetIndex, KnowledgeAgentSearchActivityRecordQuery query, DateTimeOffset? queryTime, int? count, int? elapsedMs) : base(id, type, serializedAdditionalRawData) { TargetIndex = targetIndex; Query = query; @@ -38,6 +40,11 @@ internal KnowledgeAgentSearchActivityRecord(int id, string type, string targetIn Type = type ?? "AzureSearchQuery"; } + /// Initializes a new instance of for deserialization. + internal KnowledgeAgentSearchActivityRecord() + { + } + /// The target index for the retrieval activity. public string TargetIndex { get; } /// The query details for the retrieval activity. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSearchActivityRecordQuery.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSearchActivityRecordQuery.Serialization.cs index e77cb3f28c2e..4d56ec6cf2ae 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSearchActivityRecordQuery.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSearchActivityRecordQuery.Serialization.cs @@ -5,20 +5,86 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class KnowledgeAgentSearchActivityRecordQuery + public partial class KnowledgeAgentSearchActivityRecordQuery : IUtf8JsonSerializable, IJsonModel { - internal static KnowledgeAgentSearchActivityRecordQuery DeserializeKnowledgeAgentSearchActivityRecordQuery(JsonElement element) + 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(KnowledgeAgentSearchActivityRecordQuery)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Search)) + { + writer.WritePropertyName("search"u8); + writer.WriteStringValue(Search); + } + if (Optional.IsDefined(Filter)) + { + writer.WritePropertyName("filter"u8); + writer.WriteStringValue(Filter); + } + 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 + } + } + } + + KnowledgeAgentSearchActivityRecordQuery 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(KnowledgeAgentSearchActivityRecordQuery)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentSearchActivityRecordQuery(document.RootElement, options); + } + + internal static KnowledgeAgentSearchActivityRecordQuery DeserializeKnowledgeAgentSearchActivityRecordQuery(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string search = default; string filter = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("search"u8)) @@ -31,10 +97,46 @@ internal static KnowledgeAgentSearchActivityRecordQuery DeserializeKnowledgeAgen filter = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeAgentSearchActivityRecordQuery(search, filter, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentSearchActivityRecordQuery)} does not support writing '{options.Format}' format."); } - return new KnowledgeAgentSearchActivityRecordQuery(search, filter); } + KnowledgeAgentSearchActivityRecordQuery 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 DeserializeKnowledgeAgentSearchActivityRecordQuery(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentSearchActivityRecordQuery)} 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 KnowledgeAgentSearchActivityRecordQuery FromResponse(Response response) @@ -42,5 +144,13 @@ internal static KnowledgeAgentSearchActivityRecordQuery FromResponse(Response re using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeKnowledgeAgentSearchActivityRecordQuery(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/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSearchActivityRecordQuery.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSearchActivityRecordQuery.cs index 5018dd3c2608..ddc917676a2e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSearchActivityRecordQuery.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSearchActivityRecordQuery.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Models { /// The query details for the retrieval activity. public partial class KnowledgeAgentSearchActivityRecordQuery { + /// + /// 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 . internal KnowledgeAgentSearchActivityRecordQuery() { @@ -18,10 +53,12 @@ internal KnowledgeAgentSearchActivityRecordQuery() /// Initializes a new instance of . /// The search string. /// The filter string. - internal KnowledgeAgentSearchActivityRecordQuery(string search, string filter) + /// Keeps track of any properties unknown to the library. + internal KnowledgeAgentSearchActivityRecordQuery(string search, string filter, IDictionary serializedAdditionalRawData) { Search = search; Filter = filter; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The search string. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSemanticRankerActivityRecord.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSemanticRankerActivityRecord.Serialization.cs index 2ef70f86fb9f..fe7ce0e0dadc 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSemanticRankerActivityRecord.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSemanticRankerActivityRecord.Serialization.cs @@ -5,14 +5,64 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Agents.Models { - public partial class KnowledgeAgentSemanticRankerActivityRecord + public partial class KnowledgeAgentSemanticRankerActivityRecord : IUtf8JsonSerializable, IJsonModel { - internal static KnowledgeAgentSemanticRankerActivityRecord DeserializeKnowledgeAgentSemanticRankerActivityRecord(JsonElement element) + 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(KnowledgeAgentSemanticRankerActivityRecord)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(InputTokens)) + { + writer.WritePropertyName("inputTokens"u8); + writer.WriteNumberValue(InputTokens.Value); + } + if (Optional.IsDefined(ElapsedMs)) + { + writer.WritePropertyName("elapsedMs"u8); + writer.WriteNumberValue(ElapsedMs.Value); + } + } + + KnowledgeAgentSemanticRankerActivityRecord 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(KnowledgeAgentSemanticRankerActivityRecord)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentSemanticRankerActivityRecord(document.RootElement, options); + } + + internal static KnowledgeAgentSemanticRankerActivityRecord DeserializeKnowledgeAgentSemanticRankerActivityRecord(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -21,6 +71,8 @@ internal static KnowledgeAgentSemanticRankerActivityRecord DeserializeKnowledgeA int? elapsedMs = default; int id = default; string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("inputTokens"u8)) @@ -51,10 +103,46 @@ internal static KnowledgeAgentSemanticRankerActivityRecord DeserializeKnowledgeA type = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeAgentSemanticRankerActivityRecord(id, type, serializedAdditionalRawData, inputTokens, elapsedMs); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentSemanticRankerActivityRecord)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeAgentSemanticRankerActivityRecord 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 DeserializeKnowledgeAgentSemanticRankerActivityRecord(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentSemanticRankerActivityRecord)} does not support reading '{options.Format}' format."); } - return new KnowledgeAgentSemanticRankerActivityRecord(id, type, inputTokens, elapsedMs); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new KnowledgeAgentSemanticRankerActivityRecord FromResponse(Response response) @@ -62,5 +150,13 @@ internal static KnowledgeAgentSemanticRankerActivityRecord DeserializeKnowledgeA using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeKnowledgeAgentSemanticRankerActivityRecord(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/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSemanticRankerActivityRecord.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSemanticRankerActivityRecord.cs index af0c8b254be3..982e881f2d5f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSemanticRankerActivityRecord.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentSemanticRankerActivityRecord.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Agents.Models { /// Represents a semantic ranker activity record. @@ -20,15 +23,21 @@ internal KnowledgeAgentSemanticRankerActivityRecord(int id) : base(id) /// Initializes a new instance of . /// The ID of the activity record. /// The type of the activity record. + /// Keeps track of any properties unknown to the library. /// The number of input tokens for the semantic ranker activity. /// The elapsed time in milliseconds for the model activity. - internal KnowledgeAgentSemanticRankerActivityRecord(int id, string type, int? inputTokens, int? elapsedMs) : base(id, type) + internal KnowledgeAgentSemanticRankerActivityRecord(int id, string type, IDictionary serializedAdditionalRawData, int? inputTokens, int? elapsedMs) : base(id, type, serializedAdditionalRawData) { InputTokens = inputTokens; ElapsedMs = elapsedMs; Type = type ?? "AzureSearchSemanticRanker"; } + /// Initializes a new instance of for deserialization. + internal KnowledgeAgentSemanticRankerActivityRecord() + { + } + /// The number of input tokens for the semantic ranker activity. public int? InputTokens { get; } /// The elapsed time in milliseconds for the model activity. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentTargetIndex.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentTargetIndex.Serialization.cs index 5a7b5d33c61e..b4f247cf8c5f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentTargetIndex.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentTargetIndex.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class KnowledgeAgentTargetIndex : IUtf8JsonSerializable + public partial class KnowledgeAgentTargetIndex : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(KnowledgeAgentTargetIndex)} does not support writing '{format}' format."); + } + writer.WritePropertyName("indexName"u8); writer.WriteStringValue(IndexName); if (Optional.IsDefined(DefaultRerankerThreshold)) @@ -32,11 +51,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("defaultMaxDocsForReranker"u8); writer.WriteNumberValue(DefaultMaxDocsForReranker.Value); } - writer.WriteEndObject(); + 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 + } + } } - internal static KnowledgeAgentTargetIndex DeserializeKnowledgeAgentTargetIndex(JsonElement element) + KnowledgeAgentTargetIndex 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(KnowledgeAgentTargetIndex)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentTargetIndex(document.RootElement, options); + } + + internal static KnowledgeAgentTargetIndex DeserializeKnowledgeAgentTargetIndex(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -45,6 +92,8 @@ internal static KnowledgeAgentTargetIndex DeserializeKnowledgeAgentTargetIndex(J float? defaultRerankerThreshold = default; bool? defaultIncludeReferenceSourceData = default; int? defaultMaxDocsForReranker = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("indexName"u8)) @@ -79,10 +128,46 @@ internal static KnowledgeAgentTargetIndex DeserializeKnowledgeAgentTargetIndex(J defaultMaxDocsForReranker = property.Value.GetInt32(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeAgentTargetIndex(indexName, defaultRerankerThreshold, defaultIncludeReferenceSourceData, defaultMaxDocsForReranker, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentTargetIndex)} does not support writing '{options.Format}' format."); } - return new KnowledgeAgentTargetIndex(indexName, defaultRerankerThreshold, defaultIncludeReferenceSourceData, defaultMaxDocsForReranker); } + KnowledgeAgentTargetIndex 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 DeserializeKnowledgeAgentTargetIndex(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentTargetIndex)} 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 KnowledgeAgentTargetIndex FromResponse(Response response) @@ -95,7 +180,7 @@ internal static KnowledgeAgentTargetIndex FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentTargetIndex.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentTargetIndex.cs index c4824d90658b..ea3ae9f7b858 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentTargetIndex.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeAgentTargetIndex.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// The KnowledgeAgentTargetIndex. public partial class KnowledgeAgentTargetIndex { + /// + /// 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 . /// The name of the target index. /// is null. @@ -27,12 +60,19 @@ public KnowledgeAgentTargetIndex(string indexName) /// A threshold for reranking results (range: 0-4). /// Indicates whether reference source data should be included. /// Limits the number of documents considered for ranking. - internal KnowledgeAgentTargetIndex(string indexName, float? defaultRerankerThreshold, bool? defaultIncludeReferenceSourceData, int? defaultMaxDocsForReranker) + /// Keeps track of any properties unknown to the library. + internal KnowledgeAgentTargetIndex(string indexName, float? defaultRerankerThreshold, bool? defaultIncludeReferenceSourceData, int? defaultMaxDocsForReranker, IDictionary serializedAdditionalRawData) { IndexName = indexName; DefaultRerankerThreshold = defaultRerankerThreshold; DefaultIncludeReferenceSourceData = defaultIncludeReferenceSourceData; DefaultMaxDocsForReranker = defaultMaxDocsForReranker; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal KnowledgeAgentTargetIndex() + { } /// The name of the target index. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStore.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStore.Serialization.cs index 5b4c7ba81149..ab30aabf6f82 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStore.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStore.Serialization.cs @@ -5,24 +5,42 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class KnowledgeStore : IUtf8JsonSerializable + public partial class KnowledgeStore : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(KnowledgeStore)} does not support writing '{format}' format."); + } + writer.WritePropertyName("storageConnectionString"u8); writer.WriteStringValue(StorageConnectionString); writer.WritePropertyName("projections"u8); writer.WriteStartArray(); foreach (var item in Projections) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); if (Optional.IsDefined(Identity)) @@ -30,7 +48,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Identity != null) { writer.WritePropertyName("identity"u8); - writer.WriteObjectValue(Identity); + writer.WriteObjectValue(Identity, options); } else { @@ -40,13 +58,41 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Parameters)) { writer.WritePropertyName("parameters"u8); - writer.WriteObjectValue(Parameters); + writer.WriteObjectValue(Parameters, options); + } + 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 + } } - writer.WriteEndObject(); } - internal static KnowledgeStore DeserializeKnowledgeStore(JsonElement element) + KnowledgeStore 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(KnowledgeStore)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeStore(document.RootElement, options); + } + + internal static KnowledgeStore DeserializeKnowledgeStore(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -55,6 +101,8 @@ internal static KnowledgeStore DeserializeKnowledgeStore(JsonElement element) IList projections = default; SearchIndexerDataIdentity identity = default; SearchIndexerKnowledgeStoreParameters parameters = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("storageConnectionString"u8)) @@ -67,7 +115,7 @@ internal static KnowledgeStore DeserializeKnowledgeStore(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KnowledgeStoreProjection.DeserializeKnowledgeStoreProjection(item)); + array.Add(KnowledgeStoreProjection.DeserializeKnowledgeStoreProjection(item, options)); } projections = array; continue; @@ -79,7 +127,7 @@ internal static KnowledgeStore DeserializeKnowledgeStore(JsonElement element) identity = null; continue; } - identity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value); + identity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value, options); continue; } if (property.NameEquals("parameters"u8)) @@ -88,13 +136,49 @@ internal static KnowledgeStore DeserializeKnowledgeStore(JsonElement element) { continue; } - parameters = SearchIndexerKnowledgeStoreParameters.DeserializeSearchIndexerKnowledgeStoreParameters(property.Value); + parameters = SearchIndexerKnowledgeStoreParameters.DeserializeSearchIndexerKnowledgeStoreParameters(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeStore(storageConnectionString, projections, identity, parameters, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeStore)} does not support writing '{options.Format}' format."); } - return new KnowledgeStore(storageConnectionString, projections, identity, parameters); } + KnowledgeStore 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 DeserializeKnowledgeStore(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeStore)} 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 KnowledgeStore FromResponse(Response response) @@ -107,7 +191,7 @@ internal static KnowledgeStore FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStore.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStore.cs index 64d90d0c5341..4cf23f1eb697 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStore.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStore.cs @@ -14,6 +14,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Definition of additional projections to azure blob, table, or files, of enriched data. public partial class KnowledgeStore { + /// + /// 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 . /// The connection string to the storage account projections will be stored in. /// A list of additional projections to perform during indexing. @@ -36,12 +68,19 @@ public KnowledgeStore(string storageConnectionString, IEnumerable and . /// /// A dictionary of knowledge store-specific configuration properties. Each name is the name of a specific property. Each value must be of a primitive type. - internal KnowledgeStore(string storageConnectionString, IList projections, SearchIndexerDataIdentity identity, SearchIndexerKnowledgeStoreParameters parameters) + /// Keeps track of any properties unknown to the library. + internal KnowledgeStore(string storageConnectionString, IList projections, SearchIndexerDataIdentity identity, SearchIndexerKnowledgeStoreParameters parameters, IDictionary serializedAdditionalRawData) { StorageConnectionString = storageConnectionString; Projections = projections; Identity = identity; Parameters = parameters; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal KnowledgeStore() + { } /// The connection string to the storage account projections will be stored in. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreFileProjectionSelector.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreFileProjectionSelector.Serialization.cs index 2d241a3680b5..833b2deaa4c9 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreFileProjectionSelector.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreFileProjectionSelector.Serialization.cs @@ -5,54 +5,54 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class KnowledgeStoreFileProjectionSelector : IUtf8JsonSerializable + public partial class KnowledgeStoreFileProjectionSelector : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("storageContainer"u8); - writer.WriteStringValue(StorageContainer); - if (Optional.IsDefined(ReferenceKeyName)) - { - writer.WritePropertyName("referenceKeyName"u8); - writer.WriteStringValue(ReferenceKeyName); - } - if (Optional.IsDefined(GeneratedKeyName)) - { - writer.WritePropertyName("generatedKeyName"u8); - writer.WriteStringValue(GeneratedKeyName); - } - if (Optional.IsDefined(Source)) - { - writer.WritePropertyName("source"u8); - writer.WriteStringValue(Source); - } - if (Optional.IsDefined(SourceContext)) + 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") { - writer.WritePropertyName("sourceContext"u8); - writer.WriteStringValue(SourceContext); + throw new FormatException($"The model {nameof(KnowledgeStoreFileProjectionSelector)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Inputs)) + + base.JsonModelWriteCore(writer, options); + } + + KnowledgeStoreFileProjectionSelector IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); + throw new FormatException($"The model {nameof(KnowledgeStoreFileProjectionSelector)} does not support reading '{format}' format."); } - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeStoreFileProjectionSelector(document.RootElement, options); } - internal static KnowledgeStoreFileProjectionSelector DeserializeKnowledgeStoreFileProjectionSelector(JsonElement element) + internal static KnowledgeStoreFileProjectionSelector DeserializeKnowledgeStoreFileProjectionSelector(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -63,6 +63,8 @@ internal static KnowledgeStoreFileProjectionSelector DeserializeKnowledgeStoreFi string source = default; string sourceContext = default; IList inputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("storageContainer"u8)) @@ -99,21 +101,58 @@ internal static KnowledgeStoreFileProjectionSelector DeserializeKnowledgeStoreFi List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new KnowledgeStoreFileProjectionSelector( referenceKeyName, generatedKeyName, source, sourceContext, inputs ?? new ChangeTrackingList(), + serializedAdditionalRawData, storageContainer); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeStoreFileProjectionSelector)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeStoreFileProjectionSelector 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 DeserializeKnowledgeStoreFileProjectionSelector(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeStoreFileProjectionSelector)} 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 KnowledgeStoreFileProjectionSelector FromResponse(Response response) @@ -126,7 +165,7 @@ internal static KnowledgeStoreFileProjectionSelector DeserializeKnowledgeStoreFi internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreFileProjectionSelector.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreFileProjectionSelector.cs index e0b91c0f9339..a9eca5d8d60c 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreFileProjectionSelector.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreFileProjectionSelector.cs @@ -27,8 +27,14 @@ public KnowledgeStoreFileProjectionSelector(string storageContainer) : base(stor /// Source data to project. /// Source context for complex projections. /// Nested inputs for complex projections. + /// Keeps track of any properties unknown to the library. /// Blob container to store projections in. - internal KnowledgeStoreFileProjectionSelector(string referenceKeyName, string generatedKeyName, string source, string sourceContext, IList inputs, string storageContainer) : base(referenceKeyName, generatedKeyName, source, sourceContext, inputs, storageContainer) + internal KnowledgeStoreFileProjectionSelector(string referenceKeyName, string generatedKeyName, string source, string sourceContext, IList inputs, IDictionary serializedAdditionalRawData, string storageContainer) : base(referenceKeyName, generatedKeyName, source, sourceContext, inputs, serializedAdditionalRawData, storageContainer) + { + } + + /// Initializes a new instance of for deserialization. + internal KnowledgeStoreFileProjectionSelector() { } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreObjectProjectionSelector.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreObjectProjectionSelector.Serialization.cs index c47998060921..fcc3cbe5451a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreObjectProjectionSelector.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreObjectProjectionSelector.Serialization.cs @@ -5,54 +5,54 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class KnowledgeStoreObjectProjectionSelector : IUtf8JsonSerializable + public partial class KnowledgeStoreObjectProjectionSelector : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("storageContainer"u8); - writer.WriteStringValue(StorageContainer); - if (Optional.IsDefined(ReferenceKeyName)) - { - writer.WritePropertyName("referenceKeyName"u8); - writer.WriteStringValue(ReferenceKeyName); - } - if (Optional.IsDefined(GeneratedKeyName)) - { - writer.WritePropertyName("generatedKeyName"u8); - writer.WriteStringValue(GeneratedKeyName); - } - if (Optional.IsDefined(Source)) - { - writer.WritePropertyName("source"u8); - writer.WriteStringValue(Source); - } - if (Optional.IsDefined(SourceContext)) + 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") { - writer.WritePropertyName("sourceContext"u8); - writer.WriteStringValue(SourceContext); + throw new FormatException($"The model {nameof(KnowledgeStoreObjectProjectionSelector)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Inputs)) + + base.JsonModelWriteCore(writer, options); + } + + KnowledgeStoreObjectProjectionSelector IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); + throw new FormatException($"The model {nameof(KnowledgeStoreObjectProjectionSelector)} does not support reading '{format}' format."); } - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeStoreObjectProjectionSelector(document.RootElement, options); } - internal static KnowledgeStoreObjectProjectionSelector DeserializeKnowledgeStoreObjectProjectionSelector(JsonElement element) + internal static KnowledgeStoreObjectProjectionSelector DeserializeKnowledgeStoreObjectProjectionSelector(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -63,6 +63,8 @@ internal static KnowledgeStoreObjectProjectionSelector DeserializeKnowledgeStore string source = default; string sourceContext = default; IList inputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("storageContainer"u8)) @@ -99,21 +101,58 @@ internal static KnowledgeStoreObjectProjectionSelector DeserializeKnowledgeStore List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new KnowledgeStoreObjectProjectionSelector( referenceKeyName, generatedKeyName, source, sourceContext, inputs ?? new ChangeTrackingList(), + serializedAdditionalRawData, storageContainer); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeStoreObjectProjectionSelector)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeStoreObjectProjectionSelector 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 DeserializeKnowledgeStoreObjectProjectionSelector(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeStoreObjectProjectionSelector)} 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 KnowledgeStoreObjectProjectionSelector FromResponse(Response response) @@ -126,7 +165,7 @@ internal static KnowledgeStoreObjectProjectionSelector DeserializeKnowledgeStore internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreObjectProjectionSelector.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreObjectProjectionSelector.cs index 323d29c1e4ee..718c1c4d8de3 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreObjectProjectionSelector.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreObjectProjectionSelector.cs @@ -27,8 +27,14 @@ public KnowledgeStoreObjectProjectionSelector(string storageContainer) : base(st /// Source data to project. /// Source context for complex projections. /// Nested inputs for complex projections. + /// Keeps track of any properties unknown to the library. /// Blob container to store projections in. - internal KnowledgeStoreObjectProjectionSelector(string referenceKeyName, string generatedKeyName, string source, string sourceContext, IList inputs, string storageContainer) : base(referenceKeyName, generatedKeyName, source, sourceContext, inputs, storageContainer) + internal KnowledgeStoreObjectProjectionSelector(string referenceKeyName, string generatedKeyName, string source, string sourceContext, IList inputs, IDictionary serializedAdditionalRawData, string storageContainer) : base(referenceKeyName, generatedKeyName, source, sourceContext, inputs, serializedAdditionalRawData, storageContainer) + { + } + + /// Initializes a new instance of for deserialization. + internal KnowledgeStoreObjectProjectionSelector() { } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreProjection.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreProjection.Serialization.cs index 27b6e653a6b6..6f928d65fa0f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreProjection.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreProjection.Serialization.cs @@ -5,24 +5,42 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class KnowledgeStoreProjection : IUtf8JsonSerializable + public partial class KnowledgeStoreProjection : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(KnowledgeStoreProjection)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Tables)) { writer.WritePropertyName("tables"u8); writer.WriteStartArray(); foreach (var item in Tables) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } @@ -32,7 +50,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in Objects) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } @@ -42,15 +60,43 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in Files) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - writer.WriteEndObject(); + 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 + } + } } - internal static KnowledgeStoreProjection DeserializeKnowledgeStoreProjection(JsonElement element) + KnowledgeStoreProjection 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(KnowledgeStoreProjection)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeStoreProjection(document.RootElement, options); + } + + internal static KnowledgeStoreProjection DeserializeKnowledgeStoreProjection(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -58,6 +104,8 @@ internal static KnowledgeStoreProjection DeserializeKnowledgeStoreProjection(Jso IList tables = default; IList objects = default; IList files = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("tables"u8)) @@ -69,7 +117,7 @@ internal static KnowledgeStoreProjection DeserializeKnowledgeStoreProjection(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KnowledgeStoreTableProjectionSelector.DeserializeKnowledgeStoreTableProjectionSelector(item)); + array.Add(KnowledgeStoreTableProjectionSelector.DeserializeKnowledgeStoreTableProjectionSelector(item, options)); } tables = array; continue; @@ -83,7 +131,7 @@ internal static KnowledgeStoreProjection DeserializeKnowledgeStoreProjection(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KnowledgeStoreObjectProjectionSelector.DeserializeKnowledgeStoreObjectProjectionSelector(item)); + array.Add(KnowledgeStoreObjectProjectionSelector.DeserializeKnowledgeStoreObjectProjectionSelector(item, options)); } objects = array; continue; @@ -97,15 +145,51 @@ internal static KnowledgeStoreProjection DeserializeKnowledgeStoreProjection(Jso List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KnowledgeStoreFileProjectionSelector.DeserializeKnowledgeStoreFileProjectionSelector(item)); + array.Add(KnowledgeStoreFileProjectionSelector.DeserializeKnowledgeStoreFileProjectionSelector(item, options)); } files = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeStoreProjection(tables ?? new ChangeTrackingList(), objects ?? new ChangeTrackingList(), files ?? 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeStoreProjection)} does not support writing '{options.Format}' format."); } - return new KnowledgeStoreProjection(tables ?? new ChangeTrackingList(), objects ?? new ChangeTrackingList(), files ?? new ChangeTrackingList()); } + KnowledgeStoreProjection 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 DeserializeKnowledgeStoreProjection(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeStoreProjection)} 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 KnowledgeStoreProjection FromResponse(Response response) @@ -118,7 +202,7 @@ internal static KnowledgeStoreProjection FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreProjection.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreProjection.cs index f8b9bc2da7cf..1c496f8b4177 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreProjection.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreProjection.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models @@ -12,6 +13,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Container object for various projection selectors. public partial class KnowledgeStoreProjection { + /// + /// 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 KnowledgeStoreProjection() { @@ -24,11 +57,13 @@ public KnowledgeStoreProjection() /// Projections to Azure Table storage. /// Projections to Azure Blob storage. /// Projections to Azure File storage. - internal KnowledgeStoreProjection(IList tables, IList objects, IList files) + /// Keeps track of any properties unknown to the library. + internal KnowledgeStoreProjection(IList tables, IList objects, IList files, IDictionary serializedAdditionalRawData) { Tables = tables; Objects = objects; Files = files; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Projections to Azure Table storage. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreProjectionSelector.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreProjectionSelector.Serialization.cs index c623670b2466..daf2a8b90a3f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreProjectionSelector.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreProjectionSelector.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class KnowledgeStoreProjectionSelector : IUtf8JsonSerializable + public partial class KnowledgeStoreProjectionSelector : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(KnowledgeStoreProjectionSelector)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(ReferenceKeyName)) { writer.WritePropertyName("referenceKeyName"u8); @@ -42,15 +60,43 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in Inputs) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - writer.WriteEndObject(); + 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 + } + } } - internal static KnowledgeStoreProjectionSelector DeserializeKnowledgeStoreProjectionSelector(JsonElement element) + KnowledgeStoreProjectionSelector 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(KnowledgeStoreProjectionSelector)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeStoreProjectionSelector(document.RootElement, options); + } + + internal static KnowledgeStoreProjectionSelector DeserializeKnowledgeStoreProjectionSelector(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -60,6 +106,8 @@ internal static KnowledgeStoreProjectionSelector DeserializeKnowledgeStoreProjec string source = default; string sourceContext = default; IList inputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("referenceKeyName"u8)) @@ -91,15 +139,57 @@ internal static KnowledgeStoreProjectionSelector DeserializeKnowledgeStoreProjec List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeStoreProjectionSelector( + referenceKeyName, + generatedKeyName, + source, + sourceContext, + inputs ?? 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeStoreProjectionSelector)} does not support writing '{options.Format}' format."); } - return new KnowledgeStoreProjectionSelector(referenceKeyName, generatedKeyName, source, sourceContext, inputs ?? new ChangeTrackingList()); } + KnowledgeStoreProjectionSelector 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 DeserializeKnowledgeStoreProjectionSelector(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeStoreProjectionSelector)} 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 KnowledgeStoreProjectionSelector FromResponse(Response response) @@ -112,7 +202,7 @@ internal static KnowledgeStoreProjectionSelector FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreProjectionSelector.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreProjectionSelector.cs index d514104a5151..24dc51c1791a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreProjectionSelector.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreProjectionSelector.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models @@ -12,6 +13,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Abstract class to share properties between concrete selectors. public partial class KnowledgeStoreProjectionSelector { + /// + /// 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 . public KnowledgeStoreProjectionSelector() { @@ -24,13 +57,15 @@ public KnowledgeStoreProjectionSelector() /// Source data to project. /// Source context for complex projections. /// Nested inputs for complex projections. - internal KnowledgeStoreProjectionSelector(string referenceKeyName, string generatedKeyName, string source, string sourceContext, IList inputs) + /// Keeps track of any properties unknown to the library. + internal KnowledgeStoreProjectionSelector(string referenceKeyName, string generatedKeyName, string source, string sourceContext, IList inputs, IDictionary serializedAdditionalRawData) { ReferenceKeyName = referenceKeyName; GeneratedKeyName = generatedKeyName; Source = source; SourceContext = sourceContext; Inputs = inputs; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Name of reference key to different projection. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreStorageProjectionSelector.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreStorageProjectionSelector.Serialization.cs index e53e1fcd25ad..7416238b3b14 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreStorageProjectionSelector.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreStorageProjectionSelector.Serialization.cs @@ -5,54 +5,56 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class KnowledgeStoreStorageProjectionSelector : IUtf8JsonSerializable + public partial class KnowledgeStoreStorageProjectionSelector : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("storageContainer"u8); - writer.WriteStringValue(StorageContainer); - if (Optional.IsDefined(ReferenceKeyName)) - { - writer.WritePropertyName("referenceKeyName"u8); - writer.WriteStringValue(ReferenceKeyName); - } - if (Optional.IsDefined(GeneratedKeyName)) - { - writer.WritePropertyName("generatedKeyName"u8); - writer.WriteStringValue(GeneratedKeyName); - } - if (Optional.IsDefined(Source)) - { - writer.WritePropertyName("source"u8); - writer.WriteStringValue(Source); - } - if (Optional.IsDefined(SourceContext)) + 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") { - writer.WritePropertyName("sourceContext"u8); - writer.WriteStringValue(SourceContext); + throw new FormatException($"The model {nameof(KnowledgeStoreStorageProjectionSelector)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Inputs)) + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("storageContainer"u8); + writer.WriteStringValue(StorageContainer); + } + + KnowledgeStoreStorageProjectionSelector IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); + throw new FormatException($"The model {nameof(KnowledgeStoreStorageProjectionSelector)} does not support reading '{format}' format."); } - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeStoreStorageProjectionSelector(document.RootElement, options); } - internal static KnowledgeStoreStorageProjectionSelector DeserializeKnowledgeStoreStorageProjectionSelector(JsonElement element) + internal static KnowledgeStoreStorageProjectionSelector DeserializeKnowledgeStoreStorageProjectionSelector(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -63,6 +65,8 @@ internal static KnowledgeStoreStorageProjectionSelector DeserializeKnowledgeStor string source = default; string sourceContext = default; IList inputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("storageContainer"u8)) @@ -99,21 +103,58 @@ internal static KnowledgeStoreStorageProjectionSelector DeserializeKnowledgeStor List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new KnowledgeStoreStorageProjectionSelector( referenceKeyName, generatedKeyName, source, sourceContext, inputs ?? new ChangeTrackingList(), + serializedAdditionalRawData, storageContainer); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeStoreStorageProjectionSelector)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeStoreStorageProjectionSelector 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 DeserializeKnowledgeStoreStorageProjectionSelector(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeStoreStorageProjectionSelector)} 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 KnowledgeStoreStorageProjectionSelector FromResponse(Response response) @@ -126,7 +167,7 @@ internal static KnowledgeStoreStorageProjectionSelector DeserializeKnowledgeStor internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreStorageProjectionSelector.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreStorageProjectionSelector.cs index 34f7a292a26a..0879b2223506 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreStorageProjectionSelector.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreStorageProjectionSelector.cs @@ -29,12 +29,18 @@ public KnowledgeStoreStorageProjectionSelector(string storageContainer) /// Source data to project. /// Source context for complex projections. /// Nested inputs for complex projections. + /// Keeps track of any properties unknown to the library. /// Blob container to store projections in. - internal KnowledgeStoreStorageProjectionSelector(string referenceKeyName, string generatedKeyName, string source, string sourceContext, IList inputs, string storageContainer) : base(referenceKeyName, generatedKeyName, source, sourceContext, inputs) + internal KnowledgeStoreStorageProjectionSelector(string referenceKeyName, string generatedKeyName, string source, string sourceContext, IList inputs, IDictionary serializedAdditionalRawData, string storageContainer) : base(referenceKeyName, generatedKeyName, source, sourceContext, inputs, serializedAdditionalRawData) { StorageContainer = storageContainer; } + /// Initializes a new instance of for deserialization. + internal KnowledgeStoreStorageProjectionSelector() + { + } + /// Blob container to store projections in. public string StorageContainer { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreTableProjectionSelector.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreTableProjectionSelector.Serialization.cs index bd2e0078a964..0cdb6e5c852d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreTableProjectionSelector.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreTableProjectionSelector.Serialization.cs @@ -5,54 +5,56 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class KnowledgeStoreTableProjectionSelector : IUtf8JsonSerializable + public partial class KnowledgeStoreTableProjectionSelector : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("tableName"u8); - writer.WriteStringValue(TableName); - if (Optional.IsDefined(ReferenceKeyName)) - { - writer.WritePropertyName("referenceKeyName"u8); - writer.WriteStringValue(ReferenceKeyName); - } - if (Optional.IsDefined(GeneratedKeyName)) - { - writer.WritePropertyName("generatedKeyName"u8); - writer.WriteStringValue(GeneratedKeyName); - } - if (Optional.IsDefined(Source)) - { - writer.WritePropertyName("source"u8); - writer.WriteStringValue(Source); - } - if (Optional.IsDefined(SourceContext)) + 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") { - writer.WritePropertyName("sourceContext"u8); - writer.WriteStringValue(SourceContext); + throw new FormatException($"The model {nameof(KnowledgeStoreTableProjectionSelector)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Inputs)) + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("tableName"u8); + writer.WriteStringValue(TableName); + } + + KnowledgeStoreTableProjectionSelector IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); + throw new FormatException($"The model {nameof(KnowledgeStoreTableProjectionSelector)} does not support reading '{format}' format."); } - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeStoreTableProjectionSelector(document.RootElement, options); } - internal static KnowledgeStoreTableProjectionSelector DeserializeKnowledgeStoreTableProjectionSelector(JsonElement element) + internal static KnowledgeStoreTableProjectionSelector DeserializeKnowledgeStoreTableProjectionSelector(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -63,6 +65,8 @@ internal static KnowledgeStoreTableProjectionSelector DeserializeKnowledgeStoreT string source = default; string sourceContext = default; IList inputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("tableName"u8)) @@ -99,21 +103,58 @@ internal static KnowledgeStoreTableProjectionSelector DeserializeKnowledgeStoreT List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new KnowledgeStoreTableProjectionSelector( referenceKeyName, generatedKeyName, source, sourceContext, inputs ?? new ChangeTrackingList(), + serializedAdditionalRawData, tableName); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeStoreTableProjectionSelector)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeStoreTableProjectionSelector 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 DeserializeKnowledgeStoreTableProjectionSelector(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeStoreTableProjectionSelector)} 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 KnowledgeStoreTableProjectionSelector FromResponse(Response response) @@ -126,7 +167,7 @@ internal static KnowledgeStoreTableProjectionSelector DeserializeKnowledgeStoreT internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreTableProjectionSelector.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreTableProjectionSelector.cs index 58f6e6341a66..55f359aa42bf 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreTableProjectionSelector.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KnowledgeStoreTableProjectionSelector.cs @@ -29,12 +29,18 @@ public KnowledgeStoreTableProjectionSelector(string tableName) /// Source data to project. /// Source context for complex projections. /// Nested inputs for complex projections. + /// Keeps track of any properties unknown to the library. /// Name of the Azure table to store projected data in. - internal KnowledgeStoreTableProjectionSelector(string referenceKeyName, string generatedKeyName, string source, string sourceContext, IList inputs, string tableName) : base(referenceKeyName, generatedKeyName, source, sourceContext, inputs) + internal KnowledgeStoreTableProjectionSelector(string referenceKeyName, string generatedKeyName, string source, string sourceContext, IList inputs, IDictionary serializedAdditionalRawData, string tableName) : base(referenceKeyName, generatedKeyName, source, sourceContext, inputs, serializedAdditionalRawData) { TableName = tableName; } + /// Initializes a new instance of for deserialization. + internal KnowledgeStoreTableProjectionSelector() + { + } + /// Name of the Azure table to store projected data in. public string TableName { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LanguageDetectionSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/LanguageDetectionSkill.Serialization.cs index 855d6aa2fd89..52c5e22f8419 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LanguageDetectionSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/LanguageDetectionSkill.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class LanguageDetectionSkill : IUtf8JsonSerializable + public partial class LanguageDetectionSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(LanguageDetectionSkill)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(DefaultCountryHint)) { if (DefaultCountryHint != null) @@ -40,42 +59,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("modelVersion"); } } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + LanguageDetectionSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(LanguageDetectionSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLanguageDetectionSkill(document.RootElement, options); } - internal static LanguageDetectionSkill DeserializeLanguageDetectionSkill(JsonElement element) + internal static LanguageDetectionSkill DeserializeLanguageDetectionSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -88,6 +89,8 @@ internal static LanguageDetectionSkill DeserializeLanguageDetectionSkill(JsonEle string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("defaultCountryHint"u8)) @@ -135,7 +138,7 @@ internal static LanguageDetectionSkill DeserializeLanguageDetectionSkill(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -145,12 +148,17 @@ internal static LanguageDetectionSkill DeserializeLanguageDetectionSkill(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new LanguageDetectionSkill( odataType, name, @@ -158,10 +166,42 @@ internal static LanguageDetectionSkill DeserializeLanguageDetectionSkill(JsonEle context, inputs, outputs, + serializedAdditionalRawData, defaultCountryHint, modelVersion); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(LanguageDetectionSkill)} does not support writing '{options.Format}' format."); + } + } + + LanguageDetectionSkill 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 DeserializeLanguageDetectionSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LanguageDetectionSkill)} 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 LanguageDetectionSkill FromResponse(Response response) @@ -174,7 +214,7 @@ internal static LanguageDetectionSkill DeserializeLanguageDetectionSkill(JsonEle internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LanguageDetectionSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/LanguageDetectionSkill.cs index 12ffc9f170fa..f295d253cf38 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LanguageDetectionSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/LanguageDetectionSkill.cs @@ -32,15 +32,21 @@ public LanguageDetectionSkill(IEnumerable inputs, IEnume /// Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// A country code to use as a hint to the language detection model if it cannot disambiguate the language. /// The version of the model to use when calling the Text Analytics service. It will default to the latest available when not specified. We recommend you do not specify this value unless absolutely necessary. - internal LanguageDetectionSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, string defaultCountryHint, string modelVersion) : base(oDataType, name, description, context, inputs, outputs) + internal LanguageDetectionSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, string defaultCountryHint, string modelVersion) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { DefaultCountryHint = defaultCountryHint; ModelVersion = modelVersion; ODataType = oDataType ?? "#Microsoft.Skills.Text.LanguageDetectionSkill"; } + /// Initializes a new instance of for deserialization. + internal LanguageDetectionSkill() + { + } + /// A country code to use as a hint to the language detection model if it cannot disambiguate the language. public string DefaultCountryHint { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LengthTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/LengthTokenFilter.Serialization.cs index 164b39d92bea..f68fdf03643d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LengthTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/LengthTokenFilter.Serialization.cs @@ -5,16 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class LengthTokenFilter : IUtf8JsonSerializable + public partial class LengthTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(LengthTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(MinLength)) { writer.WritePropertyName("min"u8); @@ -25,15 +45,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("max"u8); writer.WriteNumberValue(MaxLength.Value); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static LengthTokenFilter DeserializeLengthTokenFilter(JsonElement element) + LengthTokenFilter 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(LengthTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLengthTokenFilter(document.RootElement, options); + } + + internal static LengthTokenFilter DeserializeLengthTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -42,6 +71,8 @@ internal static LengthTokenFilter DeserializeLengthTokenFilter(JsonElement eleme int? max = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("min"u8)) @@ -72,10 +103,46 @@ internal static LengthTokenFilter DeserializeLengthTokenFilter(JsonElement eleme name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new LengthTokenFilter(odataType, name, serializedAdditionalRawData, min, max); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(LengthTokenFilter)} does not support writing '{options.Format}' format."); + } + } + + LengthTokenFilter 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 DeserializeLengthTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LengthTokenFilter)} does not support reading '{options.Format}' format."); } - return new LengthTokenFilter(odataType, name, min, max); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new LengthTokenFilter FromResponse(Response response) @@ -88,7 +155,7 @@ internal static LengthTokenFilter DeserializeLengthTokenFilter(JsonElement eleme internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LengthTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/LengthTokenFilter.cs index 0cc11a9aef0c..3306f5267b47 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LengthTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/LengthTokenFilter.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,13 +26,19 @@ public LengthTokenFilter(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The minimum length in characters. Default is 0. Maximum is 300. Must be less than the value of max. /// The maximum length in characters. Default and maximum is 300. - internal LengthTokenFilter(string oDataType, string name, int? minLength, int? maxLength) : base(oDataType, name) + internal LengthTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, int? minLength, int? maxLength) : base(oDataType, name, serializedAdditionalRawData) { MinLength = minLength; MaxLength = maxLength; ODataType = oDataType ?? "#Microsoft.Azure.Search.LengthTokenFilter"; } + + /// Initializes a new instance of for deserialization. + internal LengthTokenFilter() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalAnalyzer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalAnalyzer.Serialization.cs index e2701deaac0d..d243fc907932 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalAnalyzer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalAnalyzer.Serialization.cs @@ -5,26 +5,72 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Indexes.Models { - public partial class LexicalAnalyzer : IUtf8JsonSerializable + public partial class LexicalAnalyzer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(LexicalAnalyzer)} does not support writing '{format}' format."); + } + writer.WritePropertyName("@odata.type"u8); writer.WriteStringValue(ODataType); writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); - writer.WriteEndObject(); + 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 + } + } } - internal static LexicalAnalyzer DeserializeLexicalAnalyzer(JsonElement element) + LexicalAnalyzer 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(LexicalAnalyzer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLexicalAnalyzer(document.RootElement, options); + } + + internal static LexicalAnalyzer DeserializeLexicalAnalyzer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -33,15 +79,46 @@ internal static LexicalAnalyzer DeserializeLexicalAnalyzer(JsonElement element) { switch (discriminator.GetString()) { - case "#Microsoft.Azure.Search.CustomAnalyzer": return CustomAnalyzer.DeserializeCustomAnalyzer(element); - case "#Microsoft.Azure.Search.PatternAnalyzer": return PatternAnalyzer.DeserializePatternAnalyzer(element); - case "#Microsoft.Azure.Search.StandardAnalyzer": return LuceneStandardAnalyzer.DeserializeLuceneStandardAnalyzer(element); - case "#Microsoft.Azure.Search.StopAnalyzer": return StopAnalyzer.DeserializeStopAnalyzer(element); + case "#Microsoft.Azure.Search.CustomAnalyzer": return CustomAnalyzer.DeserializeCustomAnalyzer(element, options); + case "#Microsoft.Azure.Search.PatternAnalyzer": return PatternAnalyzer.DeserializePatternAnalyzer(element, options); + case "#Microsoft.Azure.Search.StandardAnalyzer": return LuceneStandardAnalyzer.DeserializeLuceneStandardAnalyzer(element, options); + case "#Microsoft.Azure.Search.StopAnalyzer": return StopAnalyzer.DeserializeStopAnalyzer(element, options); } } - return UnknownLexicalAnalyzer.DeserializeUnknownLexicalAnalyzer(element); + return UnknownLexicalAnalyzer.DeserializeUnknownLexicalAnalyzer(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(LexicalAnalyzer)} does not support writing '{options.Format}' format."); + } + } + + LexicalAnalyzer 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 DeserializeLexicalAnalyzer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LexicalAnalyzer)} 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 LexicalAnalyzer FromResponse(Response response) @@ -54,7 +131,7 @@ internal static LexicalAnalyzer FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalAnalyzer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalAnalyzer.cs index 53cf65dad465..439dc5c258a1 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalAnalyzer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalAnalyzer.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -16,13 +17,52 @@ namespace Azure.Search.Documents.Indexes.Models /// public partial class LexicalAnalyzer { + /// + /// 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 . /// A URI fragment specifying the type of analyzer. /// The name of the analyzer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - internal LexicalAnalyzer(string oDataType, string name) + /// Keeps track of any properties unknown to the library. + internal LexicalAnalyzer(string oDataType, string name, IDictionary serializedAdditionalRawData) { ODataType = oDataType; Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal LexicalAnalyzer() + { } /// A URI fragment specifying the type of analyzer. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalNormalizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalNormalizer.Serialization.cs index 19893b348aef..2dcaf6a839e6 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalNormalizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalNormalizer.Serialization.cs @@ -5,26 +5,72 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Indexes.Models { - public partial class LexicalNormalizer : IUtf8JsonSerializable + public partial class LexicalNormalizer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(LexicalNormalizer)} does not support writing '{format}' format."); + } + writer.WritePropertyName("@odata.type"u8); writer.WriteStringValue(ODataType); writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); - writer.WriteEndObject(); + 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 + } + } } - internal static LexicalNormalizer DeserializeLexicalNormalizer(JsonElement element) + LexicalNormalizer 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(LexicalNormalizer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLexicalNormalizer(document.RootElement, options); + } + + internal static LexicalNormalizer DeserializeLexicalNormalizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -33,12 +79,43 @@ internal static LexicalNormalizer DeserializeLexicalNormalizer(JsonElement eleme { switch (discriminator.GetString()) { - case "#Microsoft.Azure.Search.CustomNormalizer": return CustomNormalizer.DeserializeCustomNormalizer(element); + case "#Microsoft.Azure.Search.CustomNormalizer": return CustomNormalizer.DeserializeCustomNormalizer(element, options); } } - return UnknownLexicalNormalizer.DeserializeUnknownLexicalNormalizer(element); + return UnknownLexicalNormalizer.DeserializeUnknownLexicalNormalizer(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(LexicalNormalizer)} does not support writing '{options.Format}' format."); + } + } + + LexicalNormalizer 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 DeserializeLexicalNormalizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LexicalNormalizer)} 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 LexicalNormalizer FromResponse(Response response) @@ -51,7 +128,7 @@ internal static LexicalNormalizer FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalNormalizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalNormalizer.cs index 4f5638a8dc94..5d967c618bbb 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalNormalizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalNormalizer.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -16,6 +17,38 @@ namespace Azure.Search.Documents.Indexes.Models /// public partial class LexicalNormalizer { + /// + /// 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 . /// The name of the normalizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. It cannot end in '.microsoft' nor '.lucene', nor be named 'asciifolding', 'standard', 'lowercase', 'uppercase', or 'elision'. /// is null. @@ -29,10 +62,17 @@ public LexicalNormalizer(string name) /// Initializes a new instance of . /// A URI fragment specifying the type of normalizer. /// The name of the normalizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. It cannot end in '.microsoft' nor '.lucene', nor be named 'asciifolding', 'standard', 'lowercase', 'uppercase', or 'elision'. - internal LexicalNormalizer(string oDataType, string name) + /// Keeps track of any properties unknown to the library. + internal LexicalNormalizer(string oDataType, string name, IDictionary serializedAdditionalRawData) { ODataType = oDataType; Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal LexicalNormalizer() + { } /// A URI fragment specifying the type of normalizer. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalTokenizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalTokenizer.Serialization.cs index 308657a0bedf..c4af0f5fd7b9 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalTokenizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalTokenizer.Serialization.cs @@ -5,51 +5,98 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; -using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Indexes.Models { - public partial class LexicalTokenizer : IUtf8JsonSerializable + public partial class LexicalTokenizer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(LexicalTokenizer)} does not support writing '{format}' format."); + } + writer.WritePropertyName("@odata.type"u8); writer.WriteStringValue(ODataType); writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); - writer.WriteEndObject(); + 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 + } + } } - internal static LexicalTokenizer DeserializeLexicalTokenizer(JsonElement element) + LexicalTokenizer IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - if (element.ValueKind == JsonValueKind.Null) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - return null; + throw new FormatException($"The model {nameof(LexicalTokenizer)} does not support reading '{format}' format."); } - if (element.TryGetProperty("@odata.type", out JsonElement discriminator)) + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLexicalTokenizer(document.RootElement, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - switch (discriminator.GetString()) - { - case "#Microsoft.Azure.Search.ClassicTokenizer": return ClassicTokenizer.DeserializeClassicTokenizer(element); - case "#Microsoft.Azure.Search.EdgeNGramTokenizer": return EdgeNGramTokenizer.DeserializeEdgeNGramTokenizer(element); - case "#Microsoft.Azure.Search.KeywordTokenizer": return KeywordTokenizer.DeserializeKeywordTokenizer(element); - case "#Microsoft.Azure.Search.KeywordTokenizerV2": return KeywordTokenizer.DeserializeKeywordTokenizer(element); - case "#Microsoft.Azure.Search.MicrosoftLanguageStemmingTokenizer": return MicrosoftLanguageStemmingTokenizer.DeserializeMicrosoftLanguageStemmingTokenizer(element); - case "#Microsoft.Azure.Search.MicrosoftLanguageTokenizer": return MicrosoftLanguageTokenizer.DeserializeMicrosoftLanguageTokenizer(element); - case "#Microsoft.Azure.Search.NGramTokenizer": return NGramTokenizer.DeserializeNGramTokenizer(element); - case "#Microsoft.Azure.Search.PathHierarchyTokenizerV2": return PathHierarchyTokenizer.DeserializePathHierarchyTokenizer(element); - case "#Microsoft.Azure.Search.PatternTokenizer": return PatternTokenizer.DeserializePatternTokenizer(element); - case "#Microsoft.Azure.Search.StandardTokenizer": return LuceneStandardTokenizer.DeserializeLuceneStandardTokenizer(element); - case "#Microsoft.Azure.Search.StandardTokenizerV2": return LuceneStandardTokenizer.DeserializeLuceneStandardTokenizer(element); - case "#Microsoft.Azure.Search.UaxUrlEmailTokenizer": return UaxUrlEmailTokenizer.DeserializeUaxUrlEmailTokenizer(element); - } + case "J": + return ModelReaderWriter.Write(this, options, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(LexicalTokenizer)} does not support writing '{options.Format}' format."); } - return UnknownLexicalTokenizer.DeserializeUnknownLexicalTokenizer(element); } + LexicalTokenizer 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 DeserializeLexicalTokenizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LexicalTokenizer)} 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 LexicalTokenizer FromResponse(Response response) @@ -62,7 +109,7 @@ internal static LexicalTokenizer FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalTokenizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalTokenizer.cs index d5e4a6c6413c..141a437db5b8 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalTokenizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalTokenizer.cs @@ -6,23 +6,63 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// /// Base type for tokenizers. /// 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 available derived classes include , , , , , , , , and . /// public partial class LexicalTokenizer { + /// + /// 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 . /// A URI fragment specifying the type of tokenizer. /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - internal LexicalTokenizer(string oDataType, string name) + /// Keeps track of any properties unknown to the library. + internal LexicalTokenizer(string oDataType, string name, IDictionary serializedAdditionalRawData) { ODataType = oDataType; Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal LexicalTokenizer() + { } /// A URI fragment specifying the type of tokenizer. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LimitTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/LimitTokenFilter.Serialization.cs index b4df7bcd37eb..8a1fc5dd19ac 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LimitTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/LimitTokenFilter.Serialization.cs @@ -5,16 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class LimitTokenFilter : IUtf8JsonSerializable + public partial class LimitTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(LimitTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(MaxTokenCount)) { writer.WritePropertyName("maxTokenCount"u8); @@ -25,15 +45,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("consumeAllTokens"u8); writer.WriteBooleanValue(ConsumeAllTokens.Value); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static LimitTokenFilter DeserializeLimitTokenFilter(JsonElement element) + LimitTokenFilter 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(LimitTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLimitTokenFilter(document.RootElement, options); + } + + internal static LimitTokenFilter DeserializeLimitTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -42,6 +71,8 @@ internal static LimitTokenFilter DeserializeLimitTokenFilter(JsonElement element bool? consumeAllTokens = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("maxTokenCount"u8)) @@ -72,10 +103,46 @@ internal static LimitTokenFilter DeserializeLimitTokenFilter(JsonElement element name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new LimitTokenFilter(odataType, name, serializedAdditionalRawData, maxTokenCount, consumeAllTokens); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(LimitTokenFilter)} does not support writing '{options.Format}' format."); + } + } + + LimitTokenFilter 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 DeserializeLimitTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LimitTokenFilter)} does not support reading '{options.Format}' format."); } - return new LimitTokenFilter(odataType, name, maxTokenCount, consumeAllTokens); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new LimitTokenFilter FromResponse(Response response) @@ -88,7 +155,7 @@ internal static LimitTokenFilter DeserializeLimitTokenFilter(JsonElement element internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LimitTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/LimitTokenFilter.cs index 0e5fc63519f6..fd1efa782993 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LimitTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/LimitTokenFilter.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,15 +26,21 @@ public LimitTokenFilter(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The maximum number of tokens to produce. Default is 1. /// A value indicating whether all tokens from the input must be consumed even if maxTokenCount is reached. Default is false. - internal LimitTokenFilter(string oDataType, string name, int? maxTokenCount, bool? consumeAllTokens) : base(oDataType, name) + internal LimitTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, int? maxTokenCount, bool? consumeAllTokens) : base(oDataType, name, serializedAdditionalRawData) { MaxTokenCount = maxTokenCount; ConsumeAllTokens = consumeAllTokens; ODataType = oDataType ?? "#Microsoft.Azure.Search.LimitTokenFilter"; } + /// Initializes a new instance of for deserialization. + internal LimitTokenFilter() + { + } + /// The maximum number of tokens to produce. Default is 1. public int? MaxTokenCount { get; set; } /// A value indicating whether all tokens from the input must be consumed even if maxTokenCount is reached. Default is false. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListAliasesResult.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListAliasesResult.Serialization.cs index a9eb35a542ba..71f9db89674c 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListAliasesResult.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListAliasesResult.Serialization.cs @@ -5,20 +5,85 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - internal partial class ListAliasesResult + internal partial class ListAliasesResult : IUtf8JsonSerializable, IJsonModel { - internal static ListAliasesResult DeserializeListAliasesResult(JsonElement element) + 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(ListAliasesResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Aliases) + { + 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 + } + } + } + + ListAliasesResult 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(ListAliasesResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeListAliasesResult(document.RootElement, options); + } + + internal static ListAliasesResult DeserializeListAliasesResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } IReadOnlyList value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value"u8)) @@ -26,15 +91,51 @@ internal static ListAliasesResult DeserializeListAliasesResult(JsonElement eleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SearchAlias.DeserializeSearchAlias(item)); + array.Add(SearchAlias.DeserializeSearchAlias(item, options)); } value = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ListAliasesResult(value, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ListAliasesResult)} does not support writing '{options.Format}' format."); } - return new ListAliasesResult(value); } + ListAliasesResult 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 DeserializeListAliasesResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ListAliasesResult)} 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 ListAliasesResult FromResponse(Response response) @@ -42,5 +143,13 @@ internal static ListAliasesResult FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeListAliasesResult(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/search/Azure.Search.Documents/src/Generated/Models/ListAliasesResult.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListAliasesResult.cs index fa7098882a44..428532869fd3 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListAliasesResult.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListAliasesResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using System.Linq; @@ -13,6 +14,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Response from a List Aliases request. If successful, it includes the associated index mappings for all aliases. internal partial class ListAliasesResult { + /// + /// 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 . /// The aliases in the Search service. internal ListAliasesResult(IEnumerable aliases) @@ -22,9 +55,16 @@ internal ListAliasesResult(IEnumerable aliases) /// Initializes a new instance of . /// The aliases in the Search service. - internal ListAliasesResult(IReadOnlyList aliases) + /// Keeps track of any properties unknown to the library. + internal ListAliasesResult(IReadOnlyList aliases, IDictionary serializedAdditionalRawData) { Aliases = aliases; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ListAliasesResult() + { } /// The aliases in the Search service. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListDataSourcesResult.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListDataSourcesResult.Serialization.cs index 484b67d3a9df..5865e9f4c365 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListDataSourcesResult.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListDataSourcesResult.Serialization.cs @@ -5,20 +5,85 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - internal partial class ListDataSourcesResult + internal partial class ListDataSourcesResult : IUtf8JsonSerializable, IJsonModel { - internal static ListDataSourcesResult DeserializeListDataSourcesResult(JsonElement element) + 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(ListDataSourcesResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in DataSources) + { + 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 + } + } + } + + ListDataSourcesResult 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(ListDataSourcesResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeListDataSourcesResult(document.RootElement, options); + } + + internal static ListDataSourcesResult DeserializeListDataSourcesResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } IReadOnlyList value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value"u8)) @@ -26,15 +91,51 @@ internal static ListDataSourcesResult DeserializeListDataSourcesResult(JsonEleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SearchIndexerDataSourceConnection.DeserializeSearchIndexerDataSourceConnection(item)); + array.Add(SearchIndexerDataSourceConnection.DeserializeSearchIndexerDataSourceConnection(item, options)); } value = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ListDataSourcesResult(value, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ListDataSourcesResult)} does not support writing '{options.Format}' format."); } - return new ListDataSourcesResult(value); } + ListDataSourcesResult 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 DeserializeListDataSourcesResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ListDataSourcesResult)} 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 ListDataSourcesResult FromResponse(Response response) @@ -42,5 +143,13 @@ internal static ListDataSourcesResult FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeListDataSourcesResult(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/search/Azure.Search.Documents/src/Generated/Models/ListDataSourcesResult.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListDataSourcesResult.cs index ff14bbdc4a9c..a31c824498ab 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListDataSourcesResult.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListDataSourcesResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using System.Linq; @@ -13,6 +14,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Response from a List Datasources request. If successful, it includes the full definitions of all datasources. internal partial class ListDataSourcesResult { + /// + /// 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 . /// The datasources in the Search service. internal ListDataSourcesResult(IEnumerable dataSources) @@ -22,9 +55,16 @@ internal ListDataSourcesResult(IEnumerable da /// Initializes a new instance of . /// The datasources in the Search service. - internal ListDataSourcesResult(IReadOnlyList dataSources) + /// Keeps track of any properties unknown to the library. + internal ListDataSourcesResult(IReadOnlyList dataSources, IDictionary serializedAdditionalRawData) { DataSources = dataSources; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ListDataSourcesResult() + { } /// The datasources in the Search service. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexStatsSummary.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexStatsSummary.Serialization.cs index 057ab563766c..6e936f61de2a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexStatsSummary.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexStatsSummary.Serialization.cs @@ -5,20 +5,85 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class ListIndexStatsSummary + public partial class ListIndexStatsSummary : IUtf8JsonSerializable, IJsonModel { - internal static ListIndexStatsSummary DeserializeListIndexStatsSummary(JsonElement element) + 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(ListIndexStatsSummary)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in IndexesStatistics) + { + 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 + } + } + } + + ListIndexStatsSummary 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(ListIndexStatsSummary)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeListIndexStatsSummary(document.RootElement, options); + } + + internal static ListIndexStatsSummary DeserializeListIndexStatsSummary(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } IReadOnlyList value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value"u8)) @@ -26,15 +91,51 @@ internal static ListIndexStatsSummary DeserializeListIndexStatsSummary(JsonEleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(IndexStatisticsSummary.DeserializeIndexStatisticsSummary(item)); + array.Add(IndexStatisticsSummary.DeserializeIndexStatisticsSummary(item, options)); } value = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ListIndexStatsSummary(value, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ListIndexStatsSummary)} does not support writing '{options.Format}' format."); } - return new ListIndexStatsSummary(value); } + ListIndexStatsSummary 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 DeserializeListIndexStatsSummary(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ListIndexStatsSummary)} 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 ListIndexStatsSummary FromResponse(Response response) @@ -42,5 +143,13 @@ internal static ListIndexStatsSummary FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeListIndexStatsSummary(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/search/Azure.Search.Documents/src/Generated/Models/ListIndexStatsSummary.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexStatsSummary.cs index 3cd8803f85bc..2204bb3af10e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexStatsSummary.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexStatsSummary.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using System.Linq; @@ -13,6 +14,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Response from a request to retrieve stats summary of all indexes. If successful, it includes the stats of each index in the service. public partial class ListIndexStatsSummary { + /// + /// 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 . /// The Statistics summary of all indexes in the Search service. internal ListIndexStatsSummary(IEnumerable indexesStatistics) @@ -22,9 +55,16 @@ internal ListIndexStatsSummary(IEnumerable indexesStatis /// Initializes a new instance of . /// The Statistics summary of all indexes in the Search service. - internal ListIndexStatsSummary(IReadOnlyList indexesStatistics) + /// Keeps track of any properties unknown to the library. + internal ListIndexStatsSummary(IReadOnlyList indexesStatistics, IDictionary serializedAdditionalRawData) { IndexesStatistics = indexesStatistics; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ListIndexStatsSummary() + { } /// The Statistics summary of all indexes in the Search service. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexersResult.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexersResult.Serialization.cs index 3d0f0714e9bb..cf6ffdb3d784 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexersResult.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexersResult.Serialization.cs @@ -5,20 +5,85 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - internal partial class ListIndexersResult + internal partial class ListIndexersResult : IUtf8JsonSerializable, IJsonModel { - internal static ListIndexersResult DeserializeListIndexersResult(JsonElement element) + 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(ListIndexersResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Indexers) + { + 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 + } + } + } + + ListIndexersResult 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(ListIndexersResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeListIndexersResult(document.RootElement, options); + } + + internal static ListIndexersResult DeserializeListIndexersResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } IReadOnlyList value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value"u8)) @@ -26,15 +91,51 @@ internal static ListIndexersResult DeserializeListIndexersResult(JsonElement ele List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SearchIndexer.DeserializeSearchIndexer(item)); + array.Add(SearchIndexer.DeserializeSearchIndexer(item, options)); } value = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ListIndexersResult(value, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ListIndexersResult)} does not support writing '{options.Format}' format."); } - return new ListIndexersResult(value); } + ListIndexersResult 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 DeserializeListIndexersResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ListIndexersResult)} 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 ListIndexersResult FromResponse(Response response) @@ -42,5 +143,13 @@ internal static ListIndexersResult FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeListIndexersResult(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/search/Azure.Search.Documents/src/Generated/Models/ListIndexersResult.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexersResult.cs index 2f541fc5fe08..31c66611af4d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexersResult.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexersResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using System.Linq; @@ -13,6 +14,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Response from a List Indexers request. If successful, it includes the full definitions of all indexers. internal partial class ListIndexersResult { + /// + /// 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 . /// The indexers in the Search service. internal ListIndexersResult(IEnumerable indexers) @@ -22,9 +55,16 @@ internal ListIndexersResult(IEnumerable indexers) /// Initializes a new instance of . /// The indexers in the Search service. - internal ListIndexersResult(IReadOnlyList indexers) + /// Keeps track of any properties unknown to the library. + internal ListIndexersResult(IReadOnlyList indexers, IDictionary serializedAdditionalRawData) { Indexers = indexers; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ListIndexersResult() + { } /// The indexers in the Search service. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexesResult.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexesResult.Serialization.cs index 61a1be1236cd..2ba6220de10a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexesResult.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexesResult.Serialization.cs @@ -5,20 +5,85 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - internal partial class ListIndexesResult + internal partial class ListIndexesResult : IUtf8JsonSerializable, IJsonModel { - internal static ListIndexesResult DeserializeListIndexesResult(JsonElement element) + 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(ListIndexesResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Indexes) + { + 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 + } + } + } + + ListIndexesResult 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(ListIndexesResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeListIndexesResult(document.RootElement, options); + } + + internal static ListIndexesResult DeserializeListIndexesResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } IReadOnlyList value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value"u8)) @@ -26,15 +91,51 @@ internal static ListIndexesResult DeserializeListIndexesResult(JsonElement eleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SearchIndex.DeserializeSearchIndex(item)); + array.Add(SearchIndex.DeserializeSearchIndex(item, options)); } value = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ListIndexesResult(value, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ListIndexesResult)} does not support writing '{options.Format}' format."); } - return new ListIndexesResult(value); } + ListIndexesResult 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 DeserializeListIndexesResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ListIndexesResult)} 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 ListIndexesResult FromResponse(Response response) @@ -42,5 +143,13 @@ internal static ListIndexesResult FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeListIndexesResult(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/search/Azure.Search.Documents/src/Generated/Models/ListIndexesResult.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexesResult.cs index 323d24fc4181..42d07c516ba4 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexesResult.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListIndexesResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using System.Linq; @@ -13,6 +14,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Response from a List Indexes request. If successful, it includes the full definitions of all indexes. internal partial class ListIndexesResult { + /// + /// 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 . /// The indexes in the Search service. internal ListIndexesResult(IEnumerable indexes) @@ -22,9 +55,16 @@ internal ListIndexesResult(IEnumerable indexes) /// Initializes a new instance of . /// The indexes in the Search service. - internal ListIndexesResult(IReadOnlyList indexes) + /// Keeps track of any properties unknown to the library. + internal ListIndexesResult(IReadOnlyList indexes, IDictionary serializedAdditionalRawData) { Indexes = indexes; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ListIndexesResult() + { } /// The indexes in the Search service. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListKnowledgeAgentsResult.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListKnowledgeAgentsResult.Serialization.cs index 385c76c7feca..7fd11cf8fbed 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListKnowledgeAgentsResult.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListKnowledgeAgentsResult.Serialization.cs @@ -5,20 +5,82 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - internal partial class ListKnowledgeAgentsResult + internal partial class ListKnowledgeAgentsResult : IUtf8JsonSerializable, IJsonModel { - internal static ListKnowledgeAgentsResult DeserializeListKnowledgeAgentsResult(JsonElement element) + 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(ListKnowledgeAgentsResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in KnowledgeAgents) + { + 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 + } + } + } + + ListKnowledgeAgentsResult 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(ListKnowledgeAgentsResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeListKnowledgeAgentsResult(document.RootElement, options); + } + + internal static ListKnowledgeAgentsResult DeserializeListKnowledgeAgentsResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } IReadOnlyList value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value"u8)) @@ -26,15 +88,51 @@ internal static ListKnowledgeAgentsResult DeserializeListKnowledgeAgentsResult(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(KnowledgeAgent.DeserializeKnowledgeAgent(item)); + array.Add(KnowledgeAgent.DeserializeKnowledgeAgent(item, options)); } value = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ListKnowledgeAgentsResult(value, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ListKnowledgeAgentsResult)} does not support writing '{options.Format}' format."); + } + } + + ListKnowledgeAgentsResult 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 DeserializeListKnowledgeAgentsResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ListKnowledgeAgentsResult)} does not support reading '{options.Format}' format."); } - return new ListKnowledgeAgentsResult(value); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static ListKnowledgeAgentsResult FromResponse(Response response) @@ -42,5 +140,13 @@ internal static ListKnowledgeAgentsResult FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeListKnowledgeAgentsResult(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/search/Azure.Search.Documents/src/Generated/Models/ListKnowledgeAgentsResult.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListKnowledgeAgentsResult.cs index c1900d566b28..39cadc23fb85 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListKnowledgeAgentsResult.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListKnowledgeAgentsResult.cs @@ -14,6 +14,38 @@ namespace Azure.Search.Documents.Indexes.Models /// The ListKnowledgeAgentsResult. internal partial class ListKnowledgeAgentsResult { + /// + /// 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 . /// /// is null. @@ -26,9 +58,16 @@ internal ListKnowledgeAgentsResult(IEnumerable knowledgeAgents) /// Initializes a new instance of . /// - internal ListKnowledgeAgentsResult(IReadOnlyList knowledgeAgents) + /// Keeps track of any properties unknown to the library. + internal ListKnowledgeAgentsResult(IReadOnlyList knowledgeAgents, IDictionary serializedAdditionalRawData) { KnowledgeAgents = knowledgeAgents; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ListKnowledgeAgentsResult() + { } /// Gets the knowledge agents. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListSkillsetsResult.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListSkillsetsResult.Serialization.cs index 586f28a3adca..55c39eda0e43 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListSkillsetsResult.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListSkillsetsResult.Serialization.cs @@ -5,20 +5,85 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - internal partial class ListSkillsetsResult + internal partial class ListSkillsetsResult : IUtf8JsonSerializable, IJsonModel { - internal static ListSkillsetsResult DeserializeListSkillsetsResult(JsonElement element) + 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(ListSkillsetsResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Skillsets) + { + 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 + } + } + } + + ListSkillsetsResult 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(ListSkillsetsResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeListSkillsetsResult(document.RootElement, options); + } + + internal static ListSkillsetsResult DeserializeListSkillsetsResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } IReadOnlyList value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value"u8)) @@ -26,15 +91,51 @@ internal static ListSkillsetsResult DeserializeListSkillsetsResult(JsonElement e List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SearchIndexerSkillset.DeserializeSearchIndexerSkillset(item)); + array.Add(SearchIndexerSkillset.DeserializeSearchIndexerSkillset(item, options)); } value = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ListSkillsetsResult(value, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ListSkillsetsResult)} does not support writing '{options.Format}' format."); } - return new ListSkillsetsResult(value); } + ListSkillsetsResult 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 DeserializeListSkillsetsResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ListSkillsetsResult)} 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 ListSkillsetsResult FromResponse(Response response) @@ -42,5 +143,13 @@ internal static ListSkillsetsResult FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeListSkillsetsResult(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/search/Azure.Search.Documents/src/Generated/Models/ListSkillsetsResult.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListSkillsetsResult.cs index aae21ff90fb6..9e72aec2e703 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListSkillsetsResult.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListSkillsetsResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using System.Linq; @@ -13,6 +14,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Response from a list skillset request. If successful, it includes the full definitions of all skillsets. internal partial class ListSkillsetsResult { + /// + /// 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 . /// The skillsets defined in the Search service. internal ListSkillsetsResult(IEnumerable skillsets) @@ -22,9 +55,16 @@ internal ListSkillsetsResult(IEnumerable skillsets) /// Initializes a new instance of . /// The skillsets defined in the Search service. - internal ListSkillsetsResult(IReadOnlyList skillsets) + /// Keeps track of any properties unknown to the library. + internal ListSkillsetsResult(IReadOnlyList skillsets, IDictionary serializedAdditionalRawData) { Skillsets = skillsets; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ListSkillsetsResult() + { } /// The skillsets defined in the Search service. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListSynonymMapsResult.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListSynonymMapsResult.Serialization.cs index 07d410387fab..d08acee75f96 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListSynonymMapsResult.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListSynonymMapsResult.Serialization.cs @@ -5,20 +5,85 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - internal partial class ListSynonymMapsResult + internal partial class ListSynonymMapsResult : IUtf8JsonSerializable, IJsonModel { - internal static ListSynonymMapsResult DeserializeListSynonymMapsResult(JsonElement element) + 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(ListSynonymMapsResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in SynonymMaps) + { + 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 + } + } + } + + ListSynonymMapsResult 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(ListSynonymMapsResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeListSynonymMapsResult(document.RootElement, options); + } + + internal static ListSynonymMapsResult DeserializeListSynonymMapsResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } IReadOnlyList value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value"u8)) @@ -26,15 +91,51 @@ internal static ListSynonymMapsResult DeserializeListSynonymMapsResult(JsonEleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SynonymMap.DeserializeSynonymMap(item)); + array.Add(SynonymMap.DeserializeSynonymMap(item, options)); } value = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ListSynonymMapsResult(value, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ListSynonymMapsResult)} does not support writing '{options.Format}' format."); } - return new ListSynonymMapsResult(value); } + ListSynonymMapsResult 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 DeserializeListSynonymMapsResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ListSynonymMapsResult)} 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 ListSynonymMapsResult FromResponse(Response response) @@ -42,5 +143,13 @@ internal static ListSynonymMapsResult FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeListSynonymMapsResult(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/search/Azure.Search.Documents/src/Generated/Models/ListSynonymMapsResult.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListSynonymMapsResult.cs index 7374791d2d65..0c275bee8c16 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ListSynonymMapsResult.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ListSynonymMapsResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using System.Linq; @@ -13,6 +14,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Response from a List SynonymMaps request. If successful, it includes the full definitions of all synonym maps. internal partial class ListSynonymMapsResult { + /// + /// 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 . /// The synonym maps in the Search service. internal ListSynonymMapsResult(IEnumerable synonymMaps) @@ -22,9 +55,16 @@ internal ListSynonymMapsResult(IEnumerable synonymMaps) /// Initializes a new instance of . /// The synonym maps in the Search service. - internal ListSynonymMapsResult(IReadOnlyList synonymMaps) + /// Keeps track of any properties unknown to the library. + internal ListSynonymMapsResult(IReadOnlyList synonymMaps, IDictionary serializedAdditionalRawData) { SynonymMaps = synonymMaps; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ListSynonymMapsResult() + { } /// The synonym maps in the Search service. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardAnalyzer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardAnalyzer.Serialization.cs index 61433b095e65..acb7589150bb 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardAnalyzer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardAnalyzer.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class LuceneStandardAnalyzer : IUtf8JsonSerializable + public partial class LuceneStandardAnalyzer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(LuceneStandardAnalyzer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(MaxTokenLength)) { writer.WritePropertyName("maxTokenLength"u8); @@ -31,15 +50,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WriteEndArray(); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static LuceneStandardAnalyzer DeserializeLuceneStandardAnalyzer(JsonElement element) + LuceneStandardAnalyzer 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(LuceneStandardAnalyzer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLuceneStandardAnalyzer(document.RootElement, options); + } + + internal static LuceneStandardAnalyzer DeserializeLuceneStandardAnalyzer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -48,6 +76,8 @@ internal static LuceneStandardAnalyzer DeserializeLuceneStandardAnalyzer(JsonEle IList stopwords = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("maxTokenLength"u8)) @@ -83,10 +113,46 @@ internal static LuceneStandardAnalyzer DeserializeLuceneStandardAnalyzer(JsonEle name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new LuceneStandardAnalyzer(odataType, name, serializedAdditionalRawData, maxTokenLength, stopwords ?? new ChangeTrackingList()); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(LuceneStandardAnalyzer)} does not support writing '{options.Format}' format."); + } + } + + LuceneStandardAnalyzer 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 DeserializeLuceneStandardAnalyzer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LuceneStandardAnalyzer)} does not support reading '{options.Format}' format."); } - return new LuceneStandardAnalyzer(odataType, name, maxTokenLength, stopwords ?? new ChangeTrackingList()); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new LuceneStandardAnalyzer FromResponse(Response response) @@ -99,7 +165,7 @@ internal static LuceneStandardAnalyzer DeserializeLuceneStandardAnalyzer(JsonEle internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardAnalyzer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardAnalyzer.cs index 0f822d6248b0..3c4d693a74b4 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardAnalyzer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardAnalyzer.cs @@ -27,15 +27,21 @@ public LuceneStandardAnalyzer(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of analyzer. /// The name of the analyzer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The maximum token length. Default is 255. Tokens longer than the maximum length are split. The maximum token length that can be used is 300 characters. /// A list of stopwords. - internal LuceneStandardAnalyzer(string oDataType, string name, int? maxTokenLength, IList stopwords) : base(oDataType, name) + internal LuceneStandardAnalyzer(string oDataType, string name, IDictionary serializedAdditionalRawData, int? maxTokenLength, IList stopwords) : base(oDataType, name, serializedAdditionalRawData) { MaxTokenLength = maxTokenLength; Stopwords = stopwords; ODataType = oDataType ?? "#Microsoft.Azure.Search.StandardAnalyzer"; } + /// Initializes a new instance of for deserialization. + internal LuceneStandardAnalyzer() + { + } + /// The maximum token length. Default is 255. Tokens longer than the maximum length are split. The maximum token length that can be used is 300 characters. public int? MaxTokenLength { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizer.Serialization.cs index 31d8d1db1ed6..e4435c6e6aef 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizer.Serialization.cs @@ -5,13 +5,127 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class LuceneStandardTokenizer : IUtf8JsonSerializable + public partial class LuceneStandardTokenizer : IUtf8JsonSerializable, IJsonModel { + 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(LuceneStandardTokenizer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(MaxTokenLength)) + { + writer.WritePropertyName("maxTokenLength"u8); + writer.WriteNumberValue(MaxTokenLength.Value); + } + } + + LuceneStandardTokenizer 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(LuceneStandardTokenizer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLuceneStandardTokenizer(document.RootElement, options); + } + + internal static LuceneStandardTokenizer DeserializeLuceneStandardTokenizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? maxTokenLength = default; + string odataType = default; + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("maxTokenLength"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxTokenLength = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("@odata.type"u8)) + { + odataType = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new LuceneStandardTokenizer(odataType, name, serializedAdditionalRawData, maxTokenLength); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(LuceneStandardTokenizer)} does not support writing '{options.Format}' format."); + } + } + + LuceneStandardTokenizer 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 DeserializeLuceneStandardTokenizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LuceneStandardTokenizer)} 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 LuceneStandardTokenizer FromResponse(Response response) @@ -24,7 +138,7 @@ public partial class LuceneStandardTokenizer : IUtf8JsonSerializable internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizer.cs index 823541f9e403..21329d3fa998 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizer.cs @@ -6,11 +6,27 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Breaks text following the Unicode Text Segmentation rules. This tokenizer is implemented using Apache Lucene. public partial class LuceneStandardTokenizer : LexicalTokenizer { + /// Initializes a new instance of . + /// A URI fragment specifying the type of tokenizer. + /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. + /// The maximum token length. Default is 255. Tokens longer than the maximum length are split. The maximum token length that can be used is 300 characters. + internal LuceneStandardTokenizer(string oDataType, string name, IDictionary serializedAdditionalRawData, int? maxTokenLength) : base(oDataType, name, serializedAdditionalRawData) + { + MaxTokenLength = maxTokenLength; + ODataType = oDataType ?? "#Microsoft.Azure.Search.StandardTokenizerV2"; + } + + /// Initializes a new instance of for deserialization. + internal LuceneStandardTokenizer() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/MagnitudeScoringFunction.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/MagnitudeScoringFunction.Serialization.cs index db8a124e1c57..fb1779dedfb2 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/MagnitudeScoringFunction.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/MagnitudeScoringFunction.Serialization.cs @@ -5,34 +5,56 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class MagnitudeScoringFunction : IUtf8JsonSerializable + public partial class MagnitudeScoringFunction : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(MagnitudeScoringFunction)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("magnitude"u8); - writer.WriteObjectValue(Parameters); - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - writer.WritePropertyName("fieldName"u8); - writer.WriteStringValue(FieldName); - writer.WritePropertyName("boost"u8); - writer.WriteNumberValue(Boost); - if (Optional.IsDefined(Interpolation)) + writer.WriteObjectValue(Parameters, options); + } + + MagnitudeScoringFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WritePropertyName("interpolation"u8); - writer.WriteStringValue(Interpolation.Value.ToSerialString()); + throw new FormatException($"The model {nameof(MagnitudeScoringFunction)} does not support reading '{format}' format."); } - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMagnitudeScoringFunction(document.RootElement, options); } - internal static MagnitudeScoringFunction DeserializeMagnitudeScoringFunction(JsonElement element) + internal static MagnitudeScoringFunction DeserializeMagnitudeScoringFunction(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -42,11 +64,13 @@ internal static MagnitudeScoringFunction DeserializeMagnitudeScoringFunction(Jso string fieldName = default; double boost = default; ScoringFunctionInterpolation? interpolation = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("magnitude"u8)) { - magnitude = MagnitudeScoringParameters.DeserializeMagnitudeScoringParameters(property.Value); + magnitude = MagnitudeScoringParameters.DeserializeMagnitudeScoringParameters(property.Value, options); continue; } if (property.NameEquals("type"u8)) @@ -73,10 +97,52 @@ internal static MagnitudeScoringFunction DeserializeMagnitudeScoringFunction(Jso interpolation = property.Value.GetString().ToScoringFunctionInterpolation(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new MagnitudeScoringFunction(type, fieldName, boost, interpolation, magnitude); + serializedAdditionalRawData = rawDataDictionary; + return new MagnitudeScoringFunction( + type, + fieldName, + boost, + interpolation, + serializedAdditionalRawData, + magnitude); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(MagnitudeScoringFunction)} does not support writing '{options.Format}' format."); + } + } + + MagnitudeScoringFunction 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 DeserializeMagnitudeScoringFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MagnitudeScoringFunction)} 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 MagnitudeScoringFunction FromResponse(Response response) @@ -89,7 +155,7 @@ internal static MagnitudeScoringFunction DeserializeMagnitudeScoringFunction(Jso internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/MagnitudeScoringFunction.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/MagnitudeScoringFunction.cs index e3eb898e2fe6..23ec82c9be2f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/MagnitudeScoringFunction.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/MagnitudeScoringFunction.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -17,13 +18,19 @@ public partial class MagnitudeScoringFunction : ScoringFunction /// The name of the field used as input to the scoring function. /// A multiplier for the raw score. Must be a positive number not equal to 1.0. /// A value indicating how boosting will be interpolated across document scores; defaults to "Linear". + /// Keeps track of any properties unknown to the library. /// Parameter values for the magnitude scoring function. - internal MagnitudeScoringFunction(string type, string fieldName, double boost, ScoringFunctionInterpolation? interpolation, MagnitudeScoringParameters parameters) : base(type, fieldName, boost, interpolation) + internal MagnitudeScoringFunction(string type, string fieldName, double boost, ScoringFunctionInterpolation? interpolation, IDictionary serializedAdditionalRawData, MagnitudeScoringParameters parameters) : base(type, fieldName, boost, interpolation, serializedAdditionalRawData) { Parameters = parameters; Type = type ?? "magnitude"; } + /// Initializes a new instance of for deserialization. + internal MagnitudeScoringFunction() + { + } + /// Parameter values for the magnitude scoring function. public MagnitudeScoringParameters Parameters { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/MagnitudeScoringParameters.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/MagnitudeScoringParameters.Serialization.cs index 4870165a6f1c..8bf24beacccf 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/MagnitudeScoringParameters.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/MagnitudeScoringParameters.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class MagnitudeScoringParameters : IUtf8JsonSerializable + public partial class MagnitudeScoringParameters : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(MagnitudeScoringParameters)} does not support writing '{format}' format."); + } + writer.WritePropertyName("boostingRangeStart"u8); writer.WriteNumberValue(BoostingRangeStart); writer.WritePropertyName("boostingRangeEnd"u8); @@ -24,11 +43,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("constantBoostBeyondRange"u8); writer.WriteBooleanValue(ShouldBoostBeyondRangeByConstant.Value); } - writer.WriteEndObject(); + 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 + } + } } - internal static MagnitudeScoringParameters DeserializeMagnitudeScoringParameters(JsonElement element) + MagnitudeScoringParameters 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(MagnitudeScoringParameters)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMagnitudeScoringParameters(document.RootElement, options); + } + + internal static MagnitudeScoringParameters DeserializeMagnitudeScoringParameters(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -36,6 +83,8 @@ internal static MagnitudeScoringParameters DeserializeMagnitudeScoringParameters double boostingRangeStart = default; double boostingRangeEnd = default; bool? constantBoostBeyondRange = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("boostingRangeStart"u8)) @@ -57,10 +106,46 @@ internal static MagnitudeScoringParameters DeserializeMagnitudeScoringParameters constantBoostBeyondRange = property.Value.GetBoolean(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MagnitudeScoringParameters(boostingRangeStart, boostingRangeEnd, constantBoostBeyondRange, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(MagnitudeScoringParameters)} does not support writing '{options.Format}' format."); } - return new MagnitudeScoringParameters(boostingRangeStart, boostingRangeEnd, constantBoostBeyondRange); } + MagnitudeScoringParameters 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 DeserializeMagnitudeScoringParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MagnitudeScoringParameters)} 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 MagnitudeScoringParameters FromResponse(Response response) @@ -73,7 +158,7 @@ internal static MagnitudeScoringParameters FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/MagnitudeScoringParameters.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/MagnitudeScoringParameters.cs index b838605f7a74..1e94cede7e12 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/MagnitudeScoringParameters.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/MagnitudeScoringParameters.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Provides parameter values to a magnitude scoring function. public partial class MagnitudeScoringParameters { + /// + /// 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 . /// The field value at which boosting starts. /// The field value at which boosting ends. @@ -23,11 +58,18 @@ public MagnitudeScoringParameters(double boostingRangeStart, double boostingRang /// The field value at which boosting starts. /// The field value at which boosting ends. /// A value indicating whether to apply a constant boost for field values beyond the range end value; default is false. - internal MagnitudeScoringParameters(double boostingRangeStart, double boostingRangeEnd, bool? shouldBoostBeyondRangeByConstant) + /// Keeps track of any properties unknown to the library. + internal MagnitudeScoringParameters(double boostingRangeStart, double boostingRangeEnd, bool? shouldBoostBeyondRangeByConstant, IDictionary serializedAdditionalRawData) { BoostingRangeStart = boostingRangeStart; BoostingRangeEnd = boostingRangeEnd; ShouldBoostBeyondRangeByConstant = shouldBoostBeyondRangeByConstant; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MagnitudeScoringParameters() + { } /// The field value at which boosting starts. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/MappingCharFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/MappingCharFilter.Serialization.cs index f2b503b4023d..1fb4474be28c 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/MappingCharFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/MappingCharFilter.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class MappingCharFilter : IUtf8JsonSerializable + public partial class MappingCharFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(MappingCharFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("mappings"u8); writer.WriteStartArray(); foreach (var item in Mappings) @@ -23,15 +42,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStringValue(item); } writer.WriteEndArray(); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static MappingCharFilter DeserializeMappingCharFilter(JsonElement element) + MappingCharFilter 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(MappingCharFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMappingCharFilter(document.RootElement, options); + } + + internal static MappingCharFilter DeserializeMappingCharFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -39,6 +67,8 @@ internal static MappingCharFilter DeserializeMappingCharFilter(JsonElement eleme IList mappings = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("mappings"u8)) @@ -61,10 +91,46 @@ internal static MappingCharFilter DeserializeMappingCharFilter(JsonElement eleme name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MappingCharFilter(odataType, name, serializedAdditionalRawData, mappings); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(MappingCharFilter)} does not support writing '{options.Format}' format."); + } + } + + MappingCharFilter 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 DeserializeMappingCharFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MappingCharFilter)} does not support reading '{options.Format}' format."); } - return new MappingCharFilter(odataType, name, mappings); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new MappingCharFilter FromResponse(Response response) @@ -77,7 +143,7 @@ internal static MappingCharFilter DeserializeMappingCharFilter(JsonElement eleme internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/MappingCharFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/MappingCharFilter.cs index 14598cafd754..754a8056a2d2 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/MappingCharFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/MappingCharFilter.cs @@ -30,11 +30,17 @@ public MappingCharFilter(string name, IEnumerable mappings) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of char filter. /// The name of the char filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// A list of mappings of the following format: "a=>b" (all occurrences of the character "a" will be replaced with character "b"). - internal MappingCharFilter(string oDataType, string name, IList mappings) : base(oDataType, name) + internal MappingCharFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, IList mappings) : base(oDataType, name, serializedAdditionalRawData) { Mappings = mappings; ODataType = oDataType ?? "#Microsoft.Azure.Search.MappingCharFilter"; } + + /// Initializes a new instance of for deserialization. + internal MappingCharFilter() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/MergeSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/MergeSkill.Serialization.cs index 405b7a8d5eb8..fa696790f12e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/MergeSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/MergeSkill.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class MergeSkill : IUtf8JsonSerializable + public partial class MergeSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(MergeSkill)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(InsertPreTag)) { writer.WritePropertyName("insertPreTag"u8); @@ -26,42 +45,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("insertPostTag"u8); writer.WriteStringValue(InsertPostTag); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + MergeSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(MergeSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMergeSkill(document.RootElement, options); } - internal static MergeSkill DeserializeMergeSkill(JsonElement element) + internal static MergeSkill DeserializeMergeSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -74,6 +75,8 @@ internal static MergeSkill DeserializeMergeSkill(JsonElement element) string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("insertPreTag"u8)) @@ -111,7 +114,7 @@ internal static MergeSkill DeserializeMergeSkill(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -121,12 +124,17 @@ internal static MergeSkill DeserializeMergeSkill(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new MergeSkill( odataType, name, @@ -134,10 +142,42 @@ internal static MergeSkill DeserializeMergeSkill(JsonElement element) context, inputs, outputs, + serializedAdditionalRawData, insertPreTag, insertPostTag); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(MergeSkill)} does not support writing '{options.Format}' format."); + } + } + + MergeSkill 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 DeserializeMergeSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MergeSkill)} 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 MergeSkill FromResponse(Response response) @@ -150,7 +190,7 @@ internal static MergeSkill DeserializeMergeSkill(JsonElement element) internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/MergeSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/MergeSkill.cs index 801f0e9eba9a..da598d8fe665 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/MergeSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/MergeSkill.cs @@ -32,15 +32,21 @@ public MergeSkill(IEnumerable inputs, IEnumerable Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// The tag indicates the start of the merged text. By default, the tag is an empty space. /// The tag indicates the end of the merged text. By default, the tag is an empty space. - internal MergeSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, string insertPreTag, string insertPostTag) : base(oDataType, name, description, context, inputs, outputs) + internal MergeSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, string insertPreTag, string insertPostTag) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { InsertPreTag = insertPreTag; InsertPostTag = insertPostTag; ODataType = oDataType ?? "#Microsoft.Skills.Text.MergeSkill"; } + /// Initializes a new instance of for deserialization. + internal MergeSkill() + { + } + /// The tag indicates the start of the merged text. By default, the tag is an empty space. public string InsertPreTag { get; set; } /// The tag indicates the end of the merged text. By default, the tag is an empty space. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/MicrosoftLanguageStemmingTokenizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/MicrosoftLanguageStemmingTokenizer.Serialization.cs index 7542955042f6..6bfa266fe40f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/MicrosoftLanguageStemmingTokenizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/MicrosoftLanguageStemmingTokenizer.Serialization.cs @@ -5,16 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class MicrosoftLanguageStemmingTokenizer : IUtf8JsonSerializable + public partial class MicrosoftLanguageStemmingTokenizer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(MicrosoftLanguageStemmingTokenizer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(MaxTokenLength)) { writer.WritePropertyName("maxTokenLength"u8); @@ -30,15 +50,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("language"u8); writer.WriteStringValue(Language.Value.ToSerialString()); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static MicrosoftLanguageStemmingTokenizer DeserializeMicrosoftLanguageStemmingTokenizer(JsonElement element) + MicrosoftLanguageStemmingTokenizer 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(MicrosoftLanguageStemmingTokenizer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMicrosoftLanguageStemmingTokenizer(document.RootElement, options); + } + + internal static MicrosoftLanguageStemmingTokenizer DeserializeMicrosoftLanguageStemmingTokenizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -48,6 +77,8 @@ internal static MicrosoftLanguageStemmingTokenizer DeserializeMicrosoftLanguageS MicrosoftStemmingTokenizerLanguage? language = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("maxTokenLength"u8)) @@ -87,10 +118,52 @@ internal static MicrosoftLanguageStemmingTokenizer DeserializeMicrosoftLanguageS name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MicrosoftLanguageStemmingTokenizer( + odataType, + name, + serializedAdditionalRawData, + maxTokenLength, + isSearchTokenizer, + language); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(MicrosoftLanguageStemmingTokenizer)} does not support writing '{options.Format}' format."); + } + } + + MicrosoftLanguageStemmingTokenizer 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 DeserializeMicrosoftLanguageStemmingTokenizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MicrosoftLanguageStemmingTokenizer)} does not support reading '{options.Format}' format."); } - return new MicrosoftLanguageStemmingTokenizer(odataType, name, maxTokenLength, isSearchTokenizer, language); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new MicrosoftLanguageStemmingTokenizer FromResponse(Response response) @@ -103,7 +176,7 @@ internal static MicrosoftLanguageStemmingTokenizer DeserializeMicrosoftLanguageS internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/MicrosoftLanguageStemmingTokenizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/MicrosoftLanguageStemmingTokenizer.cs index 60f00ae9d371..b5ec659cf1b0 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/MicrosoftLanguageStemmingTokenizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/MicrosoftLanguageStemmingTokenizer.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,10 +26,11 @@ public MicrosoftLanguageStemmingTokenizer(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of tokenizer. /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The maximum token length. Tokens longer than the maximum length are split. Maximum token length that can be used is 300 characters. Tokens longer than 300 characters are first split into tokens of length 300 and then each of those tokens is split based on the max token length set. Default is 255. /// A value indicating how the tokenizer is used. Set to true if used as the search tokenizer, set to false if used as the indexing tokenizer. Default is false. /// The language to use. The default is English. - internal MicrosoftLanguageStemmingTokenizer(string oDataType, string name, int? maxTokenLength, bool? isSearchTokenizer, MicrosoftStemmingTokenizerLanguage? language) : base(oDataType, name) + internal MicrosoftLanguageStemmingTokenizer(string oDataType, string name, IDictionary serializedAdditionalRawData, int? maxTokenLength, bool? isSearchTokenizer, MicrosoftStemmingTokenizerLanguage? language) : base(oDataType, name, serializedAdditionalRawData) { MaxTokenLength = maxTokenLength; IsSearchTokenizer = isSearchTokenizer; @@ -36,6 +38,11 @@ internal MicrosoftLanguageStemmingTokenizer(string oDataType, string name, int? ODataType = oDataType ?? "#Microsoft.Azure.Search.MicrosoftLanguageStemmingTokenizer"; } + /// Initializes a new instance of for deserialization. + internal MicrosoftLanguageStemmingTokenizer() + { + } + /// The maximum token length. Tokens longer than the maximum length are split. Maximum token length that can be used is 300 characters. Tokens longer than 300 characters are first split into tokens of length 300 and then each of those tokens is split based on the max token length set. Default is 255. public int? MaxTokenLength { get; set; } /// A value indicating how the tokenizer is used. Set to true if used as the search tokenizer, set to false if used as the indexing tokenizer. Default is false. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/MicrosoftLanguageTokenizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/MicrosoftLanguageTokenizer.Serialization.cs index 7053ccd820ec..188d8a8620b1 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/MicrosoftLanguageTokenizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/MicrosoftLanguageTokenizer.Serialization.cs @@ -5,16 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class MicrosoftLanguageTokenizer : IUtf8JsonSerializable + public partial class MicrosoftLanguageTokenizer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(MicrosoftLanguageTokenizer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(MaxTokenLength)) { writer.WritePropertyName("maxTokenLength"u8); @@ -30,15 +50,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("language"u8); writer.WriteStringValue(Language.Value.ToSerialString()); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static MicrosoftLanguageTokenizer DeserializeMicrosoftLanguageTokenizer(JsonElement element) + MicrosoftLanguageTokenizer 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(MicrosoftLanguageTokenizer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMicrosoftLanguageTokenizer(document.RootElement, options); + } + + internal static MicrosoftLanguageTokenizer DeserializeMicrosoftLanguageTokenizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -48,6 +77,8 @@ internal static MicrosoftLanguageTokenizer DeserializeMicrosoftLanguageTokenizer MicrosoftTokenizerLanguage? language = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("maxTokenLength"u8)) @@ -87,10 +118,52 @@ internal static MicrosoftLanguageTokenizer DeserializeMicrosoftLanguageTokenizer name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MicrosoftLanguageTokenizer( + odataType, + name, + serializedAdditionalRawData, + maxTokenLength, + isSearchTokenizer, + language); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(MicrosoftLanguageTokenizer)} does not support writing '{options.Format}' format."); + } + } + + MicrosoftLanguageTokenizer 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 DeserializeMicrosoftLanguageTokenizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MicrosoftLanguageTokenizer)} does not support reading '{options.Format}' format."); } - return new MicrosoftLanguageTokenizer(odataType, name, maxTokenLength, isSearchTokenizer, language); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new MicrosoftLanguageTokenizer FromResponse(Response response) @@ -103,7 +176,7 @@ internal static MicrosoftLanguageTokenizer DeserializeMicrosoftLanguageTokenizer internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/MicrosoftLanguageTokenizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/MicrosoftLanguageTokenizer.cs index 44e38f47db40..133aba3086b2 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/MicrosoftLanguageTokenizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/MicrosoftLanguageTokenizer.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,10 +26,11 @@ public MicrosoftLanguageTokenizer(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of tokenizer. /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The maximum token length. Tokens longer than the maximum length are split. Maximum token length that can be used is 300 characters. Tokens longer than 300 characters are first split into tokens of length 300 and then each of those tokens is split based on the max token length set. Default is 255. /// A value indicating how the tokenizer is used. Set to true if used as the search tokenizer, set to false if used as the indexing tokenizer. Default is false. /// The language to use. The default is English. - internal MicrosoftLanguageTokenizer(string oDataType, string name, int? maxTokenLength, bool? isSearchTokenizer, MicrosoftTokenizerLanguage? language) : base(oDataType, name) + internal MicrosoftLanguageTokenizer(string oDataType, string name, IDictionary serializedAdditionalRawData, int? maxTokenLength, bool? isSearchTokenizer, MicrosoftTokenizerLanguage? language) : base(oDataType, name, serializedAdditionalRawData) { MaxTokenLength = maxTokenLength; IsSearchTokenizer = isSearchTokenizer; @@ -36,6 +38,11 @@ internal MicrosoftLanguageTokenizer(string oDataType, string name, int? maxToken ODataType = oDataType ?? "#Microsoft.Azure.Search.MicrosoftLanguageTokenizer"; } + /// Initializes a new instance of for deserialization. + internal MicrosoftLanguageTokenizer() + { + } + /// The maximum token length. Tokens longer than the maximum length are split. Maximum token length that can be used is 300 characters. Tokens longer than 300 characters are first split into tokens of length 300 and then each of those tokens is split based on the max token length set. Default is 255. public int? MaxTokenLength { get; set; } /// A value indicating how the tokenizer is used. Set to true if used as the search tokenizer, set to false if used as the indexing tokenizer. Default is false. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilter.Serialization.cs index 1c337ea49060..a5bc288652e1 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilter.Serialization.cs @@ -5,13 +5,142 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class NGramTokenFilter : IUtf8JsonSerializable + public partial class NGramTokenFilter : IUtf8JsonSerializable, IJsonModel { + 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(NGramTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(MinGram)) + { + writer.WritePropertyName("minGram"u8); + writer.WriteNumberValue(MinGram.Value); + } + if (Optional.IsDefined(MaxGram)) + { + writer.WritePropertyName("maxGram"u8); + writer.WriteNumberValue(MaxGram.Value); + } + } + + NGramTokenFilter 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(NGramTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNGramTokenFilter(document.RootElement, options); + } + + internal static NGramTokenFilter DeserializeNGramTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? minGram = default; + int? maxGram = default; + string odataType = default; + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("minGram"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + minGram = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("maxGram"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxGram = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("@odata.type"u8)) + { + odataType = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NGramTokenFilter(odataType, name, serializedAdditionalRawData, minGram, maxGram); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(NGramTokenFilter)} does not support writing '{options.Format}' format."); + } + } + + NGramTokenFilter 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 DeserializeNGramTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NGramTokenFilter)} 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 NGramTokenFilter FromResponse(Response response) @@ -24,7 +153,7 @@ public partial class NGramTokenFilter : IUtf8JsonSerializable internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilter.cs index 423858fa3c89..acc9c9d31726 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilter.cs @@ -6,11 +6,29 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Generates n-grams of the given size(s). This token filter is implemented using Apache Lucene. public partial class NGramTokenFilter : TokenFilter { + /// Initializes a new instance of . + /// A URI fragment specifying the type of token filter. + /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. + /// The minimum n-gram length. Default is 1. Maximum is 300. Must be less than the value of maxGram. + /// The maximum n-gram length. Default is 2. Maximum is 300. + internal NGramTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, int? minGram, int? maxGram) : base(oDataType, name, serializedAdditionalRawData) + { + MinGram = minGram; + MaxGram = maxGram; + ODataType = oDataType ?? "#Microsoft.Azure.Search.NGramTokenFilterV2"; + } + + /// Initializes a new instance of for deserialization. + internal NGramTokenFilter() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenizer.Serialization.cs index 6ba59a63e9f9..3827a9973aa6 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenizer.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class NGramTokenizer : IUtf8JsonSerializable + public partial class NGramTokenizer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(NGramTokenizer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(MinGram)) { writer.WritePropertyName("minGram"u8); @@ -36,15 +55,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WriteEndArray(); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static NGramTokenizer DeserializeNGramTokenizer(JsonElement element) + NGramTokenizer 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(NGramTokenizer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNGramTokenizer(document.RootElement, options); + } + + internal static NGramTokenizer DeserializeNGramTokenizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -54,6 +82,8 @@ internal static NGramTokenizer DeserializeNGramTokenizer(JsonElement element) IList tokenChars = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("minGram"u8)) @@ -98,10 +128,52 @@ internal static NGramTokenizer DeserializeNGramTokenizer(JsonElement element) name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NGramTokenizer( + odataType, + name, + serializedAdditionalRawData, + minGram, + maxGram, + tokenChars ?? new ChangeTrackingList()); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(NGramTokenizer)} does not support writing '{options.Format}' format."); + } + } + + NGramTokenizer 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 DeserializeNGramTokenizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NGramTokenizer)} does not support reading '{options.Format}' format."); } - return new NGramTokenizer(odataType, name, minGram, maxGram, tokenChars ?? new ChangeTrackingList()); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new NGramTokenizer FromResponse(Response response) @@ -114,7 +186,7 @@ internal static NGramTokenizer DeserializeNGramTokenizer(JsonElement element) internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenizer.cs index 5b43dc4e8d67..8481b6688ece 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenizer.cs @@ -27,10 +27,11 @@ public NGramTokenizer(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of tokenizer. /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The minimum n-gram length. Default is 1. Maximum is 300. Must be less than the value of maxGram. /// The maximum n-gram length. Default is 2. Maximum is 300. /// Character classes to keep in the tokens. - internal NGramTokenizer(string oDataType, string name, int? minGram, int? maxGram, IList tokenChars) : base(oDataType, name) + internal NGramTokenizer(string oDataType, string name, IDictionary serializedAdditionalRawData, int? minGram, int? maxGram, IList tokenChars) : base(oDataType, name, serializedAdditionalRawData) { MinGram = minGram; MaxGram = maxGram; @@ -38,6 +39,11 @@ internal NGramTokenizer(string oDataType, string name, int? minGram, int? maxGra ODataType = oDataType ?? "#Microsoft.Azure.Search.NGramTokenizer"; } + /// Initializes a new instance of for deserialization. + internal NGramTokenizer() + { + } + /// The minimum n-gram length. Default is 1. Maximum is 300. Must be less than the value of maxGram. public int? MinGram { get; set; } /// The maximum n-gram length. Default is 2. Maximum is 300. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/NativeBlobSoftDeleteDeletionDetectionPolicy.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/NativeBlobSoftDeleteDeletionDetectionPolicy.Serialization.cs index 251f91780504..78d17dc513ba 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/NativeBlobSoftDeleteDeletionDetectionPolicy.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/NativeBlobSoftDeleteDeletionDetectionPolicy.Serialization.cs @@ -5,28 +5,61 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class NativeBlobSoftDeleteDeletionDetectionPolicy : IUtf8JsonSerializable + public partial class NativeBlobSoftDeleteDeletionDetectionPolicy : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); + JsonModelWriteCore(writer, options); writer.WriteEndObject(); } - internal static NativeBlobSoftDeleteDeletionDetectionPolicy DeserializeNativeBlobSoftDeleteDeletionDetectionPolicy(JsonElement element) + /// 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(NativeBlobSoftDeleteDeletionDetectionPolicy)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + NativeBlobSoftDeleteDeletionDetectionPolicy 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(NativeBlobSoftDeleteDeletionDetectionPolicy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNativeBlobSoftDeleteDeletionDetectionPolicy(document.RootElement, options); + } + + internal static NativeBlobSoftDeleteDeletionDetectionPolicy DeserializeNativeBlobSoftDeleteDeletionDetectionPolicy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string odataType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@odata.type"u8)) @@ -34,10 +67,46 @@ internal static NativeBlobSoftDeleteDeletionDetectionPolicy DeserializeNativeBlo odataType = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NativeBlobSoftDeleteDeletionDetectionPolicy(odataType, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(NativeBlobSoftDeleteDeletionDetectionPolicy)} does not support writing '{options.Format}' format."); } - return new NativeBlobSoftDeleteDeletionDetectionPolicy(odataType); } + NativeBlobSoftDeleteDeletionDetectionPolicy 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 DeserializeNativeBlobSoftDeleteDeletionDetectionPolicy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NativeBlobSoftDeleteDeletionDetectionPolicy)} 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 NativeBlobSoftDeleteDeletionDetectionPolicy FromResponse(Response response) @@ -50,7 +119,7 @@ internal static NativeBlobSoftDeleteDeletionDetectionPolicy DeserializeNativeBlo internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/NativeBlobSoftDeleteDeletionDetectionPolicy.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/NativeBlobSoftDeleteDeletionDetectionPolicy.cs index 959cb8a79fcf..7b12efc8f3cb 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/NativeBlobSoftDeleteDeletionDetectionPolicy.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/NativeBlobSoftDeleteDeletionDetectionPolicy.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Defines a data deletion detection policy utilizing Azure Blob Storage's native soft delete feature for deletion detection. @@ -18,7 +21,8 @@ public NativeBlobSoftDeleteDeletionDetectionPolicy() /// Initializes a new instance of . /// A URI fragment specifying the type of data deletion detection policy. - internal NativeBlobSoftDeleteDeletionDetectionPolicy(string oDataType) : base(oDataType) + /// Keeps track of any properties unknown to the library. + internal NativeBlobSoftDeleteDeletionDetectionPolicy(string oDataType, IDictionary serializedAdditionalRawData) : base(oDataType, serializedAdditionalRawData) { ODataType = oDataType ?? "#Microsoft.Azure.Search.NativeBlobSoftDeleteDeletionDetectionPolicy"; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/OcrSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/OcrSkill.Serialization.cs index af2075198e02..d454a0a32457 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/OcrSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/OcrSkill.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class OcrSkill : IUtf8JsonSerializable + public partial class OcrSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(OcrSkill)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(DefaultLanguageCode)) { if (DefaultLanguageCode != null) @@ -45,42 +64,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("lineEnding"u8); writer.WriteStringValue(LineEnding.Value.ToString()); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + OcrSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(OcrSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOcrSkill(document.RootElement, options); } - internal static OcrSkill DeserializeOcrSkill(JsonElement element) + internal static OcrSkill DeserializeOcrSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -94,6 +95,8 @@ internal static OcrSkill DeserializeOcrSkill(JsonElement element) string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("defaultLanguageCode"u8)) @@ -150,7 +153,7 @@ internal static OcrSkill DeserializeOcrSkill(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -160,12 +163,17 @@ internal static OcrSkill DeserializeOcrSkill(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new OcrSkill( odataType, name, @@ -173,11 +181,43 @@ internal static OcrSkill DeserializeOcrSkill(JsonElement element) context, inputs, outputs, + serializedAdditionalRawData, defaultLanguageCode, detectOrientation, lineEnding); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(OcrSkill)} does not support writing '{options.Format}' format."); + } + } + + OcrSkill 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 DeserializeOcrSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OcrSkill)} 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 OcrSkill FromResponse(Response response) @@ -190,7 +230,7 @@ internal static OcrSkill DeserializeOcrSkill(JsonElement element) internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/OcrSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/OcrSkill.cs index 07a1c8208686..08faaaa776b3 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/OcrSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/OcrSkill.cs @@ -32,16 +32,22 @@ public OcrSkill(IEnumerable inputs, IEnumerable Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// A value indicating which language code to use. Default is `en`. /// A value indicating to turn orientation detection on or not. Default is false. /// Defines the sequence of characters to use between the lines of text recognized by the OCR skill. The default value is "space". - internal OcrSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, OcrSkillLanguage? defaultLanguageCode, bool? shouldDetectOrientation, OcrLineEnding? lineEnding) : base(oDataType, name, description, context, inputs, outputs) + internal OcrSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, OcrSkillLanguage? defaultLanguageCode, bool? shouldDetectOrientation, OcrLineEnding? lineEnding) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { DefaultLanguageCode = defaultLanguageCode; ShouldDetectOrientation = shouldDetectOrientation; LineEnding = lineEnding; ODataType = oDataType ?? "#Microsoft.Skills.Vision.OcrSkill"; } + + /// Initializes a new instance of for deserialization. + internal OcrSkill() + { + } /// Defines the sequence of characters to use between the lines of text recognized by the OCR skill. The default value is "space". public OcrLineEnding? LineEnding { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/OutputFieldMappingEntry.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/OutputFieldMappingEntry.Serialization.cs index 71c35b52d31f..ca63c26f5648 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/OutputFieldMappingEntry.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/OutputFieldMappingEntry.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class OutputFieldMappingEntry : IUtf8JsonSerializable + public partial class OutputFieldMappingEntry : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(OutputFieldMappingEntry)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); if (Optional.IsDefined(TargetName)) @@ -22,17 +41,47 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("targetName"u8); writer.WriteStringValue(TargetName); } - writer.WriteEndObject(); + 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 + } + } } - internal static OutputFieldMappingEntry DeserializeOutputFieldMappingEntry(JsonElement element) + OutputFieldMappingEntry 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(OutputFieldMappingEntry)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOutputFieldMappingEntry(document.RootElement, options); + } + + internal static OutputFieldMappingEntry DeserializeOutputFieldMappingEntry(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string name = default; string targetName = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -45,10 +94,46 @@ internal static OutputFieldMappingEntry DeserializeOutputFieldMappingEntry(JsonE targetName = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new OutputFieldMappingEntry(name, targetName); + serializedAdditionalRawData = rawDataDictionary; + return new OutputFieldMappingEntry(name, targetName, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(OutputFieldMappingEntry)} does not support writing '{options.Format}' format."); + } + } + + OutputFieldMappingEntry 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 DeserializeOutputFieldMappingEntry(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OutputFieldMappingEntry)} 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 OutputFieldMappingEntry FromResponse(Response response) @@ -61,7 +146,7 @@ internal static OutputFieldMappingEntry FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/OutputFieldMappingEntry.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/OutputFieldMappingEntry.cs index 76ee37088e8a..dd217b2e902e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/OutputFieldMappingEntry.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/OutputFieldMappingEntry.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Output field mapping for a skill. public partial class OutputFieldMappingEntry { + /// + /// 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 . /// The name of the output defined by the skill. /// is null. @@ -25,10 +58,17 @@ public OutputFieldMappingEntry(string name) /// Initializes a new instance of . /// The name of the output defined by the skill. /// The target name of the output. It is optional and default to name. - internal OutputFieldMappingEntry(string name, string targetName) + /// Keeps track of any properties unknown to the library. + internal OutputFieldMappingEntry(string name, string targetName, IDictionary serializedAdditionalRawData) { Name = name; TargetName = targetName; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OutputFieldMappingEntry() + { } /// The name of the output defined by the skill. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/PathHierarchyTokenizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/PathHierarchyTokenizer.Serialization.cs index 7d6001aee909..7602e3ebffdd 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/PathHierarchyTokenizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/PathHierarchyTokenizer.Serialization.cs @@ -5,16 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class PathHierarchyTokenizer : IUtf8JsonSerializable + public partial class PathHierarchyTokenizer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(PathHierarchyTokenizer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Delimiter)) { writer.WritePropertyName("delimiter"u8); @@ -40,15 +60,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("skip"u8); writer.WriteNumberValue(NumberOfTokensToSkip.Value); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static PathHierarchyTokenizer DeserializePathHierarchyTokenizer(JsonElement element) + PathHierarchyTokenizer 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(PathHierarchyTokenizer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePathHierarchyTokenizer(document.RootElement, options); + } + + internal static PathHierarchyTokenizer DeserializePathHierarchyTokenizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -60,6 +89,8 @@ internal static PathHierarchyTokenizer DeserializePathHierarchyTokenizer(JsonEle int? skip = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("delimiter"u8)) @@ -117,10 +148,16 @@ internal static PathHierarchyTokenizer DeserializePathHierarchyTokenizer(JsonEle name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new PathHierarchyTokenizer( odataType, name, + serializedAdditionalRawData, delimiter, replacement, maxTokenLength, @@ -128,6 +165,37 @@ internal static PathHierarchyTokenizer DeserializePathHierarchyTokenizer(JsonEle skip); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(PathHierarchyTokenizer)} does not support writing '{options.Format}' format."); + } + } + + PathHierarchyTokenizer 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 DeserializePathHierarchyTokenizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PathHierarchyTokenizer)} 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 PathHierarchyTokenizer FromResponse(Response response) @@ -140,7 +208,7 @@ internal static PathHierarchyTokenizer DeserializePathHierarchyTokenizer(JsonEle internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/PathHierarchyTokenizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/PathHierarchyTokenizer.cs index d6a96eeccd99..73cf24b2ef1d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/PathHierarchyTokenizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/PathHierarchyTokenizer.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,12 +26,13 @@ public PathHierarchyTokenizer(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of tokenizer. /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The delimiter character to use. Default is "/". /// A value that, if set, replaces the delimiter character. Default is "/". /// The maximum token length. Default and maximum is 300. /// A value indicating whether to generate tokens in reverse order. Default is false. /// The number of initial tokens to skip. Default is 0. - internal PathHierarchyTokenizer(string oDataType, string name, char? delimiter, char? replacement, int? maxTokenLength, bool? reverseTokenOrder, int? numberOfTokensToSkip) : base(oDataType, name) + internal PathHierarchyTokenizer(string oDataType, string name, IDictionary serializedAdditionalRawData, char? delimiter, char? replacement, int? maxTokenLength, bool? reverseTokenOrder, int? numberOfTokensToSkip) : base(oDataType, name, serializedAdditionalRawData) { Delimiter = delimiter; Replacement = replacement; @@ -40,6 +42,11 @@ internal PathHierarchyTokenizer(string oDataType, string name, char? delimiter, ODataType = oDataType ?? "#Microsoft.Azure.Search.PathHierarchyTokenizerV2"; } + /// Initializes a new instance of for deserialization. + internal PathHierarchyTokenizer() + { + } + /// The delimiter character to use. Default is "/". public char? Delimiter { get; set; } /// A value that, if set, replaces the delimiter character. Default is "/". diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternAnalyzer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternAnalyzer.Serialization.cs index f88774ce9fe2..f7ba7a1a75a9 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternAnalyzer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternAnalyzer.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class PatternAnalyzer : IUtf8JsonSerializable + public partial class PatternAnalyzer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(PatternAnalyzer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(LowerCaseTerms)) { writer.WritePropertyName("lowercase"u8); @@ -41,15 +60,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WriteEndArray(); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static PatternAnalyzer DeserializePatternAnalyzer(JsonElement element) + PatternAnalyzer 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(PatternAnalyzer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePatternAnalyzer(document.RootElement, options); + } + + internal static PatternAnalyzer DeserializePatternAnalyzer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -60,6 +88,8 @@ internal static PatternAnalyzer DeserializePatternAnalyzer(JsonElement element) IList stopwords = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("lowercase"u8)) @@ -105,16 +135,53 @@ internal static PatternAnalyzer DeserializePatternAnalyzer(JsonElement element) name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new PatternAnalyzer( odataType, name, + serializedAdditionalRawData, lowercase, pattern, flags, stopwords ?? new ChangeTrackingList()); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(PatternAnalyzer)} does not support writing '{options.Format}' format."); + } + } + + PatternAnalyzer 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 DeserializePatternAnalyzer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PatternAnalyzer)} 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 PatternAnalyzer FromResponse(Response response) @@ -127,7 +194,7 @@ internal static PatternAnalyzer DeserializePatternAnalyzer(JsonElement element) internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternAnalyzer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternAnalyzer.cs index 39653249ef7f..46429934ce7f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternAnalyzer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternAnalyzer.cs @@ -27,11 +27,12 @@ public PatternAnalyzer(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of analyzer. /// The name of the analyzer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// A value indicating whether terms should be lower-cased. Default is true. /// A regular expression pattern to match token separators. Default is an expression that matches one or more non-word characters. /// Regular expression flags. /// A list of stopwords. - internal PatternAnalyzer(string oDataType, string name, bool? lowerCaseTerms, string pattern, string flagsInternal, IList stopwords) : base(oDataType, name) + internal PatternAnalyzer(string oDataType, string name, IDictionary serializedAdditionalRawData, bool? lowerCaseTerms, string pattern, string flagsInternal, IList stopwords) : base(oDataType, name, serializedAdditionalRawData) { LowerCaseTerms = lowerCaseTerms; Pattern = pattern; @@ -40,6 +41,11 @@ internal PatternAnalyzer(string oDataType, string name, bool? lowerCaseTerms, st ODataType = oDataType ?? "#Microsoft.Azure.Search.PatternAnalyzer"; } + /// Initializes a new instance of for deserialization. + internal PatternAnalyzer() + { + } + /// A value indicating whether terms should be lower-cased. Default is true. public bool? LowerCaseTerms { get; set; } /// A regular expression pattern to match token separators. Default is an expression that matches one or more non-word characters. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternCaptureTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternCaptureTokenFilter.Serialization.cs index 3d08f2e5b6ea..5723fceb4e11 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternCaptureTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternCaptureTokenFilter.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class PatternCaptureTokenFilter : IUtf8JsonSerializable + public partial class PatternCaptureTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(PatternCaptureTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("patterns"u8); writer.WriteStartArray(); foreach (var item in Patterns) @@ -28,15 +47,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("preserveOriginal"u8); writer.WriteBooleanValue(PreserveOriginal.Value); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static PatternCaptureTokenFilter DeserializePatternCaptureTokenFilter(JsonElement element) + PatternCaptureTokenFilter 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(PatternCaptureTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePatternCaptureTokenFilter(document.RootElement, options); + } + + internal static PatternCaptureTokenFilter DeserializePatternCaptureTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -45,6 +73,8 @@ internal static PatternCaptureTokenFilter DeserializePatternCaptureTokenFilter(J bool? preserveOriginal = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("patterns"u8)) @@ -76,10 +106,46 @@ internal static PatternCaptureTokenFilter DeserializePatternCaptureTokenFilter(J name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PatternCaptureTokenFilter(odataType, name, serializedAdditionalRawData, patterns, preserveOriginal); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(PatternCaptureTokenFilter)} does not support writing '{options.Format}' format."); + } + } + + PatternCaptureTokenFilter 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 DeserializePatternCaptureTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PatternCaptureTokenFilter)} does not support reading '{options.Format}' format."); } - return new PatternCaptureTokenFilter(odataType, name, patterns, preserveOriginal); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new PatternCaptureTokenFilter FromResponse(Response response) @@ -92,7 +158,7 @@ internal static PatternCaptureTokenFilter DeserializePatternCaptureTokenFilter(J internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternCaptureTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternCaptureTokenFilter.cs index c1e82ef1c9e0..2008deaba0f6 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternCaptureTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternCaptureTokenFilter.cs @@ -30,14 +30,20 @@ public PatternCaptureTokenFilter(string name, IEnumerable patterns) : ba /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// A list of patterns to match against each token. /// A value indicating whether to return the original token even if one of the patterns matches. Default is true. - internal PatternCaptureTokenFilter(string oDataType, string name, IList patterns, bool? preserveOriginal) : base(oDataType, name) + internal PatternCaptureTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, IList patterns, bool? preserveOriginal) : base(oDataType, name, serializedAdditionalRawData) { Patterns = patterns; PreserveOriginal = preserveOriginal; ODataType = oDataType ?? "#Microsoft.Azure.Search.PatternCaptureTokenFilter"; } + + /// Initializes a new instance of for deserialization. + internal PatternCaptureTokenFilter() + { + } /// A value indicating whether to return the original token even if one of the patterns matches. Default is true. public bool? PreserveOriginal { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternReplaceCharFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternReplaceCharFilter.Serialization.cs index 122dcaed6eed..41d761c847e6 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternReplaceCharFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternReplaceCharFilter.Serialization.cs @@ -5,29 +5,58 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class PatternReplaceCharFilter : IUtf8JsonSerializable + public partial class PatternReplaceCharFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(PatternReplaceCharFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("pattern"u8); writer.WriteStringValue(Pattern); writer.WritePropertyName("replacement"u8); writer.WriteStringValue(Replacement); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static PatternReplaceCharFilter DeserializePatternReplaceCharFilter(JsonElement element) + PatternReplaceCharFilter 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(PatternReplaceCharFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePatternReplaceCharFilter(document.RootElement, options); + } + + internal static PatternReplaceCharFilter DeserializePatternReplaceCharFilter(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -36,6 +65,8 @@ internal static PatternReplaceCharFilter DeserializePatternReplaceCharFilter(Jso string replacement = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("pattern"u8)) @@ -58,10 +89,46 @@ internal static PatternReplaceCharFilter DeserializePatternReplaceCharFilter(Jso name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PatternReplaceCharFilter(odataType, name, serializedAdditionalRawData, pattern, replacement); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(PatternReplaceCharFilter)} does not support writing '{options.Format}' format."); } - return new PatternReplaceCharFilter(odataType, name, pattern, replacement); } + PatternReplaceCharFilter 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 DeserializePatternReplaceCharFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PatternReplaceCharFilter)} 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 PatternReplaceCharFilter FromResponse(Response response) @@ -74,7 +141,7 @@ internal static PatternReplaceCharFilter DeserializePatternReplaceCharFilter(Jso internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternReplaceCharFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternReplaceCharFilter.cs index 4a5761057e6c..38ef043ad70a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternReplaceCharFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternReplaceCharFilter.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -31,15 +32,21 @@ public PatternReplaceCharFilter(string name, string pattern, string replacement) /// Initializes a new instance of . /// A URI fragment specifying the type of char filter. /// The name of the char filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// A regular expression pattern. /// The replacement text. - internal PatternReplaceCharFilter(string oDataType, string name, string pattern, string replacement) : base(oDataType, name) + internal PatternReplaceCharFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, string pattern, string replacement) : base(oDataType, name, serializedAdditionalRawData) { Pattern = pattern; Replacement = replacement; ODataType = oDataType ?? "#Microsoft.Azure.Search.PatternReplaceCharFilter"; } + /// Initializes a new instance of for deserialization. + internal PatternReplaceCharFilter() + { + } + /// A regular expression pattern. public string Pattern { get; set; } /// The replacement text. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternReplaceTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternReplaceTokenFilter.Serialization.cs index fb280d321229..9a17c0a1ad97 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternReplaceTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternReplaceTokenFilter.Serialization.cs @@ -5,29 +5,58 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class PatternReplaceTokenFilter : IUtf8JsonSerializable + public partial class PatternReplaceTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(PatternReplaceTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("pattern"u8); writer.WriteStringValue(Pattern); writer.WritePropertyName("replacement"u8); writer.WriteStringValue(Replacement); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static PatternReplaceTokenFilter DeserializePatternReplaceTokenFilter(JsonElement element) + PatternReplaceTokenFilter 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(PatternReplaceTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePatternReplaceTokenFilter(document.RootElement, options); + } + + internal static PatternReplaceTokenFilter DeserializePatternReplaceTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -36,6 +65,8 @@ internal static PatternReplaceTokenFilter DeserializePatternReplaceTokenFilter(J string replacement = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("pattern"u8)) @@ -58,10 +89,46 @@ internal static PatternReplaceTokenFilter DeserializePatternReplaceTokenFilter(J name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PatternReplaceTokenFilter(odataType, name, serializedAdditionalRawData, pattern, replacement); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(PatternReplaceTokenFilter)} does not support writing '{options.Format}' format."); } - return new PatternReplaceTokenFilter(odataType, name, pattern, replacement); } + PatternReplaceTokenFilter 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 DeserializePatternReplaceTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PatternReplaceTokenFilter)} 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 PatternReplaceTokenFilter FromResponse(Response response) @@ -74,7 +141,7 @@ internal static PatternReplaceTokenFilter DeserializePatternReplaceTokenFilter(J internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternReplaceTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternReplaceTokenFilter.cs index a0c709b8ad22..1ec523e6fc03 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternReplaceTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternReplaceTokenFilter.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -31,15 +32,21 @@ public PatternReplaceTokenFilter(string name, string pattern, string replacement /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// A regular expression pattern. /// The replacement text. - internal PatternReplaceTokenFilter(string oDataType, string name, string pattern, string replacement) : base(oDataType, name) + internal PatternReplaceTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, string pattern, string replacement) : base(oDataType, name, serializedAdditionalRawData) { Pattern = pattern; Replacement = replacement; ODataType = oDataType ?? "#Microsoft.Azure.Search.PatternReplaceTokenFilter"; } + /// Initializes a new instance of for deserialization. + internal PatternReplaceTokenFilter() + { + } + /// A regular expression pattern. public string Pattern { get; set; } /// The replacement text. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternTokenizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternTokenizer.Serialization.cs index 61adbe5f4725..3919b103b740 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternTokenizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternTokenizer.Serialization.cs @@ -5,16 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class PatternTokenizer : IUtf8JsonSerializable + public partial class PatternTokenizer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(PatternTokenizer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Pattern)) { writer.WritePropertyName("pattern"u8); @@ -30,15 +50,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("group"u8); writer.WriteNumberValue(Group.Value); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static PatternTokenizer DeserializePatternTokenizer(JsonElement element) + PatternTokenizer 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(PatternTokenizer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePatternTokenizer(document.RootElement, options); + } + + internal static PatternTokenizer DeserializePatternTokenizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -48,6 +77,8 @@ internal static PatternTokenizer DeserializePatternTokenizer(JsonElement element int? group = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("pattern"u8)) @@ -79,10 +110,52 @@ internal static PatternTokenizer DeserializePatternTokenizer(JsonElement element name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PatternTokenizer( + odataType, + name, + serializedAdditionalRawData, + pattern, + flags, + group); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(PatternTokenizer)} does not support writing '{options.Format}' format."); + } + } + + PatternTokenizer 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 DeserializePatternTokenizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PatternTokenizer)} does not support reading '{options.Format}' format."); } - return new PatternTokenizer(odataType, name, pattern, flags, group); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new PatternTokenizer FromResponse(Response response) @@ -95,7 +168,7 @@ internal static PatternTokenizer DeserializePatternTokenizer(JsonElement element internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternTokenizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternTokenizer.cs index 80b07f3896c4..1f31d6d721e3 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternTokenizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/PatternTokenizer.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,10 +26,11 @@ public PatternTokenizer(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of tokenizer. /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// A regular expression pattern to match token separators. Default is an expression that matches one or more non-word characters. /// Regular expression flags. /// The zero-based ordinal of the matching group in the regular expression pattern to extract into tokens. Use -1 if you want to use the entire pattern to split the input into tokens, irrespective of matching groups. Default is -1. - internal PatternTokenizer(string oDataType, string name, string pattern, string flagsInternal, int? group) : base(oDataType, name) + internal PatternTokenizer(string oDataType, string name, IDictionary serializedAdditionalRawData, string pattern, string flagsInternal, int? group) : base(oDataType, name, serializedAdditionalRawData) { Pattern = pattern; FlagsInternal = flagsInternal; @@ -36,6 +38,11 @@ internal PatternTokenizer(string oDataType, string name, string pattern, string ODataType = oDataType ?? "#Microsoft.Azure.Search.PatternTokenizer"; } + /// Initializes a new instance of for deserialization. + internal PatternTokenizer() + { + } + /// A regular expression pattern to match token separators. Default is an expression that matches one or more non-word characters. public string Pattern { get; set; } /// The zero-based ordinal of the matching group in the regular expression pattern to extract into tokens. Use -1 if you want to use the entire pattern to split the input into tokens, irrespective of matching groups. Default is -1. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/PhoneticTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/PhoneticTokenFilter.Serialization.cs index b949f979fd35..0f6c4245969d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/PhoneticTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/PhoneticTokenFilter.Serialization.cs @@ -5,16 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class PhoneticTokenFilter : IUtf8JsonSerializable + public partial class PhoneticTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(PhoneticTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Encoder)) { writer.WritePropertyName("encoder"u8); @@ -25,15 +45,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("replace"u8); writer.WriteBooleanValue(ReplaceOriginalTokens.Value); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static PhoneticTokenFilter DeserializePhoneticTokenFilter(JsonElement element) + PhoneticTokenFilter 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(PhoneticTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePhoneticTokenFilter(document.RootElement, options); + } + + internal static PhoneticTokenFilter DeserializePhoneticTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -42,6 +71,8 @@ internal static PhoneticTokenFilter DeserializePhoneticTokenFilter(JsonElement e bool? replace = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("encoder"u8)) @@ -72,10 +103,46 @@ internal static PhoneticTokenFilter DeserializePhoneticTokenFilter(JsonElement e name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PhoneticTokenFilter(odataType, name, serializedAdditionalRawData, encoder, replace); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(PhoneticTokenFilter)} does not support writing '{options.Format}' format."); + } + } + + PhoneticTokenFilter 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 DeserializePhoneticTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PhoneticTokenFilter)} does not support reading '{options.Format}' format."); } - return new PhoneticTokenFilter(odataType, name, encoder, replace); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new PhoneticTokenFilter FromResponse(Response response) @@ -88,7 +155,7 @@ internal static PhoneticTokenFilter DeserializePhoneticTokenFilter(JsonElement e internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/PhoneticTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/PhoneticTokenFilter.cs index be1d1186619e..d595fc9d7a32 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/PhoneticTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/PhoneticTokenFilter.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,15 +26,21 @@ public PhoneticTokenFilter(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The phonetic encoder to use. Default is "metaphone". /// A value indicating whether encoded tokens should replace original tokens. If false, encoded tokens are added as synonyms. Default is true. - internal PhoneticTokenFilter(string oDataType, string name, PhoneticEncoder? encoder, bool? replaceOriginalTokens) : base(oDataType, name) + internal PhoneticTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, PhoneticEncoder? encoder, bool? replaceOriginalTokens) : base(oDataType, name, serializedAdditionalRawData) { Encoder = encoder; ReplaceOriginalTokens = replaceOriginalTokens; ODataType = oDataType ?? "#Microsoft.Azure.Search.PhoneticTokenFilter"; } + /// Initializes a new instance of for deserialization. + internal PhoneticTokenFilter() + { + } + /// The phonetic encoder to use. Default is "metaphone". public PhoneticEncoder? Encoder { get; set; } /// A value indicating whether encoded tokens should replace original tokens. If false, encoded tokens are added as synonyms. Default is true. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/PiiDetectionSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/PiiDetectionSkill.Serialization.cs index f8588dd11a72..097ee8d38bd2 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/PiiDetectionSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/PiiDetectionSkill.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class PiiDetectionSkill : IUtf8JsonSerializable + public partial class PiiDetectionSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(PiiDetectionSkill)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(DefaultLanguageCode)) { if (DefaultLanguageCode != null) @@ -91,42 +110,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("domain"); } } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + PiiDetectionSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(PiiDetectionSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePiiDetectionSkill(document.RootElement, options); } - internal static PiiDetectionSkill DeserializePiiDetectionSkill(JsonElement element) + internal static PiiDetectionSkill DeserializePiiDetectionSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -144,6 +145,8 @@ internal static PiiDetectionSkill DeserializePiiDetectionSkill(JsonElement eleme string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("defaultLanguageCode"u8)) @@ -244,7 +247,7 @@ internal static PiiDetectionSkill DeserializePiiDetectionSkill(JsonElement eleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -254,12 +257,17 @@ internal static PiiDetectionSkill DeserializePiiDetectionSkill(JsonElement eleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new PiiDetectionSkill( odataType, name, @@ -267,6 +275,7 @@ internal static PiiDetectionSkill DeserializePiiDetectionSkill(JsonElement eleme context, inputs, outputs, + serializedAdditionalRawData, defaultLanguageCode, minimumPrecision, maskingMode, @@ -276,6 +285,37 @@ internal static PiiDetectionSkill DeserializePiiDetectionSkill(JsonElement eleme domain); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(PiiDetectionSkill)} does not support writing '{options.Format}' format."); + } + } + + PiiDetectionSkill 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 DeserializePiiDetectionSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PiiDetectionSkill)} 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 PiiDetectionSkill FromResponse(Response response) @@ -288,7 +328,7 @@ internal static PiiDetectionSkill DeserializePiiDetectionSkill(JsonElement eleme internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/PiiDetectionSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/PiiDetectionSkill.cs index 3062a265e535..2158d4404a08 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/PiiDetectionSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/PiiDetectionSkill.cs @@ -33,6 +33,7 @@ public PiiDetectionSkill(IEnumerable inputs, IEnumerable /// Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// A value indicating which language code to use. Default is `en`. /// A value between 0 and 1 that be used to only include entities whose confidence score is greater than the value specified. If not set (default), or if explicitly set to null, all entities will be included. /// A parameter that provides various ways to mask the personal information detected in the input text. Default is 'none'. @@ -40,7 +41,7 @@ public PiiDetectionSkill(IEnumerable inputs, IEnumerable /// The version of the model to use when calling the Text Analytics service. It will default to the latest available when not specified. We recommend you do not specify this value unless absolutely necessary. /// A list of PII entity categories that should be extracted and masked. /// If specified, will set the PII domain to include only a subset of the entity categories. Possible values include: 'phi', 'none'. Default is 'none'. - internal PiiDetectionSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, string defaultLanguageCode, double? minPrecision, PiiDetectionSkillMaskingMode? maskingMode, string mask, string modelVersion, IList piiCategories, string domain) : base(oDataType, name, description, context, inputs, outputs) + internal PiiDetectionSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, string defaultLanguageCode, double? minPrecision, PiiDetectionSkillMaskingMode? maskingMode, string mask, string modelVersion, IList piiCategories, string domain) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { DefaultLanguageCode = defaultLanguageCode; MinPrecision = minPrecision; @@ -51,6 +52,11 @@ internal PiiDetectionSkill(string oDataType, string name, string description, st Domain = domain; ODataType = oDataType ?? "#Microsoft.Skills.Text.PIIDetectionSkill"; } + + /// Initializes a new instance of for deserialization. + internal PiiDetectionSkill() + { + } /// A value between 0 and 1 that be used to only include entities whose confidence score is greater than the value specified. If not set (default), or if explicitly set to null, all entities will be included. public double? MinPrecision { get; set; } /// A parameter that provides various ways to mask the personal information detected in the input text. Default is 'none'. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryAnswerResult.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryAnswerResult.Serialization.cs index 718d0db7a9cb..aff898e1b18b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryAnswerResult.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryAnswerResult.Serialization.cs @@ -5,15 +5,85 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class QueryAnswerResult + public partial class QueryAnswerResult : IUtf8JsonSerializable, IJsonModel { - internal static QueryAnswerResult DeserializeQueryAnswerResult(JsonElement element) + 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(QueryAnswerResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Score)) + { + writer.WritePropertyName("score"u8); + writer.WriteNumberValue(Score.Value); + } + if (options.Format != "W" && Optional.IsDefined(Key)) + { + writer.WritePropertyName("key"u8); + writer.WriteStringValue(Key); + } + if (options.Format != "W" && Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + if (options.Format != "W" && Optional.IsDefined(Highlights)) + { + if (Highlights != null) + { + writer.WritePropertyName("highlights"u8); + writer.WriteStringValue(Highlights); + } + else + { + writer.WriteNull("highlights"); + } + } + foreach (var item in AdditionalProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + } + + QueryAnswerResult 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(QueryAnswerResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeQueryAnswerResult(document.RootElement, options); + } + + internal static QueryAnswerResult DeserializeQueryAnswerResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -61,6 +131,37 @@ internal static QueryAnswerResult DeserializeQueryAnswerResult(JsonElement eleme return new QueryAnswerResult(score, key, text, highlights, additionalProperties); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(QueryAnswerResult)} does not support writing '{options.Format}' format."); + } + } + + QueryAnswerResult 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 DeserializeQueryAnswerResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(QueryAnswerResult)} 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 QueryAnswerResult FromResponse(Response response) @@ -68,5 +169,13 @@ internal static QueryAnswerResult FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeQueryAnswerResult(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/search/Azure.Search.Documents/src/Generated/Models/QueryCaptionResult.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryCaptionResult.Serialization.cs index 8d3a2ec4053c..b5baaa44d816 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryCaptionResult.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryCaptionResult.Serialization.cs @@ -5,15 +5,75 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class QueryCaptionResult + public partial class QueryCaptionResult : IUtf8JsonSerializable, IJsonModel { - internal static QueryCaptionResult DeserializeQueryCaptionResult(JsonElement element) + 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(QueryCaptionResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + if (options.Format != "W" && Optional.IsDefined(Highlights)) + { + if (Highlights != null) + { + writer.WritePropertyName("highlights"u8); + writer.WriteStringValue(Highlights); + } + else + { + writer.WriteNull("highlights"); + } + } + foreach (var item in AdditionalProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + } + + QueryCaptionResult 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(QueryCaptionResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeQueryCaptionResult(document.RootElement, options); + } + + internal static QueryCaptionResult DeserializeQueryCaptionResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -45,6 +105,37 @@ internal static QueryCaptionResult DeserializeQueryCaptionResult(JsonElement ele return new QueryCaptionResult(text, highlights, additionalProperties); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(QueryCaptionResult)} does not support writing '{options.Format}' format."); + } + } + + QueryCaptionResult 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 DeserializeQueryCaptionResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(QueryCaptionResult)} 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 QueryCaptionResult FromResponse(Response response) @@ -52,5 +143,13 @@ internal static QueryCaptionResult FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeQueryCaptionResult(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/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentInnerHit.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentInnerHit.Serialization.cs index fea2233a9271..56bde74d0d4b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentInnerHit.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentInnerHit.Serialization.cs @@ -5,21 +5,102 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class QueryResultDocumentInnerHit + public partial class QueryResultDocumentInnerHit : IUtf8JsonSerializable, IJsonModel { - internal static QueryResultDocumentInnerHit DeserializeQueryResultDocumentInnerHit(JsonElement element) + 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(QueryResultDocumentInnerHit)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Ordinal)) + { + writer.WritePropertyName("ordinal"u8); + writer.WriteNumberValue(Ordinal.Value); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Vectors)) + { + writer.WritePropertyName("vectors"u8); + writer.WriteStartArray(); + foreach (var item in Vectors) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStartObject(); + foreach (var item0 in item) + { + writer.WritePropertyName(item0.Key); + writer.WriteObjectValue(item0.Value, options); + } + writer.WriteEndObject(); + } + 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 + } + } + } + + QueryResultDocumentInnerHit 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(QueryResultDocumentInnerHit)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeQueryResultDocumentInnerHit(document.RootElement, options); + } + + internal static QueryResultDocumentInnerHit DeserializeQueryResultDocumentInnerHit(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } long? ordinal = default; IReadOnlyList> vectors = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("ordinal"u8)) @@ -49,7 +130,7 @@ internal static QueryResultDocumentInnerHit DeserializeQueryResultDocumentInnerH Dictionary dictionary = new Dictionary(); foreach (var property0 in item.EnumerateObject()) { - dictionary.Add(property0.Name, SingleVectorFieldResult.DeserializeSingleVectorFieldResult(property0.Value)); + dictionary.Add(property0.Name, SingleVectorFieldResult.DeserializeSingleVectorFieldResult(property0.Value, options)); } array.Add(dictionary); } @@ -57,10 +138,46 @@ internal static QueryResultDocumentInnerHit DeserializeQueryResultDocumentInnerH vectors = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new QueryResultDocumentInnerHit(ordinal, vectors ?? new ChangeTrackingList>()); + serializedAdditionalRawData = rawDataDictionary; + return new QueryResultDocumentInnerHit(ordinal, vectors ?? 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(QueryResultDocumentInnerHit)} does not support writing '{options.Format}' format."); + } + } + + QueryResultDocumentInnerHit 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 DeserializeQueryResultDocumentInnerHit(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(QueryResultDocumentInnerHit)} 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 QueryResultDocumentInnerHit FromResponse(Response response) @@ -68,5 +185,13 @@ internal static QueryResultDocumentInnerHit FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeQueryResultDocumentInnerHit(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/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentInnerHit.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentInnerHit.cs index 153a06f76870..584beab8e1b2 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentInnerHit.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentInnerHit.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.Search.Documents.Models @@ -12,6 +13,38 @@ namespace Azure.Search.Documents.Models /// Detailed scoring information for an individual element of a complex collection. public partial class QueryResultDocumentInnerHit { + /// + /// 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 . internal QueryResultDocumentInnerHit() { @@ -21,10 +54,12 @@ internal QueryResultDocumentInnerHit() /// Initializes a new instance of . /// Position of this specific matching element within it's original collection. Position starts at 0. /// Detailed scoring information for an individual element of a complex collection that matched a vector query. - internal QueryResultDocumentInnerHit(long? ordinal, IReadOnlyList> vectors) + /// Keeps track of any properties unknown to the library. + internal QueryResultDocumentInnerHit(long? ordinal, IReadOnlyList> vectors, IDictionary serializedAdditionalRawData) { Ordinal = ordinal; Vectors = vectors; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Position of this specific matching element within it's original collection. Position starts at 0. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentRerankerInput.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentRerankerInput.Serialization.cs index 4843d26ac77a..af75bc6a3d2d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentRerankerInput.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentRerankerInput.Serialization.cs @@ -5,14 +5,83 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class QueryResultDocumentRerankerInput + public partial class QueryResultDocumentRerankerInput : IUtf8JsonSerializable, IJsonModel { - internal static QueryResultDocumentRerankerInput DeserializeQueryResultDocumentRerankerInput(JsonElement element) + 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(QueryResultDocumentRerankerInput)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Title)) + { + writer.WritePropertyName("title"u8); + writer.WriteStringValue(Title); + } + if (options.Format != "W" && Optional.IsDefined(Content)) + { + writer.WritePropertyName("content"u8); + writer.WriteStringValue(Content); + } + if (options.Format != "W" && Optional.IsDefined(Keywords)) + { + writer.WritePropertyName("keywords"u8); + writer.WriteStringValue(Keywords); + } + 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 + } + } + } + + QueryResultDocumentRerankerInput 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(QueryResultDocumentRerankerInput)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeQueryResultDocumentRerankerInput(document.RootElement, options); + } + + internal static QueryResultDocumentRerankerInput DeserializeQueryResultDocumentRerankerInput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -20,6 +89,8 @@ internal static QueryResultDocumentRerankerInput DeserializeQueryResultDocumentR string title = default; string content = default; string keywords = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("title"u8)) @@ -37,10 +108,46 @@ internal static QueryResultDocumentRerankerInput DeserializeQueryResultDocumentR keywords = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new QueryResultDocumentRerankerInput(title, content, keywords, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(QueryResultDocumentRerankerInput)} does not support writing '{options.Format}' format."); } - return new QueryResultDocumentRerankerInput(title, content, keywords); } + QueryResultDocumentRerankerInput 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 DeserializeQueryResultDocumentRerankerInput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(QueryResultDocumentRerankerInput)} 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 QueryResultDocumentRerankerInput FromResponse(Response response) @@ -48,5 +155,13 @@ internal static QueryResultDocumentRerankerInput FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeQueryResultDocumentRerankerInput(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/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentRerankerInput.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentRerankerInput.cs index 2980704e7d3c..6deede5dfc4a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentRerankerInput.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentRerankerInput.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Models { /// The raw concatenated strings that were sent to the semantic enrichment process. public partial class QueryResultDocumentRerankerInput { + /// + /// 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 . internal QueryResultDocumentRerankerInput() { @@ -19,11 +54,13 @@ internal QueryResultDocumentRerankerInput() /// The raw string for the title field that was used for semantic enrichment. /// The raw concatenated strings for the content fields that were used for semantic enrichment. /// The raw concatenated strings for the keyword fields that were used for semantic enrichment. - internal QueryResultDocumentRerankerInput(string title, string content, string keywords) + /// Keeps track of any properties unknown to the library. + internal QueryResultDocumentRerankerInput(string title, string content, string keywords, IDictionary serializedAdditionalRawData) { Title = title; Content = content; Keywords = keywords; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The raw string for the title field that was used for semantic enrichment. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentSemanticField.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentSemanticField.Serialization.cs index 566cb4b3fc78..4e31d94c2e8a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentSemanticField.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentSemanticField.Serialization.cs @@ -5,20 +5,86 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class QueryResultDocumentSemanticField + public partial class QueryResultDocumentSemanticField : IUtf8JsonSerializable, IJsonModel { - internal static QueryResultDocumentSemanticField DeserializeQueryResultDocumentSemanticField(JsonElement element) + 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(QueryResultDocumentSemanticField)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && Optional.IsDefined(State)) + { + writer.WritePropertyName("state"u8); + writer.WriteStringValue(State.Value.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 + } + } + } + + QueryResultDocumentSemanticField 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(QueryResultDocumentSemanticField)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeQueryResultDocumentSemanticField(document.RootElement, options); + } + + internal static QueryResultDocumentSemanticField DeserializeQueryResultDocumentSemanticField(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string name = default; SemanticFieldState? state = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -35,10 +101,46 @@ internal static QueryResultDocumentSemanticField DeserializeQueryResultDocumentS state = new SemanticFieldState(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new QueryResultDocumentSemanticField(name, state, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(QueryResultDocumentSemanticField)} does not support writing '{options.Format}' format."); } - return new QueryResultDocumentSemanticField(name, state); } + QueryResultDocumentSemanticField 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 DeserializeQueryResultDocumentSemanticField(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(QueryResultDocumentSemanticField)} 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 QueryResultDocumentSemanticField FromResponse(Response response) @@ -46,5 +148,13 @@ internal static QueryResultDocumentSemanticField FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeQueryResultDocumentSemanticField(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/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentSemanticField.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentSemanticField.cs index 6d05204a9fc2..760ea76f0264 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentSemanticField.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentSemanticField.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Models { /// Description of fields that were sent to the semantic enrichment process, as well as how they were used. public partial class QueryResultDocumentSemanticField { + /// + /// 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 . internal QueryResultDocumentSemanticField() { @@ -18,10 +53,12 @@ internal QueryResultDocumentSemanticField() /// Initializes a new instance of . /// The name of the field that was sent to the semantic enrichment process. /// The way the field was used for the semantic enrichment process (fully used, partially used, or unused). - internal QueryResultDocumentSemanticField(string name, SemanticFieldState? state) + /// Keeps track of any properties unknown to the library. + internal QueryResultDocumentSemanticField(string name, SemanticFieldState? state, IDictionary serializedAdditionalRawData) { Name = name; State = state; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The name of the field that was sent to the semantic enrichment process. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentSubscores.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentSubscores.Serialization.cs index 000d2cd0471c..f40acd173224 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentSubscores.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentSubscores.Serialization.cs @@ -5,15 +5,99 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class QueryResultDocumentSubscores + public partial class QueryResultDocumentSubscores : IUtf8JsonSerializable, IJsonModel { - internal static QueryResultDocumentSubscores DeserializeQueryResultDocumentSubscores(JsonElement element) + 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(QueryResultDocumentSubscores)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteObjectValue(Text, options); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Vectors)) + { + writer.WritePropertyName("vectors"u8); + writer.WriteStartArray(); + foreach (var item in Vectors) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStartObject(); + foreach (var item0 in item) + { + writer.WritePropertyName(item0.Key); + writer.WriteObjectValue(item0.Value, options); + } + writer.WriteEndObject(); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(DocumentBoost)) + { + writer.WritePropertyName("documentBoost"u8); + writer.WriteNumberValue(DocumentBoost.Value); + } + 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 + } + } + } + + QueryResultDocumentSubscores 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(QueryResultDocumentSubscores)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeQueryResultDocumentSubscores(document.RootElement, options); + } + + internal static QueryResultDocumentSubscores DeserializeQueryResultDocumentSubscores(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -21,6 +105,8 @@ internal static QueryResultDocumentSubscores DeserializeQueryResultDocumentSubsc TextResult text = default; IReadOnlyList> vectors = default; double? documentBoost = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("text"u8)) @@ -29,7 +115,7 @@ internal static QueryResultDocumentSubscores DeserializeQueryResultDocumentSubsc { continue; } - text = TextResult.DeserializeTextResult(property.Value); + text = TextResult.DeserializeTextResult(property.Value, options); continue; } if (property.NameEquals("vectors"u8)) @@ -50,7 +136,7 @@ internal static QueryResultDocumentSubscores DeserializeQueryResultDocumentSubsc Dictionary dictionary = new Dictionary(); foreach (var property0 in item.EnumerateObject()) { - dictionary.Add(property0.Name, SingleVectorFieldResult.DeserializeSingleVectorFieldResult(property0.Value)); + dictionary.Add(property0.Name, SingleVectorFieldResult.DeserializeSingleVectorFieldResult(property0.Value, options)); } array.Add(dictionary); } @@ -67,10 +153,46 @@ internal static QueryResultDocumentSubscores DeserializeQueryResultDocumentSubsc documentBoost = property.Value.GetDouble(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new QueryResultDocumentSubscores(text, vectors ?? new ChangeTrackingList>(), documentBoost, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(QueryResultDocumentSubscores)} does not support writing '{options.Format}' format."); + } + } + + QueryResultDocumentSubscores 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 DeserializeQueryResultDocumentSubscores(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(QueryResultDocumentSubscores)} does not support reading '{options.Format}' format."); } - return new QueryResultDocumentSubscores(text, vectors ?? new ChangeTrackingList>(), documentBoost); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static QueryResultDocumentSubscores FromResponse(Response response) @@ -78,5 +200,13 @@ internal static QueryResultDocumentSubscores FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeQueryResultDocumentSubscores(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/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentSubscores.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentSubscores.cs index 6b4cbd764cb4..6ac7a3c0e2dc 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentSubscores.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryResultDocumentSubscores.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.Search.Documents.Models @@ -12,6 +13,38 @@ namespace Azure.Search.Documents.Models /// The breakdown of subscores between the text and vector query components of the search query for this document. Each vector query is shown as a separate object in the same order they were received. public partial class QueryResultDocumentSubscores { + /// + /// 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 . internal QueryResultDocumentSubscores() { @@ -22,11 +55,13 @@ internal QueryResultDocumentSubscores() /// The BM25 or Classic score for the text portion of the query. /// The vector similarity and @search.score values for each vector query. /// The BM25 or Classic score for the text portion of the query. - internal QueryResultDocumentSubscores(TextResult text, IReadOnlyList> vectors, double? documentBoost) + /// Keeps track of any properties unknown to the library. + internal QueryResultDocumentSubscores(TextResult text, IReadOnlyList> vectors, double? documentBoost, IDictionary serializedAdditionalRawData) { Text = text; Vectors = vectors; DocumentBoost = documentBoost; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The BM25 or Classic score for the text portion of the query. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryRewritesDebugInfo.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryRewritesDebugInfo.Serialization.cs index 35aaca3c1312..46aef4e68d31 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryRewritesDebugInfo.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryRewritesDebugInfo.Serialization.cs @@ -5,21 +5,91 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class QueryRewritesDebugInfo + public partial class QueryRewritesDebugInfo : IUtf8JsonSerializable, IJsonModel { - internal static QueryRewritesDebugInfo DeserializeQueryRewritesDebugInfo(JsonElement element) + 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(QueryRewritesDebugInfo)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteObjectValue(Text, options); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Vectors)) + { + writer.WritePropertyName("vectors"u8); + writer.WriteStartArray(); + foreach (var item in Vectors) + { + 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 + } + } + } + + QueryRewritesDebugInfo 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(QueryRewritesDebugInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeQueryRewritesDebugInfo(document.RootElement, options); + } + + internal static QueryRewritesDebugInfo DeserializeQueryRewritesDebugInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } QueryRewritesValuesDebugInfo text = default; IReadOnlyList vectors = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("text"u8)) @@ -28,7 +98,7 @@ internal static QueryRewritesDebugInfo DeserializeQueryRewritesDebugInfo(JsonEle { continue; } - text = QueryRewritesValuesDebugInfo.DeserializeQueryRewritesValuesDebugInfo(property.Value); + text = QueryRewritesValuesDebugInfo.DeserializeQueryRewritesValuesDebugInfo(property.Value, options); continue; } if (property.NameEquals("vectors"u8)) @@ -40,15 +110,51 @@ internal static QueryRewritesDebugInfo DeserializeQueryRewritesDebugInfo(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(QueryRewritesValuesDebugInfo.DeserializeQueryRewritesValuesDebugInfo(item)); + array.Add(QueryRewritesValuesDebugInfo.DeserializeQueryRewritesValuesDebugInfo(item, options)); } vectors = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new QueryRewritesDebugInfo(text, vectors ?? 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(QueryRewritesDebugInfo)} does not support writing '{options.Format}' format."); } - return new QueryRewritesDebugInfo(text, vectors ?? new ChangeTrackingList()); } + QueryRewritesDebugInfo 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 DeserializeQueryRewritesDebugInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(QueryRewritesDebugInfo)} 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 QueryRewritesDebugInfo FromResponse(Response response) @@ -56,5 +162,13 @@ internal static QueryRewritesDebugInfo FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeQueryRewritesDebugInfo(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/search/Azure.Search.Documents/src/Generated/Models/QueryRewritesDebugInfo.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryRewritesDebugInfo.cs index 29f0f869191e..2a147ec48520 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryRewritesDebugInfo.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryRewritesDebugInfo.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.Search.Documents.Models @@ -12,6 +13,38 @@ namespace Azure.Search.Documents.Models /// Contains debugging information specific to query rewrites. public partial class QueryRewritesDebugInfo { + /// + /// 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 . internal QueryRewritesDebugInfo() { @@ -21,10 +54,12 @@ internal QueryRewritesDebugInfo() /// Initializes a new instance of . /// List of query rewrites generated for the text query. /// List of query rewrites generated for the vectorizable text queries. - internal QueryRewritesDebugInfo(QueryRewritesValuesDebugInfo text, IReadOnlyList vectors) + /// Keeps track of any properties unknown to the library. + internal QueryRewritesDebugInfo(QueryRewritesValuesDebugInfo text, IReadOnlyList vectors, IDictionary serializedAdditionalRawData) { Text = text; Vectors = vectors; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// List of query rewrites generated for the text query. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryRewritesValuesDebugInfo.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryRewritesValuesDebugInfo.Serialization.cs index abb1edb64f43..d6faa227576d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryRewritesValuesDebugInfo.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryRewritesValuesDebugInfo.Serialization.cs @@ -5,21 +5,91 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class QueryRewritesValuesDebugInfo + public partial class QueryRewritesValuesDebugInfo : IUtf8JsonSerializable, IJsonModel { - internal static QueryRewritesValuesDebugInfo DeserializeQueryRewritesValuesDebugInfo(JsonElement element) + 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(QueryRewritesValuesDebugInfo)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(InputQuery)) + { + writer.WritePropertyName("inputQuery"u8); + writer.WriteStringValue(InputQuery); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Rewrites)) + { + writer.WritePropertyName("rewrites"u8); + writer.WriteStartArray(); + foreach (var item in Rewrites) + { + writer.WriteStringValue(item); + } + 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 + } + } + } + + QueryRewritesValuesDebugInfo 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(QueryRewritesValuesDebugInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeQueryRewritesValuesDebugInfo(document.RootElement, options); + } + + internal static QueryRewritesValuesDebugInfo DeserializeQueryRewritesValuesDebugInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string inputQuery = default; IReadOnlyList rewrites = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("inputQuery"u8)) @@ -41,10 +111,46 @@ internal static QueryRewritesValuesDebugInfo DeserializeQueryRewritesValuesDebug rewrites = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new QueryRewritesValuesDebugInfo(inputQuery, rewrites ?? 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(QueryRewritesValuesDebugInfo)} does not support writing '{options.Format}' format."); } - return new QueryRewritesValuesDebugInfo(inputQuery, rewrites ?? new ChangeTrackingList()); } + QueryRewritesValuesDebugInfo 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 DeserializeQueryRewritesValuesDebugInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(QueryRewritesValuesDebugInfo)} 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 QueryRewritesValuesDebugInfo FromResponse(Response response) @@ -52,5 +158,13 @@ internal static QueryRewritesValuesDebugInfo FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeQueryRewritesValuesDebugInfo(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/search/Azure.Search.Documents/src/Generated/Models/QueryRewritesValuesDebugInfo.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryRewritesValuesDebugInfo.cs index 953d64ae6719..22ef69fe1b53 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryRewritesValuesDebugInfo.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/QueryRewritesValuesDebugInfo.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.Search.Documents.Models @@ -12,6 +13,38 @@ namespace Azure.Search.Documents.Models /// Contains debugging information specific to query rewrites. public partial class QueryRewritesValuesDebugInfo { + /// + /// 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 . internal QueryRewritesValuesDebugInfo() { @@ -21,10 +54,12 @@ internal QueryRewritesValuesDebugInfo() /// Initializes a new instance of . /// The input text to the generative query rewriting model. There may be cases where the user query and the input to the generative model are not identical. /// List of query rewrites. - internal QueryRewritesValuesDebugInfo(string inputQuery, IReadOnlyList rewrites) + /// Keeps track of any properties unknown to the library. + internal QueryRewritesValuesDebugInfo(string inputQuery, IReadOnlyList rewrites, IDictionary serializedAdditionalRawData) { InputQuery = inputQuery; Rewrites = rewrites; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The input text to the generative query rewriting model. There may be cases where the user query and the input to the generative model are not identical. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/RescoringOptions.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/RescoringOptions.Serialization.cs index d6751c95b0f3..1d5db052d796 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/RescoringOptions.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/RescoringOptions.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class RescoringOptions : IUtf8JsonSerializable + public partial class RescoringOptions : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(RescoringOptions)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(EnableRescoring)) { if (EnableRescoring != null) @@ -51,11 +70,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("rescoreStorageMethod"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static RescoringOptions DeserializeRescoringOptions(JsonElement element) + RescoringOptions 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(RescoringOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRescoringOptions(document.RootElement, options); + } + + internal static RescoringOptions DeserializeRescoringOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -63,6 +110,8 @@ internal static RescoringOptions DeserializeRescoringOptions(JsonElement element bool? enableRescoring = default; double? defaultOversampling = default; VectorSearchCompressionRescoreStorageMethod? rescoreStorageMethod = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("enableRescoring"u8)) @@ -95,10 +144,46 @@ internal static RescoringOptions DeserializeRescoringOptions(JsonElement element rescoreStorageMethod = new VectorSearchCompressionRescoreStorageMethod(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RescoringOptions(enableRescoring, defaultOversampling, rescoreStorageMethod, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(RescoringOptions)} does not support writing '{options.Format}' format."); } - return new RescoringOptions(enableRescoring, defaultOversampling, rescoreStorageMethod); } + RescoringOptions 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 DeserializeRescoringOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RescoringOptions)} 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 RescoringOptions FromResponse(Response response) @@ -111,7 +196,7 @@ internal static RescoringOptions FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/RescoringOptions.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/RescoringOptions.cs index e267c291cf03..9a90d484925c 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/RescoringOptions.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/RescoringOptions.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Contains the options for rescoring. public partial class RescoringOptions { + /// + /// 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 RescoringOptions() { @@ -19,11 +54,13 @@ public RescoringOptions() /// If set to true, after the initial search on the compressed vectors, the similarity scores are recalculated using the full-precision vectors. This will improve recall at the expense of latency. /// Default oversampling factor. Oversampling retrieves a greater set of potential documents to offset the resolution loss due to quantization. This increases the set of results that will be rescored on full-precision vectors. Minimum value is 1, meaning no oversampling (1x). This parameter can only be set when 'enableRescoring' is true. Higher values improve recall at the expense of latency. /// Controls the storage method for original vectors. This setting is immutable. - internal RescoringOptions(bool? enableRescoring, double? defaultOversampling, VectorSearchCompressionRescoreStorageMethod? rescoreStorageMethod) + /// Keeps track of any properties unknown to the library. + internal RescoringOptions(bool? enableRescoring, double? defaultOversampling, VectorSearchCompressionRescoreStorageMethod? rescoreStorageMethod, IDictionary serializedAdditionalRawData) { EnableRescoring = enableRescoring; DefaultOversampling = defaultOversampling; RescoreStorageMethod = rescoreStorageMethod; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// If set to true, after the initial search on the compressed vectors, the similarity scores are recalculated using the full-precision vectors. This will improve recall at the expense of latency. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ResetDocumentOptions.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ResetDocumentOptions.Serialization.cs index d80cf96ab34a..97ad2bee9c9b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ResetDocumentOptions.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ResetDocumentOptions.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class ResetDocumentOptions : IUtf8JsonSerializable + public partial class ResetDocumentOptions : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(ResetDocumentOptions)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(DocumentKeys)) { writer.WritePropertyName("documentKeys"u8); @@ -35,14 +54,130 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WriteEndArray(); } - writer.WriteEndObject(); + 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 + } + } + } + + ResetDocumentOptions 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(ResetDocumentOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResetDocumentOptions(document.RootElement, options); + } + + internal static ResetDocumentOptions DeserializeResetDocumentOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList documentKeys = default; + IList datasourceDocumentIds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("documentKeys"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + documentKeys = array; + continue; + } + if (property.NameEquals("datasourceDocumentIds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + datasourceDocumentIds = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ResetDocumentOptions(documentKeys ?? new ChangeTrackingList(), datasourceDocumentIds ?? 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ResetDocumentOptions)} does not support writing '{options.Format}' format."); + } + } + + ResetDocumentOptions 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 DeserializeResetDocumentOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResetDocumentOptions)} 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 ResetDocumentOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeResetDocumentOptions(document.RootElement); } /// Convert into a . internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ResetDocumentOptions.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ResetDocumentOptions.cs index dbd74a1ae1f4..096847a12f10 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ResetDocumentOptions.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ResetDocumentOptions.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.Search.Documents.Models @@ -12,6 +13,38 @@ namespace Azure.Search.Documents.Models /// The DocumentKeysOrIds. public partial class ResetDocumentOptions { + /// + /// 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 ResetDocumentOptions() { @@ -22,10 +55,12 @@ public ResetDocumentOptions() /// Initializes a new instance of . /// document keys to be reset. /// datasource document identifiers to be reset. - internal ResetDocumentOptions(IList documentKeys, IList dataSourceDocumentIds) + /// Keeps track of any properties unknown to the library. + internal ResetDocumentOptions(IList documentKeys, IList dataSourceDocumentIds, IDictionary serializedAdditionalRawData) { DocumentKeys = documentKeys; DataSourceDocumentIds = dataSourceDocumentIds; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// document keys to be reset. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ResetSkillsOptions.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ResetSkillsOptions.Serialization.cs index defcd28822f0..b3c19304b89f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ResetSkillsOptions.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ResetSkillsOptions.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class ResetSkillsOptions : IUtf8JsonSerializable + public partial class ResetSkillsOptions : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(ResetSkillsOptions)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(SkillNames)) { writer.WritePropertyName("skillNames"u8); @@ -25,14 +44,115 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WriteEndArray(); } - writer.WriteEndObject(); + 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 + } + } + } + + ResetSkillsOptions 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(ResetSkillsOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResetSkillsOptions(document.RootElement, options); + } + + internal static ResetSkillsOptions DeserializeResetSkillsOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList skillNames = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("skillNames"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + skillNames = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ResetSkillsOptions(skillNames ?? 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ResetSkillsOptions)} does not support writing '{options.Format}' format."); + } + } + + ResetSkillsOptions 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 DeserializeResetSkillsOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResetSkillsOptions)} 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 ResetSkillsOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeResetSkillsOptions(document.RootElement); } /// Convert into a . internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ResetSkillsOptions.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ResetSkillsOptions.cs index 3cfade9e4f97..8138a66089c8 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ResetSkillsOptions.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ResetSkillsOptions.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.Search.Documents.Models @@ -12,6 +13,38 @@ namespace Azure.Search.Documents.Models /// The SkillNames. public partial class ResetSkillsOptions { + /// + /// 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 ResetSkillsOptions() { @@ -20,9 +53,11 @@ public ResetSkillsOptions() /// Initializes a new instance of . /// the names of skills to be reset. - internal ResetSkillsOptions(IList skillNames) + /// Keeps track of any properties unknown to the library. + internal ResetSkillsOptions(IList skillNames, IDictionary serializedAdditionalRawData) { SkillNames = skillNames; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// the names of skills to be reset. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ScalarQuantizationCompression.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ScalarQuantizationCompression.Serialization.cs index 0b68cdef505e..cb6ff0cb73c8 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ScalarQuantizationCompression.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ScalarQuantizationCompression.Serialization.cs @@ -5,78 +5,59 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class ScalarQuantizationCompression : IUtf8JsonSerializable + public partial class ScalarQuantizationCompression : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - if (Optional.IsDefined(Parameters)) - { - writer.WritePropertyName("scalarQuantizationParameters"u8); - writer.WriteObjectValue(Parameters); - } - writer.WritePropertyName("name"u8); - writer.WriteStringValue(CompressionName); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); - if (Optional.IsDefined(RerankWithOriginalVectors)) - { - if (RerankWithOriginalVectors != null) - { - writer.WritePropertyName("rerankWithOriginalVectors"u8); - writer.WriteBooleanValue(RerankWithOriginalVectors.Value); - } - else - { - writer.WriteNull("rerankWithOriginalVectors"); - } - } - if (Optional.IsDefined(DefaultOversampling)) + 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") { - if (DefaultOversampling != null) - { - writer.WritePropertyName("defaultOversampling"u8); - writer.WriteNumberValue(DefaultOversampling.Value); - } - else - { - writer.WriteNull("defaultOversampling"); - } + throw new FormatException($"The model {nameof(ScalarQuantizationCompression)} does not support writing '{format}' format."); } - if (Optional.IsDefined(RescoringOptions)) + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Parameters)) { - if (RescoringOptions != null) - { - writer.WritePropertyName("rescoringOptions"u8); - writer.WriteObjectValue(RescoringOptions); - } - else - { - writer.WriteNull("rescoringOptions"); - } + writer.WritePropertyName("scalarQuantizationParameters"u8); + writer.WriteObjectValue(Parameters, options); } - if (Optional.IsDefined(TruncationDimension)) + } + + ScalarQuantizationCompression IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - if (TruncationDimension != null) - { - writer.WritePropertyName("truncationDimension"u8); - writer.WriteNumberValue(TruncationDimension.Value); - } - else - { - writer.WriteNull("truncationDimension"); - } + throw new FormatException($"The model {nameof(ScalarQuantizationCompression)} does not support reading '{format}' format."); } - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeScalarQuantizationCompression(document.RootElement, options); } - internal static ScalarQuantizationCompression DeserializeScalarQuantizationCompression(JsonElement element) + internal static ScalarQuantizationCompression DeserializeScalarQuantizationCompression(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -88,6 +69,8 @@ internal static ScalarQuantizationCompression DeserializeScalarQuantizationCompr double? defaultOversampling = default; RescoringOptions rescoringOptions = default; int? truncationDimension = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("scalarQuantizationParameters"u8)) @@ -96,7 +79,7 @@ internal static ScalarQuantizationCompression DeserializeScalarQuantizationCompr { continue; } - scalarQuantizationParameters = ScalarQuantizationParameters.DeserializeScalarQuantizationParameters(property.Value); + scalarQuantizationParameters = ScalarQuantizationParameters.DeserializeScalarQuantizationParameters(property.Value, options); continue; } if (property.NameEquals("name"u8)) @@ -136,7 +119,7 @@ internal static ScalarQuantizationCompression DeserializeScalarQuantizationCompr rescoringOptions = null; continue; } - rescoringOptions = RescoringOptions.DeserializeRescoringOptions(property.Value); + rescoringOptions = RescoringOptions.DeserializeRescoringOptions(property.Value, options); continue; } if (property.NameEquals("truncationDimension"u8)) @@ -149,7 +132,12 @@ internal static ScalarQuantizationCompression DeserializeScalarQuantizationCompr truncationDimension = property.Value.GetInt32(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new ScalarQuantizationCompression( name, kind, @@ -157,9 +145,41 @@ internal static ScalarQuantizationCompression DeserializeScalarQuantizationCompr defaultOversampling, rescoringOptions, truncationDimension, + serializedAdditionalRawData, scalarQuantizationParameters); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ScalarQuantizationCompression)} does not support writing '{options.Format}' format."); + } + } + + ScalarQuantizationCompression 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 DeserializeScalarQuantizationCompression(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ScalarQuantizationCompression)} 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 ScalarQuantizationCompression FromResponse(Response response) @@ -172,7 +192,7 @@ internal static ScalarQuantizationCompression DeserializeScalarQuantizationCompr internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ScalarQuantizationCompression.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ScalarQuantizationCompression.cs index fa10f9817a63..42d55a81cd28 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ScalarQuantizationCompression.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ScalarQuantizationCompression.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -29,13 +30,19 @@ public ScalarQuantizationCompression(string compressionName) : base(compressionN /// Default oversampling factor. Oversampling will internally request more documents (specified by this multiplier) in the initial search. This increases the set of results that will be reranked using recomputed similarity scores from full-precision vectors. Minimum value is 1, meaning no oversampling (1x). This parameter can only be set when rerankWithOriginalVectors is true. Higher values improve recall at the expense of latency. /// Contains the options for rescoring. /// The number of dimensions to truncate the vectors to. Truncating the vectors reduces the size of the vectors and the amount of data that needs to be transferred during search. This can save storage cost and improve search performance at the expense of recall. It should be only used for embeddings trained with Matryoshka Representation Learning (MRL) such as OpenAI text-embedding-3-large (small). The default value is null, which means no truncation. + /// Keeps track of any properties unknown to the library. /// Contains the parameters specific to Scalar Quantization. - internal ScalarQuantizationCompression(string compressionName, VectorSearchCompressionKind kind, bool? rerankWithOriginalVectors, double? defaultOversampling, RescoringOptions rescoringOptions, int? truncationDimension, ScalarQuantizationParameters parameters) : base(compressionName, kind, rerankWithOriginalVectors, defaultOversampling, rescoringOptions, truncationDimension) + internal ScalarQuantizationCompression(string compressionName, VectorSearchCompressionKind kind, bool? rerankWithOriginalVectors, double? defaultOversampling, RescoringOptions rescoringOptions, int? truncationDimension, IDictionary serializedAdditionalRawData, ScalarQuantizationParameters parameters) : base(compressionName, kind, rerankWithOriginalVectors, defaultOversampling, rescoringOptions, truncationDimension, serializedAdditionalRawData) { Parameters = parameters; Kind = kind; } + /// Initializes a new instance of for deserialization. + internal ScalarQuantizationCompression() + { + } + /// Contains the parameters specific to Scalar Quantization. public ScalarQuantizationParameters Parameters { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ScalarQuantizationParameters.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ScalarQuantizationParameters.Serialization.cs index 081bee5d424f..9759e1d14b42 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ScalarQuantizationParameters.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ScalarQuantizationParameters.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class ScalarQuantizationParameters : IUtf8JsonSerializable + public partial class ScalarQuantizationParameters : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(ScalarQuantizationParameters)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(QuantizedDataType)) { if (QuantizedDataType != null) @@ -27,16 +46,46 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("quantizedDataType"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static ScalarQuantizationParameters DeserializeScalarQuantizationParameters(JsonElement element) + ScalarQuantizationParameters 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(ScalarQuantizationParameters)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeScalarQuantizationParameters(document.RootElement, options); + } + + internal static ScalarQuantizationParameters DeserializeScalarQuantizationParameters(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } VectorSearchCompressionTarget? quantizedDataType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("quantizedDataType"u8)) @@ -49,10 +98,46 @@ internal static ScalarQuantizationParameters DeserializeScalarQuantizationParame quantizedDataType = new VectorSearchCompressionTarget(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ScalarQuantizationParameters(quantizedDataType, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ScalarQuantizationParameters)} does not support writing '{options.Format}' format."); } - return new ScalarQuantizationParameters(quantizedDataType); } + ScalarQuantizationParameters 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 DeserializeScalarQuantizationParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ScalarQuantizationParameters)} 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 ScalarQuantizationParameters FromResponse(Response response) @@ -65,7 +150,7 @@ internal static ScalarQuantizationParameters FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ScalarQuantizationParameters.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ScalarQuantizationParameters.cs index c687a6d3994d..a029badaf2e7 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ScalarQuantizationParameters.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ScalarQuantizationParameters.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Contains the parameters specific to Scalar Quantization. public partial class ScalarQuantizationParameters { + /// + /// 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 ScalarQuantizationParameters() { @@ -17,9 +52,11 @@ public ScalarQuantizationParameters() /// Initializes a new instance of . /// The quantized data type of compressed vector values. - internal ScalarQuantizationParameters(VectorSearchCompressionTarget? quantizedDataType) + /// Keeps track of any properties unknown to the library. + internal ScalarQuantizationParameters(VectorSearchCompressionTarget? quantizedDataType, IDictionary serializedAdditionalRawData) { QuantizedDataType = quantizedDataType; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The quantized data type of compressed vector values. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ScoringFunction.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ScoringFunction.Serialization.cs index f0a0160b50a6..a171fa0ee9e6 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ScoringFunction.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ScoringFunction.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Indexes.Models { - public partial class ScoringFunction : IUtf8JsonSerializable + public partial class ScoringFunction : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(ScoringFunction)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); writer.WriteStringValue(Type); writer.WritePropertyName("fieldName"u8); @@ -27,11 +45,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("interpolation"u8); writer.WriteStringValue(Interpolation.Value.ToSerialString()); } - writer.WriteEndObject(); + 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 + } + } } - internal static ScoringFunction DeserializeScoringFunction(JsonElement element) + ScoringFunction 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(ScoringFunction)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeScoringFunction(document.RootElement, options); + } + + internal static ScoringFunction DeserializeScoringFunction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -40,15 +86,46 @@ internal static ScoringFunction DeserializeScoringFunction(JsonElement element) { switch (discriminator.GetString()) { - case "distance": return DistanceScoringFunction.DeserializeDistanceScoringFunction(element); - case "freshness": return FreshnessScoringFunction.DeserializeFreshnessScoringFunction(element); - case "magnitude": return MagnitudeScoringFunction.DeserializeMagnitudeScoringFunction(element); - case "tag": return TagScoringFunction.DeserializeTagScoringFunction(element); + case "distance": return DistanceScoringFunction.DeserializeDistanceScoringFunction(element, options); + case "freshness": return FreshnessScoringFunction.DeserializeFreshnessScoringFunction(element, options); + case "magnitude": return MagnitudeScoringFunction.DeserializeMagnitudeScoringFunction(element, options); + case "tag": return TagScoringFunction.DeserializeTagScoringFunction(element, options); } } - return UnknownScoringFunction.DeserializeUnknownScoringFunction(element); + return UnknownScoringFunction.DeserializeUnknownScoringFunction(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ScoringFunction)} does not support writing '{options.Format}' format."); + } + } + + ScoringFunction 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 DeserializeScoringFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ScoringFunction)} 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 ScoringFunction FromResponse(Response response) @@ -61,7 +138,7 @@ internal static ScoringFunction FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ScoringFunction.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ScoringFunction.cs index a8fc25985a03..8e615751de9a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ScoringFunction.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ScoringFunction.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -16,17 +17,56 @@ namespace Azure.Search.Documents.Indexes.Models /// public partial class ScoringFunction { + /// + /// 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 . /// Indicates the type of function to use. Valid values include magnitude, freshness, distance, and tag. The function type must be lower case. /// The name of the field used as input to the scoring function. /// A multiplier for the raw score. Must be a positive number not equal to 1.0. /// A value indicating how boosting will be interpolated across document scores; defaults to "Linear". - internal ScoringFunction(string type, string fieldName, double boost, ScoringFunctionInterpolation? interpolation) + /// Keeps track of any properties unknown to the library. + internal ScoringFunction(string type, string fieldName, double boost, ScoringFunctionInterpolation? interpolation, IDictionary serializedAdditionalRawData) { Type = type; FieldName = fieldName; Boost = boost; Interpolation = interpolation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ScoringFunction() + { } /// Indicates the type of function to use. Valid values include magnitude, freshness, distance, and tag. The function type must be lower case. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ScoringProfile.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ScoringProfile.Serialization.cs index 818539dfdc28..003cd6ed3bf6 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ScoringProfile.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ScoringProfile.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class ScoringProfile : IUtf8JsonSerializable + public partial class ScoringProfile : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(ScoringProfile)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); if (Optional.IsDefined(TextWeights)) @@ -23,7 +41,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (TextWeights != null) { writer.WritePropertyName("text"u8); - writer.WriteObjectValue(TextWeights); + writer.WriteObjectValue(TextWeights, options); } else { @@ -36,7 +54,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in Functions) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } @@ -52,11 +70,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("functionAggregation"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static ScoringProfile DeserializeScoringProfile(JsonElement element) + ScoringProfile 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(ScoringProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeScoringProfile(document.RootElement, options); + } + + internal static ScoringProfile DeserializeScoringProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -65,6 +111,8 @@ internal static ScoringProfile DeserializeScoringProfile(JsonElement element) TextWeights text = default; IList functions = default; ScoringFunctionAggregation? functionAggregation = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -79,7 +127,7 @@ internal static ScoringProfile DeserializeScoringProfile(JsonElement element) text = null; continue; } - text = TextWeights.DeserializeTextWeights(property.Value); + text = TextWeights.DeserializeTextWeights(property.Value, options); continue; } if (property.NameEquals("functions"u8)) @@ -91,7 +139,7 @@ internal static ScoringProfile DeserializeScoringProfile(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ScoringFunction.DeserializeScoringFunction(item)); + array.Add(ScoringFunction.DeserializeScoringFunction(item, options)); } functions = array; continue; @@ -106,10 +154,46 @@ internal static ScoringProfile DeserializeScoringProfile(JsonElement element) functionAggregation = property.Value.GetString().ToScoringFunctionAggregation(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ScoringProfile(name, text, functions ?? new ChangeTrackingList(), functionAggregation, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ScoringProfile)} does not support writing '{options.Format}' format."); } - return new ScoringProfile(name, text, functions ?? new ChangeTrackingList(), functionAggregation); } + ScoringProfile 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 DeserializeScoringProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ScoringProfile)} 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 ScoringProfile FromResponse(Response response) @@ -122,7 +206,7 @@ internal static ScoringProfile FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ScoringProfile.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ScoringProfile.cs index d97a650cf2fb..f4bb81f14a59 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ScoringProfile.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ScoringProfile.cs @@ -13,6 +13,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Defines parameters for a search index that influence scoring in search queries. public partial class ScoringProfile { + /// + /// 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 . /// The name of the scoring profile. /// is null. @@ -33,12 +65,19 @@ public ScoringProfile(string name) /// The available derived classes include , , and . /// /// A value indicating how the results of individual scoring functions should be combined. Defaults to "Sum". Ignored if there are no scoring functions. - internal ScoringProfile(string name, TextWeights textWeights, IList functions, ScoringFunctionAggregation? functionAggregation) + /// Keeps track of any properties unknown to the library. + internal ScoringProfile(string name, TextWeights textWeights, IList functions, ScoringFunctionAggregation? functionAggregation, IDictionary serializedAdditionalRawData) { Name = name; TextWeights = textWeights; Functions = functions; FunctionAggregation = functionAggregation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ScoringProfile() + { } /// The name of the scoring profile. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchAlias.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchAlias.Serialization.cs index 07aeeb4adcc2..7f7f86c1ff17 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchAlias.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchAlias.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchAlias : IUtf8JsonSerializable + public partial class SearchAlias : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SearchAlias)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); writer.WritePropertyName("indexes"u8); @@ -30,11 +48,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("@odata.etag"u8); writer.WriteStringValue(_etag); } - writer.WriteEndObject(); + 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 + } + } } - internal static SearchAlias DeserializeSearchAlias(JsonElement element) + SearchAlias 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(SearchAlias)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchAlias(document.RootElement, options); + } + + internal static SearchAlias DeserializeSearchAlias(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -42,6 +88,8 @@ internal static SearchAlias DeserializeSearchAlias(JsonElement element) string name = default; IList indexes = default; string odataEtag = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -64,10 +112,46 @@ internal static SearchAlias DeserializeSearchAlias(JsonElement element) odataEtag = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchAlias(name, indexes, odataEtag, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchAlias)} does not support writing '{options.Format}' format."); } - return new SearchAlias(name, indexes, odataEtag); } + SearchAlias 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 DeserializeSearchAlias(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchAlias)} 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 SearchAlias FromResponse(Response response) @@ -80,7 +164,7 @@ internal static SearchAlias FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchAlias.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchAlias.cs index d0d00e756de9..c93cba43db28 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchAlias.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchAlias.cs @@ -14,6 +14,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Represents an index alias, which describes a mapping from the alias name to an index. The alias name can be used in place of the index name for supported operations. public partial class SearchAlias { + /// + /// 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 . /// The name of the alias. /// The name of the index this alias maps to. Only one index name may be specified. @@ -31,11 +63,18 @@ public SearchAlias(string name, IEnumerable indexes) /// The name of the alias. /// The name of the index this alias maps to. Only one index name may be specified. /// The ETag of the alias. - internal SearchAlias(string name, IList indexes, string etag) + /// Keeps track of any properties unknown to the library. + internal SearchAlias(string name, IList indexes, string etag, IDictionary serializedAdditionalRawData) { Name = name; Indexes = indexes; _etag = etag; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchAlias() + { } /// The name of the alias. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchDocumentsResult.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchDocumentsResult.Serialization.cs index 21ce1e25f69d..7f820876042c 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchDocumentsResult.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchDocumentsResult.Serialization.cs @@ -5,15 +5,163 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - internal partial class SearchDocumentsResult + internal partial class SearchDocumentsResult : IUtf8JsonSerializable, IJsonModel { - internal static SearchDocumentsResult DeserializeSearchDocumentsResult(JsonElement element) + 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(SearchDocumentsResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Count)) + { + writer.WritePropertyName("@odata.count"u8); + writer.WriteNumberValue(Count.Value); + } + if (options.Format != "W" && Optional.IsDefined(Coverage)) + { + writer.WritePropertyName("@search.coverage"u8); + writer.WriteNumberValue(Coverage.Value); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Facets)) + { + writer.WritePropertyName("@search.facets"u8); + writer.WriteStartObject(); + foreach (var item in Facets) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStartArray(); + foreach (var item0 in item.Value) + { + writer.WriteObjectValue(item0, options); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Answers)) + { + if (Answers != null) + { + writer.WritePropertyName("@search.answers"u8); + writer.WriteStartArray(); + foreach (var item in Answers) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("@search.answers"); + } + } + if (options.Format != "W" && Optional.IsDefined(DebugInfo)) + { + if (DebugInfo != null) + { + writer.WritePropertyName("@search.debug"u8); + writer.WriteObjectValue(DebugInfo, options); + } + else + { + writer.WriteNull("@search.debug"); + } + } + if (options.Format != "W" && Optional.IsDefined(NextPageParameters)) + { + writer.WritePropertyName("@search.nextPageParameters"u8); + writer.WriteObjectValue(NextPageParameters, options); + } + if (options.Format != "W") + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Results) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("@odata.nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (options.Format != "W" && Optional.IsDefined(SemanticPartialResponseReason)) + { + writer.WritePropertyName("@search.semanticPartialResponseReason"u8); + writer.WriteStringValue(SemanticPartialResponseReason.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(SemanticPartialResponseType)) + { + writer.WritePropertyName("@search.semanticPartialResponseType"u8); + writer.WriteStringValue(SemanticPartialResponseType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(SemanticQueryRewritesResultType)) + { + writer.WritePropertyName("@search.semanticQueryRewritesResultType"u8); + writer.WriteStringValue(SemanticQueryRewritesResultType.Value.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 + } + } + } + + SearchDocumentsResult 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(SearchDocumentsResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchDocumentsResult(document.RootElement, options); + } + + internal static SearchDocumentsResult DeserializeSearchDocumentsResult(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -29,6 +177,8 @@ internal static SearchDocumentsResult DeserializeSearchDocumentsResult(JsonEleme SemanticErrorReason? searchSemanticPartialResponseReason = default; SemanticSearchResultsType? searchSemanticPartialResponseType = default; SemanticQueryRewritesResultType? searchSemanticQueryRewritesResultType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@odata.count"u8)) @@ -67,7 +217,7 @@ internal static SearchDocumentsResult DeserializeSearchDocumentsResult(JsonEleme List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(FacetResult.DeserializeFacetResult(item)); + array.Add(FacetResult.DeserializeFacetResult(item, options)); } dictionary.Add(property0.Name, array); } @@ -85,7 +235,7 @@ internal static SearchDocumentsResult DeserializeSearchDocumentsResult(JsonEleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(QueryAnswerResult.DeserializeQueryAnswerResult(item)); + array.Add(QueryAnswerResult.DeserializeQueryAnswerResult(item, options)); } searchAnswers = array; continue; @@ -97,7 +247,7 @@ internal static SearchDocumentsResult DeserializeSearchDocumentsResult(JsonEleme searchDebug = null; continue; } - searchDebug = DebugInfo.DeserializeDebugInfo(property.Value); + searchDebug = DebugInfo.DeserializeDebugInfo(property.Value, options); continue; } if (property.NameEquals("@search.nextPageParameters"u8)) @@ -106,7 +256,7 @@ internal static SearchDocumentsResult DeserializeSearchDocumentsResult(JsonEleme { continue; } - searchNextPageParameters = SearchOptions.DeserializeSearchOptions(property.Value); + searchNextPageParameters = SearchOptions.DeserializeSearchOptions(property.Value, options); continue; } if (property.NameEquals("value"u8)) @@ -114,7 +264,7 @@ internal static SearchDocumentsResult DeserializeSearchDocumentsResult(JsonEleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SearchResult.DeserializeSearchResult(item)); + array.Add(SearchResult.DeserializeSearchResult(item, options)); } value = array; continue; @@ -151,7 +301,12 @@ internal static SearchDocumentsResult DeserializeSearchDocumentsResult(JsonEleme searchSemanticQueryRewritesResultType = new SemanticQueryRewritesResultType(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new SearchDocumentsResult( odataCount, searchCoverage, @@ -163,9 +318,41 @@ internal static SearchDocumentsResult DeserializeSearchDocumentsResult(JsonEleme odataNextLink, searchSemanticPartialResponseReason, searchSemanticPartialResponseType, - searchSemanticQueryRewritesResultType); + searchSemanticQueryRewritesResultType, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchDocumentsResult)} does not support writing '{options.Format}' format."); + } + } + + SearchDocumentsResult 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 DeserializeSearchDocumentsResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchDocumentsResult)} 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 SearchDocumentsResult FromResponse(Response response) @@ -173,5 +360,13 @@ internal static SearchDocumentsResult FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSearchDocumentsResult(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/search/Azure.Search.Documents/src/Generated/Models/SearchDocumentsResult.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchDocumentsResult.cs index 1e3b5acb2fff..906f71cb2cb1 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchDocumentsResult.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchDocumentsResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using System.Linq; @@ -13,6 +14,38 @@ namespace Azure.Search.Documents.Models /// Response containing search results from an index. internal partial class SearchDocumentsResult { + /// + /// 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 . /// The sequence of results returned by the query. internal SearchDocumentsResult(IEnumerable results) @@ -34,7 +67,8 @@ internal SearchDocumentsResult(IEnumerable results) /// Reason that a partial response was returned for a semantic ranking request. /// Type of partial response that was returned for a semantic ranking request. /// Type of query rewrite that was used to retrieve documents. - internal SearchDocumentsResult(long? count, double? coverage, IReadOnlyDictionary> facets, IReadOnlyList answers, DebugInfo debugInfo, SearchOptions nextPageParameters, IReadOnlyList results, string nextLink, SemanticErrorReason? semanticPartialResponseReason, SemanticSearchResultsType? semanticPartialResponseType, SemanticQueryRewritesResultType? semanticQueryRewritesResultType) + /// Keeps track of any properties unknown to the library. + internal SearchDocumentsResult(long? count, double? coverage, IReadOnlyDictionary> facets, IReadOnlyList answers, DebugInfo debugInfo, SearchOptions nextPageParameters, IReadOnlyList results, string nextLink, SemanticErrorReason? semanticPartialResponseReason, SemanticSearchResultsType? semanticPartialResponseType, SemanticQueryRewritesResultType? semanticQueryRewritesResultType, IDictionary serializedAdditionalRawData) { Count = count; Coverage = coverage; @@ -47,6 +81,12 @@ internal SearchDocumentsResult(long? count, double? coverage, IReadOnlyDictionar SemanticPartialResponseReason = semanticPartialResponseReason; SemanticPartialResponseType = semanticPartialResponseType; SemanticQueryRewritesResultType = semanticQueryRewritesResultType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchDocumentsResult() + { } /// The total count of results found by the search operation, or null if the count was not requested. If present, the count may be greater than the number of results in this response. This can happen if you use the $top or $skip parameters, or if the query can't return all the requested documents in a single response. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchField.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchField.Serialization.cs index 84b2d49928f8..376791f11c16 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchField.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchField.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchField : IUtf8JsonSerializable + public partial class SearchField : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SearchField)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); writer.WritePropertyName("type"u8); @@ -167,15 +185,43 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in Fields) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - writer.WriteEndObject(); + 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 + } + } } - internal static SearchField DeserializeSearchField(JsonElement element) + SearchField 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(SearchField)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchField(document.RootElement, options); + } + + internal static SearchField DeserializeSearchField(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -199,6 +245,8 @@ internal static SearchField DeserializeSearchField(JsonElement element) VectorEncodingFormat? vectorEncoding = default; IList synonymMaps = default; IList fields = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -377,12 +425,17 @@ internal static SearchField DeserializeSearchField(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(DeserializeSearchField(item)); + array.Add(DeserializeSearchField(item, options)); } fields = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new SearchField( name, type, @@ -402,9 +455,41 @@ internal static SearchField DeserializeSearchField(JsonElement element) vectorSearchProfile, vectorEncoding, synonymMaps ?? new ChangeTrackingList(), - fields ?? new ChangeTrackingList()); + fields ?? 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchField)} does not support writing '{options.Format}' format."); + } } + SearchField 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 DeserializeSearchField(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchField)} 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 SearchField FromResponse(Response response) @@ -417,7 +502,7 @@ internal static SearchField FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchField.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchField.cs index a27a2ad1f2dd..7e3503f32c45 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchField.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchField.cs @@ -13,6 +13,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Represents a field in an index definition, which describes the name, data type, and search behavior of a field. public partial class SearchField { + /// + /// 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 . /// The name of the field, which must be unique within the fields collection of the index or parent field. /// The data type of the field. @@ -33,7 +65,8 @@ public partial class SearchField /// The encoding format to interpret the field contents. /// A list of the names of synonym maps to associate with this field. This option can be used only with searchable fields. Currently only one synonym map per field is supported. Assigning a synonym map to a field ensures that query terms targeting that field are expanded at query-time using the rules in the synonym map. This attribute can be changed on existing fields. Must be null or an empty collection for complex fields. /// A list of sub-fields if this is a field of type Edm.ComplexType or Collection(Edm.ComplexType). Must be null or empty for simple fields. - internal SearchField(string name, SearchFieldDataType type, bool? isKey, bool? isRetrievable, bool? isStored, bool? isSearchable, bool? isFilterable, bool? isSortable, bool? isFacetable, PermissionFilter? permissionFilter, LexicalAnalyzerName? analyzerName, LexicalAnalyzerName? searchAnalyzerName, LexicalAnalyzerName? indexAnalyzerName, LexicalNormalizerName? normalizerName, int? vectorSearchDimensions, string vectorSearchProfileName, VectorEncodingFormat? vectorEncodingFormat, IList synonymMapNames, IList fields) + /// Keeps track of any properties unknown to the library. + internal SearchField(string name, SearchFieldDataType type, bool? isKey, bool? isRetrievable, bool? isStored, bool? isSearchable, bool? isFilterable, bool? isSortable, bool? isFacetable, PermissionFilter? permissionFilter, LexicalAnalyzerName? analyzerName, LexicalAnalyzerName? searchAnalyzerName, LexicalAnalyzerName? indexAnalyzerName, LexicalNormalizerName? normalizerName, int? vectorSearchDimensions, string vectorSearchProfileName, VectorEncodingFormat? vectorEncodingFormat, IList synonymMapNames, IList fields, IDictionary serializedAdditionalRawData) { Name = name; Type = type; @@ -54,6 +87,12 @@ internal SearchField(string name, SearchFieldDataType type, bool? isKey, bool? i VectorEncodingFormat = vectorEncodingFormat; SynonymMapNames = synonymMapNames; Fields = fields; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchField() + { } /// A value indicating whether the field should be used as a permission filter. public PermissionFilter? PermissionFilter { get; set; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndex.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndex.Serialization.cs index 18fb1a7a9b9a..d432af74783e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndex.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndex.Serialization.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; @@ -12,11 +14,27 @@ namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchIndex : IUtf8JsonSerializable + public partial class SearchIndex : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SearchIndex)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); if (Optional.IsDefined(Description)) @@ -28,7 +46,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in _fields) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); if (Optional.IsCollectionDefined(ScoringProfiles)) @@ -37,7 +55,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in ScoringProfiles) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } @@ -51,7 +69,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (CorsOptions != null) { writer.WritePropertyName("corsOptions"u8); - writer.WriteObjectValue(CorsOptions); + writer.WriteObjectValue(CorsOptions, options); } else { @@ -64,7 +82,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in Suggesters) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } @@ -74,7 +92,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in Analyzers) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } @@ -84,7 +102,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in Tokenizers) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } @@ -94,7 +112,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in TokenFilters) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } @@ -104,7 +122,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in CharFilters) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } @@ -114,7 +132,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in Normalizers) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } @@ -123,7 +141,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (EncryptionKey != null) { writer.WritePropertyName("encryptionKey"u8); - writer.WriteObjectValue(EncryptionKey); + writer.WriteObjectValue(EncryptionKey, options); } else { @@ -133,14 +151,14 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Similarity)) { writer.WritePropertyName("similarity"u8); - writer.WriteObjectValue(Similarity); + writer.WriteObjectValue(Similarity, options); } if (Optional.IsDefined(SemanticSearch)) { if (SemanticSearch != null) { writer.WritePropertyName("semantic"u8); - writer.WriteObjectValue(SemanticSearch); + writer.WriteObjectValue(SemanticSearch, options); } else { @@ -152,7 +170,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (VectorSearch != null) { writer.WritePropertyName("vectorSearch"u8); - writer.WriteObjectValue(VectorSearch); + writer.WriteObjectValue(VectorSearch, options); } else { @@ -176,11 +194,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("@odata.etag"u8); writer.WriteStringValue(_etag); } - writer.WriteEndObject(); + 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 + } + } } - internal static SearchIndex DeserializeSearchIndex(JsonElement element) + SearchIndex 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(SearchIndex)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndex(document.RootElement, options); + } + + internal static SearchIndex DeserializeSearchIndex(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -203,6 +249,8 @@ internal static SearchIndex DeserializeSearchIndex(JsonElement element) VectorSearch vectorSearch = default; SearchIndexPermissionFilterOption? permissionFilterOption = default; string odataEtag = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -220,7 +268,7 @@ internal static SearchIndex DeserializeSearchIndex(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SearchField.DeserializeSearchField(item)); + array.Add(SearchField.DeserializeSearchField(item, options)); } fields = array; continue; @@ -234,7 +282,7 @@ internal static SearchIndex DeserializeSearchIndex(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ScoringProfile.DeserializeScoringProfile(item)); + array.Add(ScoringProfile.DeserializeScoringProfile(item, options)); } scoringProfiles = array; continue; @@ -251,7 +299,7 @@ internal static SearchIndex DeserializeSearchIndex(JsonElement element) corsOptions = null; continue; } - corsOptions = CorsOptions.DeserializeCorsOptions(property.Value); + corsOptions = CorsOptions.DeserializeCorsOptions(property.Value, options); continue; } if (property.NameEquals("suggesters"u8)) @@ -263,7 +311,7 @@ internal static SearchIndex DeserializeSearchIndex(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SearchSuggester.DeserializeSearchSuggester(item)); + array.Add(SearchSuggester.DeserializeSearchSuggester(item, options)); } suggesters = array; continue; @@ -277,7 +325,7 @@ internal static SearchIndex DeserializeSearchIndex(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(LexicalAnalyzer.DeserializeLexicalAnalyzer(item)); + array.Add(LexicalAnalyzer.DeserializeLexicalAnalyzer(item, options)); } analyzers = array; continue; @@ -291,7 +339,7 @@ internal static SearchIndex DeserializeSearchIndex(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(LexicalTokenizer.DeserializeLexicalTokenizer(item)); + array.Add(LexicalTokenizer.DeserializeLexicalTokenizer(item, options)); } tokenizers = array; continue; @@ -305,7 +353,7 @@ internal static SearchIndex DeserializeSearchIndex(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(TokenFilter.DeserializeTokenFilter(item)); + array.Add(TokenFilter.DeserializeTokenFilter(item, options)); } tokenFilters = array; continue; @@ -319,7 +367,7 @@ internal static SearchIndex DeserializeSearchIndex(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(CharFilter.DeserializeCharFilter(item)); + array.Add(CharFilter.DeserializeCharFilter(item, options)); } charFilters = array; continue; @@ -333,7 +381,7 @@ internal static SearchIndex DeserializeSearchIndex(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(LexicalNormalizer.DeserializeLexicalNormalizer(item)); + array.Add(LexicalNormalizer.DeserializeLexicalNormalizer(item, options)); } normalizers = array; continue; @@ -345,7 +393,7 @@ internal static SearchIndex DeserializeSearchIndex(JsonElement element) encryptionKey = null; continue; } - encryptionKey = SearchResourceEncryptionKey.DeserializeSearchResourceEncryptionKey(property.Value); + encryptionKey = SearchResourceEncryptionKey.DeserializeSearchResourceEncryptionKey(property.Value, options); continue; } if (property.NameEquals("similarity"u8)) @@ -354,7 +402,7 @@ internal static SearchIndex DeserializeSearchIndex(JsonElement element) { continue; } - similarity = SimilarityAlgorithm.DeserializeSimilarityAlgorithm(property.Value); + similarity = SimilarityAlgorithm.DeserializeSimilarityAlgorithm(property.Value, options); continue; } if (property.NameEquals("semantic"u8)) @@ -364,7 +412,7 @@ internal static SearchIndex DeserializeSearchIndex(JsonElement element) semantic = null; continue; } - semantic = SemanticSearch.DeserializeSemanticSearch(property.Value); + semantic = SemanticSearch.DeserializeSemanticSearch(property.Value, options); continue; } if (property.NameEquals("vectorSearch"u8)) @@ -374,7 +422,7 @@ internal static SearchIndex DeserializeSearchIndex(JsonElement element) vectorSearch = null; continue; } - vectorSearch = VectorSearch.DeserializeVectorSearch(property.Value); + vectorSearch = VectorSearch.DeserializeVectorSearch(property.Value, options); continue; } if (property.NameEquals("permissionFilterOption"u8)) @@ -392,7 +440,12 @@ internal static SearchIndex DeserializeSearchIndex(JsonElement element) odataEtag = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new SearchIndex( name, description, @@ -411,9 +464,41 @@ internal static SearchIndex DeserializeSearchIndex(JsonElement element) semantic, vectorSearch, permissionFilterOption, - odataEtag); + odataEtag, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndex)} does not support writing '{options.Format}' format."); + } } + SearchIndex 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 DeserializeSearchIndex(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndex)} 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 SearchIndex FromResponse(Response response) @@ -426,7 +511,7 @@ internal static SearchIndex FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndex.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndex.cs index 3b4e9386b210..6ed5d32a8596 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndex.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndex.cs @@ -15,6 +15,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Represents a search index definition, which describes the fields and search behavior of an index. public partial class SearchIndex { + /// + /// 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 . /// The name of the index. /// The description of the index. @@ -31,12 +63,12 @@ public partial class SearchIndex /// /// The tokenizers for the index. /// 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 available derived classes include , , , , , , , , and . /// /// /// The token filters for the index. /// 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 available derived classes include , , , , , , , , , , , , , , , , , , , , , and . /// /// /// The character filters for the index. @@ -58,7 +90,8 @@ public partial class SearchIndex /// Contains configuration options related to vector search. /// A value indicating whether permission filtering is enabled for the index. /// The ETag of the index. - internal SearchIndex(string name, string description, IList fields, IList scoringProfiles, string defaultScoringProfile, CorsOptions corsOptions, IList suggesters, IList analyzers, IList tokenizers, IList tokenFilters, IList charFilters, IList normalizers, SearchResourceEncryptionKey encryptionKey, SimilarityAlgorithm similarity, SemanticSearch semanticSearch, VectorSearch vectorSearch, SearchIndexPermissionFilterOption? permissionFilterOption, string etag) + /// Keeps track of any properties unknown to the library. + internal SearchIndex(string name, string description, IList fields, IList scoringProfiles, string defaultScoringProfile, CorsOptions corsOptions, IList suggesters, IList analyzers, IList tokenizers, IList tokenFilters, IList charFilters, IList normalizers, SearchResourceEncryptionKey encryptionKey, SimilarityAlgorithm similarity, SemanticSearch semanticSearch, VectorSearch vectorSearch, SearchIndexPermissionFilterOption? permissionFilterOption, string etag, IDictionary serializedAdditionalRawData) { Name = name; Description = description; @@ -78,6 +111,12 @@ internal SearchIndex(string name, string description, IList fields, VectorSearch = vectorSearch; PermissionFilterOption = permissionFilterOption; _etag = etag; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchIndex() + { } /// The description of the index. public string Description { get; set; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexStatistics.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexStatistics.Serialization.cs index db8623c6e853..d3210c1c6885 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexStatistics.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexStatistics.Serialization.cs @@ -5,14 +5,83 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchIndexStatistics + public partial class SearchIndexStatistics : IUtf8JsonSerializable, IJsonModel { - internal static SearchIndexStatistics DeserializeSearchIndexStatistics(JsonElement element) + 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(SearchIndexStatistics)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("documentCount"u8); + writer.WriteNumberValue(DocumentCount); + } + if (options.Format != "W") + { + writer.WritePropertyName("storageSize"u8); + writer.WriteNumberValue(StorageSize); + } + if (options.Format != "W") + { + writer.WritePropertyName("vectorIndexSize"u8); + writer.WriteNumberValue(VectorIndexSize); + } + 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 + } + } + } + + SearchIndexStatistics 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(SearchIndexStatistics)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndexStatistics(document.RootElement, options); + } + + internal static SearchIndexStatistics DeserializeSearchIndexStatistics(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -20,6 +89,8 @@ internal static SearchIndexStatistics DeserializeSearchIndexStatistics(JsonEleme long documentCount = default; long storageSize = default; long vectorIndexSize = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("documentCount"u8)) @@ -37,10 +108,46 @@ internal static SearchIndexStatistics DeserializeSearchIndexStatistics(JsonEleme vectorIndexSize = property.Value.GetInt64(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchIndexStatistics(documentCount, storageSize, vectorIndexSize, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndexStatistics)} does not support writing '{options.Format}' format."); } - return new SearchIndexStatistics(documentCount, storageSize, vectorIndexSize); } + SearchIndexStatistics 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 DeserializeSearchIndexStatistics(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndexStatistics)} 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 SearchIndexStatistics FromResponse(Response response) @@ -48,5 +155,13 @@ internal static SearchIndexStatistics FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSearchIndexStatistics(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/search/Azure.Search.Documents/src/Generated/Models/SearchIndexStatistics.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexStatistics.cs index 6dcacbea3f3d..d39bfd00226a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexStatistics.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexStatistics.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Statistics for a given index. Statistics are collected periodically and are not guaranteed to always be up-to-date. public partial class SearchIndexStatistics { + /// + /// 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 . /// The number of documents in the index. /// The amount of storage in bytes consumed by the index. @@ -21,6 +56,24 @@ internal SearchIndexStatistics(long documentCount, long storageSize, long vector VectorIndexSize = vectorIndexSize; } + /// Initializes a new instance of . + /// The number of documents in the index. + /// The amount of storage in bytes consumed by the index. + /// The amount of memory in bytes consumed by vectors in the index. + /// Keeps track of any properties unknown to the library. + internal SearchIndexStatistics(long documentCount, long storageSize, long vectorIndexSize, IDictionary serializedAdditionalRawData) + { + DocumentCount = documentCount; + StorageSize = storageSize; + VectorIndexSize = vectorIndexSize; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchIndexStatistics() + { + } + /// The number of documents in the index. public long DocumentCount { get; } /// The amount of storage in bytes consumed by the index. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexer.Serialization.cs index e2f6013c6e34..e366e8c7b754 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexer.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchIndexer : IUtf8JsonSerializable + public partial class SearchIndexer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SearchIndexer)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); if (Optional.IsDefined(Description)) @@ -37,7 +55,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Schedule != null) { writer.WritePropertyName("schedule"u8); - writer.WriteObjectValue(Schedule); + writer.WriteObjectValue(Schedule, options); } else { @@ -49,7 +67,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Parameters != null) { writer.WritePropertyName("parameters"u8); - writer.WriteObjectValue(Parameters); + writer.WriteObjectValue(Parameters, options); } else { @@ -62,7 +80,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in FieldMappings) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } @@ -72,7 +90,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in OutputFieldMappings) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } @@ -98,7 +116,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (EncryptionKey != null) { writer.WritePropertyName("encryptionKey"u8); - writer.WriteObjectValue(EncryptionKey); + writer.WriteObjectValue(EncryptionKey, options); } else { @@ -110,18 +128,46 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Cache != null) { writer.WritePropertyName("cache"u8); - writer.WriteObjectValue(Cache); + writer.WriteObjectValue(Cache, options); } else { writer.WriteNull("cache"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static SearchIndexer DeserializeSearchIndexer(JsonElement element) + SearchIndexer 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(SearchIndexer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndexer(document.RootElement, options); + } + + internal static SearchIndexer DeserializeSearchIndexer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -139,6 +185,8 @@ internal static SearchIndexer DeserializeSearchIndexer(JsonElement element) string odataEtag = default; SearchResourceEncryptionKey encryptionKey = default; SearchIndexerCache cache = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -173,7 +221,7 @@ internal static SearchIndexer DeserializeSearchIndexer(JsonElement element) schedule = null; continue; } - schedule = IndexingSchedule.DeserializeIndexingSchedule(property.Value); + schedule = IndexingSchedule.DeserializeIndexingSchedule(property.Value, options); continue; } if (property.NameEquals("parameters"u8)) @@ -183,7 +231,7 @@ internal static SearchIndexer DeserializeSearchIndexer(JsonElement element) parameters = null; continue; } - parameters = IndexingParameters.DeserializeIndexingParameters(property.Value); + parameters = IndexingParameters.DeserializeIndexingParameters(property.Value, options); continue; } if (property.NameEquals("fieldMappings"u8)) @@ -195,7 +243,7 @@ internal static SearchIndexer DeserializeSearchIndexer(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(FieldMapping.DeserializeFieldMapping(item)); + array.Add(FieldMapping.DeserializeFieldMapping(item, options)); } fieldMappings = array; continue; @@ -209,7 +257,7 @@ internal static SearchIndexer DeserializeSearchIndexer(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(FieldMapping.DeserializeFieldMapping(item)); + array.Add(FieldMapping.DeserializeFieldMapping(item, options)); } outputFieldMappings = array; continue; @@ -236,7 +284,7 @@ internal static SearchIndexer DeserializeSearchIndexer(JsonElement element) encryptionKey = null; continue; } - encryptionKey = SearchResourceEncryptionKey.DeserializeSearchResourceEncryptionKey(property.Value); + encryptionKey = SearchResourceEncryptionKey.DeserializeSearchResourceEncryptionKey(property.Value, options); continue; } if (property.NameEquals("cache"u8)) @@ -246,10 +294,15 @@ internal static SearchIndexer DeserializeSearchIndexer(JsonElement element) cache = null; continue; } - cache = SearchIndexerCache.DeserializeSearchIndexerCache(property.Value); + cache = SearchIndexerCache.DeserializeSearchIndexerCache(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new SearchIndexer( name, description, @@ -263,9 +316,41 @@ internal static SearchIndexer DeserializeSearchIndexer(JsonElement element) disabled, odataEtag, encryptionKey, - cache); + cache, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndexer)} does not support writing '{options.Format}' format."); + } } + SearchIndexer 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 DeserializeSearchIndexer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndexer)} 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 SearchIndexer FromResponse(Response response) @@ -278,7 +363,7 @@ internal static SearchIndexer FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexer.cs index 2d851fc20771..46f648619870 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexer.cs @@ -13,6 +13,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Represents an indexer. public partial class SearchIndexer { + /// + /// 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 . /// The name of the indexer. /// The name of the datasource from which this indexer reads data. @@ -45,7 +77,8 @@ public SearchIndexer(string name, string dataSourceName, string targetIndexName) /// The ETag of the indexer. /// A description of an encryption key that you create in Azure Key Vault. This key is used to provide an additional level of encryption-at-rest for your indexer definition (as well as indexer execution status) when you want full assurance that no one, not even Microsoft, can decrypt them. Once you have encrypted your indexer definition, it will always remain encrypted. The search service will ignore attempts to set this property to null. You can change this property as needed if you want to rotate your encryption key; Your indexer definition (and indexer execution status) will be unaffected. Encryption with customer-managed keys is not available for free search services, and is only available for paid services created on or after January 1, 2019. /// Adds caching to an enrichment pipeline to allow for incremental modification steps without having to rebuild the index every time. - internal SearchIndexer(string name, string description, string dataSourceName, string skillsetName, string targetIndexName, IndexingSchedule schedule, IndexingParameters parameters, IList fieldMappings, IList outputFieldMappings, bool? isDisabled, string etag, SearchResourceEncryptionKey encryptionKey, SearchIndexerCache cache) + /// Keeps track of any properties unknown to the library. + internal SearchIndexer(string name, string description, string dataSourceName, string skillsetName, string targetIndexName, IndexingSchedule schedule, IndexingParameters parameters, IList fieldMappings, IList outputFieldMappings, bool? isDisabled, string etag, SearchResourceEncryptionKey encryptionKey, SearchIndexerCache cache, IDictionary serializedAdditionalRawData) { Name = name; Description = description; @@ -60,6 +93,12 @@ internal SearchIndexer(string name, string description, string dataSourceName, s _etag = etag; EncryptionKey = encryptionKey; Cache = cache; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchIndexer() + { } /// The name of the indexer. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerCache.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerCache.Serialization.cs index 1b2596884feb..9f9713086a3c 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerCache.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerCache.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchIndexerCache : IUtf8JsonSerializable + public partial class SearchIndexerCache : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SearchIndexerCache)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Id)) { writer.WritePropertyName("id"u8); @@ -42,18 +61,46 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Identity != null) { writer.WritePropertyName("identity"u8); - writer.WriteObjectValue(Identity); + writer.WriteObjectValue(Identity, options); } else { writer.WriteNull("identity"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static SearchIndexerCache DeserializeSearchIndexerCache(JsonElement element) + SearchIndexerCache 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(SearchIndexerCache)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndexerCache(document.RootElement, options); + } + + internal static SearchIndexerCache DeserializeSearchIndexerCache(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -62,6 +109,8 @@ internal static SearchIndexerCache DeserializeSearchIndexerCache(JsonElement ele string storageConnectionString = default; bool? enableReprocessing = default; SearchIndexerDataIdentity identity = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id"u8)) @@ -91,13 +140,49 @@ internal static SearchIndexerCache DeserializeSearchIndexerCache(JsonElement ele identity = null; continue; } - identity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value); + identity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchIndexerCache(id, storageConnectionString, enableReprocessing, identity, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndexerCache)} does not support writing '{options.Format}' format."); } - return new SearchIndexerCache(id, storageConnectionString, enableReprocessing, identity); } + SearchIndexerCache 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 DeserializeSearchIndexerCache(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndexerCache)} 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 SearchIndexerCache FromResponse(Response response) @@ -110,7 +195,7 @@ internal static SearchIndexerCache FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerCache.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerCache.cs index 2a7e3b785262..06e0883ad2d9 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerCache.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerCache.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// The SearchIndexerCache. public partial class SearchIndexerCache { + /// + /// 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 SearchIndexerCache() { @@ -24,12 +59,14 @@ public SearchIndexerCache() /// 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 . /// - internal SearchIndexerCache(string id, string storageConnectionString, bool? enableReprocessing, SearchIndexerDataIdentity identity) + /// Keeps track of any properties unknown to the library. + internal SearchIndexerCache(string id, string storageConnectionString, bool? enableReprocessing, SearchIndexerDataIdentity identity, IDictionary serializedAdditionalRawData) { Id = id; StorageConnectionString = storageConnectionString; EnableReprocessing = enableReprocessing; Identity = identity; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// A guid for the SearchIndexerCache. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataContainer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataContainer.Serialization.cs index 8c8309cbaa03..ab062e3b5877 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataContainer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataContainer.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchIndexerDataContainer : IUtf8JsonSerializable + public partial class SearchIndexerDataContainer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SearchIndexerDataContainer)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); if (Optional.IsDefined(Query)) @@ -22,17 +41,47 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("query"u8); writer.WriteStringValue(Query); } - writer.WriteEndObject(); + 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 + } + } } - internal static SearchIndexerDataContainer DeserializeSearchIndexerDataContainer(JsonElement element) + SearchIndexerDataContainer 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(SearchIndexerDataContainer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndexerDataContainer(document.RootElement, options); + } + + internal static SearchIndexerDataContainer DeserializeSearchIndexerDataContainer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string name = default; string query = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -45,10 +94,46 @@ internal static SearchIndexerDataContainer DeserializeSearchIndexerDataContainer query = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new SearchIndexerDataContainer(name, query); + serializedAdditionalRawData = rawDataDictionary; + return new SearchIndexerDataContainer(name, query, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndexerDataContainer)} does not support writing '{options.Format}' format."); + } + } + + SearchIndexerDataContainer 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 DeserializeSearchIndexerDataContainer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndexerDataContainer)} 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 SearchIndexerDataContainer FromResponse(Response response) @@ -61,7 +146,7 @@ internal static SearchIndexerDataContainer FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataContainer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataContainer.cs index ee53b07012c5..17dcdc8058e6 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataContainer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataContainer.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Represents information about the entity (such as Azure SQL table or CosmosDB collection) that will be indexed. public partial class SearchIndexerDataContainer { + /// + /// 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 . /// The name of the table or view (for Azure SQL data source) or collection (for CosmosDB data source) that will be indexed. /// is null. @@ -25,10 +58,17 @@ public SearchIndexerDataContainer(string name) /// Initializes a new instance of . /// The name of the table or view (for Azure SQL data source) or collection (for CosmosDB data source) that will be indexed. /// A query that is applied to this data container. The syntax and meaning of this parameter is datasource-specific. Not supported by Azure SQL datasources. - internal SearchIndexerDataContainer(string name, string query) + /// Keeps track of any properties unknown to the library. + internal SearchIndexerDataContainer(string name, string query, IDictionary serializedAdditionalRawData) { Name = name; Query = query; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchIndexerDataContainer() + { } /// The name of the table or view (for Azure SQL data source) or collection (for CosmosDB data source) that will be indexed. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataIdentity.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataIdentity.Serialization.cs index c718810f29f1..518467d4f43f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataIdentity.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataIdentity.Serialization.cs @@ -5,24 +5,71 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchIndexerDataIdentity : IUtf8JsonSerializable + [PersistableModelProxy(typeof(UnknownSearchIndexerDataIdentity))] + public partial class SearchIndexerDataIdentity : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SearchIndexerDataIdentity)} does not support writing '{format}' format."); + } + writer.WritePropertyName("@odata.type"u8); writer.WriteStringValue(ODataType); - writer.WriteEndObject(); + 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 + } + } } - internal static SearchIndexerDataIdentity DeserializeSearchIndexerDataIdentity(JsonElement element) + SearchIndexerDataIdentity 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(SearchIndexerDataIdentity)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndexerDataIdentity(document.RootElement, options); + } + + internal static SearchIndexerDataIdentity DeserializeSearchIndexerDataIdentity(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -31,13 +78,44 @@ internal static SearchIndexerDataIdentity DeserializeSearchIndexerDataIdentity(J { switch (discriminator.GetString()) { - case "#Microsoft.Azure.Search.DataNoneIdentity": return SearchIndexerDataNoneIdentity.DeserializeSearchIndexerDataNoneIdentity(element); - case "#Microsoft.Azure.Search.DataUserAssignedIdentity": return SearchIndexerDataUserAssignedIdentity.DeserializeSearchIndexerDataUserAssignedIdentity(element); + case "#Microsoft.Azure.Search.DataNoneIdentity": return SearchIndexerDataNoneIdentity.DeserializeSearchIndexerDataNoneIdentity(element, options); + case "#Microsoft.Azure.Search.DataUserAssignedIdentity": return SearchIndexerDataUserAssignedIdentity.DeserializeSearchIndexerDataUserAssignedIdentity(element, options); } } - return UnknownSearchIndexerDataIdentity.DeserializeUnknownSearchIndexerDataIdentity(element); + return UnknownSearchIndexerDataIdentity.DeserializeUnknownSearchIndexerDataIdentity(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndexerDataIdentity)} does not support writing '{options.Format}' format."); + } + } + + SearchIndexerDataIdentity 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 DeserializeSearchIndexerDataIdentity(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndexerDataIdentity)} 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 SearchIndexerDataIdentity FromResponse(Response response) @@ -50,7 +128,7 @@ internal static SearchIndexerDataIdentity FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataIdentity.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataIdentity.cs index b60660581053..e019d767fa5f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataIdentity.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataIdentity.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// @@ -14,6 +17,38 @@ namespace Azure.Search.Documents.Indexes.Models /// public abstract partial class SearchIndexerDataIdentity { + /// + /// 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 . public SearchIndexerDataIdentity() { @@ -21,9 +56,11 @@ public SearchIndexerDataIdentity() /// Initializes a new instance of . /// A URI fragment specifying the type of identity. - internal SearchIndexerDataIdentity(string oDataType) + /// Keeps track of any properties unknown to the library. + internal SearchIndexerDataIdentity(string oDataType, IDictionary serializedAdditionalRawData) { ODataType = oDataType; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// A URI fragment specifying the type of identity. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataNoneIdentity.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataNoneIdentity.Serialization.cs index 7cacdce4e8b7..afae30675e11 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataNoneIdentity.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataNoneIdentity.Serialization.cs @@ -5,28 +5,61 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchIndexerDataNoneIdentity : IUtf8JsonSerializable + public partial class SearchIndexerDataNoneIdentity : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); + JsonModelWriteCore(writer, options); writer.WriteEndObject(); } - internal static SearchIndexerDataNoneIdentity DeserializeSearchIndexerDataNoneIdentity(JsonElement element) + /// 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(SearchIndexerDataNoneIdentity)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + SearchIndexerDataNoneIdentity 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(SearchIndexerDataNoneIdentity)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndexerDataNoneIdentity(document.RootElement, options); + } + + internal static SearchIndexerDataNoneIdentity DeserializeSearchIndexerDataNoneIdentity(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string odataType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@odata.type"u8)) @@ -34,10 +67,46 @@ internal static SearchIndexerDataNoneIdentity DeserializeSearchIndexerDataNoneId odataType = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchIndexerDataNoneIdentity(odataType, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndexerDataNoneIdentity)} does not support writing '{options.Format}' format."); } - return new SearchIndexerDataNoneIdentity(odataType); } + SearchIndexerDataNoneIdentity 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 DeserializeSearchIndexerDataNoneIdentity(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndexerDataNoneIdentity)} 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 SearchIndexerDataNoneIdentity FromResponse(Response response) @@ -50,7 +119,7 @@ internal static SearchIndexerDataNoneIdentity DeserializeSearchIndexerDataNoneId internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataNoneIdentity.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataNoneIdentity.cs index 1ca02ea386cf..d1c76ca64ed5 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataNoneIdentity.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataNoneIdentity.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Clears the identity property of a datasource. @@ -18,7 +21,8 @@ public SearchIndexerDataNoneIdentity() /// Initializes a new instance of . /// A URI fragment specifying the type of identity. - internal SearchIndexerDataNoneIdentity(string oDataType) : base(oDataType) + /// Keeps track of any properties unknown to the library. + internal SearchIndexerDataNoneIdentity(string oDataType, IDictionary serializedAdditionalRawData) : base(oDataType, serializedAdditionalRawData) { ODataType = oDataType ?? "#Microsoft.Azure.Search.DataNoneIdentity"; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataSourceConnection.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataSourceConnection.Serialization.cs index ad980aa07a70..795dee493356 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataSourceConnection.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataSourceConnection.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchIndexerDataSourceConnection : IUtf8JsonSerializable + public partial class SearchIndexerDataSourceConnection : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SearchIndexerDataSourceConnection)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); if (Optional.IsDefined(Description)) @@ -26,15 +44,15 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("type"u8); writer.WriteStringValue(Type.ToString()); writer.WritePropertyName("credentials"u8); - writer.WriteObjectValue(CredentialsInternal); + writer.WriteObjectValue(CredentialsInternal, options); writer.WritePropertyName("container"u8); - writer.WriteObjectValue(Container); + writer.WriteObjectValue(Container, options); if (Optional.IsDefined(Identity)) { if (Identity != null) { writer.WritePropertyName("identity"u8); - writer.WriteObjectValue(Identity); + writer.WriteObjectValue(Identity, options); } else { @@ -56,7 +74,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (DataChangeDetectionPolicy != null) { writer.WritePropertyName("dataChangeDetectionPolicy"u8); - writer.WriteObjectValue(DataChangeDetectionPolicy); + writer.WriteObjectValue(DataChangeDetectionPolicy, options); } else { @@ -68,7 +86,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (DataDeletionDetectionPolicy != null) { writer.WritePropertyName("dataDeletionDetectionPolicy"u8); - writer.WriteObjectValue(DataDeletionDetectionPolicy); + writer.WriteObjectValue(DataDeletionDetectionPolicy, options); } else { @@ -85,18 +103,46 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (EncryptionKey != null) { writer.WritePropertyName("encryptionKey"u8); - writer.WriteObjectValue(EncryptionKey); + writer.WriteObjectValue(EncryptionKey, options); } else { writer.WriteNull("encryptionKey"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static SearchIndexerDataSourceConnection DeserializeSearchIndexerDataSourceConnection(JsonElement element) + SearchIndexerDataSourceConnection 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(SearchIndexerDataSourceConnection)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndexerDataSourceConnection(document.RootElement, options); + } + + internal static SearchIndexerDataSourceConnection DeserializeSearchIndexerDataSourceConnection(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -112,6 +158,8 @@ internal static SearchIndexerDataSourceConnection DeserializeSearchIndexerDataSo DataDeletionDetectionPolicy dataDeletionDetectionPolicy = default; string odataEtag = default; SearchResourceEncryptionKey encryptionKey = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -131,12 +179,12 @@ internal static SearchIndexerDataSourceConnection DeserializeSearchIndexerDataSo } if (property.NameEquals("credentials"u8)) { - credentials = DataSourceCredentials.DeserializeDataSourceCredentials(property.Value); + credentials = DataSourceCredentials.DeserializeDataSourceCredentials(property.Value, options); continue; } if (property.NameEquals("container"u8)) { - container = SearchIndexerDataContainer.DeserializeSearchIndexerDataContainer(property.Value); + container = SearchIndexerDataContainer.DeserializeSearchIndexerDataContainer(property.Value, options); continue; } if (property.NameEquals("identity"u8)) @@ -146,7 +194,7 @@ internal static SearchIndexerDataSourceConnection DeserializeSearchIndexerDataSo identity = null; continue; } - identity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value); + identity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value, options); continue; } if (property.NameEquals("indexerPermissionOptions"u8)) @@ -170,7 +218,7 @@ internal static SearchIndexerDataSourceConnection DeserializeSearchIndexerDataSo dataChangeDetectionPolicy = null; continue; } - dataChangeDetectionPolicy = DataChangeDetectionPolicy.DeserializeDataChangeDetectionPolicy(property.Value); + dataChangeDetectionPolicy = DataChangeDetectionPolicy.DeserializeDataChangeDetectionPolicy(property.Value, options); continue; } if (property.NameEquals("dataDeletionDetectionPolicy"u8)) @@ -180,7 +228,7 @@ internal static SearchIndexerDataSourceConnection DeserializeSearchIndexerDataSo dataDeletionDetectionPolicy = null; continue; } - dataDeletionDetectionPolicy = DataDeletionDetectionPolicy.DeserializeDataDeletionDetectionPolicy(property.Value); + dataDeletionDetectionPolicy = DataDeletionDetectionPolicy.DeserializeDataDeletionDetectionPolicy(property.Value, options); continue; } if (property.NameEquals("@odata.etag"u8)) @@ -195,10 +243,15 @@ internal static SearchIndexerDataSourceConnection DeserializeSearchIndexerDataSo encryptionKey = null; continue; } - encryptionKey = SearchResourceEncryptionKey.DeserializeSearchResourceEncryptionKey(property.Value); + encryptionKey = SearchResourceEncryptionKey.DeserializeSearchResourceEncryptionKey(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new SearchIndexerDataSourceConnection( name, description, @@ -210,9 +263,41 @@ internal static SearchIndexerDataSourceConnection DeserializeSearchIndexerDataSo dataChangeDetectionPolicy, dataDeletionDetectionPolicy, odataEtag, - encryptionKey); + encryptionKey, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndexerDataSourceConnection)} does not support writing '{options.Format}' format."); + } } + SearchIndexerDataSourceConnection 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 DeserializeSearchIndexerDataSourceConnection(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndexerDataSourceConnection)} 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 SearchIndexerDataSourceConnection FromResponse(Response response) @@ -225,7 +310,7 @@ internal static SearchIndexerDataSourceConnection FromResponse(Response response internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataSourceConnection.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataSourceConnection.cs index 6edf57185de7..558f1ef115cd 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataSourceConnection.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataSourceConnection.cs @@ -13,6 +13,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Represents a datasource definition, which can be used to configure an indexer. public partial class SearchIndexerDataSourceConnection { + /// + /// 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 . /// The name of the datasource. /// The description of the datasource. @@ -37,7 +69,8 @@ public partial class SearchIndexerDataSourceConnection /// /// The ETag of the data source. /// A description of an encryption key that you create in Azure Key Vault. This key is used to provide an additional level of encryption-at-rest for your datasource definition when you want full assurance that no one, not even Microsoft, can decrypt your data source definition. Once you have encrypted your data source definition, it will always remain encrypted. The search service will ignore attempts to set this property to null. You can change this property as needed if you want to rotate your encryption key; Your datasource definition will be unaffected. Encryption with customer-managed keys is not available for free search services, and is only available for paid services created on or after January 1, 2019. - internal SearchIndexerDataSourceConnection(string name, string description, SearchIndexerDataSourceType type, DataSourceCredentials credentialsInternal, SearchIndexerDataContainer container, SearchIndexerDataIdentity identity, IList indexerPermissionOptions, DataChangeDetectionPolicy dataChangeDetectionPolicy, DataDeletionDetectionPolicy dataDeletionDetectionPolicy, string etag, SearchResourceEncryptionKey encryptionKey) + /// Keeps track of any properties unknown to the library. + internal SearchIndexerDataSourceConnection(string name, string description, SearchIndexerDataSourceType type, DataSourceCredentials credentialsInternal, SearchIndexerDataContainer container, SearchIndexerDataIdentity identity, IList indexerPermissionOptions, DataChangeDetectionPolicy dataChangeDetectionPolicy, DataDeletionDetectionPolicy dataDeletionDetectionPolicy, string etag, SearchResourceEncryptionKey encryptionKey, IDictionary serializedAdditionalRawData) { Name = name; Description = description; @@ -50,6 +83,12 @@ internal SearchIndexerDataSourceConnection(string name, string description, Sear DataDeletionDetectionPolicy = dataDeletionDetectionPolicy; _etag = etag; EncryptionKey = encryptionKey; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchIndexerDataSourceConnection() + { } /// The name of the datasource. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataUserAssignedIdentity.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataUserAssignedIdentity.Serialization.cs index 4b31e19f6776..f65e8093cf8c 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataUserAssignedIdentity.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataUserAssignedIdentity.Serialization.cs @@ -5,31 +5,64 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchIndexerDataUserAssignedIdentity : IUtf8JsonSerializable + public partial class SearchIndexerDataUserAssignedIdentity : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SearchIndexerDataUserAssignedIdentity)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("userAssignedIdentity"u8); writer.WriteStringValue(UserAssignedIdentity); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WriteEndObject(); } - internal static SearchIndexerDataUserAssignedIdentity DeserializeSearchIndexerDataUserAssignedIdentity(JsonElement element) + SearchIndexerDataUserAssignedIdentity 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(SearchIndexerDataUserAssignedIdentity)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndexerDataUserAssignedIdentity(document.RootElement, options); + } + + internal static SearchIndexerDataUserAssignedIdentity DeserializeSearchIndexerDataUserAssignedIdentity(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } ResourceIdentifier userAssignedIdentity = default; string odataType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("userAssignedIdentity"u8)) @@ -42,10 +75,46 @@ internal static SearchIndexerDataUserAssignedIdentity DeserializeSearchIndexerDa odataType = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchIndexerDataUserAssignedIdentity(odataType, serializedAdditionalRawData, userAssignedIdentity); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndexerDataUserAssignedIdentity)} does not support writing '{options.Format}' format."); } - return new SearchIndexerDataUserAssignedIdentity(odataType, userAssignedIdentity); } + SearchIndexerDataUserAssignedIdentity 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 DeserializeSearchIndexerDataUserAssignedIdentity(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndexerDataUserAssignedIdentity)} 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 SearchIndexerDataUserAssignedIdentity FromResponse(Response response) @@ -58,7 +127,7 @@ internal static SearchIndexerDataUserAssignedIdentity DeserializeSearchIndexerDa internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataUserAssignedIdentity.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataUserAssignedIdentity.cs index e1d03e6a8fa3..6ae61b9c051f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataUserAssignedIdentity.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerDataUserAssignedIdentity.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models @@ -26,13 +27,19 @@ public SearchIndexerDataUserAssignedIdentity(ResourceIdentifier userAssignedIden /// Initializes a new instance of . /// A URI fragment specifying the type of identity. + /// Keeps track of any properties unknown to the library. /// The fully qualified Azure resource Id of a user assigned managed identity typically in the form "/subscriptions/12345678-1234-1234-1234-1234567890ab/resourceGroups/rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId" that should have been assigned to the search service. - internal SearchIndexerDataUserAssignedIdentity(string oDataType, ResourceIdentifier userAssignedIdentity) : base(oDataType) + internal SearchIndexerDataUserAssignedIdentity(string oDataType, IDictionary serializedAdditionalRawData, ResourceIdentifier userAssignedIdentity) : base(oDataType, serializedAdditionalRawData) { UserAssignedIdentity = userAssignedIdentity; ODataType = oDataType ?? "#Microsoft.Azure.Search.DataUserAssignedIdentity"; } + /// Initializes a new instance of for deserialization. + internal SearchIndexerDataUserAssignedIdentity() + { + } + /// The fully qualified Azure resource Id of a user assigned managed identity typically in the form "/subscriptions/12345678-1234-1234-1234-1234567890ab/resourceGroups/rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId" that should have been assigned to the search service. public ResourceIdentifier UserAssignedIdentity { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerError.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerError.Serialization.cs index 3b07d15dd27a..2b9db7d0577a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerError.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerError.Serialization.cs @@ -5,14 +5,98 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchIndexerError + public partial class SearchIndexerError : IUtf8JsonSerializable, IJsonModel { - internal static SearchIndexerError DeserializeSearchIndexerError(JsonElement element) + 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(SearchIndexerError)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Key)) + { + writer.WritePropertyName("key"u8); + writer.WriteStringValue(Key); + } + if (options.Format != "W") + { + writer.WritePropertyName("errorMessage"u8); + writer.WriteStringValue(ErrorMessage); + } + if (options.Format != "W") + { + writer.WritePropertyName("statusCode"u8); + writer.WriteNumberValue(StatusCode); + } + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && Optional.IsDefined(Details)) + { + writer.WritePropertyName("details"u8); + writer.WriteStringValue(Details); + } + if (options.Format != "W" && Optional.IsDefined(DocumentationLink)) + { + writer.WritePropertyName("documentationLink"u8); + writer.WriteStringValue(DocumentationLink); + } + 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 + } + } + } + + SearchIndexerError 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(SearchIndexerError)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndexerError(document.RootElement, options); + } + + internal static SearchIndexerError DeserializeSearchIndexerError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -23,6 +107,8 @@ internal static SearchIndexerError DeserializeSearchIndexerError(JsonElement ele string name = default; string details = default; string documentationLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("key"u8)) @@ -55,16 +141,53 @@ internal static SearchIndexerError DeserializeSearchIndexerError(JsonElement ele documentationLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new SearchIndexerError( key, errorMessage, statusCode, name, details, - documentationLink); + documentationLink, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndexerError)} does not support writing '{options.Format}' format."); + } + } + + SearchIndexerError 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 DeserializeSearchIndexerError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndexerError)} 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 SearchIndexerError FromResponse(Response response) @@ -72,5 +195,13 @@ internal static SearchIndexerError FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSearchIndexerError(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/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerError.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerError.cs index eb32cea6dde4..5f02dd27f633 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerError.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerError.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Represents an item- or document-level indexing error. public partial class SearchIndexerError { + /// + /// 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 . /// The message describing the error that occurred while processing the item. /// The status code indicating why the indexing operation failed. Possible values include: 400 for a malformed input document, 404 for document not found, 409 for a version conflict, 422 when the index is temporarily unavailable, or 503 for when the service is too busy. @@ -26,7 +61,8 @@ internal SearchIndexerError(string errorMessage, int statusCode) /// The name of the source at which the error originated. For example, this could refer to a particular skill in the attached skillset. This may not be always available. /// Additional, verbose details about the error to assist in debugging the indexer. This may not be always available. /// A link to a troubleshooting guide for these classes of errors. This may not be always available. - internal SearchIndexerError(string key, string errorMessage, int statusCode, string name, string details, string documentationLink) + /// Keeps track of any properties unknown to the library. + internal SearchIndexerError(string key, string errorMessage, int statusCode, string name, string details, string documentationLink, IDictionary serializedAdditionalRawData) { Key = key; ErrorMessage = errorMessage; @@ -34,6 +70,12 @@ internal SearchIndexerError(string key, string errorMessage, int statusCode, str Name = name; Details = details; DocumentationLink = documentationLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchIndexerError() + { } /// The key of the item for which indexing failed. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerIndexProjection.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerIndexProjection.Serialization.cs index f3eec83fb1a2..a9fee7591b3b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerIndexProjection.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerIndexProjection.Serialization.cs @@ -5,40 +5,88 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchIndexerIndexProjection : IUtf8JsonSerializable + public partial class SearchIndexerIndexProjection : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SearchIndexerIndexProjection)} does not support writing '{format}' format."); + } + writer.WritePropertyName("selectors"u8); writer.WriteStartArray(); foreach (var item in Selectors) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); if (Optional.IsDefined(Parameters)) { writer.WritePropertyName("parameters"u8); - writer.WriteObjectValue(Parameters); + writer.WriteObjectValue(Parameters, options); + } + 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 + } } - writer.WriteEndObject(); } - internal static SearchIndexerIndexProjection DeserializeSearchIndexerIndexProjection(JsonElement element) + SearchIndexerIndexProjection 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(SearchIndexerIndexProjection)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndexerIndexProjection(document.RootElement, options); + } + + internal static SearchIndexerIndexProjection DeserializeSearchIndexerIndexProjection(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } IList selectors = default; SearchIndexerIndexProjectionsParameters parameters = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("selectors"u8)) @@ -46,7 +94,7 @@ internal static SearchIndexerIndexProjection DeserializeSearchIndexerIndexProjec List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SearchIndexerIndexProjectionSelector.DeserializeSearchIndexerIndexProjectionSelector(item)); + array.Add(SearchIndexerIndexProjectionSelector.DeserializeSearchIndexerIndexProjectionSelector(item, options)); } selectors = array; continue; @@ -57,13 +105,49 @@ internal static SearchIndexerIndexProjection DeserializeSearchIndexerIndexProjec { continue; } - parameters = SearchIndexerIndexProjectionsParameters.DeserializeSearchIndexerIndexProjectionsParameters(property.Value); + parameters = SearchIndexerIndexProjectionsParameters.DeserializeSearchIndexerIndexProjectionsParameters(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchIndexerIndexProjection(selectors, parameters, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndexerIndexProjection)} does not support writing '{options.Format}' format."); } - return new SearchIndexerIndexProjection(selectors, parameters); } + SearchIndexerIndexProjection 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 DeserializeSearchIndexerIndexProjection(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndexerIndexProjection)} 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 SearchIndexerIndexProjection FromResponse(Response response) @@ -76,7 +160,7 @@ internal static SearchIndexerIndexProjection FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerIndexProjection.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerIndexProjection.cs index 3ce3c39f5fe1..486e952c8a41 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerIndexProjection.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerIndexProjection.cs @@ -14,6 +14,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Definition of additional projections to secondary search indexes. public partial class SearchIndexerIndexProjection { + /// + /// 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 . /// A list of projections to be performed to secondary search indexes. /// is null. @@ -27,10 +59,17 @@ public SearchIndexerIndexProjection(IEnumerable Initializes a new instance of . /// A list of projections to be performed to secondary search indexes. /// A dictionary of index projection-specific configuration properties. Each name is the name of a specific property. Each value must be of a primitive type. - internal SearchIndexerIndexProjection(IList selectors, SearchIndexerIndexProjectionsParameters parameters) + /// Keeps track of any properties unknown to the library. + internal SearchIndexerIndexProjection(IList selectors, SearchIndexerIndexProjectionsParameters parameters, IDictionary serializedAdditionalRawData) { Selectors = selectors; Parameters = parameters; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchIndexerIndexProjection() + { } /// A list of projections to be performed to secondary search indexes. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerIndexProjectionSelector.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerIndexProjectionSelector.Serialization.cs index bccda23a9744..29630b432a14 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerIndexProjectionSelector.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerIndexProjectionSelector.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchIndexerIndexProjectionSelector : IUtf8JsonSerializable + public partial class SearchIndexerIndexProjectionSelector : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SearchIndexerIndexProjectionSelector)} does not support writing '{format}' format."); + } + writer.WritePropertyName("targetIndexName"u8); writer.WriteStringValue(TargetIndexName); writer.WritePropertyName("parentKeyFieldName"u8); @@ -26,14 +44,42 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in Mappings) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); - writer.WriteEndObject(); + 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 + } + } } - internal static SearchIndexerIndexProjectionSelector DeserializeSearchIndexerIndexProjectionSelector(JsonElement element) + SearchIndexerIndexProjectionSelector 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(SearchIndexerIndexProjectionSelector)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndexerIndexProjectionSelector(document.RootElement, options); + } + + internal static SearchIndexerIndexProjectionSelector DeserializeSearchIndexerIndexProjectionSelector(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -42,6 +88,8 @@ internal static SearchIndexerIndexProjectionSelector DeserializeSearchIndexerInd string parentKeyFieldName = default; string sourceContext = default; IList mappings = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("targetIndexName"u8)) @@ -64,15 +112,51 @@ internal static SearchIndexerIndexProjectionSelector DeserializeSearchIndexerInd List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } mappings = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchIndexerIndexProjectionSelector(targetIndexName, parentKeyFieldName, sourceContext, mappings, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndexerIndexProjectionSelector)} does not support writing '{options.Format}' format."); } - return new SearchIndexerIndexProjectionSelector(targetIndexName, parentKeyFieldName, sourceContext, mappings); } + SearchIndexerIndexProjectionSelector 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 DeserializeSearchIndexerIndexProjectionSelector(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndexerIndexProjectionSelector)} 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 SearchIndexerIndexProjectionSelector FromResponse(Response response) @@ -85,7 +169,7 @@ internal static SearchIndexerIndexProjectionSelector FromResponse(Response respo internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerIndexProjectionSelector.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerIndexProjectionSelector.cs index 3feefca6507f..01102479057d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerIndexProjectionSelector.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerIndexProjectionSelector.cs @@ -14,6 +14,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Description for what data to store in the designated search index. public partial class SearchIndexerIndexProjectionSelector { + /// + /// 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 . /// Name of the search index to project to. Must have a key field with the 'keyword' analyzer set. /// Name of the field in the search index to map the parent document's key value to. Must be a string field that is filterable and not the key field. @@ -38,12 +70,19 @@ public SearchIndexerIndexProjectionSelector(string targetIndexName, string paren /// Name of the field in the search index to map the parent document's key value to. Must be a string field that is filterable and not the key field. /// Source context for the projections. Represents the cardinality at which the document will be split into multiple sub documents. /// Mappings for the projection, or which source should be mapped to which field in the target index. - internal SearchIndexerIndexProjectionSelector(string targetIndexName, string parentKeyFieldName, string sourceContext, IList mappings) + /// Keeps track of any properties unknown to the library. + internal SearchIndexerIndexProjectionSelector(string targetIndexName, string parentKeyFieldName, string sourceContext, IList mappings, IDictionary serializedAdditionalRawData) { TargetIndexName = targetIndexName; ParentKeyFieldName = parentKeyFieldName; SourceContext = sourceContext; Mappings = mappings; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchIndexerIndexProjectionSelector() + { } /// Name of the search index to project to. Must have a key field with the 'keyword' analyzer set. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerIndexProjectionsParameters.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerIndexProjectionsParameters.Serialization.cs index ffa5a8543fe7..b568534fe8e2 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerIndexProjectionsParameters.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerIndexProjectionsParameters.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchIndexerIndexProjectionsParameters : IUtf8JsonSerializable + public partial class SearchIndexerIndexProjectionsParameters : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SearchIndexerIndexProjectionsParameters)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(ProjectionMode)) { writer.WritePropertyName("projectionMode"u8); @@ -24,13 +42,26 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) foreach (var item in AdditionalProperties) { writer.WritePropertyName(item.Key); - writer.WriteObjectValue(item.Value); + writer.WriteObjectValue(item.Value, options); } - writer.WriteEndObject(); } - internal static SearchIndexerIndexProjectionsParameters DeserializeSearchIndexerIndexProjectionsParameters(JsonElement element) + SearchIndexerIndexProjectionsParameters 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(SearchIndexerIndexProjectionsParameters)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndexerIndexProjectionsParameters(document.RootElement, options); + } + + internal static SearchIndexerIndexProjectionsParameters DeserializeSearchIndexerIndexProjectionsParameters(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -55,6 +86,37 @@ internal static SearchIndexerIndexProjectionsParameters DeserializeSearchIndexer return new SearchIndexerIndexProjectionsParameters(projectionMode, additionalProperties); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndexerIndexProjectionsParameters)} does not support writing '{options.Format}' format."); + } + } + + SearchIndexerIndexProjectionsParameters 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 DeserializeSearchIndexerIndexProjectionsParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndexerIndexProjectionsParameters)} 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 SearchIndexerIndexProjectionsParameters FromResponse(Response response) @@ -67,7 +129,7 @@ internal static SearchIndexerIndexProjectionsParameters FromResponse(Response re internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerKnowledgeStoreParameters.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerKnowledgeStoreParameters.Serialization.cs index 615bebe72fdd..e96f7bb924d1 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerKnowledgeStoreParameters.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerKnowledgeStoreParameters.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchIndexerKnowledgeStoreParameters : IUtf8JsonSerializable + public partial class SearchIndexerKnowledgeStoreParameters : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SearchIndexerKnowledgeStoreParameters)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(SynthesizeGeneratedKeyName)) { writer.WritePropertyName("synthesizeGeneratedKeyName"u8); @@ -24,13 +42,26 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) foreach (var item in AdditionalProperties) { writer.WritePropertyName(item.Key); - writer.WriteObjectValue(item.Value); + writer.WriteObjectValue(item.Value, options); } - writer.WriteEndObject(); } - internal static SearchIndexerKnowledgeStoreParameters DeserializeSearchIndexerKnowledgeStoreParameters(JsonElement element) + SearchIndexerKnowledgeStoreParameters 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(SearchIndexerKnowledgeStoreParameters)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndexerKnowledgeStoreParameters(document.RootElement, options); + } + + internal static SearchIndexerKnowledgeStoreParameters DeserializeSearchIndexerKnowledgeStoreParameters(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -55,6 +86,37 @@ internal static SearchIndexerKnowledgeStoreParameters DeserializeSearchIndexerKn return new SearchIndexerKnowledgeStoreParameters(synthesizeGeneratedKeyName, additionalProperties); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndexerKnowledgeStoreParameters)} does not support writing '{options.Format}' format."); + } + } + + SearchIndexerKnowledgeStoreParameters 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 DeserializeSearchIndexerKnowledgeStoreParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndexerKnowledgeStoreParameters)} 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 SearchIndexerKnowledgeStoreParameters FromResponse(Response response) @@ -67,7 +129,7 @@ internal static SearchIndexerKnowledgeStoreParameters FromResponse(Response resp internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerLimits.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerLimits.Serialization.cs index b27c89954b63..0a15f64b346c 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerLimits.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerLimits.Serialization.cs @@ -6,14 +6,82 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchIndexerLimits + public partial class SearchIndexerLimits : IUtf8JsonSerializable, IJsonModel { - internal static SearchIndexerLimits DeserializeSearchIndexerLimits(JsonElement element) + 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(SearchIndexerLimits)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(MaxRunTime)) + { + writer.WritePropertyName("maxRunTime"u8); + writer.WriteStringValue(MaxRunTime.Value, "P"); + } + if (options.Format != "W" && Optional.IsDefined(MaxDocumentExtractionSize)) + { + writer.WritePropertyName("maxDocumentExtractionSize"u8); + writer.WriteNumberValue(MaxDocumentExtractionSize.Value); + } + if (options.Format != "W" && Optional.IsDefined(MaxDocumentContentCharactersToExtract)) + { + writer.WritePropertyName("maxDocumentContentCharactersToExtract"u8); + writer.WriteNumberValue(MaxDocumentContentCharactersToExtract.Value); + } + 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 + } + } + } + + SearchIndexerLimits 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(SearchIndexerLimits)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndexerLimits(document.RootElement, options); + } + + internal static SearchIndexerLimits DeserializeSearchIndexerLimits(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -21,6 +89,8 @@ internal static SearchIndexerLimits DeserializeSearchIndexerLimits(JsonElement e TimeSpan? maxRunTime = default; long? maxDocumentExtractionSize = default; long? maxDocumentContentCharactersToExtract = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("maxRunTime"u8)) @@ -50,10 +120,46 @@ internal static SearchIndexerLimits DeserializeSearchIndexerLimits(JsonElement e maxDocumentContentCharactersToExtract = property.Value.GetInt64(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchIndexerLimits(maxRunTime, maxDocumentExtractionSize, maxDocumentContentCharactersToExtract, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndexerLimits)} does not support writing '{options.Format}' format."); } - return new SearchIndexerLimits(maxRunTime, maxDocumentExtractionSize, maxDocumentContentCharactersToExtract); } + SearchIndexerLimits 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 DeserializeSearchIndexerLimits(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndexerLimits)} 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 SearchIndexerLimits FromResponse(Response response) @@ -61,5 +167,13 @@ internal static SearchIndexerLimits FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSearchIndexerLimits(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/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerLimits.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerLimits.cs index 1cadd38c7662..afcbcb79f787 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerLimits.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerLimits.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// The SearchIndexerLimits. public partial class SearchIndexerLimits { + /// + /// 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 . internal SearchIndexerLimits() { @@ -21,11 +54,13 @@ internal SearchIndexerLimits() /// The maximum duration that the indexer is permitted to run for one execution. /// The maximum size of a document, in bytes, which will be considered valid for indexing. /// The maximum number of characters that will be extracted from a document picked up for indexing. - internal SearchIndexerLimits(TimeSpan? maxRunTime, long? maxDocumentExtractionSize, long? maxDocumentContentCharactersToExtract) + /// Keeps track of any properties unknown to the library. + internal SearchIndexerLimits(TimeSpan? maxRunTime, long? maxDocumentExtractionSize, long? maxDocumentContentCharactersToExtract, IDictionary serializedAdditionalRawData) { MaxRunTime = maxRunTime; MaxDocumentExtractionSize = maxDocumentExtractionSize; MaxDocumentContentCharactersToExtract = maxDocumentContentCharactersToExtract; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The maximum duration that the indexer is permitted to run for one execution. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerSkill.Serialization.cs index 1e17380885a3..ba4101b91cb9 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerSkill.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchIndexerSkill : IUtf8JsonSerializable + public partial class SearchIndexerSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SearchIndexerSkill)} does not support writing '{format}' format."); + } + writer.WritePropertyName("@odata.type"u8); writer.WriteStringValue(ODataType); if (Optional.IsDefined(Name)) @@ -37,21 +55,49 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in Inputs) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); writer.WritePropertyName("outputs"u8); writer.WriteStartArray(); foreach (var item in Outputs) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); - writer.WriteEndObject(); + 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 + } + } } - internal static SearchIndexerSkill DeserializeSearchIndexerSkill(JsonElement element) + SearchIndexerSkill 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(SearchIndexerSkill)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndexerSkill(document.RootElement, options); + } + + internal static SearchIndexerSkill DeserializeSearchIndexerSkill(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -60,34 +106,65 @@ internal static SearchIndexerSkill DeserializeSearchIndexerSkill(JsonElement ele { switch (discriminator.GetString()) { - case "#Microsoft.Skills.Custom.AmlSkill": return AzureMachineLearningSkill.DeserializeAzureMachineLearningSkill(element); - case "#Microsoft.Skills.Custom.ChatCompletionSkill": return ChatCompletionSkill.DeserializeChatCompletionSkill(element); - case "#Microsoft.Skills.Custom.WebApiSkill": return WebApiSkill.DeserializeWebApiSkill(element); - case "#Microsoft.Skills.Text.AzureOpenAIEmbeddingSkill": return AzureOpenAIEmbeddingSkill.DeserializeAzureOpenAIEmbeddingSkill(element); - case "#Microsoft.Skills.Text.CustomEntityLookupSkill": return CustomEntityLookupSkill.DeserializeCustomEntityLookupSkill(element); - case "#Microsoft.Skills.Text.EntityRecognitionSkill": return EntityRecognitionSkill.DeserializeEntityRecognitionSkill(element); - case "#Microsoft.Skills.Text.KeyPhraseExtractionSkill": return KeyPhraseExtractionSkill.DeserializeKeyPhraseExtractionSkill(element); - case "#Microsoft.Skills.Text.LanguageDetectionSkill": return LanguageDetectionSkill.DeserializeLanguageDetectionSkill(element); - case "#Microsoft.Skills.Text.MergeSkill": return MergeSkill.DeserializeMergeSkill(element); - case "#Microsoft.Skills.Text.PIIDetectionSkill": return PiiDetectionSkill.DeserializePiiDetectionSkill(element); - case "#Microsoft.Skills.Text.SentimentSkill": return SentimentSkill.DeserializeSentimentSkill(element); - case "#Microsoft.Skills.Text.SplitSkill": return SplitSkill.DeserializeSplitSkill(element); - case "#Microsoft.Skills.Text.TranslationSkill": return TextTranslationSkill.DeserializeTextTranslationSkill(element); - case "#Microsoft.Skills.Text.V3.EntityLinkingSkill": return EntityLinkingSkill.DeserializeEntityLinkingSkill(element); - case "#Microsoft.Skills.Text.V3.EntityRecognitionSkill": return EntityRecognitionSkillV3.DeserializeEntityRecognitionSkillV3(element); - case "#Microsoft.Skills.Text.V3.SentimentSkill": return SentimentSkillV3.DeserializeSentimentSkillV3(element); - case "#Microsoft.Skills.Util.ConditionalSkill": return ConditionalSkill.DeserializeConditionalSkill(element); - case "#Microsoft.Skills.Util.DocumentExtractionSkill": return DocumentExtractionSkill.DeserializeDocumentExtractionSkill(element); - case "#Microsoft.Skills.Util.DocumentIntelligenceLayoutSkill": return DocumentIntelligenceLayoutSkill.DeserializeDocumentIntelligenceLayoutSkill(element); - case "#Microsoft.Skills.Util.ShaperSkill": return ShaperSkill.DeserializeShaperSkill(element); - case "#Microsoft.Skills.Vision.ImageAnalysisSkill": return ImageAnalysisSkill.DeserializeImageAnalysisSkill(element); - case "#Microsoft.Skills.Vision.OcrSkill": return OcrSkill.DeserializeOcrSkill(element); - case "#Microsoft.Skills.Vision.VectorizeSkill": return VisionVectorizeSkill.DeserializeVisionVectorizeSkill(element); + case "#Microsoft.Skills.Custom.AmlSkill": return AzureMachineLearningSkill.DeserializeAzureMachineLearningSkill(element, options); + case "#Microsoft.Skills.Custom.ChatCompletionSkill": return ChatCompletionSkill.DeserializeChatCompletionSkill(element, options); + case "#Microsoft.Skills.Custom.WebApiSkill": return WebApiSkill.DeserializeWebApiSkill(element, options); + case "#Microsoft.Skills.Text.AzureOpenAIEmbeddingSkill": return AzureOpenAIEmbeddingSkill.DeserializeAzureOpenAIEmbeddingSkill(element, options); + case "#Microsoft.Skills.Text.CustomEntityLookupSkill": return CustomEntityLookupSkill.DeserializeCustomEntityLookupSkill(element, options); + case "#Microsoft.Skills.Text.EntityRecognitionSkill": return EntityRecognitionSkill.DeserializeEntityRecognitionSkill(element, options); + case "#Microsoft.Skills.Text.KeyPhraseExtractionSkill": return KeyPhraseExtractionSkill.DeserializeKeyPhraseExtractionSkill(element, options); + case "#Microsoft.Skills.Text.LanguageDetectionSkill": return LanguageDetectionSkill.DeserializeLanguageDetectionSkill(element, options); + case "#Microsoft.Skills.Text.MergeSkill": return MergeSkill.DeserializeMergeSkill(element, options); + case "#Microsoft.Skills.Text.PIIDetectionSkill": return PiiDetectionSkill.DeserializePiiDetectionSkill(element, options); + case "#Microsoft.Skills.Text.SentimentSkill": return SentimentSkill.DeserializeSentimentSkill(element, options); + case "#Microsoft.Skills.Text.SplitSkill": return SplitSkill.DeserializeSplitSkill(element, options); + case "#Microsoft.Skills.Text.TranslationSkill": return TextTranslationSkill.DeserializeTextTranslationSkill(element, options); + case "#Microsoft.Skills.Text.V3.EntityLinkingSkill": return EntityLinkingSkill.DeserializeEntityLinkingSkill(element, options); + case "#Microsoft.Skills.Text.V3.EntityRecognitionSkill": return EntityRecognitionSkillV3.DeserializeEntityRecognitionSkillV3(element, options); + case "#Microsoft.Skills.Text.V3.SentimentSkill": return SentimentSkillV3.DeserializeSentimentSkillV3(element, options); + case "#Microsoft.Skills.Util.ConditionalSkill": return ConditionalSkill.DeserializeConditionalSkill(element, options); + case "#Microsoft.Skills.Util.DocumentExtractionSkill": return DocumentExtractionSkill.DeserializeDocumentExtractionSkill(element, options); + case "#Microsoft.Skills.Util.DocumentIntelligenceLayoutSkill": return DocumentIntelligenceLayoutSkill.DeserializeDocumentIntelligenceLayoutSkill(element, options); + case "#Microsoft.Skills.Util.ShaperSkill": return ShaperSkill.DeserializeShaperSkill(element, options); + case "#Microsoft.Skills.Vision.ImageAnalysisSkill": return ImageAnalysisSkill.DeserializeImageAnalysisSkill(element, options); + case "#Microsoft.Skills.Vision.OcrSkill": return OcrSkill.DeserializeOcrSkill(element, options); + case "#Microsoft.Skills.Vision.VectorizeSkill": return VisionVectorizeSkill.DeserializeVisionVectorizeSkill(element, options); } } - return UnknownSearchIndexerSkill.DeserializeUnknownSearchIndexerSkill(element); + return UnknownSearchIndexerSkill.DeserializeUnknownSearchIndexerSkill(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndexerSkill)} does not support writing '{options.Format}' format."); + } + } + + SearchIndexerSkill 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 DeserializeSearchIndexerSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndexerSkill)} 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 SearchIndexerSkill FromResponse(Response response) @@ -100,7 +177,7 @@ internal static SearchIndexerSkill FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerSkill.cs index fbecf5239a35..1377c89577ce 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerSkill.cs @@ -18,6 +18,38 @@ namespace Azure.Search.Documents.Indexes.Models /// public partial class SearchIndexerSkill { + /// + /// 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 . /// A URI fragment specifying the type of skill. /// The name of the skill which uniquely identifies it within the skillset. A skill with no name defined will be given a default name of its 1-based index in the skills array, prefixed with the character '#'. @@ -25,7 +57,8 @@ public partial class SearchIndexerSkill /// Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. - internal SearchIndexerSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs) + /// Keeps track of any properties unknown to the library. + internal SearchIndexerSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData) { ODataType = oDataType; Name = name; @@ -33,6 +66,12 @@ internal SearchIndexerSkill(string oDataType, string name, string description, s Context = context; Inputs = inputs; Outputs = outputs; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchIndexerSkill() + { } /// A URI fragment specifying the type of skill. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerSkillset.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerSkillset.Serialization.cs index f7e37d7bd4bd..20ae3e3fbad3 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerSkillset.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerSkillset.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchIndexerSkillset : IUtf8JsonSerializable + public partial class SearchIndexerSkillset : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SearchIndexerSkillset)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); if (Optional.IsDefined(Description)) @@ -27,23 +45,23 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in Skills) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); if (Optional.IsDefined(CognitiveServicesAccount)) { writer.WritePropertyName("cognitiveServices"u8); - writer.WriteObjectValue(CognitiveServicesAccount); + writer.WriteObjectValue(CognitiveServicesAccount, options); } if (Optional.IsDefined(KnowledgeStore)) { writer.WritePropertyName("knowledgeStore"u8); - writer.WriteObjectValue(KnowledgeStore); + writer.WriteObjectValue(KnowledgeStore, options); } if (Optional.IsDefined(IndexProjection)) { writer.WritePropertyName("indexProjections"u8); - writer.WriteObjectValue(IndexProjection); + writer.WriteObjectValue(IndexProjection, options); } if (Optional.IsDefined(_etag)) { @@ -55,18 +73,46 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (EncryptionKey != null) { writer.WritePropertyName("encryptionKey"u8); - writer.WriteObjectValue(EncryptionKey); + writer.WriteObjectValue(EncryptionKey, options); } else { writer.WriteNull("encryptionKey"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static SearchIndexerSkillset DeserializeSearchIndexerSkillset(JsonElement element) + SearchIndexerSkillset 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(SearchIndexerSkillset)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndexerSkillset(document.RootElement, options); + } + + internal static SearchIndexerSkillset DeserializeSearchIndexerSkillset(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -79,6 +125,8 @@ internal static SearchIndexerSkillset DeserializeSearchIndexerSkillset(JsonEleme SearchIndexerIndexProjection indexProjections = default; string odataEtag = default; SearchResourceEncryptionKey encryptionKey = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -96,7 +144,7 @@ internal static SearchIndexerSkillset DeserializeSearchIndexerSkillset(JsonEleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SearchIndexerSkill.DeserializeSearchIndexerSkill(item)); + array.Add(SearchIndexerSkill.DeserializeSearchIndexerSkill(item, options)); } skills = array; continue; @@ -107,7 +155,7 @@ internal static SearchIndexerSkillset DeserializeSearchIndexerSkillset(JsonEleme { continue; } - cognitiveServices = CognitiveServicesAccount.DeserializeCognitiveServicesAccount(property.Value); + cognitiveServices = CognitiveServicesAccount.DeserializeCognitiveServicesAccount(property.Value, options); continue; } if (property.NameEquals("knowledgeStore"u8)) @@ -116,7 +164,7 @@ internal static SearchIndexerSkillset DeserializeSearchIndexerSkillset(JsonEleme { continue; } - knowledgeStore = KnowledgeStore.DeserializeKnowledgeStore(property.Value); + knowledgeStore = KnowledgeStore.DeserializeKnowledgeStore(property.Value, options); continue; } if (property.NameEquals("indexProjections"u8)) @@ -125,7 +173,7 @@ internal static SearchIndexerSkillset DeserializeSearchIndexerSkillset(JsonEleme { continue; } - indexProjections = SearchIndexerIndexProjection.DeserializeSearchIndexerIndexProjection(property.Value); + indexProjections = SearchIndexerIndexProjection.DeserializeSearchIndexerIndexProjection(property.Value, options); continue; } if (property.NameEquals("@odata.etag"u8)) @@ -140,10 +188,15 @@ internal static SearchIndexerSkillset DeserializeSearchIndexerSkillset(JsonEleme encryptionKey = null; continue; } - encryptionKey = SearchResourceEncryptionKey.DeserializeSearchResourceEncryptionKey(property.Value); + encryptionKey = SearchResourceEncryptionKey.DeserializeSearchResourceEncryptionKey(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new SearchIndexerSkillset( name, description, @@ -152,9 +205,41 @@ internal static SearchIndexerSkillset DeserializeSearchIndexerSkillset(JsonEleme knowledgeStore, indexProjections, odataEtag, - encryptionKey); + encryptionKey, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndexerSkillset)} does not support writing '{options.Format}' format."); + } } + SearchIndexerSkillset 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 DeserializeSearchIndexerSkillset(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndexerSkillset)} 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 SearchIndexerSkillset FromResponse(Response response) @@ -167,7 +252,7 @@ internal static SearchIndexerSkillset FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerSkillset.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerSkillset.cs index c53829ce63db..588db99739b2 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerSkillset.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerSkillset.cs @@ -14,6 +14,38 @@ namespace Azure.Search.Documents.Indexes.Models /// A list of skills. public partial class SearchIndexerSkillset { + /// + /// 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 . /// The name of the skillset. /// @@ -48,7 +80,8 @@ public SearchIndexerSkillset(string name, IEnumerable skills /// Definition of additional projections to secondary search index(es). /// The ETag of the skillset. /// A description of an encryption key that you create in Azure Key Vault. This key is used to provide an additional level of encryption-at-rest for your skillset definition when you want full assurance that no one, not even Microsoft, can decrypt your skillset definition. Once you have encrypted your skillset definition, it will always remain encrypted. The search service will ignore attempts to set this property to null. You can change this property as needed if you want to rotate your encryption key; Your skillset definition will be unaffected. Encryption with customer-managed keys is not available for free search services, and is only available for paid services created on or after January 1, 2019. - internal SearchIndexerSkillset(string name, string description, IList skills, CognitiveServicesAccount cognitiveServicesAccount, KnowledgeStore knowledgeStore, SearchIndexerIndexProjection indexProjection, string etag, SearchResourceEncryptionKey encryptionKey) + /// Keeps track of any properties unknown to the library. + internal SearchIndexerSkillset(string name, string description, IList skills, CognitiveServicesAccount cognitiveServicesAccount, KnowledgeStore knowledgeStore, SearchIndexerIndexProjection indexProjection, string etag, SearchResourceEncryptionKey encryptionKey, IDictionary serializedAdditionalRawData) { Name = name; Description = description; @@ -58,6 +91,12 @@ internal SearchIndexerSkillset(string name, string description, IList Initializes a new instance of for deserialization. + internal SearchIndexerSkillset() + { } /// The name of the skillset. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerStatus.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerStatus.Serialization.cs index 7cf3f9a0c5f7..350a409d71fe 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerStatus.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerStatus.Serialization.cs @@ -5,15 +5,105 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchIndexerStatus + public partial class SearchIndexerStatus : IUtf8JsonSerializable, IJsonModel { - internal static SearchIndexerStatus DeserializeSearchIndexerStatus(JsonElement element) + 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(SearchIndexerStatus)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToSerialString()); + } + if (options.Format != "W" && Optional.IsDefined(LastResult)) + { + if (LastResult != null) + { + writer.WritePropertyName("lastResult"u8); + writer.WriteObjectValue(LastResult, options); + } + else + { + writer.WriteNull("lastResult"); + } + } + if (options.Format != "W") + { + writer.WritePropertyName("executionHistory"u8); + writer.WriteStartArray(); + foreach (var item in ExecutionHistory) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W") + { + writer.WritePropertyName("limits"u8); + writer.WriteObjectValue(Limits, options); + } + if (options.Format != "W" && Optional.IsDefined(CurrentState)) + { + writer.WritePropertyName("currentState"u8); + writer.WriteObjectValue(CurrentState, options); + } + 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 + } + } + } + + SearchIndexerStatus 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(SearchIndexerStatus)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndexerStatus(document.RootElement, options); + } + + internal static SearchIndexerStatus DeserializeSearchIndexerStatus(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -23,6 +113,8 @@ internal static SearchIndexerStatus DeserializeSearchIndexerStatus(JsonElement e IReadOnlyList executionHistory = default; SearchIndexerLimits limits = default; IndexerState currentState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("status"u8)) @@ -37,7 +129,7 @@ internal static SearchIndexerStatus DeserializeSearchIndexerStatus(JsonElement e lastResult = null; continue; } - lastResult = IndexerExecutionResult.DeserializeIndexerExecutionResult(property.Value); + lastResult = IndexerExecutionResult.DeserializeIndexerExecutionResult(property.Value, options); continue; } if (property.NameEquals("executionHistory"u8)) @@ -45,14 +137,14 @@ internal static SearchIndexerStatus DeserializeSearchIndexerStatus(JsonElement e List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(IndexerExecutionResult.DeserializeIndexerExecutionResult(item)); + array.Add(IndexerExecutionResult.DeserializeIndexerExecutionResult(item, options)); } executionHistory = array; continue; } if (property.NameEquals("limits"u8)) { - limits = SearchIndexerLimits.DeserializeSearchIndexerLimits(property.Value); + limits = SearchIndexerLimits.DeserializeSearchIndexerLimits(property.Value, options); continue; } if (property.NameEquals("currentState"u8)) @@ -61,13 +153,55 @@ internal static SearchIndexerStatus DeserializeSearchIndexerStatus(JsonElement e { continue; } - currentState = IndexerState.DeserializeIndexerState(property.Value); + currentState = IndexerState.DeserializeIndexerState(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new SearchIndexerStatus(status, lastResult, executionHistory, limits, currentState); + serializedAdditionalRawData = rawDataDictionary; + return new SearchIndexerStatus( + status, + lastResult, + executionHistory, + limits, + currentState, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndexerStatus)} does not support writing '{options.Format}' format."); + } + } + + SearchIndexerStatus 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 DeserializeSearchIndexerStatus(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndexerStatus)} 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 SearchIndexerStatus FromResponse(Response response) @@ -75,5 +209,13 @@ internal static SearchIndexerStatus FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSearchIndexerStatus(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/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerStatus.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerStatus.cs index 570e3f4b6486..ac0c9f64a52b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerStatus.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerStatus.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using System.Linq; @@ -13,6 +14,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Represents the current status and execution history of an indexer. public partial class SearchIndexerStatus { + /// + /// 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 . /// Overall indexer status. /// History of the recent indexer executions, sorted in reverse chronological order. @@ -30,13 +63,20 @@ internal SearchIndexerStatus(IndexerStatus status, IEnumerable History of the recent indexer executions, sorted in reverse chronological order. /// The execution limits for the indexer. /// All of the state that defines and dictates the indexer's current execution. - internal SearchIndexerStatus(IndexerStatus status, IndexerExecutionResult lastResult, IReadOnlyList executionHistory, SearchIndexerLimits limits, IndexerState currentState) + /// Keeps track of any properties unknown to the library. + internal SearchIndexerStatus(IndexerStatus status, IndexerExecutionResult lastResult, IReadOnlyList executionHistory, SearchIndexerLimits limits, IndexerState currentState, IDictionary serializedAdditionalRawData) { Status = status; LastResult = lastResult; ExecutionHistory = executionHistory; Limits = limits; CurrentState = currentState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchIndexerStatus() + { } /// Overall indexer status. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerWarning.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerWarning.Serialization.cs index d8ef1a1f79c7..fb4c8f10ce9e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerWarning.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerWarning.Serialization.cs @@ -5,14 +5,93 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchIndexerWarning + public partial class SearchIndexerWarning : IUtf8JsonSerializable, IJsonModel { - internal static SearchIndexerWarning DeserializeSearchIndexerWarning(JsonElement element) + 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(SearchIndexerWarning)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Key)) + { + writer.WritePropertyName("key"u8); + writer.WriteStringValue(Key); + } + if (options.Format != "W") + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && Optional.IsDefined(Details)) + { + writer.WritePropertyName("details"u8); + writer.WriteStringValue(Details); + } + if (options.Format != "W" && Optional.IsDefined(DocumentationLink)) + { + writer.WritePropertyName("documentationLink"u8); + writer.WriteStringValue(DocumentationLink); + } + 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 + } + } + } + + SearchIndexerWarning 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(SearchIndexerWarning)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndexerWarning(document.RootElement, options); + } + + internal static SearchIndexerWarning DeserializeSearchIndexerWarning(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -22,6 +101,8 @@ internal static SearchIndexerWarning DeserializeSearchIndexerWarning(JsonElement string name = default; string details = default; string documentationLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("key"u8)) @@ -49,10 +130,52 @@ internal static SearchIndexerWarning DeserializeSearchIndexerWarning(JsonElement documentationLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchIndexerWarning( + key, + message, + name, + details, + documentationLink, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndexerWarning)} does not support writing '{options.Format}' format."); + } + } + + SearchIndexerWarning 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 DeserializeSearchIndexerWarning(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndexerWarning)} does not support reading '{options.Format}' format."); } - return new SearchIndexerWarning(key, message, name, details, documentationLink); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static SearchIndexerWarning FromResponse(Response response) @@ -60,5 +183,13 @@ internal static SearchIndexerWarning FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSearchIndexerWarning(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/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerWarning.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerWarning.cs index d26b5f34e587..4c39d82309f8 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerWarning.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchIndexerWarning.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Represents an item-level warning. public partial class SearchIndexerWarning { + /// + /// 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 . /// The message describing the warning that occurred while processing the item. internal SearchIndexerWarning(string message) @@ -23,13 +58,20 @@ internal SearchIndexerWarning(string message) /// The name of the source at which the warning originated. For example, this could refer to a particular skill in the attached skillset. This may not be always available. /// Additional, verbose details about the warning to assist in debugging the indexer. This may not be always available. /// A link to a troubleshooting guide for these classes of warnings. This may not be always available. - internal SearchIndexerWarning(string key, string message, string name, string details, string documentationLink) + /// Keeps track of any properties unknown to the library. + internal SearchIndexerWarning(string key, string message, string name, string details, string documentationLink, IDictionary serializedAdditionalRawData) { Key = key; Message = message; Name = name; Details = details; DocumentationLink = documentationLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchIndexerWarning() + { } /// The key of the item which generated a warning. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchOptions.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchOptions.Serialization.cs index 6faee393e77c..2ac03f7e03f0 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchOptions.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchOptions.Serialization.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; @@ -12,11 +14,27 @@ namespace Azure.Search.Documents { - public partial class SearchOptions : IUtf8JsonSerializable + public partial class SearchOptions : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SearchOptions)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(IncludeTotalCount)) { writer.WritePropertyName("count"u8); @@ -190,7 +208,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in VectorQueries) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } @@ -202,13 +220,41 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(HybridSearch)) { writer.WritePropertyName("hybridSearch"u8); - writer.WriteObjectValue(HybridSearch); + writer.WriteObjectValue(HybridSearch, options); + } + 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 + } } - writer.WriteEndObject(); } - internal static SearchOptions DeserializeSearchOptions(JsonElement element) + SearchOptions 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(SearchOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchOptions(document.RootElement, options); + } + + internal static SearchOptions DeserializeSearchOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -246,6 +292,8 @@ internal static SearchOptions DeserializeSearchOptions(JsonElement element) IList vectorQueries = default; VectorFilterMode? vectorFilterMode = default; HybridSearch hybridSearch = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("count"u8)) @@ -474,7 +522,7 @@ internal static SearchOptions DeserializeSearchOptions(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(VectorQuery.DeserializeVectorQuery(item)); + array.Add(VectorQuery.DeserializeVectorQuery(item, options)); } vectorQueries = array; continue; @@ -494,10 +542,15 @@ internal static SearchOptions DeserializeSearchOptions(JsonElement element) { continue; } - hybridSearch = HybridSearch.DeserializeHybridSearch(property.Value); + hybridSearch = HybridSearch.DeserializeHybridSearch(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new SearchOptions( count, facets ?? new ChangeTrackingList(), @@ -531,9 +584,41 @@ internal static SearchOptions DeserializeSearchOptions(JsonElement element) semanticFields, vectorQueries ?? new ChangeTrackingList(), vectorFilterMode, - hybridSearch); + hybridSearch, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchOptions)} does not support writing '{options.Format}' format."); + } } + SearchOptions 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 DeserializeSearchOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchOptions)} 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 SearchOptions FromResponse(Response response) @@ -546,7 +631,7 @@ internal static SearchOptions FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchOptions.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchOptions.cs index 658a7d2f4873..a0cfaddecd86 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchOptions.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchOptions.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Search.Documents.Models; @@ -13,6 +14,38 @@ namespace Azure.Search.Documents /// Parameters for filtering, sorting, faceting, paging, and other search query behaviors. public partial class SearchOptions { + /// + /// 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 SearchOptions() { @@ -20,6 +53,83 @@ public SearchOptions() ScoringParameters = new ChangeTrackingList(); VectorQueries = new ChangeTrackingList(); } + + /// Initializes a new instance of . + /// A value that specifies whether to fetch the total count of results. Default is false. Setting this value to true may have a performance impact. Note that the count returned is an approximation. + /// The list of facet expressions to apply to the search query. Each facet expression contains a field name, optionally followed by a comma-separated list of name:value pairs. + /// The OData $filter expression to apply to the search query. + /// The comma-separated list of field names to use for hit highlights. Only searchable fields can be used for hit highlighting. + /// A string tag that is appended to hit highlights. Must be set with highlightPreTag. Default is </em>. + /// A string tag that is prepended to hit highlights. Must be set with highlightPostTag. Default is <em>. + /// A number between 0 and 100 indicating the percentage of the index that must be covered by a search query in order for the query to be reported as a success. This parameter can be useful for ensuring search availability even for services with only one replica. The default is 100. + /// The comma-separated list of OData $orderby expressions by which to sort the results. Each expression can be either a field name or a call to either the geo.distance() or the search.score() functions. Each expression can be followed by asc to indicate ascending, or desc to indicate descending. The default is ascending order. Ties will be broken by the match scores of documents. If no $orderby is specified, the default sort order is descending by document match score. There can be at most 32 $orderby clauses. + /// A value that specifies the syntax of the search query. The default is 'simple'. Use 'full' if your query uses the Lucene query syntax. + /// A value that specifies whether we want to calculate scoring statistics (such as document frequency) globally for more consistent scoring, or locally, for lower latency. The default is 'local'. Use 'global' to aggregate scoring statistics globally before scoring. Using global scoring statistics can increase latency of search queries. + /// A value to be used to create a sticky session, which can help getting more consistent results. As long as the same sessionId is used, a best-effort attempt will be made to target the same replica set. Be wary that reusing the same sessionID values repeatedly can interfere with the load balancing of the requests across replicas and adversely affect the performance of the search service. The value used as sessionId cannot start with a '_' character. + /// The list of parameter values to be used in scoring functions (for example, referencePointParameter) using the format name-values. For example, if the scoring profile defines a function with a parameter called 'mylocation' the parameter string would be "mylocation--122.2,44.8" (without the quotes). + /// The name of a scoring profile to evaluate match scores for matching documents in order to sort the results. + /// Enables a debugging tool that can be used to further explore your reranked results. + /// A full-text search query expression; Use "*" or omit this parameter to match all documents. + /// The comma-separated list of field names to which to scope the full-text search. When using fielded search (fieldName:searchExpression) in a full Lucene query, the field names of each fielded search expression take precedence over any field names listed in this parameter. + /// A value that specifies whether any or all of the search terms must be matched in order to count the document as a match. + /// A value that specifies the language of the search query. + /// A value that specified the type of the speller to use to spell-correct individual search query terms. + /// The comma-separated list of fields to retrieve. If unspecified, all fields marked as retrievable in the schema are included. + /// The number of search results to skip. This value cannot be greater than 100,000. If you need to scan documents in sequence, but cannot use skip due to this limitation, consider using orderby on a totally-ordered key and filter with a range query instead. + /// The number of search results to retrieve. This can be used in conjunction with $skip to implement client-side paging of search results. If results are truncated due to server-side paging, the response will include a continuation token that can be used to issue another Search request for the next page of results. + /// The name of a semantic configuration that will be used when processing documents for queries of type semantic. + /// Allows the user to choose whether a semantic call should fail completely (default / current behavior), or to return partial results. + /// Allows the user to set an upper bound on the amount of time it takes for semantic enrichment to finish processing before the request fails. + /// Allows setting a separate search query that will be solely used for semantic reranking, semantic captions and semantic answers. Is useful for scenarios where there is a need to use different queries between the base retrieval and ranking phase, and the L2 semantic phase. + /// A value that specifies whether answers should be returned as part of the search response. + /// A value that specifies whether captions should be returned as part of the search response. + /// A value that specifies whether query rewrites should be generated to augment the search query. + /// The comma-separated list of field names used for semantic ranking. + /// + /// The query parameters for vector and hybrid search queries. + /// 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 . + /// + /// Determines whether or not filters are applied before or after the vector search is performed. Default is 'preFilter' for new indexes. + /// The query parameters to configure hybrid search behaviors. + /// Keeps track of any properties unknown to the library. + internal SearchOptions(bool? includeTotalCount, IList facets, string filter, string highlightFieldsRaw, string highlightPostTag, string highlightPreTag, double? minimumCoverage, string orderByRaw, SearchQueryType? queryType, ScoringStatistics? scoringStatistics, string sessionId, IList scoringParameters, string scoringProfile, QueryDebugMode? debug, string searchText, string searchFieldsRaw, SearchMode? searchMode, QueryLanguage? queryLanguage, QuerySpellerType? querySpeller, string selectRaw, int? skip, int? size, string semanticConfigurationName, SemanticErrorMode? semanticErrorMode, int? semanticMaxWaitInMilliseconds, string semanticQuery, string queryAnswerRaw, string queryCaptionRaw, string queryRewritesRaw, string semanticFieldsRaw, IList vectorQueries, VectorFilterMode? filterMode, HybridSearch hybridSearch, IDictionary serializedAdditionalRawData) + { + IncludeTotalCount = includeTotalCount; + Facets = facets; + Filter = filter; + HighlightFieldsRaw = highlightFieldsRaw; + HighlightPostTag = highlightPostTag; + HighlightPreTag = highlightPreTag; + MinimumCoverage = minimumCoverage; + OrderByRaw = orderByRaw; + QueryType = queryType; + ScoringStatistics = scoringStatistics; + SessionId = sessionId; + ScoringParameters = scoringParameters; + ScoringProfile = scoringProfile; + Debug = debug; + SearchText = searchText; + SearchFieldsRaw = searchFieldsRaw; + SearchMode = searchMode; + QueryLanguage = queryLanguage; + QuerySpeller = querySpeller; + SelectRaw = selectRaw; + Skip = skip; + Size = size; + SemanticConfigurationName = semanticConfigurationName; + SemanticErrorMode = semanticErrorMode; + SemanticMaxWaitInMilliseconds = semanticMaxWaitInMilliseconds; + SemanticQuery = semanticQuery; + QueryAnswerRaw = queryAnswerRaw; + QueryCaptionRaw = queryCaptionRaw; + QueryRewritesRaw = queryRewritesRaw; + SemanticFieldsRaw = semanticFieldsRaw; + VectorQueries = vectorQueries; + FilterMode = filterMode; + HybridSearch = hybridSearch; + _serializedAdditionalRawData = serializedAdditionalRawData; + } /// A string tag that is appended to hit highlights. Must be set with highlightPreTag. Default is </em>. public string HighlightPostTag { get; set; } /// A string tag that is prepended to hit highlights. Must be set with highlightPostTag. Default is <em>. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResourceCounter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResourceCounter.Serialization.cs index 357a80dc776e..45fdff16707e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResourceCounter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResourceCounter.Serialization.cs @@ -5,20 +5,90 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchResourceCounter + public partial class SearchResourceCounter : IUtf8JsonSerializable, IJsonModel { - internal static SearchResourceCounter DeserializeSearchResourceCounter(JsonElement element) + 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(SearchResourceCounter)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("usage"u8); + writer.WriteNumberValue(Usage); + if (Optional.IsDefined(Quota)) + { + if (Quota != null) + { + writer.WritePropertyName("quota"u8); + writer.WriteNumberValue(Quota.Value); + } + else + { + writer.WriteNull("quota"); + } + } + 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 + } + } + } + + SearchResourceCounter 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(SearchResourceCounter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchResourceCounter(document.RootElement, options); + } + + internal static SearchResourceCounter DeserializeSearchResourceCounter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } long usage = default; long? quota = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("usage"u8)) @@ -36,10 +106,46 @@ internal static SearchResourceCounter DeserializeSearchResourceCounter(JsonEleme quota = property.Value.GetInt64(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchResourceCounter(usage, quota, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchResourceCounter)} does not support writing '{options.Format}' format."); } - return new SearchResourceCounter(usage, quota); } + SearchResourceCounter 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 DeserializeSearchResourceCounter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchResourceCounter)} 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 SearchResourceCounter FromResponse(Response response) @@ -47,5 +153,13 @@ internal static SearchResourceCounter FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSearchResourceCounter(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/search/Azure.Search.Documents/src/Generated/Models/SearchResourceCounter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResourceCounter.cs index 07134d24e83f..8e7aceaa9c61 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResourceCounter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResourceCounter.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Represents a resource's usage and quota. public partial class SearchResourceCounter { + /// + /// 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 . /// The resource usage amount. internal SearchResourceCounter(long usage) @@ -20,10 +55,17 @@ internal SearchResourceCounter(long usage) /// Initializes a new instance of . /// The resource usage amount. /// The resource amount quota. - internal SearchResourceCounter(long usage, long? quota) + /// Keeps track of any properties unknown to the library. + internal SearchResourceCounter(long usage, long? quota, IDictionary serializedAdditionalRawData) { Usage = usage; Quota = quota; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchResourceCounter() + { } /// The resource usage amount. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResourceEncryptionKey.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResourceEncryptionKey.Serialization.cs index da4aa4996060..152fe3ab7d2b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResourceEncryptionKey.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResourceEncryptionKey.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchResourceEncryptionKey : IUtf8JsonSerializable + public partial class SearchResourceEncryptionKey : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SearchResourceEncryptionKey)} does not support writing '{format}' format."); + } + writer.WritePropertyName("keyVaultKeyName"u8); writer.WriteStringValue(KeyName); if (Optional.IsDefined(KeyVersion)) @@ -27,25 +46,53 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(AccessCredentialsInternal)) { writer.WritePropertyName("accessCredentials"u8); - writer.WriteObjectValue(AccessCredentialsInternal); + writer.WriteObjectValue(AccessCredentialsInternal, options); } if (Optional.IsDefined(Identity)) { if (Identity != null) { writer.WritePropertyName("identity"u8); - writer.WriteObjectValue(Identity); + writer.WriteObjectValue(Identity, options); } else { writer.WriteNull("identity"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static SearchResourceEncryptionKey DeserializeSearchResourceEncryptionKey(JsonElement element) + SearchResourceEncryptionKey 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(SearchResourceEncryptionKey)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchResourceEncryptionKey(document.RootElement, options); + } + + internal static SearchResourceEncryptionKey DeserializeSearchResourceEncryptionKey(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -55,6 +102,8 @@ internal static SearchResourceEncryptionKey DeserializeSearchResourceEncryptionK string keyVaultUri = default; AzureActiveDirectoryApplicationCredentials accessCredentials = default; SearchIndexerDataIdentity identity = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("keyVaultKeyName"u8)) @@ -78,7 +127,7 @@ internal static SearchResourceEncryptionKey DeserializeSearchResourceEncryptionK { continue; } - accessCredentials = AzureActiveDirectoryApplicationCredentials.DeserializeAzureActiveDirectoryApplicationCredentials(property.Value); + accessCredentials = AzureActiveDirectoryApplicationCredentials.DeserializeAzureActiveDirectoryApplicationCredentials(property.Value, options); continue; } if (property.NameEquals("identity"u8)) @@ -88,13 +137,55 @@ internal static SearchResourceEncryptionKey DeserializeSearchResourceEncryptionK identity = null; continue; } - identity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value); + identity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchResourceEncryptionKey( + keyVaultKeyName, + keyVaultKeyVersion, + keyVaultUri, + accessCredentials, + identity, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchResourceEncryptionKey)} does not support writing '{options.Format}' format."); } - return new SearchResourceEncryptionKey(keyVaultKeyName, keyVaultKeyVersion, keyVaultUri, accessCredentials, identity); } + SearchResourceEncryptionKey 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 DeserializeSearchResourceEncryptionKey(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchResourceEncryptionKey)} 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 SearchResourceEncryptionKey FromResponse(Response response) @@ -107,7 +198,7 @@ internal static SearchResourceEncryptionKey FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResourceEncryptionKey.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResourceEncryptionKey.cs index bbb9e6c17fa1..2e9fee132219 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResourceEncryptionKey.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResourceEncryptionKey.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// A customer-managed encryption key in Azure Key Vault. Keys that you create and manage can be used to encrypt or decrypt data-at-rest, such as indexes and synonym maps. public partial class SearchResourceEncryptionKey { + /// + /// 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 . /// The name of your Azure Key Vault key to be used to encrypt your data at rest. /// The version of your Azure Key Vault key to be used to encrypt your data at rest. @@ -22,13 +55,20 @@ public partial class SearchResourceEncryptionKey /// 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 . /// - internal SearchResourceEncryptionKey(string keyName, string keyVersion, string vaultUri, AzureActiveDirectoryApplicationCredentials accessCredentialsInternal, SearchIndexerDataIdentity identity) + /// Keeps track of any properties unknown to the library. + internal SearchResourceEncryptionKey(string keyName, string keyVersion, string vaultUri, AzureActiveDirectoryApplicationCredentials accessCredentialsInternal, SearchIndexerDataIdentity identity, IDictionary serializedAdditionalRawData) { KeyName = keyName; KeyVersion = keyVersion; _vaultUri = vaultUri; AccessCredentialsInternal = accessCredentialsInternal; Identity = identity; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchResourceEncryptionKey() + { } /// /// An explicit managed identity to use for this encryption key. If not specified and the access credentials property is null, the system-assigned managed identity is used. On update to the resource, if the explicit identity is unspecified, it remains unchanged. If "none" is specified, the value of this property is cleared. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResult.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResult.Serialization.cs index 49d0e3f94357..614a3804d8db 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResult.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResult.Serialization.cs @@ -5,15 +5,137 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - internal partial class SearchResult + internal partial class SearchResult : IUtf8JsonSerializable, IJsonModel { - internal static SearchResult DeserializeSearchResult(JsonElement element) + 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(SearchResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("@search.score"u8); + writer.WriteNumberValue(Score); + } + if (options.Format != "W" && Optional.IsDefined(RerankerScore)) + { + if (RerankerScore != null) + { + writer.WritePropertyName("@search.rerankerScore"u8); + writer.WriteNumberValue(RerankerScore.Value); + } + else + { + writer.WriteNull("@search.rerankerScore"); + } + } + if (options.Format != "W" && Optional.IsDefined(RerankerBoostedScore)) + { + if (RerankerBoostedScore != null) + { + writer.WritePropertyName("@search.rerankerBoostedScore"u8); + writer.WriteNumberValue(RerankerBoostedScore.Value); + } + else + { + writer.WriteNull("@search.rerankerBoostedScore"); + } + } + if (options.Format != "W" && Optional.IsCollectionDefined(Highlights)) + { + writer.WritePropertyName("@search.highlights"u8); + writer.WriteStartObject(); + foreach (var item in Highlights) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStartArray(); + foreach (var item0 in item.Value) + { + writer.WriteStringValue(item0); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Captions)) + { + if (Captions != null) + { + writer.WritePropertyName("@search.captions"u8); + writer.WriteStartArray(); + foreach (var item in Captions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("@search.captions"); + } + } + if (options.Format != "W" && Optional.IsDefined(DocumentDebugInfo)) + { + if (DocumentDebugInfo != null) + { + writer.WritePropertyName("@search.documentDebugInfo"u8); + writer.WriteObjectValue(DocumentDebugInfo, options); + } + else + { + writer.WriteNull("@search.documentDebugInfo"); + } + } + foreach (var item in AdditionalProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + } + + SearchResult 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(SearchResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchResult(document.RootElement, options); + } + + internal static SearchResult DeserializeSearchResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -89,7 +211,7 @@ internal static SearchResult DeserializeSearchResult(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(QueryCaptionResult.DeserializeQueryCaptionResult(item)); + array.Add(QueryCaptionResult.DeserializeQueryCaptionResult(item, options)); } searchCaptions = array; continue; @@ -101,7 +223,7 @@ internal static SearchResult DeserializeSearchResult(JsonElement element) searchDocumentDebugInfo = null; continue; } - searchDocumentDebugInfo = DocumentDebugInfo.DeserializeDocumentDebugInfo(property.Value); + searchDocumentDebugInfo = DocumentDebugInfo.DeserializeDocumentDebugInfo(property.Value, options); continue; } additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject()); @@ -117,6 +239,37 @@ internal static SearchResult DeserializeSearchResult(JsonElement element) additionalProperties); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchResult)} does not support writing '{options.Format}' format."); + } + } + + SearchResult 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 DeserializeSearchResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchResult)} 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 SearchResult FromResponse(Response response) @@ -124,5 +277,13 @@ internal static SearchResult FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSearchResult(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/search/Azure.Search.Documents/src/Generated/Models/SearchResult.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResult.cs index 55cde1b732e1..ef4a0c775561 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResult.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchResult.cs @@ -41,6 +41,11 @@ internal SearchResult(double score, double? rerankerScore, double? rerankerBoost AdditionalProperties = additionalProperties; } + /// Initializes a new instance of for deserialization. + internal SearchResult() + { + } + /// The relevance score of the document compared to other documents returned by the query. public double Score { get; } /// The relevance score computed by the semantic ranker for the top search results. Search results are sorted by the RerankerScore first and then by the Score. RerankerScore is only returned for queries of type 'semantic'. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchScoreThreshold.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchScoreThreshold.Serialization.cs index a64d6a234c91..04287f0b5bfe 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchScoreThreshold.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchScoreThreshold.Serialization.cs @@ -5,31 +5,64 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class SearchScoreThreshold : IUtf8JsonSerializable + public partial class SearchScoreThreshold : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SearchScoreThreshold)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("value"u8); writer.WriteNumberValue(Value); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); - writer.WriteEndObject(); } - internal static SearchScoreThreshold DeserializeSearchScoreThreshold(JsonElement element) + SearchScoreThreshold 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(SearchScoreThreshold)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchScoreThreshold(document.RootElement, options); + } + + internal static SearchScoreThreshold DeserializeSearchScoreThreshold(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } double value = default; VectorThresholdKind kind = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value"u8)) @@ -42,10 +75,46 @@ internal static SearchScoreThreshold DeserializeSearchScoreThreshold(JsonElement kind = new VectorThresholdKind(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchScoreThreshold(kind, serializedAdditionalRawData, value); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchScoreThreshold)} does not support writing '{options.Format}' format."); } - return new SearchScoreThreshold(kind, value); } + SearchScoreThreshold 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 DeserializeSearchScoreThreshold(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchScoreThreshold)} 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 SearchScoreThreshold FromResponse(Response response) @@ -58,7 +127,7 @@ internal static SearchScoreThreshold DeserializeSearchScoreThreshold(JsonElement internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchScoreThreshold.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchScoreThreshold.cs index c4187e5820ae..d241d96bc429 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchScoreThreshold.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchScoreThreshold.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Models { /// The results of the vector query will filter based on the '@search.score' value. Note this is the @search.score returned as part of the search response. The threshold direction will be chosen for higher @search.score. @@ -20,13 +23,19 @@ public SearchScoreThreshold(double value) /// Initializes a new instance of . /// The kind of threshold used to filter vector queries. + /// Keeps track of any properties unknown to the library. /// The threshold will filter based on the '@search.score' value. Note this is the @search.score returned as part of the search response. The threshold direction will be chosen for higher @search.score. - internal SearchScoreThreshold(VectorThresholdKind kind, double value) : base(kind) + internal SearchScoreThreshold(VectorThresholdKind kind, IDictionary serializedAdditionalRawData, double value) : base(kind, serializedAdditionalRawData) { Value = value; Kind = kind; } + /// Initializes a new instance of for deserialization. + internal SearchScoreThreshold() + { + } + /// The threshold will filter based on the '@search.score' value. Note this is the @search.score returned as part of the search response. The threshold direction will be chosen for higher @search.score. public double Value { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceCounters.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceCounters.Serialization.cs index 0ce21b6def7a..623bf47e4317 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceCounters.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceCounters.Serialization.cs @@ -5,14 +5,86 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchServiceCounters + public partial class SearchServiceCounters : IUtf8JsonSerializable, IJsonModel { - internal static SearchServiceCounters DeserializeSearchServiceCounters(JsonElement element) + 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(SearchServiceCounters)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("aliasesCount"u8); + writer.WriteObjectValue(AliasCounter, options); + writer.WritePropertyName("documentCount"u8); + writer.WriteObjectValue(DocumentCounter, options); + writer.WritePropertyName("indexesCount"u8); + writer.WriteObjectValue(IndexCounter, options); + writer.WritePropertyName("indexersCount"u8); + writer.WriteObjectValue(IndexerCounter, options); + writer.WritePropertyName("dataSourcesCount"u8); + writer.WriteObjectValue(DataSourceCounter, options); + writer.WritePropertyName("storageSize"u8); + writer.WriteObjectValue(StorageSizeCounter, options); + writer.WritePropertyName("synonymMaps"u8); + writer.WriteObjectValue(SynonymMapCounter, options); + writer.WritePropertyName("skillsetCount"u8); + writer.WriteObjectValue(SkillsetCounter, options); + writer.WritePropertyName("vectorIndexSize"u8); + writer.WriteObjectValue(VectorIndexSizeCounter, options); + 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 + } + } + } + + SearchServiceCounters 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(SearchServiceCounters)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchServiceCounters(document.RootElement, options); + } + + internal static SearchServiceCounters DeserializeSearchServiceCounters(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -26,54 +98,61 @@ internal static SearchServiceCounters DeserializeSearchServiceCounters(JsonEleme SearchResourceCounter synonymMaps = default; SearchResourceCounter skillsetCount = default; SearchResourceCounter vectorIndexSize = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("aliasesCount"u8)) { - aliasesCount = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value); + aliasesCount = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value, options); continue; } if (property.NameEquals("documentCount"u8)) { - documentCount = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value); + documentCount = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value, options); continue; } if (property.NameEquals("indexesCount"u8)) { - indexesCount = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value); + indexesCount = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value, options); continue; } if (property.NameEquals("indexersCount"u8)) { - indexersCount = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value); + indexersCount = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value, options); continue; } if (property.NameEquals("dataSourcesCount"u8)) { - dataSourcesCount = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value); + dataSourcesCount = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value, options); continue; } if (property.NameEquals("storageSize"u8)) { - storageSize = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value); + storageSize = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value, options); continue; } if (property.NameEquals("synonymMaps"u8)) { - synonymMaps = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value); + synonymMaps = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value, options); continue; } if (property.NameEquals("skillsetCount"u8)) { - skillsetCount = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value); + skillsetCount = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value, options); continue; } if (property.NameEquals("vectorIndexSize"u8)) { - vectorIndexSize = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value); + vectorIndexSize = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new SearchServiceCounters( aliasesCount, documentCount, @@ -83,9 +162,41 @@ internal static SearchServiceCounters DeserializeSearchServiceCounters(JsonEleme storageSize, synonymMaps, skillsetCount, - vectorIndexSize); + vectorIndexSize, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchServiceCounters)} does not support writing '{options.Format}' format."); + } } + SearchServiceCounters 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 DeserializeSearchServiceCounters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchServiceCounters)} 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 SearchServiceCounters FromResponse(Response response) @@ -93,5 +204,13 @@ internal static SearchServiceCounters FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSearchServiceCounters(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/search/Azure.Search.Documents/src/Generated/Models/SearchServiceCounters.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceCounters.cs index c63049576a30..875f403e9c4b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceCounters.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceCounters.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Represents service-level resource counters and quotas. public partial class SearchServiceCounters { + /// + /// 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 . /// Total number of aliases. /// Total number of documents across all indexes in the service. @@ -46,6 +79,36 @@ internal SearchServiceCounters(SearchResourceCounter aliasCounter, SearchResourc VectorIndexSizeCounter = vectorIndexSizeCounter; } + /// Initializes a new instance of . + /// Total number of aliases. + /// Total number of documents across all indexes in the service. + /// Total number of indexes. + /// Total number of indexers. + /// Total number of data sources. + /// Total size of used storage in bytes. + /// Total number of synonym maps. + /// Total number of skillsets. + /// Total memory consumption of all vector indexes within the service, in bytes. + /// Keeps track of any properties unknown to the library. + internal SearchServiceCounters(SearchResourceCounter aliasCounter, SearchResourceCounter documentCounter, SearchResourceCounter indexCounter, SearchResourceCounter indexerCounter, SearchResourceCounter dataSourceCounter, SearchResourceCounter storageSizeCounter, SearchResourceCounter synonymMapCounter, SearchResourceCounter skillsetCounter, SearchResourceCounter vectorIndexSizeCounter, IDictionary serializedAdditionalRawData) + { + AliasCounter = aliasCounter; + DocumentCounter = documentCounter; + IndexCounter = indexCounter; + IndexerCounter = indexerCounter; + DataSourceCounter = dataSourceCounter; + StorageSizeCounter = storageSizeCounter; + SynonymMapCounter = synonymMapCounter; + SkillsetCounter = skillsetCounter; + VectorIndexSizeCounter = vectorIndexSizeCounter; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchServiceCounters() + { + } + /// Total number of aliases. public SearchResourceCounter AliasCounter { get; } /// Total number of documents across all indexes in the service. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceLimits.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceLimits.Serialization.cs index b36a4c809482..de3f53e4efd0 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceLimits.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceLimits.Serialization.cs @@ -5,14 +5,128 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchServiceLimits + public partial class SearchServiceLimits : IUtf8JsonSerializable, IJsonModel { - internal static SearchServiceLimits DeserializeSearchServiceLimits(JsonElement element) + 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(SearchServiceLimits)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(MaxFieldsPerIndex)) + { + if (MaxFieldsPerIndex != null) + { + writer.WritePropertyName("maxFieldsPerIndex"u8); + writer.WriteNumberValue(MaxFieldsPerIndex.Value); + } + else + { + writer.WriteNull("maxFieldsPerIndex"); + } + } + if (Optional.IsDefined(MaxFieldNestingDepthPerIndex)) + { + if (MaxFieldNestingDepthPerIndex != null) + { + writer.WritePropertyName("maxFieldNestingDepthPerIndex"u8); + writer.WriteNumberValue(MaxFieldNestingDepthPerIndex.Value); + } + else + { + writer.WriteNull("maxFieldNestingDepthPerIndex"); + } + } + if (Optional.IsDefined(MaxComplexCollectionFieldsPerIndex)) + { + if (MaxComplexCollectionFieldsPerIndex != null) + { + writer.WritePropertyName("maxComplexCollectionFieldsPerIndex"u8); + writer.WriteNumberValue(MaxComplexCollectionFieldsPerIndex.Value); + } + else + { + writer.WriteNull("maxComplexCollectionFieldsPerIndex"); + } + } + if (Optional.IsDefined(MaxComplexObjectsInCollectionsPerDocument)) + { + if (MaxComplexObjectsInCollectionsPerDocument != null) + { + writer.WritePropertyName("maxComplexObjectsInCollectionsPerDocument"u8); + writer.WriteNumberValue(MaxComplexObjectsInCollectionsPerDocument.Value); + } + else + { + writer.WriteNull("maxComplexObjectsInCollectionsPerDocument"); + } + } + if (Optional.IsDefined(MaxStoragePerIndexInBytes)) + { + if (MaxStoragePerIndexInBytes != null) + { + writer.WritePropertyName("maxStoragePerIndex"u8); + writer.WriteNumberValue(MaxStoragePerIndexInBytes.Value); + } + else + { + writer.WriteNull("maxStoragePerIndex"); + } + } + 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 + } + } + } + + SearchServiceLimits 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(SearchServiceLimits)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchServiceLimits(document.RootElement, options); + } + + internal static SearchServiceLimits DeserializeSearchServiceLimits(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -22,6 +136,8 @@ internal static SearchServiceLimits DeserializeSearchServiceLimits(JsonElement e int? maxComplexCollectionFieldsPerIndex = default; int? maxComplexObjectsInCollectionsPerDocument = default; long? maxStoragePerIndex = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("maxFieldsPerIndex"u8)) @@ -74,10 +190,52 @@ internal static SearchServiceLimits DeserializeSearchServiceLimits(JsonElement e maxStoragePerIndex = property.Value.GetInt64(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new SearchServiceLimits(maxFieldsPerIndex, maxFieldNestingDepthPerIndex, maxComplexCollectionFieldsPerIndex, maxComplexObjectsInCollectionsPerDocument, maxStoragePerIndex); + serializedAdditionalRawData = rawDataDictionary; + return new SearchServiceLimits( + maxFieldsPerIndex, + maxFieldNestingDepthPerIndex, + maxComplexCollectionFieldsPerIndex, + maxComplexObjectsInCollectionsPerDocument, + maxStoragePerIndex, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchServiceLimits)} does not support writing '{options.Format}' format."); + } + } + + SearchServiceLimits 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 DeserializeSearchServiceLimits(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchServiceLimits)} 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 SearchServiceLimits FromResponse(Response response) @@ -85,5 +243,13 @@ internal static SearchServiceLimits FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSearchServiceLimits(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/search/Azure.Search.Documents/src/Generated/Models/SearchServiceLimits.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceLimits.cs index 842c21705ab0..185b90e12725 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceLimits.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceLimits.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Represents various service level limits. public partial class SearchServiceLimits { + /// + /// 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 . internal SearchServiceLimits() { @@ -21,13 +56,15 @@ internal SearchServiceLimits() /// The maximum number of fields of type Collection(Edm.ComplexType) allowed in an index. /// The maximum number of objects in complex collections allowed per document. /// The maximum amount of storage in bytes allowed per index. - internal SearchServiceLimits(int? maxFieldsPerIndex, int? maxFieldNestingDepthPerIndex, int? maxComplexCollectionFieldsPerIndex, int? maxComplexObjectsInCollectionsPerDocument, long? maxStoragePerIndexInBytes) + /// Keeps track of any properties unknown to the library. + internal SearchServiceLimits(int? maxFieldsPerIndex, int? maxFieldNestingDepthPerIndex, int? maxComplexCollectionFieldsPerIndex, int? maxComplexObjectsInCollectionsPerDocument, long? maxStoragePerIndexInBytes, IDictionary serializedAdditionalRawData) { MaxFieldsPerIndex = maxFieldsPerIndex; MaxFieldNestingDepthPerIndex = maxFieldNestingDepthPerIndex; MaxComplexCollectionFieldsPerIndex = maxComplexCollectionFieldsPerIndex; MaxComplexObjectsInCollectionsPerDocument = maxComplexObjectsInCollectionsPerDocument; MaxStoragePerIndexInBytes = maxStoragePerIndexInBytes; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The maximum allowed fields per index. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceStatistics.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceStatistics.Serialization.cs index ac0dde12f064..6818c1b7eebe 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceStatistics.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceStatistics.Serialization.cs @@ -5,36 +5,132 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchServiceStatistics + public partial class SearchServiceStatistics : IUtf8JsonSerializable, IJsonModel { - internal static SearchServiceStatistics DeserializeSearchServiceStatistics(JsonElement element) + 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(SearchServiceStatistics)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("counters"u8); + writer.WriteObjectValue(Counters, options); + writer.WritePropertyName("limits"u8); + writer.WriteObjectValue(Limits, options); + 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 + } + } + } + + SearchServiceStatistics 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(SearchServiceStatistics)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchServiceStatistics(document.RootElement, options); + } + + internal static SearchServiceStatistics DeserializeSearchServiceStatistics(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } SearchServiceCounters counters = default; SearchServiceLimits limits = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("counters"u8)) { - counters = SearchServiceCounters.DeserializeSearchServiceCounters(property.Value); + counters = SearchServiceCounters.DeserializeSearchServiceCounters(property.Value, options); continue; } if (property.NameEquals("limits"u8)) { - limits = SearchServiceLimits.DeserializeSearchServiceLimits(property.Value); + limits = SearchServiceLimits.DeserializeSearchServiceLimits(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchServiceStatistics(counters, limits, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchServiceStatistics)} does not support writing '{options.Format}' format."); } - return new SearchServiceStatistics(counters, limits); } + SearchServiceStatistics 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 DeserializeSearchServiceStatistics(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchServiceStatistics)} 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 SearchServiceStatistics FromResponse(Response response) @@ -42,5 +138,13 @@ internal static SearchServiceStatistics FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSearchServiceStatistics(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/search/Azure.Search.Documents/src/Generated/Models/SearchServiceStatistics.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceStatistics.cs index efd1ac4579d3..f5762b951ad9 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceStatistics.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchServiceStatistics.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Response from a get service statistics request. If successful, it includes service level counters and limits. public partial class SearchServiceStatistics { + /// + /// 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 . /// Service level resource counters. /// Service level general limits. @@ -25,6 +58,22 @@ internal SearchServiceStatistics(SearchServiceCounters counters, SearchServiceLi Limits = limits; } + /// Initializes a new instance of . + /// Service level resource counters. + /// Service level general limits. + /// Keeps track of any properties unknown to the library. + internal SearchServiceStatistics(SearchServiceCounters counters, SearchServiceLimits limits, IDictionary serializedAdditionalRawData) + { + Counters = counters; + Limits = limits; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchServiceStatistics() + { + } + /// Service level resource counters. public SearchServiceCounters Counters { get; } /// Service level general limits. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchSuggester.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchSuggester.Serialization.cs index 2e7603718715..90c6604c2db3 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchSuggester.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchSuggester.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SearchSuggester : IUtf8JsonSerializable + public partial class SearchSuggester : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SearchSuggester)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); writer.WritePropertyName("searchMode"u8); @@ -27,11 +45,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStringValue(item); } writer.WriteEndArray(); - writer.WriteEndObject(); + 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 + } + } } - internal static SearchSuggester DeserializeSearchSuggester(JsonElement element) + SearchSuggester 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(SearchSuggester)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchSuggester(document.RootElement, options); + } + + internal static SearchSuggester DeserializeSearchSuggester(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -39,6 +85,8 @@ internal static SearchSuggester DeserializeSearchSuggester(JsonElement element) string name = default; string searchMode = default; IList sourceFields = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -61,10 +109,46 @@ internal static SearchSuggester DeserializeSearchSuggester(JsonElement element) sourceFields = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchSuggester(name, searchMode, sourceFields, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchSuggester)} does not support writing '{options.Format}' format."); } - return new SearchSuggester(name, searchMode, sourceFields); } + SearchSuggester 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 DeserializeSearchSuggester(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchSuggester)} 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 SearchSuggester FromResponse(Response response) @@ -77,7 +161,7 @@ internal static SearchSuggester FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchSuggester.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchSuggester.cs index 88c8806cea54..9e31852996cb 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchSuggester.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchSuggester.cs @@ -14,15 +14,54 @@ namespace Azure.Search.Documents.Indexes.Models /// Defines how the Suggest API should apply to a group of fields in the index. public partial class SearchSuggester { + /// + /// 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 . /// The name of the suggester. /// A value indicating the capabilities of the suggester. /// The list of field names to which the suggester applies. Each field must be searchable. - internal SearchSuggester(string name, string searchMode, IList sourceFields) + /// Keeps track of any properties unknown to the library. + internal SearchSuggester(string name, string searchMode, IList sourceFields, IDictionary serializedAdditionalRawData) { Name = name; SearchMode = searchMode; SourceFields = sourceFields; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchSuggester() + { } /// The name of the suggester. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticConfiguration.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticConfiguration.Serialization.cs index 8a943b7b9c30..ea0d61820d9d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticConfiguration.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticConfiguration.Serialization.cs @@ -5,20 +5,39 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SemanticConfiguration : IUtf8JsonSerializable + public partial class SemanticConfiguration : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SemanticConfiguration)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); writer.WritePropertyName("prioritizedFields"u8); - writer.WriteObjectValue(PrioritizedFields); + writer.WriteObjectValue(PrioritizedFields, options); if (Optional.IsDefined(RankingOrder)) { if (RankingOrder != null) @@ -36,11 +55,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("flightingOptIn"u8); writer.WriteBooleanValue(FlightingOptIn.Value); } - writer.WriteEndObject(); + 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 + } + } } - internal static SemanticConfiguration DeserializeSemanticConfiguration(JsonElement element) + SemanticConfiguration 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(SemanticConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSemanticConfiguration(document.RootElement, options); + } + + internal static SemanticConfiguration DeserializeSemanticConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -49,6 +96,8 @@ internal static SemanticConfiguration DeserializeSemanticConfiguration(JsonEleme SemanticPrioritizedFields prioritizedFields = default; RankingOrder? rankingOrder = default; bool? flightingOptIn = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -58,7 +107,7 @@ internal static SemanticConfiguration DeserializeSemanticConfiguration(JsonEleme } if (property.NameEquals("prioritizedFields"u8)) { - prioritizedFields = SemanticPrioritizedFields.DeserializeSemanticPrioritizedFields(property.Value); + prioritizedFields = SemanticPrioritizedFields.DeserializeSemanticPrioritizedFields(property.Value, options); continue; } if (property.NameEquals("rankingOrder"u8)) @@ -80,10 +129,46 @@ internal static SemanticConfiguration DeserializeSemanticConfiguration(JsonEleme flightingOptIn = property.Value.GetBoolean(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SemanticConfiguration(name, prioritizedFields, rankingOrder, flightingOptIn, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SemanticConfiguration)} does not support writing '{options.Format}' format."); } - return new SemanticConfiguration(name, prioritizedFields, rankingOrder, flightingOptIn); } + SemanticConfiguration 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 DeserializeSemanticConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SemanticConfiguration)} 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 SemanticConfiguration FromResponse(Response response) @@ -96,7 +181,7 @@ internal static SemanticConfiguration FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticConfiguration.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticConfiguration.cs index d14b81359622..8d749a135132 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticConfiguration.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticConfiguration.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Defines a specific configuration to be used in the context of semantic capabilities. public partial class SemanticConfiguration { + /// + /// 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 . /// The name of the semantic configuration. /// Describes the title, content, and keyword fields to be used for semantic ranking, captions, highlights, and answers. At least one of the three sub properties (titleField, prioritizedKeywordsFields and prioritizedContentFields) need to be set. @@ -30,12 +63,19 @@ public SemanticConfiguration(string name, SemanticPrioritizedFields prioritizedF /// Describes the title, content, and keyword fields to be used for semantic ranking, captions, highlights, and answers. At least one of the three sub properties (titleField, prioritizedKeywordsFields and prioritizedContentFields) need to be set. /// Specifies the score type to be used for the sort order of the search results. /// Determines which semantic or query rewrite models to use during model flighting/upgrades. - internal SemanticConfiguration(string name, SemanticPrioritizedFields prioritizedFields, RankingOrder? rankingOrder, bool? flightingOptIn) + /// Keeps track of any properties unknown to the library. + internal SemanticConfiguration(string name, SemanticPrioritizedFields prioritizedFields, RankingOrder? rankingOrder, bool? flightingOptIn, IDictionary serializedAdditionalRawData) { Name = name; PrioritizedFields = prioritizedFields; RankingOrder = rankingOrder; FlightingOptIn = flightingOptIn; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SemanticConfiguration() + { } /// The name of the semantic configuration. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticDebugInfo.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticDebugInfo.Serialization.cs index c536dd1ff547..f6e91387c4b2 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticDebugInfo.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticDebugInfo.Serialization.cs @@ -5,15 +5,98 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class SemanticDebugInfo + public partial class SemanticDebugInfo : IUtf8JsonSerializable, IJsonModel { - internal static SemanticDebugInfo DeserializeSemanticDebugInfo(JsonElement element) + 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(SemanticDebugInfo)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(TitleField)) + { + writer.WritePropertyName("titleField"u8); + writer.WriteObjectValue(TitleField, options); + } + if (options.Format != "W" && Optional.IsCollectionDefined(ContentFields)) + { + writer.WritePropertyName("contentFields"u8); + writer.WriteStartArray(); + foreach (var item in ContentFields) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(KeywordFields)) + { + writer.WritePropertyName("keywordFields"u8); + writer.WriteStartArray(); + foreach (var item in KeywordFields) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(RerankerInput)) + { + writer.WritePropertyName("rerankerInput"u8); + writer.WriteObjectValue(RerankerInput, options); + } + 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 + } + } + } + + SemanticDebugInfo 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(SemanticDebugInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSemanticDebugInfo(document.RootElement, options); + } + + internal static SemanticDebugInfo DeserializeSemanticDebugInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -22,6 +105,8 @@ internal static SemanticDebugInfo DeserializeSemanticDebugInfo(JsonElement eleme IReadOnlyList contentFields = default; IReadOnlyList keywordFields = default; QueryResultDocumentRerankerInput rerankerInput = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("titleField"u8)) @@ -30,7 +115,7 @@ internal static SemanticDebugInfo DeserializeSemanticDebugInfo(JsonElement eleme { continue; } - titleField = QueryResultDocumentSemanticField.DeserializeQueryResultDocumentSemanticField(property.Value); + titleField = QueryResultDocumentSemanticField.DeserializeQueryResultDocumentSemanticField(property.Value, options); continue; } if (property.NameEquals("contentFields"u8)) @@ -42,7 +127,7 @@ internal static SemanticDebugInfo DeserializeSemanticDebugInfo(JsonElement eleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(QueryResultDocumentSemanticField.DeserializeQueryResultDocumentSemanticField(item)); + array.Add(QueryResultDocumentSemanticField.DeserializeQueryResultDocumentSemanticField(item, options)); } contentFields = array; continue; @@ -56,7 +141,7 @@ internal static SemanticDebugInfo DeserializeSemanticDebugInfo(JsonElement eleme List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(QueryResultDocumentSemanticField.DeserializeQueryResultDocumentSemanticField(item)); + array.Add(QueryResultDocumentSemanticField.DeserializeQueryResultDocumentSemanticField(item, options)); } keywordFields = array; continue; @@ -67,13 +152,49 @@ internal static SemanticDebugInfo DeserializeSemanticDebugInfo(JsonElement eleme { continue; } - rerankerInput = QueryResultDocumentRerankerInput.DeserializeQueryResultDocumentRerankerInput(property.Value); + rerankerInput = QueryResultDocumentRerankerInput.DeserializeQueryResultDocumentRerankerInput(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new SemanticDebugInfo(titleField, contentFields ?? new ChangeTrackingList(), keywordFields ?? new ChangeTrackingList(), rerankerInput); + serializedAdditionalRawData = rawDataDictionary; + return new SemanticDebugInfo(titleField, contentFields ?? new ChangeTrackingList(), keywordFields ?? new ChangeTrackingList(), rerankerInput, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SemanticDebugInfo)} does not support writing '{options.Format}' format."); + } + } + + SemanticDebugInfo 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 DeserializeSemanticDebugInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SemanticDebugInfo)} 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 SemanticDebugInfo FromResponse(Response response) @@ -81,5 +202,13 @@ internal static SemanticDebugInfo FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSemanticDebugInfo(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/search/Azure.Search.Documents/src/Generated/Models/SemanticDebugInfo.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticDebugInfo.cs index 6f15066b9bbe..ac93a95b383f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticDebugInfo.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticDebugInfo.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.Search.Documents.Models @@ -12,6 +13,38 @@ namespace Azure.Search.Documents.Models /// The SemanticDebugInfo. public partial class SemanticDebugInfo { + /// + /// 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 . internal SemanticDebugInfo() { @@ -24,12 +57,14 @@ internal SemanticDebugInfo() /// The content fields that were sent to the semantic enrichment process, as well as how they were used. /// The keyword fields that were sent to the semantic enrichment process, as well as how they were used. /// The raw concatenated strings that were sent to the semantic enrichment process. - internal SemanticDebugInfo(QueryResultDocumentSemanticField titleField, IReadOnlyList contentFields, IReadOnlyList keywordFields, QueryResultDocumentRerankerInput rerankerInput) + /// Keeps track of any properties unknown to the library. + internal SemanticDebugInfo(QueryResultDocumentSemanticField titleField, IReadOnlyList contentFields, IReadOnlyList keywordFields, QueryResultDocumentRerankerInput rerankerInput, IDictionary serializedAdditionalRawData) { TitleField = titleField; ContentFields = contentFields; KeywordFields = keywordFields; RerankerInput = rerankerInput; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The title field that was sent to the semantic enrichment process, as well as how it was used. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticField.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticField.Serialization.cs index be9118e13fca..e38c1cc1bfe0 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticField.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticField.Serialization.cs @@ -5,28 +5,77 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SemanticField : IUtf8JsonSerializable + public partial class SemanticField : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SemanticField)} does not support writing '{format}' format."); + } + writer.WritePropertyName("fieldName"u8); writer.WriteStringValue(FieldName); - writer.WriteEndObject(); + 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 + } + } } - internal static SemanticField DeserializeSemanticField(JsonElement element) + SemanticField 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(SemanticField)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSemanticField(document.RootElement, options); + } + + internal static SemanticField DeserializeSemanticField(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string fieldName = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("fieldName"u8)) @@ -34,10 +83,46 @@ internal static SemanticField DeserializeSemanticField(JsonElement element) fieldName = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new SemanticField(fieldName); + serializedAdditionalRawData = rawDataDictionary; + return new SemanticField(fieldName, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SemanticField)} does not support writing '{options.Format}' format."); + } + } + + SemanticField 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 DeserializeSemanticField(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SemanticField)} 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 SemanticField FromResponse(Response response) @@ -50,7 +135,7 @@ internal static SemanticField FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticField.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticField.cs index 4950fffd26d8..188d79e9d081 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticField.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticField.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// A field that is used as part of the semantic configuration. public partial class SemanticField { + /// + /// 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 . /// /// is null. @@ -22,6 +55,20 @@ public SemanticField(string fieldName) FieldName = fieldName; } + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal SemanticField(string fieldName, IDictionary serializedAdditionalRawData) + { + FieldName = fieldName; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SemanticField() + { + } + /// Gets or sets the field name. public string FieldName { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticPrioritizedFields.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticPrioritizedFields.Serialization.cs index 6c0b880a94bf..aecc849f72bb 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticPrioritizedFields.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticPrioritizedFields.Serialization.cs @@ -5,21 +5,39 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SemanticPrioritizedFields : IUtf8JsonSerializable + public partial class SemanticPrioritizedFields : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SemanticPrioritizedFields)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(TitleField)) { writer.WritePropertyName("titleField"u8); - writer.WriteObjectValue(TitleField); + writer.WriteObjectValue(TitleField, options); } if (Optional.IsCollectionDefined(ContentFields)) { @@ -27,7 +45,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in ContentFields) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } @@ -37,15 +55,43 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in KeywordsFields) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - writer.WriteEndObject(); + 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 + } + } } - internal static SemanticPrioritizedFields DeserializeSemanticPrioritizedFields(JsonElement element) + SemanticPrioritizedFields 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(SemanticPrioritizedFields)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSemanticPrioritizedFields(document.RootElement, options); + } + + internal static SemanticPrioritizedFields DeserializeSemanticPrioritizedFields(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -53,6 +99,8 @@ internal static SemanticPrioritizedFields DeserializeSemanticPrioritizedFields(J SemanticField titleField = default; IList prioritizedContentFields = default; IList prioritizedKeywordsFields = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("titleField"u8)) @@ -61,7 +109,7 @@ internal static SemanticPrioritizedFields DeserializeSemanticPrioritizedFields(J { continue; } - titleField = SemanticField.DeserializeSemanticField(property.Value); + titleField = SemanticField.DeserializeSemanticField(property.Value, options); continue; } if (property.NameEquals("prioritizedContentFields"u8)) @@ -73,7 +121,7 @@ internal static SemanticPrioritizedFields DeserializeSemanticPrioritizedFields(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SemanticField.DeserializeSemanticField(item)); + array.Add(SemanticField.DeserializeSemanticField(item, options)); } prioritizedContentFields = array; continue; @@ -87,15 +135,51 @@ internal static SemanticPrioritizedFields DeserializeSemanticPrioritizedFields(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SemanticField.DeserializeSemanticField(item)); + array.Add(SemanticField.DeserializeSemanticField(item, options)); } prioritizedKeywordsFields = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SemanticPrioritizedFields(titleField, prioritizedContentFields ?? new ChangeTrackingList(), prioritizedKeywordsFields ?? 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SemanticPrioritizedFields)} does not support writing '{options.Format}' format."); } - return new SemanticPrioritizedFields(titleField, prioritizedContentFields ?? new ChangeTrackingList(), prioritizedKeywordsFields ?? new ChangeTrackingList()); } + SemanticPrioritizedFields 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 DeserializeSemanticPrioritizedFields(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SemanticPrioritizedFields)} 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 SemanticPrioritizedFields FromResponse(Response response) @@ -108,7 +192,7 @@ internal static SemanticPrioritizedFields FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticPrioritizedFields.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticPrioritizedFields.cs index a45fa8dfdda5..bbb1709c82cd 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticPrioritizedFields.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticPrioritizedFields.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models @@ -12,6 +13,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Describes the title, content, and keywords fields to be used for semantic ranking, captions, highlights, and answers. public partial class SemanticPrioritizedFields { + /// + /// 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 SemanticPrioritizedFields() { @@ -23,11 +56,13 @@ public SemanticPrioritizedFields() /// Defines the title field to be used for semantic ranking, captions, highlights, and answers. If you don't have a title field in your index, leave this blank. /// Defines the content fields to be used for semantic ranking, captions, highlights, and answers. For the best result, the selected fields should contain text in natural language form. The order of the fields in the array represents their priority. Fields with lower priority may get truncated if the content is long. /// Defines the keyword fields to be used for semantic ranking, captions, highlights, and answers. For the best result, the selected fields should contain a list of keywords. The order of the fields in the array represents their priority. Fields with lower priority may get truncated if the content is long. - internal SemanticPrioritizedFields(SemanticField titleField, IList contentFields, IList keywordsFields) + /// Keeps track of any properties unknown to the library. + internal SemanticPrioritizedFields(SemanticField titleField, IList contentFields, IList keywordsFields, IDictionary serializedAdditionalRawData) { TitleField = titleField; ContentFields = contentFields; KeywordsFields = keywordsFields; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Defines the title field to be used for semantic ranking, captions, highlights, and answers. If you don't have a title field in your index, leave this blank. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticSearch.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticSearch.Serialization.cs index b77c7e5cff99..c4510d75931d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticSearch.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticSearch.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SemanticSearch : IUtf8JsonSerializable + public partial class SemanticSearch : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SemanticSearch)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(DefaultConfigurationName)) { writer.WritePropertyName("defaultConfiguration"u8); @@ -27,21 +45,51 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in Configurations) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - writer.WriteEndObject(); + 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 + } + } } - internal static SemanticSearch DeserializeSemanticSearch(JsonElement element) + SemanticSearch 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(SemanticSearch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSemanticSearch(document.RootElement, options); + } + + internal static SemanticSearch DeserializeSemanticSearch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string defaultConfiguration = default; IList configurations = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("defaultConfiguration"u8)) @@ -58,15 +106,51 @@ internal static SemanticSearch DeserializeSemanticSearch(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SemanticConfiguration.DeserializeSemanticConfiguration(item)); + array.Add(SemanticConfiguration.DeserializeSemanticConfiguration(item, options)); } configurations = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SemanticSearch(defaultConfiguration, configurations ?? 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SemanticSearch)} does not support writing '{options.Format}' format."); } - return new SemanticSearch(defaultConfiguration, configurations ?? new ChangeTrackingList()); } + SemanticSearch 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 DeserializeSemanticSearch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SemanticSearch)} 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 SemanticSearch FromResponse(Response response) @@ -79,7 +163,7 @@ internal static SemanticSearch FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticSearch.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticSearch.cs index 4f47cb113168..57d0c63392df 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticSearch.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SemanticSearch.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models @@ -12,6 +13,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Defines parameters for a search index that influence semantic capabilities. public partial class SemanticSearch { + /// + /// 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 SemanticSearch() { @@ -21,10 +54,12 @@ public SemanticSearch() /// Initializes a new instance of . /// Allows you to set the name of a default semantic configuration in your index, making it optional to pass it on as a query parameter every time. /// The semantic configurations for the index. - internal SemanticSearch(string defaultConfigurationName, IList configurations) + /// Keeps track of any properties unknown to the library. + internal SemanticSearch(string defaultConfigurationName, IList configurations, IDictionary serializedAdditionalRawData) { DefaultConfigurationName = defaultConfigurationName; Configurations = configurations; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Allows you to set the name of a default semantic configuration in your index, making it optional to pass it on as a query parameter every time. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SentimentSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SentimentSkill.Serialization.cs index df808f0b4452..74dafee86c81 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SentimentSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SentimentSkill.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SentimentSkill : IUtf8JsonSerializable + public partial class SentimentSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SentimentSkill)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(DefaultLanguageCode)) { if (DefaultLanguageCode != null) @@ -28,42 +47,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("defaultLanguageCode"); } } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + SentimentSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(SentimentSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSentimentSkill(document.RootElement, options); } - internal static SentimentSkill DeserializeSentimentSkill(JsonElement element) + internal static SentimentSkill DeserializeSentimentSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -75,6 +76,8 @@ internal static SentimentSkill DeserializeSentimentSkill(JsonElement element) string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("defaultLanguageCode"u8)) @@ -112,7 +115,7 @@ internal static SentimentSkill DeserializeSentimentSkill(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -122,12 +125,17 @@ internal static SentimentSkill DeserializeSentimentSkill(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new SentimentSkill( odataType, name, @@ -135,9 +143,41 @@ internal static SentimentSkill DeserializeSentimentSkill(JsonElement element) context, inputs, outputs, + serializedAdditionalRawData, defaultLanguageCode); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SentimentSkill)} does not support writing '{options.Format}' format."); + } + } + + SentimentSkill 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 DeserializeSentimentSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SentimentSkill)} 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 SentimentSkill FromResponse(Response response) @@ -150,7 +190,7 @@ internal static SentimentSkill DeserializeSentimentSkill(JsonElement element) internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SentimentSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SentimentSkill.cs index 7e4f18241ddd..32df544f2691 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SentimentSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SentimentSkill.cs @@ -20,11 +20,17 @@ public partial class SentimentSkill : SearchIndexerSkill /// Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// A value indicating which language code to use. Default is `en`. - internal SentimentSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, SentimentSkillLanguage? defaultLanguageCode) : base(oDataType, name, description, context, inputs, outputs) + internal SentimentSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, SentimentSkillLanguage? defaultLanguageCode) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { DefaultLanguageCode = defaultLanguageCode; ODataType = oDataType ?? "#Microsoft.Skills.Text.SentimentSkill"; } + + /// Initializes a new instance of for deserialization. + internal SentimentSkill() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SentimentSkillV3.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SentimentSkillV3.Serialization.cs index f45dad193ff2..1acbd1c4322e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SentimentSkillV3.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SentimentSkillV3.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - internal partial class SentimentSkillV3 : IUtf8JsonSerializable + internal partial class SentimentSkillV3 : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SentimentSkillV3)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(DefaultLanguageCode)) { if (DefaultLanguageCode != null) @@ -45,42 +64,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("modelVersion"); } } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + SentimentSkillV3 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(SentimentSkillV3)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSentimentSkillV3(document.RootElement, options); } - internal static SentimentSkillV3 DeserializeSentimentSkillV3(JsonElement element) + internal static SentimentSkillV3 DeserializeSentimentSkillV3(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -94,6 +95,8 @@ internal static SentimentSkillV3 DeserializeSentimentSkillV3(JsonElement element string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("defaultLanguageCode"u8)) @@ -150,7 +153,7 @@ internal static SentimentSkillV3 DeserializeSentimentSkillV3(JsonElement element List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -160,12 +163,17 @@ internal static SentimentSkillV3 DeserializeSentimentSkillV3(JsonElement element List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new SentimentSkillV3( odataType, name, @@ -173,11 +181,43 @@ internal static SentimentSkillV3 DeserializeSentimentSkillV3(JsonElement element context, inputs, outputs, + serializedAdditionalRawData, defaultLanguageCode, includeOpinionMining, modelVersion); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SentimentSkillV3)} does not support writing '{options.Format}' format."); + } + } + + SentimentSkillV3 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 DeserializeSentimentSkillV3(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SentimentSkillV3)} 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 SentimentSkillV3 FromResponse(Response response) @@ -190,7 +230,7 @@ internal static SentimentSkillV3 DeserializeSentimentSkillV3(JsonElement element internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SentimentSkillV3.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SentimentSkillV3.cs index 805858c97bad..352de445f41a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SentimentSkillV3.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SentimentSkillV3.cs @@ -32,10 +32,11 @@ public SentimentSkillV3(IEnumerable inputs, IEnumerable< /// Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// A value indicating which language code to use. Default is `en`. /// If set to true, the skill output will include information from Text Analytics for opinion mining, namely targets (nouns or verbs) and their associated assessment (adjective) in the text. Default is false. /// The version of the model to use when calling the Text Analytics service. It will default to the latest available when not specified. We recommend you do not specify this value unless absolutely necessary. - internal SentimentSkillV3(string oDataType, string name, string description, string context, IList inputs, IList outputs, string defaultLanguageCode, bool? includeOpinionMining, string modelVersion) : base(oDataType, name, description, context, inputs, outputs) + internal SentimentSkillV3(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, string defaultLanguageCode, bool? includeOpinionMining, string modelVersion) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { DefaultLanguageCode = defaultLanguageCode; IncludeOpinionMining = includeOpinionMining; @@ -43,6 +44,11 @@ internal SentimentSkillV3(string oDataType, string name, string description, str ODataType = oDataType ?? "#Microsoft.Skills.Text.V3.SentimentSkill"; } + /// Initializes a new instance of for deserialization. + internal SentimentSkillV3() + { + } + /// A value indicating which language code to use. Default is `en`. public string DefaultLanguageCode { get; set; } /// If set to true, the skill output will include information from Text Analytics for opinion mining, namely targets (nouns or verbs) and their associated assessment (adjective) in the text. Default is false. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ShaperSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ShaperSkill.Serialization.cs index eab94707aeab..2b42e5188ffa 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ShaperSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ShaperSkill.Serialization.cs @@ -5,53 +5,54 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class ShaperSkill : IUtf8JsonSerializable + public partial class ShaperSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) + 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") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(ShaperSkill)} does not support writing '{format}' format."); } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + + base.JsonModelWriteCore(writer, options); + } + + ShaperSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(ShaperSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeShaperSkill(document.RootElement, options); } - internal static ShaperSkill DeserializeShaperSkill(JsonElement element) + internal static ShaperSkill DeserializeShaperSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -62,6 +63,8 @@ internal static ShaperSkill DeserializeShaperSkill(JsonElement element) string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@odata.type"u8)) @@ -89,7 +92,7 @@ internal static ShaperSkill DeserializeShaperSkill(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -99,21 +102,58 @@ internal static ShaperSkill DeserializeShaperSkill(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new ShaperSkill( odataType, name, description, context, inputs, - outputs); + outputs, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ShaperSkill)} does not support writing '{options.Format}' format."); + } + } + + ShaperSkill 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 DeserializeShaperSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ShaperSkill)} 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 ShaperSkill FromResponse(Response response) @@ -126,7 +166,7 @@ internal static ShaperSkill DeserializeShaperSkill(JsonElement element) internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ShaperSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ShaperSkill.cs index ae558e215234..beef49b4a263 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ShaperSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ShaperSkill.cs @@ -32,9 +32,15 @@ public ShaperSkill(IEnumerable inputs, IEnumerable Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. - internal ShaperSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs) : base(oDataType, name, description, context, inputs, outputs) + /// Keeps track of any properties unknown to the library. + internal ShaperSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { ODataType = oDataType ?? "#Microsoft.Skills.Util.ShaperSkill"; } + + /// Initializes a new instance of for deserialization. + internal ShaperSkill() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ShingleTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ShingleTokenFilter.Serialization.cs index e61631618146..dc770b869603 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ShingleTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ShingleTokenFilter.Serialization.cs @@ -5,16 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class ShingleTokenFilter : IUtf8JsonSerializable + public partial class ShingleTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(ShingleTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(MaxShingleSize)) { writer.WritePropertyName("maxShingleSize"u8); @@ -45,15 +65,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("filterToken"u8); writer.WriteStringValue(FilterToken); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static ShingleTokenFilter DeserializeShingleTokenFilter(JsonElement element) + ShingleTokenFilter 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(ShingleTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeShingleTokenFilter(document.RootElement, options); + } + + internal static ShingleTokenFilter DeserializeShingleTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -66,6 +95,8 @@ internal static ShingleTokenFilter DeserializeShingleTokenFilter(JsonElement ele string filterToken = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("maxShingleSize"u8)) @@ -124,10 +155,16 @@ internal static ShingleTokenFilter DeserializeShingleTokenFilter(JsonElement ele name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new ShingleTokenFilter( odataType, name, + serializedAdditionalRawData, maxShingleSize, minShingleSize, outputUnigrams, @@ -136,6 +173,37 @@ internal static ShingleTokenFilter DeserializeShingleTokenFilter(JsonElement ele filterToken); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ShingleTokenFilter)} does not support writing '{options.Format}' format."); + } + } + + ShingleTokenFilter 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 DeserializeShingleTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ShingleTokenFilter)} 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 ShingleTokenFilter FromResponse(Response response) @@ -148,7 +216,7 @@ internal static ShingleTokenFilter DeserializeShingleTokenFilter(JsonElement ele internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/ShingleTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/ShingleTokenFilter.cs index 77b9247439dd..9307f60319da 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/ShingleTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/ShingleTokenFilter.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,13 +26,14 @@ public ShingleTokenFilter(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The maximum shingle size. Default and minimum value is 2. /// The minimum shingle size. Default and minimum value is 2. Must be less than the value of maxShingleSize. /// A value indicating whether the output stream will contain the input tokens (unigrams) as well as shingles. Default is true. /// A value indicating whether to output unigrams for those times when no shingles are available. This property takes precedence when outputUnigrams is set to false. Default is false. /// The string to use when joining adjacent tokens to form a shingle. Default is a single space (" "). /// The string to insert for each position at which there is no token. Default is an underscore ("_"). - internal ShingleTokenFilter(string oDataType, string name, int? maxShingleSize, int? minShingleSize, bool? outputUnigrams, bool? outputUnigramsIfNoShingles, string tokenSeparator, string filterToken) : base(oDataType, name) + internal ShingleTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, int? maxShingleSize, int? minShingleSize, bool? outputUnigrams, bool? outputUnigramsIfNoShingles, string tokenSeparator, string filterToken) : base(oDataType, name, serializedAdditionalRawData) { MaxShingleSize = maxShingleSize; MinShingleSize = minShingleSize; @@ -42,6 +44,11 @@ internal ShingleTokenFilter(string oDataType, string name, int? maxShingleSize, ODataType = oDataType ?? "#Microsoft.Azure.Search.ShingleTokenFilter"; } + /// Initializes a new instance of for deserialization. + internal ShingleTokenFilter() + { + } + /// The maximum shingle size. Default and minimum value is 2. public int? MaxShingleSize { get; set; } /// The minimum shingle size. Default and minimum value is 2. Must be less than the value of maxShingleSize. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SimilarityAlgorithm.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SimilarityAlgorithm.Serialization.cs index e03a07a904ab..cce74b9336f8 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SimilarityAlgorithm.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SimilarityAlgorithm.Serialization.cs @@ -5,24 +5,70 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Indexes.Models { - public partial class SimilarityAlgorithm : IUtf8JsonSerializable + public partial class SimilarityAlgorithm : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SimilarityAlgorithm)} does not support writing '{format}' format."); + } + writer.WritePropertyName("@odata.type"u8); writer.WriteStringValue(ODataType); - writer.WriteEndObject(); + 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 + } + } } - internal static SimilarityAlgorithm DeserializeSimilarityAlgorithm(JsonElement element) + SimilarityAlgorithm 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(SimilarityAlgorithm)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSimilarityAlgorithm(document.RootElement, options); + } + + internal static SimilarityAlgorithm DeserializeSimilarityAlgorithm(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -31,13 +77,44 @@ internal static SimilarityAlgorithm DeserializeSimilarityAlgorithm(JsonElement e { switch (discriminator.GetString()) { - case "#Microsoft.Azure.Search.BM25Similarity": return BM25Similarity.DeserializeBM25Similarity(element); - case "#Microsoft.Azure.Search.ClassicSimilarity": return ClassicSimilarity.DeserializeClassicSimilarity(element); + case "#Microsoft.Azure.Search.BM25Similarity": return BM25Similarity.DeserializeBM25Similarity(element, options); + case "#Microsoft.Azure.Search.ClassicSimilarity": return ClassicSimilarity.DeserializeClassicSimilarity(element, options); } } - return UnknownSimilarity.DeserializeUnknownSimilarity(element); + return UnknownSimilarity.DeserializeUnknownSimilarity(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SimilarityAlgorithm)} does not support writing '{options.Format}' format."); + } + } + + SimilarityAlgorithm 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 DeserializeSimilarityAlgorithm(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SimilarityAlgorithm)} 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 SimilarityAlgorithm FromResponse(Response response) @@ -50,7 +127,7 @@ internal static SimilarityAlgorithm FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SimilarityAlgorithm.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SimilarityAlgorithm.cs index 3531bc270017..c8218cb0f219 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SimilarityAlgorithm.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SimilarityAlgorithm.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// @@ -14,11 +17,45 @@ namespace Azure.Search.Documents.Indexes.Models /// public partial class SimilarityAlgorithm { + /// + /// 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 . /// - internal SimilarityAlgorithm(string oDataType) + /// Keeps track of any properties unknown to the library. + internal SimilarityAlgorithm(string oDataType, IDictionary serializedAdditionalRawData) { ODataType = oDataType; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Gets or sets the o data type. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SingleVectorFieldResult.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SingleVectorFieldResult.Serialization.cs index 9f683d2227c5..7f7b6ab486cf 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SingleVectorFieldResult.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SingleVectorFieldResult.Serialization.cs @@ -5,20 +5,86 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class SingleVectorFieldResult + public partial class SingleVectorFieldResult : IUtf8JsonSerializable, IJsonModel { - internal static SingleVectorFieldResult DeserializeSingleVectorFieldResult(JsonElement element) + 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(SingleVectorFieldResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(SearchScore)) + { + writer.WritePropertyName("searchScore"u8); + writer.WriteNumberValue(SearchScore.Value); + } + if (options.Format != "W" && Optional.IsDefined(VectorSimilarity)) + { + writer.WritePropertyName("vectorSimilarity"u8); + writer.WriteNumberValue(VectorSimilarity.Value); + } + 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 + } + } + } + + SingleVectorFieldResult 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(SingleVectorFieldResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSingleVectorFieldResult(document.RootElement, options); + } + + internal static SingleVectorFieldResult DeserializeSingleVectorFieldResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } double? searchScore = default; double? vectorSimilarity = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("searchScore"u8)) @@ -39,10 +105,46 @@ internal static SingleVectorFieldResult DeserializeSingleVectorFieldResult(JsonE vectorSimilarity = property.Value.GetDouble(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SingleVectorFieldResult(searchScore, vectorSimilarity, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SingleVectorFieldResult)} does not support writing '{options.Format}' format."); } - return new SingleVectorFieldResult(searchScore, vectorSimilarity); } + SingleVectorFieldResult 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 DeserializeSingleVectorFieldResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SingleVectorFieldResult)} 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 SingleVectorFieldResult FromResponse(Response response) @@ -50,5 +152,13 @@ internal static SingleVectorFieldResult FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSingleVectorFieldResult(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/search/Azure.Search.Documents/src/Generated/Models/SingleVectorFieldResult.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SingleVectorFieldResult.cs index faf48b297de8..38ccfe2abbcb 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SingleVectorFieldResult.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SingleVectorFieldResult.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Models { /// A single vector field result. Both @search.score and vector similarity values are returned. Vector similarity is related to @search.score by an equation. public partial class SingleVectorFieldResult { + /// + /// 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 . internal SingleVectorFieldResult() { @@ -18,10 +53,12 @@ internal SingleVectorFieldResult() /// Initializes a new instance of . /// The @search.score value that is calculated from the vector similarity score. This is the score that's visible in a pure single-field single-vector query. /// The vector similarity score for this document. Note this is the canonical definition of similarity metric, not the 'distance' version. For example, cosine similarity instead of cosine distance. - internal SingleVectorFieldResult(double? searchScore, double? vectorSimilarity) + /// Keeps track of any properties unknown to the library. + internal SingleVectorFieldResult(double? searchScore, double? vectorSimilarity, IDictionary serializedAdditionalRawData) { SearchScore = searchScore; VectorSimilarity = vectorSimilarity; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The @search.score value that is calculated from the vector similarity score. This is the score that's visible in a pure single-field single-vector query. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SnowballTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SnowballTokenFilter.Serialization.cs index 429feab6ea78..9bb8c7074e60 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SnowballTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SnowballTokenFilter.Serialization.cs @@ -5,27 +5,56 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SnowballTokenFilter : IUtf8JsonSerializable + public partial class SnowballTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SnowballTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("language"u8); writer.WriteStringValue(Language.ToSerialString()); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static SnowballTokenFilter DeserializeSnowballTokenFilter(JsonElement element) + SnowballTokenFilter 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(SnowballTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSnowballTokenFilter(document.RootElement, options); + } + + internal static SnowballTokenFilter DeserializeSnowballTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -33,6 +62,8 @@ internal static SnowballTokenFilter DeserializeSnowballTokenFilter(JsonElement e SnowballTokenFilterLanguage language = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("language"u8)) @@ -50,10 +81,46 @@ internal static SnowballTokenFilter DeserializeSnowballTokenFilter(JsonElement e name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SnowballTokenFilter(odataType, name, serializedAdditionalRawData, language); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SnowballTokenFilter)} does not support writing '{options.Format}' format."); } - return new SnowballTokenFilter(odataType, name, language); } + SnowballTokenFilter 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 DeserializeSnowballTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SnowballTokenFilter)} 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 SnowballTokenFilter FromResponse(Response response) @@ -66,7 +133,7 @@ internal static SnowballTokenFilter DeserializeSnowballTokenFilter(JsonElement e internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SnowballTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SnowballTokenFilter.cs index bf7e59a8780d..f5a9ca281e63 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SnowballTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SnowballTokenFilter.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -27,13 +28,19 @@ public SnowballTokenFilter(string name, SnowballTokenFilterLanguage language) : /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The language to use. - internal SnowballTokenFilter(string oDataType, string name, SnowballTokenFilterLanguage language) : base(oDataType, name) + internal SnowballTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, SnowballTokenFilterLanguage language) : base(oDataType, name, serializedAdditionalRawData) { Language = language; ODataType = oDataType ?? "#Microsoft.Azure.Search.SnowballTokenFilter"; } + /// Initializes a new instance of for deserialization. + internal SnowballTokenFilter() + { + } + /// The language to use. public SnowballTokenFilterLanguage Language { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SoftDeleteColumnDeletionDetectionPolicy.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SoftDeleteColumnDeletionDetectionPolicy.Serialization.cs index 1e19e52ee2bf..41877e694289 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SoftDeleteColumnDeletionDetectionPolicy.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SoftDeleteColumnDeletionDetectionPolicy.Serialization.cs @@ -5,16 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SoftDeleteColumnDeletionDetectionPolicy : IUtf8JsonSerializable + public partial class SoftDeleteColumnDeletionDetectionPolicy : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SoftDeleteColumnDeletionDetectionPolicy)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(SoftDeleteColumnName)) { writer.WritePropertyName("softDeleteColumnName"u8); @@ -25,13 +45,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("softDeleteMarkerValue"u8); writer.WriteStringValue(SoftDeleteMarkerValue); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WriteEndObject(); } - internal static SoftDeleteColumnDeletionDetectionPolicy DeserializeSoftDeleteColumnDeletionDetectionPolicy(JsonElement element) + SoftDeleteColumnDeletionDetectionPolicy 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(SoftDeleteColumnDeletionDetectionPolicy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSoftDeleteColumnDeletionDetectionPolicy(document.RootElement, options); + } + + internal static SoftDeleteColumnDeletionDetectionPolicy DeserializeSoftDeleteColumnDeletionDetectionPolicy(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -39,6 +70,8 @@ internal static SoftDeleteColumnDeletionDetectionPolicy DeserializeSoftDeleteCol string softDeleteColumnName = default; string softDeleteMarkerValue = default; string odataType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("softDeleteColumnName"u8)) @@ -56,10 +89,46 @@ internal static SoftDeleteColumnDeletionDetectionPolicy DeserializeSoftDeleteCol odataType = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SoftDeleteColumnDeletionDetectionPolicy(odataType, serializedAdditionalRawData, softDeleteColumnName, softDeleteMarkerValue); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SoftDeleteColumnDeletionDetectionPolicy)} does not support writing '{options.Format}' format."); } - return new SoftDeleteColumnDeletionDetectionPolicy(odataType, softDeleteColumnName, softDeleteMarkerValue); } + SoftDeleteColumnDeletionDetectionPolicy 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 DeserializeSoftDeleteColumnDeletionDetectionPolicy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SoftDeleteColumnDeletionDetectionPolicy)} 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 SoftDeleteColumnDeletionDetectionPolicy FromResponse(Response response) @@ -72,7 +141,7 @@ internal static SoftDeleteColumnDeletionDetectionPolicy DeserializeSoftDeleteCol internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SoftDeleteColumnDeletionDetectionPolicy.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SoftDeleteColumnDeletionDetectionPolicy.cs index 365c25349dd2..d252fccb8bf2 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SoftDeleteColumnDeletionDetectionPolicy.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SoftDeleteColumnDeletionDetectionPolicy.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Defines a data deletion detection policy that implements a soft-deletion strategy. It determines whether an item should be deleted based on the value of a designated 'soft delete' column. @@ -18,9 +21,10 @@ public SoftDeleteColumnDeletionDetectionPolicy() /// Initializes a new instance of . /// A URI fragment specifying the type of data deletion detection policy. + /// Keeps track of any properties unknown to the library. /// The name of the column to use for soft-deletion detection. /// The marker value that identifies an item as deleted. - internal SoftDeleteColumnDeletionDetectionPolicy(string oDataType, string softDeleteColumnName, string softDeleteMarkerValue) : base(oDataType) + internal SoftDeleteColumnDeletionDetectionPolicy(string oDataType, IDictionary serializedAdditionalRawData, string softDeleteColumnName, string softDeleteMarkerValue) : base(oDataType, serializedAdditionalRawData) { SoftDeleteColumnName = softDeleteColumnName; SoftDeleteMarkerValue = softDeleteMarkerValue; diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SplitSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SplitSkill.Serialization.cs index 94e24fbd5571..f7bf4ea5d719 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SplitSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SplitSkill.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SplitSkill : IUtf8JsonSerializable + public partial class SplitSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SplitSkill)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(DefaultLanguageCode)) { if (DefaultLanguageCode != null) @@ -86,49 +105,31 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (AzureOpenAITokenizerParameters != null) { writer.WritePropertyName("azureOpenAITokenizerParameters"u8); - writer.WriteObjectValue(AzureOpenAITokenizerParameters); + writer.WriteObjectValue(AzureOpenAITokenizerParameters, options); } else { writer.WriteNull("azureOpenAITokenizerParameters"); } } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + SplitSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(SplitSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSplitSkill(document.RootElement, options); } - internal static SplitSkill DeserializeSplitSkill(JsonElement element) + internal static SplitSkill DeserializeSplitSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -146,6 +147,8 @@ internal static SplitSkill DeserializeSplitSkill(JsonElement element) string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("defaultLanguageCode"u8)) @@ -214,7 +217,7 @@ internal static SplitSkill DeserializeSplitSkill(JsonElement element) azureOpenAITokenizerParameters = null; continue; } - azureOpenAITokenizerParameters = AzureOpenAITokenizerParameters.DeserializeAzureOpenAITokenizerParameters(property.Value); + azureOpenAITokenizerParameters = AzureOpenAITokenizerParameters.DeserializeAzureOpenAITokenizerParameters(property.Value, options); continue; } if (property.NameEquals("@odata.type"u8)) @@ -242,7 +245,7 @@ internal static SplitSkill DeserializeSplitSkill(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -252,12 +255,17 @@ internal static SplitSkill DeserializeSplitSkill(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new SplitSkill( odataType, name, @@ -265,6 +273,7 @@ internal static SplitSkill DeserializeSplitSkill(JsonElement element) context, inputs, outputs, + serializedAdditionalRawData, defaultLanguageCode, textSplitMode, maximumPageLength, @@ -274,6 +283,37 @@ internal static SplitSkill DeserializeSplitSkill(JsonElement element) azureOpenAITokenizerParameters); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SplitSkill)} does not support writing '{options.Format}' format."); + } + } + + SplitSkill 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 DeserializeSplitSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SplitSkill)} 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 SplitSkill FromResponse(Response response) @@ -286,7 +326,7 @@ internal static SplitSkill DeserializeSplitSkill(JsonElement element) internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SplitSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SplitSkill.cs index 3661a7ba2a74..50ff50342677 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SplitSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SplitSkill.cs @@ -32,6 +32,7 @@ public SplitSkill(IEnumerable inputs, IEnumerable Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// A value indicating which language code to use. Default is `en`. /// A value indicating which split mode to perform. /// The desired maximum page length. Default is 10000. @@ -39,7 +40,7 @@ public SplitSkill(IEnumerable inputs, IEnumerable Only applicable when textSplitMode is set to 'pages'. If specified, the SplitSkill will discontinue splitting after processing the first 'maximumPagesToTake' pages, in order to improve performance when only a few initial pages are needed from each document. /// Only applies if textSplitMode is set to pages. There are two possible values. The choice of the values will decide the length (maximumPageLength and pageOverlapLength) measurement. The default is 'characters', which means the length will be measured by character. /// Only applies if the unit is set to azureOpenAITokens. If specified, the splitSkill will use these parameters when performing the tokenization. The parameters are a valid 'encoderModelName' and an optional 'allowedSpecialTokens' property. - internal SplitSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, SplitSkillLanguage? defaultLanguageCode, TextSplitMode? textSplitMode, int? maximumPageLength, int? pageOverlapLength, int? maximumPagesToTake, SplitSkillUnit? unit, AzureOpenAITokenizerParameters azureOpenAITokenizerParameters) : base(oDataType, name, description, context, inputs, outputs) + internal SplitSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, SplitSkillLanguage? defaultLanguageCode, TextSplitMode? textSplitMode, int? maximumPageLength, int? pageOverlapLength, int? maximumPagesToTake, SplitSkillUnit? unit, AzureOpenAITokenizerParameters azureOpenAITokenizerParameters) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { DefaultLanguageCode = defaultLanguageCode; TextSplitMode = textSplitMode; @@ -51,6 +52,11 @@ internal SplitSkill(string oDataType, string name, string description, string co ODataType = oDataType ?? "#Microsoft.Skills.Text.SplitSkill"; } + /// Initializes a new instance of for deserialization. + internal SplitSkill() + { + } + /// A value indicating which language code to use. Default is `en`. public SplitSkillLanguage? DefaultLanguageCode { get; set; } /// A value indicating which split mode to perform. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SqlIntegratedChangeTrackingPolicy.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SqlIntegratedChangeTrackingPolicy.Serialization.cs index 22d6f9cbc5a6..afe5ad428275 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SqlIntegratedChangeTrackingPolicy.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SqlIntegratedChangeTrackingPolicy.Serialization.cs @@ -5,28 +5,61 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SqlIntegratedChangeTrackingPolicy : IUtf8JsonSerializable + public partial class SqlIntegratedChangeTrackingPolicy : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); + JsonModelWriteCore(writer, options); writer.WriteEndObject(); } - internal static SqlIntegratedChangeTrackingPolicy DeserializeSqlIntegratedChangeTrackingPolicy(JsonElement element) + /// 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(SqlIntegratedChangeTrackingPolicy)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + SqlIntegratedChangeTrackingPolicy 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(SqlIntegratedChangeTrackingPolicy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSqlIntegratedChangeTrackingPolicy(document.RootElement, options); + } + + internal static SqlIntegratedChangeTrackingPolicy DeserializeSqlIntegratedChangeTrackingPolicy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string odataType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@odata.type"u8)) @@ -34,10 +67,46 @@ internal static SqlIntegratedChangeTrackingPolicy DeserializeSqlIntegratedChange odataType = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SqlIntegratedChangeTrackingPolicy(odataType, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SqlIntegratedChangeTrackingPolicy)} does not support writing '{options.Format}' format."); } - return new SqlIntegratedChangeTrackingPolicy(odataType); } + SqlIntegratedChangeTrackingPolicy 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 DeserializeSqlIntegratedChangeTrackingPolicy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SqlIntegratedChangeTrackingPolicy)} 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 SqlIntegratedChangeTrackingPolicy FromResponse(Response response) @@ -50,7 +119,7 @@ internal static SqlIntegratedChangeTrackingPolicy DeserializeSqlIntegratedChange internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SqlIntegratedChangeTrackingPolicy.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SqlIntegratedChangeTrackingPolicy.cs index 211f7198894b..45a3024399a9 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SqlIntegratedChangeTrackingPolicy.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SqlIntegratedChangeTrackingPolicy.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Indexes.Models { /// Defines a data change detection policy that captures changes using the Integrated Change Tracking feature of Azure SQL Database. @@ -18,7 +21,8 @@ public SqlIntegratedChangeTrackingPolicy() /// Initializes a new instance of . /// A URI fragment specifying the type of data change detection policy. - internal SqlIntegratedChangeTrackingPolicy(string oDataType) : base(oDataType) + /// Keeps track of any properties unknown to the library. + internal SqlIntegratedChangeTrackingPolicy(string oDataType, IDictionary serializedAdditionalRawData) : base(oDataType, serializedAdditionalRawData) { ODataType = oDataType ?? "#Microsoft.Azure.Search.SqlIntegratedChangeTrackingPolicy"; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/StemmerOverrideTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/StemmerOverrideTokenFilter.Serialization.cs index 8c02af706bcb..b81ebd06ba12 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/StemmerOverrideTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/StemmerOverrideTokenFilter.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class StemmerOverrideTokenFilter : IUtf8JsonSerializable + public partial class StemmerOverrideTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(StemmerOverrideTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("rules"u8); writer.WriteStartArray(); foreach (var item in Rules) @@ -23,15 +42,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStringValue(item); } writer.WriteEndArray(); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static StemmerOverrideTokenFilter DeserializeStemmerOverrideTokenFilter(JsonElement element) + StemmerOverrideTokenFilter 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(StemmerOverrideTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStemmerOverrideTokenFilter(document.RootElement, options); + } + + internal static StemmerOverrideTokenFilter DeserializeStemmerOverrideTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -39,6 +67,8 @@ internal static StemmerOverrideTokenFilter DeserializeStemmerOverrideTokenFilter IList rules = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("rules"u8)) @@ -61,10 +91,46 @@ internal static StemmerOverrideTokenFilter DeserializeStemmerOverrideTokenFilter name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new StemmerOverrideTokenFilter(odataType, name, serializedAdditionalRawData, rules); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(StemmerOverrideTokenFilter)} does not support writing '{options.Format}' format."); + } + } + + StemmerOverrideTokenFilter 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 DeserializeStemmerOverrideTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StemmerOverrideTokenFilter)} does not support reading '{options.Format}' format."); } - return new StemmerOverrideTokenFilter(odataType, name, rules); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new StemmerOverrideTokenFilter FromResponse(Response response) @@ -77,7 +143,7 @@ internal static StemmerOverrideTokenFilter DeserializeStemmerOverrideTokenFilter internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/StemmerOverrideTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/StemmerOverrideTokenFilter.cs index 0422ba0332f7..4d8555e62266 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/StemmerOverrideTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/StemmerOverrideTokenFilter.cs @@ -30,11 +30,17 @@ public StemmerOverrideTokenFilter(string name, IEnumerable rules) : base /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// A list of stemming rules in the following format: "word => stem", for example: "ran => run". - internal StemmerOverrideTokenFilter(string oDataType, string name, IList rules) : base(oDataType, name) + internal StemmerOverrideTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, IList rules) : base(oDataType, name, serializedAdditionalRawData) { Rules = rules; ODataType = oDataType ?? "#Microsoft.Azure.Search.StemmerOverrideTokenFilter"; } + + /// Initializes a new instance of for deserialization. + internal StemmerOverrideTokenFilter() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/StemmerTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/StemmerTokenFilter.Serialization.cs index 72d557901f4c..4ec087b8f6bc 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/StemmerTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/StemmerTokenFilter.Serialization.cs @@ -5,27 +5,56 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class StemmerTokenFilter : IUtf8JsonSerializable + public partial class StemmerTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(StemmerTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("language"u8); writer.WriteStringValue(Language.ToSerialString()); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static StemmerTokenFilter DeserializeStemmerTokenFilter(JsonElement element) + StemmerTokenFilter 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(StemmerTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStemmerTokenFilter(document.RootElement, options); + } + + internal static StemmerTokenFilter DeserializeStemmerTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -33,6 +62,8 @@ internal static StemmerTokenFilter DeserializeStemmerTokenFilter(JsonElement ele StemmerTokenFilterLanguage language = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("language"u8)) @@ -50,10 +81,46 @@ internal static StemmerTokenFilter DeserializeStemmerTokenFilter(JsonElement ele name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new StemmerTokenFilter(odataType, name, serializedAdditionalRawData, language); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(StemmerTokenFilter)} does not support writing '{options.Format}' format."); } - return new StemmerTokenFilter(odataType, name, language); } + StemmerTokenFilter 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 DeserializeStemmerTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StemmerTokenFilter)} 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 StemmerTokenFilter FromResponse(Response response) @@ -66,7 +133,7 @@ internal static StemmerTokenFilter DeserializeStemmerTokenFilter(JsonElement ele internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/StemmerTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/StemmerTokenFilter.cs index 4115bd3d5f9f..c6ece5b7d254 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/StemmerTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/StemmerTokenFilter.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -27,13 +28,19 @@ public StemmerTokenFilter(string name, StemmerTokenFilterLanguage language) : ba /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The language to use. - internal StemmerTokenFilter(string oDataType, string name, StemmerTokenFilterLanguage language) : base(oDataType, name) + internal StemmerTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, StemmerTokenFilterLanguage language) : base(oDataType, name, serializedAdditionalRawData) { Language = language; ODataType = oDataType ?? "#Microsoft.Azure.Search.StemmerTokenFilter"; } + /// Initializes a new instance of for deserialization. + internal StemmerTokenFilter() + { + } + /// The language to use. public StemmerTokenFilterLanguage Language { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/StopAnalyzer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/StopAnalyzer.Serialization.cs index 21bd8d0f6d9f..b4010841e967 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/StopAnalyzer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/StopAnalyzer.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class StopAnalyzer : IUtf8JsonSerializable + public partial class StopAnalyzer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(StopAnalyzer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsCollectionDefined(Stopwords)) { writer.WritePropertyName("stopwords"u8); @@ -26,15 +45,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WriteEndArray(); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static StopAnalyzer DeserializeStopAnalyzer(JsonElement element) + StopAnalyzer 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(StopAnalyzer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStopAnalyzer(document.RootElement, options); + } + + internal static StopAnalyzer DeserializeStopAnalyzer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -42,6 +70,8 @@ internal static StopAnalyzer DeserializeStopAnalyzer(JsonElement element) IList stopwords = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("stopwords"u8)) @@ -68,10 +98,46 @@ internal static StopAnalyzer DeserializeStopAnalyzer(JsonElement element) name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new StopAnalyzer(odataType, name, serializedAdditionalRawData, stopwords ?? new ChangeTrackingList()); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(StopAnalyzer)} does not support writing '{options.Format}' format."); + } + } + + StopAnalyzer 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 DeserializeStopAnalyzer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StopAnalyzer)} does not support reading '{options.Format}' format."); } - return new StopAnalyzer(odataType, name, stopwords ?? new ChangeTrackingList()); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new StopAnalyzer FromResponse(Response response) @@ -84,7 +150,7 @@ internal static StopAnalyzer DeserializeStopAnalyzer(JsonElement element) internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/StopAnalyzer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/StopAnalyzer.cs index 5b8283254e8d..ae8d0ab20b7e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/StopAnalyzer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/StopAnalyzer.cs @@ -27,11 +27,17 @@ public StopAnalyzer(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of analyzer. /// The name of the analyzer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// A list of stopwords. - internal StopAnalyzer(string oDataType, string name, IList stopwords) : base(oDataType, name) + internal StopAnalyzer(string oDataType, string name, IDictionary serializedAdditionalRawData, IList stopwords) : base(oDataType, name, serializedAdditionalRawData) { Stopwords = stopwords; ODataType = oDataType ?? "#Microsoft.Azure.Search.StopAnalyzer"; } + + /// Initializes a new instance of for deserialization. + internal StopAnalyzer() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/StopwordsTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/StopwordsTokenFilter.Serialization.cs index 8860e97e8e8b..ea514803b1d2 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/StopwordsTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/StopwordsTokenFilter.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class StopwordsTokenFilter : IUtf8JsonSerializable + public partial class StopwordsTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(StopwordsTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsCollectionDefined(Stopwords)) { writer.WritePropertyName("stopwords"u8); @@ -41,15 +60,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("removeTrailing"u8); writer.WriteBooleanValue(RemoveTrailingStopWords.Value); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static StopwordsTokenFilter DeserializeStopwordsTokenFilter(JsonElement element) + StopwordsTokenFilter 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(StopwordsTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStopwordsTokenFilter(document.RootElement, options); + } + + internal static StopwordsTokenFilter DeserializeStopwordsTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -60,6 +88,8 @@ internal static StopwordsTokenFilter DeserializeStopwordsTokenFilter(JsonElement bool? removeTrailing = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("stopwords"u8)) @@ -113,16 +143,53 @@ internal static StopwordsTokenFilter DeserializeStopwordsTokenFilter(JsonElement name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new StopwordsTokenFilter( odataType, name, + serializedAdditionalRawData, stopwords ?? new ChangeTrackingList(), stopwordsList, ignoreCase, removeTrailing); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(StopwordsTokenFilter)} does not support writing '{options.Format}' format."); + } + } + + StopwordsTokenFilter 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 DeserializeStopwordsTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StopwordsTokenFilter)} 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 StopwordsTokenFilter FromResponse(Response response) @@ -135,7 +202,7 @@ internal static StopwordsTokenFilter DeserializeStopwordsTokenFilter(JsonElement internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/StopwordsTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/StopwordsTokenFilter.cs index 8693c1506cf5..ff7eb212bef7 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/StopwordsTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/StopwordsTokenFilter.cs @@ -27,11 +27,12 @@ public StopwordsTokenFilter(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The list of stopwords. This property and the stopwords list property cannot both be set. /// A predefined list of stopwords to use. This property and the stopwords property cannot both be set. Default is English. /// A value indicating whether to ignore case. If true, all words are converted to lower case first. Default is false. /// A value indicating whether to ignore the last search term if it's a stop word. Default is true. - internal StopwordsTokenFilter(string oDataType, string name, IList stopwords, StopwordsList? stopwordsList, bool? ignoreCase, bool? removeTrailingStopWords) : base(oDataType, name) + internal StopwordsTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, IList stopwords, StopwordsList? stopwordsList, bool? ignoreCase, bool? removeTrailingStopWords) : base(oDataType, name, serializedAdditionalRawData) { Stopwords = stopwords; StopwordsList = stopwordsList; @@ -39,6 +40,11 @@ internal StopwordsTokenFilter(string oDataType, string name, IList stopw RemoveTrailingStopWords = removeTrailingStopWords; ODataType = oDataType ?? "#Microsoft.Azure.Search.StopwordsTokenFilter"; } + + /// Initializes a new instance of for deserialization. + internal StopwordsTokenFilter() + { + } /// A predefined list of stopwords to use. This property and the stopwords property cannot both be set. Default is English. public StopwordsList? StopwordsList { get; set; } /// A value indicating whether to ignore case. If true, all words are converted to lower case first. Default is false. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestDocumentsResult.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestDocumentsResult.Serialization.cs index 85d2f559d9db..f731a7540700 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestDocumentsResult.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestDocumentsResult.Serialization.cs @@ -5,21 +5,91 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - internal partial class SuggestDocumentsResult + internal partial class SuggestDocumentsResult : IUtf8JsonSerializable, IJsonModel { - internal static SuggestDocumentsResult DeserializeSuggestDocumentsResult(JsonElement element) + 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(SuggestDocumentsResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Results) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(Coverage)) + { + writer.WritePropertyName("@search.coverage"u8); + writer.WriteNumberValue(Coverage.Value); + } + 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 + } + } + } + + SuggestDocumentsResult 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(SuggestDocumentsResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSuggestDocumentsResult(document.RootElement, options); + } + + internal static SuggestDocumentsResult DeserializeSuggestDocumentsResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } IReadOnlyList value = default; double? searchCoverage = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value"u8)) @@ -27,7 +97,7 @@ internal static SuggestDocumentsResult DeserializeSuggestDocumentsResult(JsonEle List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(SuggestResult.DeserializeSuggestResult(item)); + array.Add(SuggestResult.DeserializeSuggestResult(item, options)); } value = array; continue; @@ -41,10 +111,46 @@ internal static SuggestDocumentsResult DeserializeSuggestDocumentsResult(JsonEle searchCoverage = property.Value.GetDouble(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SuggestDocumentsResult(value, searchCoverage, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SuggestDocumentsResult)} does not support writing '{options.Format}' format."); } - return new SuggestDocumentsResult(value, searchCoverage); } + SuggestDocumentsResult 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 DeserializeSuggestDocumentsResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SuggestDocumentsResult)} 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 SuggestDocumentsResult FromResponse(Response response) @@ -52,5 +158,13 @@ internal static SuggestDocumentsResult FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSuggestDocumentsResult(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/search/Azure.Search.Documents/src/Generated/Models/SuggestDocumentsResult.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestDocumentsResult.cs index eb23565105f0..69ec39b9bc02 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestDocumentsResult.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestDocumentsResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using System.Linq; @@ -13,6 +14,38 @@ namespace Azure.Search.Documents.Models /// Response containing suggestion query results from an index. internal partial class SuggestDocumentsResult { + /// + /// 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 . /// The sequence of results returned by the query. internal SuggestDocumentsResult(IEnumerable results) @@ -23,10 +56,17 @@ internal SuggestDocumentsResult(IEnumerable results) /// Initializes a new instance of . /// The sequence of results returned by the query. /// A value indicating the percentage of the index that was included in the query, or null if minimumCoverage was not set in the request. - internal SuggestDocumentsResult(IReadOnlyList results, double? coverage) + /// Keeps track of any properties unknown to the library. + internal SuggestDocumentsResult(IReadOnlyList results, double? coverage, IDictionary serializedAdditionalRawData) { Results = results; Coverage = coverage; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SuggestDocumentsResult() + { } /// The sequence of results returned by the query. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestOptions.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestOptions.Serialization.cs index 719b7feb055c..3db70e9f452e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestOptions.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestOptions.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents { - public partial class SuggestOptions : IUtf8JsonSerializable + public partial class SuggestOptions : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SuggestOptions)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Filter)) { writer.WritePropertyName("filter"u8); @@ -64,14 +83,190 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("top"u8); writer.WriteNumberValue(Size.Value); } - writer.WriteEndObject(); + 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 + } + } + } + + SuggestOptions 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(SuggestOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSuggestOptions(document.RootElement, options); + } + + internal static SuggestOptions DeserializeSuggestOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string filter = default; + bool? fuzzy = default; + string highlightPostTag = default; + string highlightPreTag = default; + double? minimumCoverage = default; + string orderby = default; + string search = default; + string searchFields = default; + string select = default; + string suggesterName = default; + int? top = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("filter"u8)) + { + filter = property.Value.GetString(); + continue; + } + if (property.NameEquals("fuzzy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fuzzy = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("highlightPostTag"u8)) + { + highlightPostTag = property.Value.GetString(); + continue; + } + if (property.NameEquals("highlightPreTag"u8)) + { + highlightPreTag = property.Value.GetString(); + continue; + } + if (property.NameEquals("minimumCoverage"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + minimumCoverage = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("orderby"u8)) + { + orderby = property.Value.GetString(); + continue; + } + if (property.NameEquals("search"u8)) + { + search = property.Value.GetString(); + continue; + } + if (property.NameEquals("searchFields"u8)) + { + searchFields = property.Value.GetString(); + continue; + } + if (property.NameEquals("select"u8)) + { + select = property.Value.GetString(); + continue; + } + if (property.NameEquals("suggesterName"u8)) + { + suggesterName = property.Value.GetString(); + continue; + } + if (property.NameEquals("top"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + top = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SuggestOptions( + filter, + fuzzy, + highlightPostTag, + highlightPreTag, + minimumCoverage, + orderby, + search, + searchFields, + select, + suggesterName, + top, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SuggestOptions)} does not support writing '{options.Format}' format."); + } + } + + SuggestOptions 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 DeserializeSuggestOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SuggestOptions)} 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 SuggestOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSuggestOptions(document.RootElement); } /// Convert into a . internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestOptions.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestOptions.cs index e2c12b86e235..827bd8a20b02 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestOptions.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestOptions.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents { /// Parameters for filtering, sorting, fuzzy matching, and other suggestions query behaviors. public partial class SuggestOptions { + /// + /// 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 . /// An OData expression that filters the documents considered for suggestions. /// A value indicating whether to use fuzzy matching for the suggestion query. Default is false. When set to true, the query will find suggestions even if there's a substituted or missing character in the search text. While this provides a better experience in some scenarios, it comes at a performance cost as fuzzy suggestion searches are slower and consume more resources. @@ -24,7 +57,8 @@ public partial class SuggestOptions /// The comma-separated list of fields to retrieve. If unspecified, only the key field will be included in the results. /// The name of the suggester as specified in the suggesters collection that's part of the index definition. /// The number of suggestions to retrieve. This must be a value between 1 and 100. The default is 5. - internal SuggestOptions(string filter, bool? useFuzzyMatching, string highlightPostTag, string highlightPreTag, double? minimumCoverage, string orderByRaw, string searchText, string searchFieldsRaw, string selectRaw, string suggesterName, int? size) + /// Keeps track of any properties unknown to the library. + internal SuggestOptions(string filter, bool? useFuzzyMatching, string highlightPostTag, string highlightPreTag, double? minimumCoverage, string orderByRaw, string searchText, string searchFieldsRaw, string selectRaw, string suggesterName, int? size, IDictionary serializedAdditionalRawData) { Filter = filter; UseFuzzyMatching = useFuzzyMatching; @@ -37,6 +71,7 @@ internal SuggestOptions(string filter, bool? useFuzzyMatching, string highlightP SelectRaw = selectRaw; SuggesterName = suggesterName; Size = size; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// A value indicating whether to use fuzzy matching for the suggestion query. Default is false. When set to true, the query will find suggestions even if there's a substituted or missing character in the search text. While this provides a better experience in some scenarios, it comes at a performance cost as fuzzy suggestion searches are slower and consume more resources. public bool? UseFuzzyMatching { get; set; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestResult.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestResult.Serialization.cs index f106b4154e29..cd909ca6fe2d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestResult.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestResult.Serialization.cs @@ -5,15 +5,63 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - internal partial class SuggestResult + internal partial class SuggestResult : IUtf8JsonSerializable, IJsonModel { - internal static SuggestResult DeserializeSuggestResult(JsonElement element) + 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(SuggestResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("@search.text"u8); + writer.WriteStringValue(Text); + } + foreach (var item in AdditionalProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + } + + SuggestResult 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(SuggestResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSuggestResult(document.RootElement, options); + } + + internal static SuggestResult DeserializeSuggestResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -34,6 +82,37 @@ internal static SuggestResult DeserializeSuggestResult(JsonElement element) return new SuggestResult(searchText, additionalProperties); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SuggestResult)} does not support writing '{options.Format}' format."); + } + } + + SuggestResult 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 DeserializeSuggestResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SuggestResult)} 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 SuggestResult FromResponse(Response response) @@ -41,5 +120,13 @@ internal static SuggestResult FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSuggestResult(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/search/Azure.Search.Documents/src/Generated/Models/SuggestResult.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestResult.cs index c4023257c183..e2a57f706a28 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestResult.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SuggestResult.cs @@ -29,6 +29,11 @@ internal SuggestResult(string text, IReadOnlyDictionary addition AdditionalProperties = additionalProperties; } + /// Initializes a new instance of for deserialization. + internal SuggestResult() + { + } + /// The text of the suggestion result. public string Text { get; } /// Additional Properties. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SynonymMap.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SynonymMap.Serialization.cs index 51f87de02fe1..9c686fd169eb 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SynonymMap.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SynonymMap.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SynonymMap : IUtf8JsonSerializable + public partial class SynonymMap : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SynonymMap)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); writer.WritePropertyName("format"u8); @@ -26,7 +45,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (EncryptionKey != null) { writer.WritePropertyName("encryptionKey"u8); - writer.WriteObjectValue(EncryptionKey); + writer.WriteObjectValue(EncryptionKey, options); } else { @@ -38,11 +57,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("@odata.etag"u8); writer.WriteStringValue(_etag); } - writer.WriteEndObject(); + 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 + } + } } - internal static SynonymMap DeserializeSynonymMap(JsonElement element) + SynonymMap 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(SynonymMap)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSynonymMap(document.RootElement, options); + } + + internal static SynonymMap DeserializeSynonymMap(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -52,6 +99,8 @@ internal static SynonymMap DeserializeSynonymMap(JsonElement element) string synonyms = default; SearchResourceEncryptionKey encryptionKey = default; string odataEtag = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -76,7 +125,7 @@ internal static SynonymMap DeserializeSynonymMap(JsonElement element) encryptionKey = null; continue; } - encryptionKey = SearchResourceEncryptionKey.DeserializeSearchResourceEncryptionKey(property.Value); + encryptionKey = SearchResourceEncryptionKey.DeserializeSearchResourceEncryptionKey(property.Value, options); continue; } if (property.NameEquals("@odata.etag"u8)) @@ -84,10 +133,52 @@ internal static SynonymMap DeserializeSynonymMap(JsonElement element) odataEtag = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SynonymMap( + name, + format, + synonyms, + encryptionKey, + odataEtag, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SynonymMap)} does not support writing '{options.Format}' format."); } - return new SynonymMap(name, format, synonyms, encryptionKey, odataEtag); } + SynonymMap 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 DeserializeSynonymMap(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SynonymMap)} 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 SynonymMap FromResponse(Response response) @@ -100,7 +191,7 @@ internal static SynonymMap FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SynonymMap.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SynonymMap.cs index 4f6cd587015d..2fa0c33d31d9 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SynonymMap.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SynonymMap.cs @@ -6,25 +6,65 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Represents a synonym map definition. public partial class SynonymMap { + /// + /// 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 . /// The name of the synonym map. /// The format of the synonym map. Only the 'solr' format is currently supported. /// A series of synonym rules in the specified synonym map format. The rules must be separated by newlines. /// A description of an encryption key that you create in Azure Key Vault. This key is used to provide an additional level of encryption-at-rest for your data when you want full assurance that no one, not even Microsoft, can decrypt your data. Once you have encrypted your data, it will always remain encrypted. The search service will ignore attempts to set this property to null. You can change this property as needed if you want to rotate your encryption key; Your data will be unaffected. Encryption with customer-managed keys is not available for free search services, and is only available for paid services created on or after January 1, 2019. /// The ETag of the synonym map. - internal SynonymMap(string name, string format, string synonyms, SearchResourceEncryptionKey encryptionKey, string etag) + /// Keeps track of any properties unknown to the library. + internal SynonymMap(string name, string format, string synonyms, SearchResourceEncryptionKey encryptionKey, string etag, IDictionary serializedAdditionalRawData) { Name = name; Format = format; Synonyms = synonyms; EncryptionKey = encryptionKey; _etag = etag; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SynonymMap() + { } /// The name of the synonym map. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SynonymTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SynonymTokenFilter.Serialization.cs index 9bd6d76229c9..ca4d30f1736b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SynonymTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SynonymTokenFilter.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class SynonymTokenFilter : IUtf8JsonSerializable + public partial class SynonymTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(SynonymTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("synonyms"u8); writer.WriteStartArray(); foreach (var item in Synonyms) @@ -33,15 +52,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("expand"u8); writer.WriteBooleanValue(Expand.Value); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static SynonymTokenFilter DeserializeSynonymTokenFilter(JsonElement element) + SynonymTokenFilter 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(SynonymTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSynonymTokenFilter(document.RootElement, options); + } + + internal static SynonymTokenFilter DeserializeSynonymTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -51,6 +79,8 @@ internal static SynonymTokenFilter DeserializeSynonymTokenFilter(JsonElement ele bool? expand = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("synonyms"u8)) @@ -91,10 +121,52 @@ internal static SynonymTokenFilter DeserializeSynonymTokenFilter(JsonElement ele name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SynonymTokenFilter( + odataType, + name, + serializedAdditionalRawData, + synonyms, + ignoreCase, + expand); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SynonymTokenFilter)} does not support writing '{options.Format}' format."); + } + } + + SynonymTokenFilter 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 DeserializeSynonymTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SynonymTokenFilter)} does not support reading '{options.Format}' format."); } - return new SynonymTokenFilter(odataType, name, synonyms, ignoreCase, expand); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new SynonymTokenFilter FromResponse(Response response) @@ -107,7 +179,7 @@ internal static SynonymTokenFilter DeserializeSynonymTokenFilter(JsonElement ele internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SynonymTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SynonymTokenFilter.cs index d708bd05d2e9..2d0c338ee56e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SynonymTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SynonymTokenFilter.cs @@ -30,16 +30,22 @@ public SynonymTokenFilter(string name, IEnumerable synonyms) : base(name /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// A list of synonyms in following one of two formats: 1. incredible, unbelievable, fabulous => amazing - all terms on the left side of => symbol will be replaced with all terms on its right side; 2. incredible, unbelievable, fabulous, amazing - comma separated list of equivalent words. Set the expand option to change how this list is interpreted. /// A value indicating whether to case-fold input for matching. Default is false. /// A value indicating whether all words in the list of synonyms (if => notation is not used) will map to one another. If true, all words in the list of synonyms (if => notation is not used) will map to one another. The following list: incredible, unbelievable, fabulous, amazing is equivalent to: incredible, unbelievable, fabulous, amazing => incredible, unbelievable, fabulous, amazing. If false, the following list: incredible, unbelievable, fabulous, amazing will be equivalent to: incredible, unbelievable, fabulous, amazing => incredible. Default is true. - internal SynonymTokenFilter(string oDataType, string name, IList synonyms, bool? ignoreCase, bool? expand) : base(oDataType, name) + internal SynonymTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, IList synonyms, bool? ignoreCase, bool? expand) : base(oDataType, name, serializedAdditionalRawData) { Synonyms = synonyms; IgnoreCase = ignoreCase; Expand = expand; ODataType = oDataType ?? "#Microsoft.Azure.Search.SynonymTokenFilter"; } + + /// Initializes a new instance of for deserialization. + internal SynonymTokenFilter() + { + } /// A value indicating whether to case-fold input for matching. Default is false. public bool? IgnoreCase { get; set; } /// A value indicating whether all words in the list of synonyms (if => notation is not used) will map to one another. If true, all words in the list of synonyms (if => notation is not used) will map to one another. The following list: incredible, unbelievable, fabulous, amazing is equivalent to: incredible, unbelievable, fabulous, amazing => incredible, unbelievable, fabulous, amazing. If false, the following list: incredible, unbelievable, fabulous, amazing will be equivalent to: incredible, unbelievable, fabulous, amazing => incredible. Default is true. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/TagScoringFunction.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/TagScoringFunction.Serialization.cs index bb5917b874ef..fb5d440db584 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/TagScoringFunction.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/TagScoringFunction.Serialization.cs @@ -5,34 +5,56 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class TagScoringFunction : IUtf8JsonSerializable + public partial class TagScoringFunction : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(TagScoringFunction)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("tag"u8); - writer.WriteObjectValue(Parameters); - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - writer.WritePropertyName("fieldName"u8); - writer.WriteStringValue(FieldName); - writer.WritePropertyName("boost"u8); - writer.WriteNumberValue(Boost); - if (Optional.IsDefined(Interpolation)) + writer.WriteObjectValue(Parameters, options); + } + + TagScoringFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WritePropertyName("interpolation"u8); - writer.WriteStringValue(Interpolation.Value.ToSerialString()); + throw new FormatException($"The model {nameof(TagScoringFunction)} does not support reading '{format}' format."); } - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTagScoringFunction(document.RootElement, options); } - internal static TagScoringFunction DeserializeTagScoringFunction(JsonElement element) + internal static TagScoringFunction DeserializeTagScoringFunction(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -42,11 +64,13 @@ internal static TagScoringFunction DeserializeTagScoringFunction(JsonElement ele string fieldName = default; double boost = default; ScoringFunctionInterpolation? interpolation = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("tag"u8)) { - tag = TagScoringParameters.DeserializeTagScoringParameters(property.Value); + tag = TagScoringParameters.DeserializeTagScoringParameters(property.Value, options); continue; } if (property.NameEquals("type"u8)) @@ -73,10 +97,52 @@ internal static TagScoringFunction DeserializeTagScoringFunction(JsonElement ele interpolation = property.Value.GetString().ToScoringFunctionInterpolation(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new TagScoringFunction(type, fieldName, boost, interpolation, tag); + serializedAdditionalRawData = rawDataDictionary; + return new TagScoringFunction( + type, + fieldName, + boost, + interpolation, + serializedAdditionalRawData, + tag); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(TagScoringFunction)} does not support writing '{options.Format}' format."); + } + } + + TagScoringFunction 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 DeserializeTagScoringFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TagScoringFunction)} 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 TagScoringFunction FromResponse(Response response) @@ -89,7 +155,7 @@ internal static TagScoringFunction DeserializeTagScoringFunction(JsonElement ele internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/TagScoringFunction.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/TagScoringFunction.cs index 8fbada5b23dd..55efd7945a25 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/TagScoringFunction.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/TagScoringFunction.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -17,13 +18,19 @@ public partial class TagScoringFunction : ScoringFunction /// The name of the field used as input to the scoring function. /// A multiplier for the raw score. Must be a positive number not equal to 1.0. /// A value indicating how boosting will be interpolated across document scores; defaults to "Linear". + /// Keeps track of any properties unknown to the library. /// Parameter values for the tag scoring function. - internal TagScoringFunction(string type, string fieldName, double boost, ScoringFunctionInterpolation? interpolation, TagScoringParameters parameters) : base(type, fieldName, boost, interpolation) + internal TagScoringFunction(string type, string fieldName, double boost, ScoringFunctionInterpolation? interpolation, IDictionary serializedAdditionalRawData, TagScoringParameters parameters) : base(type, fieldName, boost, interpolation, serializedAdditionalRawData) { Parameters = parameters; Type = type ?? "tag"; } + /// Initializes a new instance of for deserialization. + internal TagScoringFunction() + { + } + /// Parameter values for the tag scoring function. public TagScoringParameters Parameters { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/TagScoringParameters.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/TagScoringParameters.Serialization.cs index fd3fa1634069..81fd3a1a8773 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/TagScoringParameters.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/TagScoringParameters.Serialization.cs @@ -5,28 +5,77 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class TagScoringParameters : IUtf8JsonSerializable + public partial class TagScoringParameters : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(TagScoringParameters)} does not support writing '{format}' format."); + } + writer.WritePropertyName("tagsParameter"u8); writer.WriteStringValue(TagsParameter); - writer.WriteEndObject(); + 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 + } + } } - internal static TagScoringParameters DeserializeTagScoringParameters(JsonElement element) + TagScoringParameters 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(TagScoringParameters)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTagScoringParameters(document.RootElement, options); + } + + internal static TagScoringParameters DeserializeTagScoringParameters(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string tagsParameter = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("tagsParameter"u8)) @@ -34,10 +83,46 @@ internal static TagScoringParameters DeserializeTagScoringParameters(JsonElement tagsParameter = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new TagScoringParameters(tagsParameter); + serializedAdditionalRawData = rawDataDictionary; + return new TagScoringParameters(tagsParameter, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(TagScoringParameters)} does not support writing '{options.Format}' format."); + } + } + + TagScoringParameters 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 DeserializeTagScoringParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TagScoringParameters)} 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 TagScoringParameters FromResponse(Response response) @@ -50,7 +135,7 @@ internal static TagScoringParameters FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/TagScoringParameters.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/TagScoringParameters.cs index d6c2df0168d7..7ed415f42a42 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/TagScoringParameters.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/TagScoringParameters.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Provides parameter values to a tag scoring function. public partial class TagScoringParameters { + /// + /// 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 . /// The name of the parameter passed in search queries to specify the list of tags to compare against the target field. /// is null. @@ -22,6 +55,20 @@ public TagScoringParameters(string tagsParameter) TagsParameter = tagsParameter; } + /// Initializes a new instance of . + /// The name of the parameter passed in search queries to specify the list of tags to compare against the target field. + /// Keeps track of any properties unknown to the library. + internal TagScoringParameters(string tagsParameter, IDictionary serializedAdditionalRawData) + { + TagsParameter = tagsParameter; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TagScoringParameters() + { + } + /// The name of the parameter passed in search queries to specify the list of tags to compare against the target field. public string TagsParameter { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/TextResult.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/TextResult.Serialization.cs index e367eaec9f0a..852b17451c05 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/TextResult.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/TextResult.Serialization.cs @@ -5,19 +5,80 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class TextResult + public partial class TextResult : IUtf8JsonSerializable, IJsonModel { - internal static TextResult DeserializeTextResult(JsonElement element) + 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(TextResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(SearchScore)) + { + writer.WritePropertyName("searchScore"u8); + writer.WriteNumberValue(SearchScore.Value); + } + 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 + } + } + } + + TextResult 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(TextResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTextResult(document.RootElement, options); + } + + internal static TextResult DeserializeTextResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } double? searchScore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("searchScore"u8)) @@ -29,10 +90,46 @@ internal static TextResult DeserializeTextResult(JsonElement element) searchScore = property.Value.GetDouble(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TextResult(searchScore, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(TextResult)} does not support writing '{options.Format}' format."); + } + } + + TextResult 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 DeserializeTextResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TextResult)} does not support reading '{options.Format}' format."); } - return new TextResult(searchScore); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static TextResult FromResponse(Response response) @@ -40,5 +137,13 @@ internal static TextResult FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTextResult(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/search/Azure.Search.Documents/src/Generated/Models/TextResult.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/TextResult.cs index 10764991dd41..9dd31c3f3a4f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/TextResult.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/TextResult.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Models { /// The BM25 or Classic score for the text portion of the query. public partial class TextResult { + /// + /// 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 . internal TextResult() { @@ -17,9 +52,11 @@ internal TextResult() /// Initializes a new instance of . /// The BM25 or Classic score for the text portion of the query. - internal TextResult(double? searchScore) + /// Keeps track of any properties unknown to the library. + internal TextResult(double? searchScore, IDictionary serializedAdditionalRawData) { SearchScore = searchScore; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The BM25 or Classic score for the text portion of the query. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/TextTranslationSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/TextTranslationSkill.Serialization.cs index fb7cf2f99c12..b1aa6004914a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/TextTranslationSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/TextTranslationSkill.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class TextTranslationSkill : IUtf8JsonSerializable + public partial class TextTranslationSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(TextTranslationSkill)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("defaultToLanguageCode"u8); writer.WriteStringValue(DefaultToLanguageCode.ToString()); if (Optional.IsDefined(DefaultFromLanguageCode)) @@ -42,42 +61,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("suggestedFrom"); } } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + TextTranslationSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(TextTranslationSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTextTranslationSkill(document.RootElement, options); } - internal static TextTranslationSkill DeserializeTextTranslationSkill(JsonElement element) + internal static TextTranslationSkill DeserializeTextTranslationSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -91,6 +92,8 @@ internal static TextTranslationSkill DeserializeTextTranslationSkill(JsonElement string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("defaultToLanguageCode"u8)) @@ -143,7 +146,7 @@ internal static TextTranslationSkill DeserializeTextTranslationSkill(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -153,12 +156,17 @@ internal static TextTranslationSkill DeserializeTextTranslationSkill(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new TextTranslationSkill( odataType, name, @@ -166,11 +174,43 @@ internal static TextTranslationSkill DeserializeTextTranslationSkill(JsonElement context, inputs, outputs, + serializedAdditionalRawData, defaultToLanguageCode, defaultFromLanguageCode, suggestedFrom); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(TextTranslationSkill)} does not support writing '{options.Format}' format."); + } + } + + TextTranslationSkill 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 DeserializeTextTranslationSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TextTranslationSkill)} 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 TextTranslationSkill FromResponse(Response response) @@ -183,7 +223,7 @@ internal static TextTranslationSkill DeserializeTextTranslationSkill(JsonElement internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/TextTranslationSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/TextTranslationSkill.cs index 7e5f5755f06b..aaf2d81897c3 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/TextTranslationSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/TextTranslationSkill.cs @@ -34,10 +34,11 @@ public TextTranslationSkill(IEnumerable inputs, IEnumera /// Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// The language code to translate documents into for documents that don't specify the to language explicitly. /// The language code to translate documents from for documents that don't specify the from language explicitly. /// The language code to translate documents from when neither the fromLanguageCode input nor the defaultFromLanguageCode parameter are provided, and the automatic language detection is unsuccessful. Default is `en`. - internal TextTranslationSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, TextTranslationSkillLanguage defaultToLanguageCode, TextTranslationSkillLanguage? defaultFromLanguageCode, TextTranslationSkillLanguage? suggestedFrom) : base(oDataType, name, description, context, inputs, outputs) + internal TextTranslationSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, TextTranslationSkillLanguage defaultToLanguageCode, TextTranslationSkillLanguage? defaultFromLanguageCode, TextTranslationSkillLanguage? suggestedFrom) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { DefaultToLanguageCode = defaultToLanguageCode; DefaultFromLanguageCode = defaultFromLanguageCode; @@ -45,6 +46,11 @@ internal TextTranslationSkill(string oDataType, string name, string description, ODataType = oDataType ?? "#Microsoft.Skills.Text.TranslationSkill"; } + /// Initializes a new instance of for deserialization. + internal TextTranslationSkill() + { + } + /// The language code to translate documents into for documents that don't specify the to language explicitly. public TextTranslationSkillLanguage DefaultToLanguageCode { get; set; } /// The language code to translate documents from for documents that don't specify the from language explicitly. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/TextWeights.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/TextWeights.Serialization.cs index 08f70409fa72..44ac06637522 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/TextWeights.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/TextWeights.Serialization.cs @@ -5,17 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class TextWeights : IUtf8JsonSerializable + public partial class TextWeights : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(TextWeights)} does not support writing '{format}' format."); + } + writer.WritePropertyName("weights"u8); writer.WriteStartObject(); foreach (var item in Weights) @@ -24,16 +42,46 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNumberValue(item.Value); } writer.WriteEndObject(); - writer.WriteEndObject(); + 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 + } + } } - internal static TextWeights DeserializeTextWeights(JsonElement element) + TextWeights 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(TextWeights)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTextWeights(document.RootElement, options); + } + + internal static TextWeights DeserializeTextWeights(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } IDictionary weights = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("weights"u8)) @@ -46,10 +94,46 @@ internal static TextWeights DeserializeTextWeights(JsonElement element) weights = dictionary; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TextWeights(weights, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(TextWeights)} does not support writing '{options.Format}' format."); } - return new TextWeights(weights); } + TextWeights 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 DeserializeTextWeights(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TextWeights)} 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 TextWeights FromResponse(Response response) @@ -62,7 +146,7 @@ internal static TextWeights FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/TextWeights.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/TextWeights.cs index b421fc9b2529..574dc107fb69 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/TextWeights.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/TextWeights.cs @@ -13,6 +13,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Defines weights on index fields for which matches should boost scoring in search queries. public partial class TextWeights { + /// + /// 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 . /// The dictionary of per-field weights to boost document scoring. The keys are field names and the values are the weights for each field. /// is null. @@ -22,5 +54,19 @@ public TextWeights(IDictionary weights) Weights = weights; } + + /// Initializes a new instance of . + /// The dictionary of per-field weights to boost document scoring. The keys are field names and the values are the weights for each field. + /// Keeps track of any properties unknown to the library. + internal TextWeights(IDictionary weights, IDictionary serializedAdditionalRawData) + { + Weights = weights; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TextWeights() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/TokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/TokenFilter.Serialization.cs index 9eff630717f8..c0874d51c204 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/TokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/TokenFilter.Serialization.cs @@ -5,64 +5,98 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; -using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Indexes.Models { - public partial class TokenFilter : IUtf8JsonSerializable + public partial class TokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(TokenFilter)} does not support writing '{format}' format."); + } + writer.WritePropertyName("@odata.type"u8); writer.WriteStringValue(ODataType); writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); - writer.WriteEndObject(); + 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 + } + } } - internal static TokenFilter DeserializeTokenFilter(JsonElement element) + TokenFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - if (element.ValueKind == JsonValueKind.Null) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - return null; + throw new FormatException($"The model {nameof(TokenFilter)} does not support reading '{format}' format."); } - if (element.TryGetProperty("@odata.type", out JsonElement discriminator)) + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTokenFilter(document.RootElement, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - switch (discriminator.GetString()) - { - case "#Microsoft.Azure.Search.AsciiFoldingTokenFilter": return AsciiFoldingTokenFilter.DeserializeAsciiFoldingTokenFilter(element); - case "#Microsoft.Azure.Search.CjkBigramTokenFilter": return CjkBigramTokenFilter.DeserializeCjkBigramTokenFilter(element); - case "#Microsoft.Azure.Search.CommonGramTokenFilter": return CommonGramTokenFilter.DeserializeCommonGramTokenFilter(element); - case "#Microsoft.Azure.Search.DictionaryDecompounderTokenFilter": return DictionaryDecompounderTokenFilter.DeserializeDictionaryDecompounderTokenFilter(element); - case "#Microsoft.Azure.Search.EdgeNGramTokenFilter": return EdgeNGramTokenFilter.DeserializeEdgeNGramTokenFilter(element); - case "#Microsoft.Azure.Search.EdgeNGramTokenFilterV2": return EdgeNGramTokenFilter.DeserializeEdgeNGramTokenFilter(element); - case "#Microsoft.Azure.Search.ElisionTokenFilter": return ElisionTokenFilter.DeserializeElisionTokenFilter(element); - case "#Microsoft.Azure.Search.KeepTokenFilter": return KeepTokenFilter.DeserializeKeepTokenFilter(element); - case "#Microsoft.Azure.Search.KeywordMarkerTokenFilter": return KeywordMarkerTokenFilter.DeserializeKeywordMarkerTokenFilter(element); - case "#Microsoft.Azure.Search.LengthTokenFilter": return LengthTokenFilter.DeserializeLengthTokenFilter(element); - case "#Microsoft.Azure.Search.LimitTokenFilter": return LimitTokenFilter.DeserializeLimitTokenFilter(element); - case "#Microsoft.Azure.Search.NGramTokenFilter": return NGramTokenFilter.DeserializeNGramTokenFilter(element); - case "#Microsoft.Azure.Search.NGramTokenFilterV2": return NGramTokenFilter.DeserializeNGramTokenFilter(element); - case "#Microsoft.Azure.Search.PatternCaptureTokenFilter": return PatternCaptureTokenFilter.DeserializePatternCaptureTokenFilter(element); - case "#Microsoft.Azure.Search.PatternReplaceTokenFilter": return PatternReplaceTokenFilter.DeserializePatternReplaceTokenFilter(element); - case "#Microsoft.Azure.Search.PhoneticTokenFilter": return PhoneticTokenFilter.DeserializePhoneticTokenFilter(element); - case "#Microsoft.Azure.Search.ShingleTokenFilter": return ShingleTokenFilter.DeserializeShingleTokenFilter(element); - case "#Microsoft.Azure.Search.SnowballTokenFilter": return SnowballTokenFilter.DeserializeSnowballTokenFilter(element); - case "#Microsoft.Azure.Search.StemmerOverrideTokenFilter": return StemmerOverrideTokenFilter.DeserializeStemmerOverrideTokenFilter(element); - case "#Microsoft.Azure.Search.StemmerTokenFilter": return StemmerTokenFilter.DeserializeStemmerTokenFilter(element); - case "#Microsoft.Azure.Search.StopwordsTokenFilter": return StopwordsTokenFilter.DeserializeStopwordsTokenFilter(element); - case "#Microsoft.Azure.Search.SynonymTokenFilter": return SynonymTokenFilter.DeserializeSynonymTokenFilter(element); - case "#Microsoft.Azure.Search.TruncateTokenFilter": return TruncateTokenFilter.DeserializeTruncateTokenFilter(element); - case "#Microsoft.Azure.Search.UniqueTokenFilter": return UniqueTokenFilter.DeserializeUniqueTokenFilter(element); - case "#Microsoft.Azure.Search.WordDelimiterTokenFilter": return WordDelimiterTokenFilter.DeserializeWordDelimiterTokenFilter(element); - } + case "J": + return ModelReaderWriter.Write(this, options, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(TokenFilter)} does not support writing '{options.Format}' format."); } - return UnknownTokenFilter.DeserializeUnknownTokenFilter(element); } + TokenFilter 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 DeserializeTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TokenFilter)} 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 TokenFilter FromResponse(Response response) @@ -75,7 +109,7 @@ internal static TokenFilter FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/TokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/TokenFilter.cs index b5c02b9cc5c5..f4a90c2d0f46 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/TokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/TokenFilter.cs @@ -6,23 +6,63 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// /// Base type for token filters. /// 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 available derived classes include , , , , , , , , , , , , , , , , , , , , , and . /// public partial class TokenFilter { + /// + /// 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 . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - internal TokenFilter(string oDataType, string name) + /// Keeps track of any properties unknown to the library. + internal TokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData) { ODataType = oDataType; Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TokenFilter() + { } /// A URI fragment specifying the type of token filter. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/TruncateTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/TruncateTokenFilter.Serialization.cs index 85eb8b4f3c9c..7c50ba5e4787 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/TruncateTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/TruncateTokenFilter.Serialization.cs @@ -5,30 +5,59 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class TruncateTokenFilter : IUtf8JsonSerializable + public partial class TruncateTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(TruncateTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Length)) { writer.WritePropertyName("length"u8); writer.WriteNumberValue(Length.Value); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static TruncateTokenFilter DeserializeTruncateTokenFilter(JsonElement element) + TruncateTokenFilter 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(TruncateTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTruncateTokenFilter(document.RootElement, options); + } + + internal static TruncateTokenFilter DeserializeTruncateTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -36,6 +65,8 @@ internal static TruncateTokenFilter DeserializeTruncateTokenFilter(JsonElement e int? length = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("length"u8)) @@ -57,10 +88,46 @@ internal static TruncateTokenFilter DeserializeTruncateTokenFilter(JsonElement e name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TruncateTokenFilter(odataType, name, serializedAdditionalRawData, length); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(TruncateTokenFilter)} does not support writing '{options.Format}' format."); + } + } + + TruncateTokenFilter 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 DeserializeTruncateTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TruncateTokenFilter)} does not support reading '{options.Format}' format."); } - return new TruncateTokenFilter(odataType, name, length); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new TruncateTokenFilter FromResponse(Response response) @@ -73,7 +140,7 @@ internal static TruncateTokenFilter DeserializeTruncateTokenFilter(JsonElement e internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/TruncateTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/TruncateTokenFilter.cs index 42ee37137509..5aa62b2133a8 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/TruncateTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/TruncateTokenFilter.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,13 +26,19 @@ public TruncateTokenFilter(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The length at which terms will be truncated. Default and maximum is 300. - internal TruncateTokenFilter(string oDataType, string name, int? length) : base(oDataType, name) + internal TruncateTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, int? length) : base(oDataType, name, serializedAdditionalRawData) { Length = length; ODataType = oDataType ?? "#Microsoft.Azure.Search.TruncateTokenFilter"; } + /// Initializes a new instance of for deserialization. + internal TruncateTokenFilter() + { + } + /// The length at which terms will be truncated. Default and maximum is 300. public int? Length { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UaxUrlEmailTokenizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UaxUrlEmailTokenizer.Serialization.cs index 6e0b91dabb00..482a5a467adb 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UaxUrlEmailTokenizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UaxUrlEmailTokenizer.Serialization.cs @@ -5,30 +5,59 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class UaxUrlEmailTokenizer : IUtf8JsonSerializable + public partial class UaxUrlEmailTokenizer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(UaxUrlEmailTokenizer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(MaxTokenLength)) { writer.WritePropertyName("maxTokenLength"u8); writer.WriteNumberValue(MaxTokenLength.Value); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static UaxUrlEmailTokenizer DeserializeUaxUrlEmailTokenizer(JsonElement element) + UaxUrlEmailTokenizer 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(UaxUrlEmailTokenizer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUaxUrlEmailTokenizer(document.RootElement, options); + } + + internal static UaxUrlEmailTokenizer DeserializeUaxUrlEmailTokenizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -36,6 +65,8 @@ internal static UaxUrlEmailTokenizer DeserializeUaxUrlEmailTokenizer(JsonElement int? maxTokenLength = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("maxTokenLength"u8)) @@ -57,10 +88,46 @@ internal static UaxUrlEmailTokenizer DeserializeUaxUrlEmailTokenizer(JsonElement name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UaxUrlEmailTokenizer(odataType, name, serializedAdditionalRawData, maxTokenLength); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(UaxUrlEmailTokenizer)} does not support writing '{options.Format}' format."); + } + } + + UaxUrlEmailTokenizer 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 DeserializeUaxUrlEmailTokenizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UaxUrlEmailTokenizer)} does not support reading '{options.Format}' format."); } - return new UaxUrlEmailTokenizer(odataType, name, maxTokenLength); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new UaxUrlEmailTokenizer FromResponse(Response response) @@ -73,7 +140,7 @@ internal static UaxUrlEmailTokenizer DeserializeUaxUrlEmailTokenizer(JsonElement internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UaxUrlEmailTokenizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UaxUrlEmailTokenizer.cs index 429e17a879a0..f91533596ce7 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UaxUrlEmailTokenizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UaxUrlEmailTokenizer.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,13 +26,19 @@ public UaxUrlEmailTokenizer(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of tokenizer. /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// The maximum token length. Default is 255. Tokens longer than the maximum length are split. The maximum token length that can be used is 300 characters. - internal UaxUrlEmailTokenizer(string oDataType, string name, int? maxTokenLength) : base(oDataType, name) + internal UaxUrlEmailTokenizer(string oDataType, string name, IDictionary serializedAdditionalRawData, int? maxTokenLength) : base(oDataType, name, serializedAdditionalRawData) { MaxTokenLength = maxTokenLength; ODataType = oDataType ?? "#Microsoft.Azure.Search.UaxUrlEmailTokenizer"; } + /// Initializes a new instance of for deserialization. + internal UaxUrlEmailTokenizer() + { + } + /// The maximum token length. Default is 255. Tokens longer than the maximum length are split. The maximum token length that can be used is 300 characters. public int? MaxTokenLength { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UniqueTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UniqueTokenFilter.Serialization.cs index bce5f7022be8..8f4dfc5c0fd6 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UniqueTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UniqueTokenFilter.Serialization.cs @@ -5,30 +5,59 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class UniqueTokenFilter : IUtf8JsonSerializable + public partial class UniqueTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(UniqueTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(OnlyOnSamePosition)) { writer.WritePropertyName("onlyOnSamePosition"u8); writer.WriteBooleanValue(OnlyOnSamePosition.Value); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static UniqueTokenFilter DeserializeUniqueTokenFilter(JsonElement element) + UniqueTokenFilter 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(UniqueTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUniqueTokenFilter(document.RootElement, options); + } + + internal static UniqueTokenFilter DeserializeUniqueTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -36,6 +65,8 @@ internal static UniqueTokenFilter DeserializeUniqueTokenFilter(JsonElement eleme bool? onlyOnSamePosition = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("onlyOnSamePosition"u8)) @@ -57,10 +88,46 @@ internal static UniqueTokenFilter DeserializeUniqueTokenFilter(JsonElement eleme name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UniqueTokenFilter(odataType, name, serializedAdditionalRawData, onlyOnSamePosition); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(UniqueTokenFilter)} does not support writing '{options.Format}' format."); + } + } + + UniqueTokenFilter 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 DeserializeUniqueTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UniqueTokenFilter)} does not support reading '{options.Format}' format."); } - return new UniqueTokenFilter(odataType, name, onlyOnSamePosition); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new UniqueTokenFilter FromResponse(Response response) @@ -73,7 +140,7 @@ internal static UniqueTokenFilter DeserializeUniqueTokenFilter(JsonElement eleme internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UniqueTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UniqueTokenFilter.cs index 55d5b9653eab..e3bd32f066fd 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UniqueTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UniqueTokenFilter.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,13 +26,19 @@ public UniqueTokenFilter(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// A value indicating whether to remove duplicates only at the same position. Default is false. - internal UniqueTokenFilter(string oDataType, string name, bool? onlyOnSamePosition) : base(oDataType, name) + internal UniqueTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, bool? onlyOnSamePosition) : base(oDataType, name, serializedAdditionalRawData) { OnlyOnSamePosition = onlyOnSamePosition; ODataType = oDataType ?? "#Microsoft.Azure.Search.UniqueTokenFilter"; } + /// Initializes a new instance of for deserialization. + internal UniqueTokenFilter() + { + } + /// A value indicating whether to remove duplicates only at the same position. Default is false. public bool? OnlyOnSamePosition { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownCharFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownCharFilter.Serialization.cs index 816a3e6b6959..4fe8b8390dc6 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownCharFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownCharFilter.Serialization.cs @@ -5,32 +5,63 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models { - internal partial class UnknownCharFilter : IUtf8JsonSerializable + internal partial class UnknownCharFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); + JsonModelWriteCore(writer, options); writer.WriteEndObject(); } - internal static UnknownCharFilter DeserializeUnknownCharFilter(JsonElement element) + /// 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(CharFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + CharFilter 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(CharFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCharFilter(document.RootElement, options); + } + + internal static UnknownCharFilter DeserializeUnknownCharFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string odataType = "Unknown"; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@odata.type"u8)) @@ -43,10 +74,46 @@ internal static UnknownCharFilter DeserializeUnknownCharFilter(JsonElement eleme name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownCharFilter(odataType, name, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(CharFilter)} does not support writing '{options.Format}' format."); } - return new UnknownCharFilter(odataType, name); } + CharFilter 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 DeserializeCharFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CharFilter)} 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 UnknownCharFilter FromResponse(Response response) @@ -59,7 +126,7 @@ internal static UnknownCharFilter DeserializeUnknownCharFilter(JsonElement eleme internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownCharFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownCharFilter.cs index e51658211389..3b7ad3a1e284 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownCharFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownCharFilter.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models @@ -15,9 +17,15 @@ internal partial class UnknownCharFilter : CharFilter /// Initializes a new instance of . /// A URI fragment specifying the type of char filter. /// The name of the char filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - internal UnknownCharFilter(string oDataType, string name) : base(oDataType, name) + /// Keeps track of any properties unknown to the library. + internal UnknownCharFilter(string oDataType, string name, IDictionary serializedAdditionalRawData) : base(oDataType, name, serializedAdditionalRawData) { ODataType = oDataType ?? "Unknown"; } + + /// Initializes a new instance of for deserialization. + internal UnknownCharFilter() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownCognitiveServicesAccount.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownCognitiveServicesAccount.Serialization.cs index 9795bb6b6b0b..0b52c9692bd7 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownCognitiveServicesAccount.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownCognitiveServicesAccount.Serialization.cs @@ -5,35 +5,63 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models { - internal partial class UnknownCognitiveServicesAccount : IUtf8JsonSerializable + internal partial class UnknownCognitiveServicesAccount : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Description)) + 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") { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); + throw new FormatException($"The model {nameof(CognitiveServicesAccount)} does not support writing '{format}' format."); } - writer.WriteEndObject(); + + base.JsonModelWriteCore(writer, options); } - internal static UnknownCognitiveServicesAccount DeserializeUnknownCognitiveServicesAccount(JsonElement element) + CognitiveServicesAccount 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(CognitiveServicesAccount)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCognitiveServicesAccount(document.RootElement, options); + } + + internal static UnknownCognitiveServicesAccount DeserializeUnknownCognitiveServicesAccount(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string odataType = "Unknown"; string description = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@odata.type"u8)) @@ -46,10 +74,46 @@ internal static UnknownCognitiveServicesAccount DeserializeUnknownCognitiveServi description = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownCognitiveServicesAccount(odataType, description, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(CognitiveServicesAccount)} does not support writing '{options.Format}' format."); } - return new UnknownCognitiveServicesAccount(odataType, description); } + CognitiveServicesAccount 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 DeserializeCognitiveServicesAccount(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CognitiveServicesAccount)} 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 UnknownCognitiveServicesAccount FromResponse(Response response) @@ -62,7 +126,7 @@ internal static UnknownCognitiveServicesAccount DeserializeUnknownCognitiveServi internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownCognitiveServicesAccount.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownCognitiveServicesAccount.cs index 9de01138d09a..b704a8082172 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownCognitiveServicesAccount.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownCognitiveServicesAccount.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models @@ -15,9 +17,15 @@ internal partial class UnknownCognitiveServicesAccount : CognitiveServicesAccoun /// Initializes a new instance of . /// A URI fragment specifying the type of Azure AI service resource attached to a skillset. /// Description of the Azure AI service resource attached to a skillset. - internal UnknownCognitiveServicesAccount(string oDataType, string description) : base(oDataType, description) + /// Keeps track of any properties unknown to the library. + internal UnknownCognitiveServicesAccount(string oDataType, string description, IDictionary serializedAdditionalRawData) : base(oDataType, description, serializedAdditionalRawData) { ODataType = oDataType ?? "Unknown"; } + + /// Initializes a new instance of for deserialization. + internal UnknownCognitiveServicesAccount() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownDataChangeDetectionPolicy.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownDataChangeDetectionPolicy.Serialization.cs index e8fa65e45478..57c26a427efa 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownDataChangeDetectionPolicy.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownDataChangeDetectionPolicy.Serialization.cs @@ -5,29 +5,62 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models { - internal partial class UnknownDataChangeDetectionPolicy : IUtf8JsonSerializable + internal partial class UnknownDataChangeDetectionPolicy : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); + JsonModelWriteCore(writer, options); writer.WriteEndObject(); } - internal static UnknownDataChangeDetectionPolicy DeserializeUnknownDataChangeDetectionPolicy(JsonElement element) + /// 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(DataChangeDetectionPolicy)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + DataChangeDetectionPolicy 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(DataChangeDetectionPolicy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataChangeDetectionPolicy(document.RootElement, options); + } + + internal static UnknownDataChangeDetectionPolicy DeserializeUnknownDataChangeDetectionPolicy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string odataType = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@odata.type"u8)) @@ -35,10 +68,46 @@ internal static UnknownDataChangeDetectionPolicy DeserializeUnknownDataChangeDet odataType = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownDataChangeDetectionPolicy(odataType, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(DataChangeDetectionPolicy)} does not support writing '{options.Format}' format."); } - return new UnknownDataChangeDetectionPolicy(odataType); } + DataChangeDetectionPolicy 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 DeserializeDataChangeDetectionPolicy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataChangeDetectionPolicy)} 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 UnknownDataChangeDetectionPolicy FromResponse(Response response) @@ -51,7 +120,7 @@ internal static UnknownDataChangeDetectionPolicy DeserializeUnknownDataChangeDet internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownDataChangeDetectionPolicy.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownDataChangeDetectionPolicy.cs index 5bb9124cabd1..371c179a43bc 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownDataChangeDetectionPolicy.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownDataChangeDetectionPolicy.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models @@ -14,9 +16,15 @@ internal partial class UnknownDataChangeDetectionPolicy : DataChangeDetectionPol { /// Initializes a new instance of . /// A URI fragment specifying the type of data change detection policy. - internal UnknownDataChangeDetectionPolicy(string oDataType) : base(oDataType) + /// Keeps track of any properties unknown to the library. + internal UnknownDataChangeDetectionPolicy(string oDataType, IDictionary serializedAdditionalRawData) : base(oDataType, serializedAdditionalRawData) { ODataType = oDataType ?? "Unknown"; } + + /// Initializes a new instance of for deserialization. + internal UnknownDataChangeDetectionPolicy() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownDataDeletionDetectionPolicy.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownDataDeletionDetectionPolicy.Serialization.cs index d5804aab4cae..2462889c9172 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownDataDeletionDetectionPolicy.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownDataDeletionDetectionPolicy.Serialization.cs @@ -5,29 +5,62 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models { - internal partial class UnknownDataDeletionDetectionPolicy : IUtf8JsonSerializable + internal partial class UnknownDataDeletionDetectionPolicy : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); + JsonModelWriteCore(writer, options); writer.WriteEndObject(); } - internal static UnknownDataDeletionDetectionPolicy DeserializeUnknownDataDeletionDetectionPolicy(JsonElement element) + /// 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(DataDeletionDetectionPolicy)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + DataDeletionDetectionPolicy 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(DataDeletionDetectionPolicy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataDeletionDetectionPolicy(document.RootElement, options); + } + + internal static UnknownDataDeletionDetectionPolicy DeserializeUnknownDataDeletionDetectionPolicy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string odataType = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@odata.type"u8)) @@ -35,10 +68,46 @@ internal static UnknownDataDeletionDetectionPolicy DeserializeUnknownDataDeletio odataType = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownDataDeletionDetectionPolicy(odataType, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(DataDeletionDetectionPolicy)} does not support writing '{options.Format}' format."); } - return new UnknownDataDeletionDetectionPolicy(odataType); } + DataDeletionDetectionPolicy 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 DeserializeDataDeletionDetectionPolicy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataDeletionDetectionPolicy)} 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 UnknownDataDeletionDetectionPolicy FromResponse(Response response) @@ -51,7 +120,7 @@ internal static UnknownDataDeletionDetectionPolicy DeserializeUnknownDataDeletio internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownDataDeletionDetectionPolicy.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownDataDeletionDetectionPolicy.cs index 45bef6c3d413..b63a0c437643 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownDataDeletionDetectionPolicy.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownDataDeletionDetectionPolicy.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models @@ -14,9 +16,15 @@ internal partial class UnknownDataDeletionDetectionPolicy : DataDeletionDetectio { /// Initializes a new instance of . /// A URI fragment specifying the type of data deletion detection policy. - internal UnknownDataDeletionDetectionPolicy(string oDataType) : base(oDataType) + /// Keeps track of any properties unknown to the library. + internal UnknownDataDeletionDetectionPolicy(string oDataType, IDictionary serializedAdditionalRawData) : base(oDataType, serializedAdditionalRawData) { ODataType = oDataType ?? "Unknown"; } + + /// Initializes a new instance of for deserialization. + internal UnknownDataDeletionDetectionPolicy() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentActivityRecord.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentActivityRecord.Serialization.cs index 6687b76388e6..d4768af2b3e8 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentActivityRecord.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentActivityRecord.Serialization.cs @@ -5,20 +5,63 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; +using Azure.Search.Documents.Agents.Models; namespace Azure.Search.Documents.Models { - internal partial class UnknownKnowledgeAgentActivityRecord + internal partial class UnknownKnowledgeAgentActivityRecord : IUtf8JsonSerializable, IJsonModel { - internal static UnknownKnowledgeAgentActivityRecord DeserializeUnknownKnowledgeAgentActivityRecord(JsonElement element) + 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(KnowledgeAgentActivityRecord)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + KnowledgeAgentActivityRecord 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(KnowledgeAgentActivityRecord)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentActivityRecord(document.RootElement, options); + } + + internal static UnknownKnowledgeAgentActivityRecord DeserializeUnknownKnowledgeAgentActivityRecord(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } int id = default; string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id"u8)) @@ -31,10 +74,46 @@ internal static UnknownKnowledgeAgentActivityRecord DeserializeUnknownKnowledgeA type = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new UnknownKnowledgeAgentActivityRecord(id, type); + serializedAdditionalRawData = rawDataDictionary; + return new UnknownKnowledgeAgentActivityRecord(id, type, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentActivityRecord)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeAgentActivityRecord 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 DeserializeKnowledgeAgentActivityRecord(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentActivityRecord)} 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 UnknownKnowledgeAgentActivityRecord FromResponse(Response response) @@ -42,5 +121,13 @@ internal static UnknownKnowledgeAgentActivityRecord DeserializeUnknownKnowledgeA using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeUnknownKnowledgeAgentActivityRecord(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/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentActivityRecord.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentActivityRecord.cs index 93c1c992b98d..455e460bda16 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentActivityRecord.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentActivityRecord.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Search.Documents.Agents.Models; namespace Azure.Search.Documents.Models @@ -15,9 +17,15 @@ internal partial class UnknownKnowledgeAgentActivityRecord : KnowledgeAgentActiv /// Initializes a new instance of . /// The ID of the activity record. /// The type of the activity record. - internal UnknownKnowledgeAgentActivityRecord(int id, string type) : base(id, type) + /// Keeps track of any properties unknown to the library. + internal UnknownKnowledgeAgentActivityRecord(int id, string type, IDictionary serializedAdditionalRawData) : base(id, type, serializedAdditionalRawData) { Type = type ?? "Unknown"; } + + /// Initializes a new instance of for deserialization. + internal UnknownKnowledgeAgentActivityRecord() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentMessageContent.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentMessageContent.Serialization.cs index f44255a1c849..e84de17d47d7 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentMessageContent.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentMessageContent.Serialization.cs @@ -5,29 +5,62 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Agents.Models; namespace Azure.Search.Documents.Models { - internal partial class UnknownKnowledgeAgentMessageContent : IUtf8JsonSerializable + internal partial class UnknownKnowledgeAgentMessageContent : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type.ToString()); + JsonModelWriteCore(writer, options); writer.WriteEndObject(); } - internal static UnknownKnowledgeAgentMessageContent DeserializeUnknownKnowledgeAgentMessageContent(JsonElement element) + /// 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(KnowledgeAgentMessageContent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + KnowledgeAgentMessageContent 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(KnowledgeAgentMessageContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentMessageContent(document.RootElement, options); + } + + internal static UnknownKnowledgeAgentMessageContent DeserializeUnknownKnowledgeAgentMessageContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } KnowledgeAgentMessageContentType type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("type"u8)) @@ -35,10 +68,46 @@ internal static UnknownKnowledgeAgentMessageContent DeserializeUnknownKnowledgeA type = new KnowledgeAgentMessageContentType(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownKnowledgeAgentMessageContent(type, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentMessageContent)} does not support writing '{options.Format}' format."); } - return new UnknownKnowledgeAgentMessageContent(type); } + KnowledgeAgentMessageContent 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 DeserializeKnowledgeAgentMessageContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentMessageContent)} 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 UnknownKnowledgeAgentMessageContent FromResponse(Response response) @@ -51,7 +120,7 @@ internal static UnknownKnowledgeAgentMessageContent DeserializeUnknownKnowledgeA internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentMessageContent.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentMessageContent.cs index d57b678fa6fc..309a5ad9b566 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentMessageContent.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentMessageContent.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Search.Documents.Agents.Models; namespace Azure.Search.Documents.Models @@ -14,9 +16,15 @@ internal partial class UnknownKnowledgeAgentMessageContent : KnowledgeAgentMessa { /// Initializes a new instance of . /// The type of the message. - internal UnknownKnowledgeAgentMessageContent(KnowledgeAgentMessageContentType type) : base(type) + /// Keeps track of any properties unknown to the library. + internal UnknownKnowledgeAgentMessageContent(KnowledgeAgentMessageContentType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) { Type = type; } + + /// Initializes a new instance of for deserialization. + internal UnknownKnowledgeAgentMessageContent() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentModel.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentModel.Serialization.cs index 7da206b0aa59..bf12dc759036 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentModel.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentModel.Serialization.cs @@ -5,29 +5,62 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models { - internal partial class UnknownKnowledgeAgentModel : IUtf8JsonSerializable + internal partial class UnknownKnowledgeAgentModel : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); + JsonModelWriteCore(writer, options); writer.WriteEndObject(); } - internal static UnknownKnowledgeAgentModel DeserializeUnknownKnowledgeAgentModel(JsonElement element) + /// 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(KnowledgeAgentModel)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + KnowledgeAgentModel 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(KnowledgeAgentModel)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentModel(document.RootElement, options); + } + + internal static UnknownKnowledgeAgentModel DeserializeUnknownKnowledgeAgentModel(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } KnowledgeAgentModelKind kind = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("kind"u8)) @@ -35,10 +68,46 @@ internal static UnknownKnowledgeAgentModel DeserializeUnknownKnowledgeAgentModel kind = new KnowledgeAgentModelKind(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownKnowledgeAgentModel(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentModel)} does not support writing '{options.Format}' format."); } - return new UnknownKnowledgeAgentModel(kind); } + KnowledgeAgentModel 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 DeserializeKnowledgeAgentModel(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentModel)} 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 UnknownKnowledgeAgentModel FromResponse(Response response) @@ -51,7 +120,7 @@ internal static UnknownKnowledgeAgentModel DeserializeUnknownKnowledgeAgentModel internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentModel.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentModel.cs index 5f4cdeb0df76..4ec6c4682dd7 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentModel.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentModel.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models @@ -14,9 +16,15 @@ internal partial class UnknownKnowledgeAgentModel : KnowledgeAgentModel { /// Initializes a new instance of . /// The type of AI model. - internal UnknownKnowledgeAgentModel(KnowledgeAgentModelKind kind) : base(kind) + /// Keeps track of any properties unknown to the library. + internal UnknownKnowledgeAgentModel(KnowledgeAgentModelKind kind, IDictionary serializedAdditionalRawData) : base(kind, serializedAdditionalRawData) { Kind = kind; } + + /// Initializes a new instance of for deserialization. + internal UnknownKnowledgeAgentModel() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentReference.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentReference.Serialization.cs index 3f2a59a6108f..6a92dce44e91 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentReference.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentReference.Serialization.cs @@ -5,14 +5,55 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; +using Azure.Search.Documents.Agents.Models; namespace Azure.Search.Documents.Models { - internal partial class UnknownKnowledgeAgentReference + internal partial class UnknownKnowledgeAgentReference : IUtf8JsonSerializable, IJsonModel { - internal static UnknownKnowledgeAgentReference DeserializeUnknownKnowledgeAgentReference(JsonElement element) + 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(KnowledgeAgentReference)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + KnowledgeAgentReference 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(KnowledgeAgentReference)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeAgentReference(document.RootElement, options); + } + + internal static UnknownKnowledgeAgentReference DeserializeUnknownKnowledgeAgentReference(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -20,6 +61,8 @@ internal static UnknownKnowledgeAgentReference DeserializeUnknownKnowledgeAgentR string type = "Unknown"; string id = default; int activitySource = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("type"u8)) @@ -37,10 +80,46 @@ internal static UnknownKnowledgeAgentReference DeserializeUnknownKnowledgeAgentR activitySource = property.Value.GetInt32(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new UnknownKnowledgeAgentReference(type, id, activitySource); + serializedAdditionalRawData = rawDataDictionary; + return new UnknownKnowledgeAgentReference(type, id, activitySource, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(KnowledgeAgentReference)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeAgentReference 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 DeserializeKnowledgeAgentReference(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeAgentReference)} 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 UnknownKnowledgeAgentReference FromResponse(Response response) @@ -48,5 +127,13 @@ internal static UnknownKnowledgeAgentReference DeserializeUnknownKnowledgeAgentR using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeUnknownKnowledgeAgentReference(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/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentReference.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentReference.cs index 5574f4776164..ff5c19531925 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentReference.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownKnowledgeAgentReference.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Search.Documents.Agents.Models; namespace Azure.Search.Documents.Models @@ -16,9 +18,15 @@ internal partial class UnknownKnowledgeAgentReference : KnowledgeAgentReference /// The type of the reference. /// The ID of the reference. /// The source activity ID for the reference. - internal UnknownKnowledgeAgentReference(string type, string id, int activitySource) : base(type, id, activitySource) + /// Keeps track of any properties unknown to the library. + internal UnknownKnowledgeAgentReference(string type, string id, int activitySource, IDictionary serializedAdditionalRawData) : base(type, id, activitySource, serializedAdditionalRawData) { Type = type ?? "Unknown"; } + + /// Initializes a new instance of for deserialization. + internal UnknownKnowledgeAgentReference() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalAnalyzer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalAnalyzer.Serialization.cs index 0db371215532..5607db511d9f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalAnalyzer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalAnalyzer.Serialization.cs @@ -5,32 +5,63 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models { - internal partial class UnknownLexicalAnalyzer : IUtf8JsonSerializable + internal partial class UnknownLexicalAnalyzer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); + JsonModelWriteCore(writer, options); writer.WriteEndObject(); } - internal static UnknownLexicalAnalyzer DeserializeUnknownLexicalAnalyzer(JsonElement element) + /// 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(LexicalAnalyzer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + LexicalAnalyzer 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(LexicalAnalyzer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLexicalAnalyzer(document.RootElement, options); + } + + internal static UnknownLexicalAnalyzer DeserializeUnknownLexicalAnalyzer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string odataType = "Unknown"; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@odata.type"u8)) @@ -43,10 +74,46 @@ internal static UnknownLexicalAnalyzer DeserializeUnknownLexicalAnalyzer(JsonEle name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownLexicalAnalyzer(odataType, name, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(LexicalAnalyzer)} does not support writing '{options.Format}' format."); } - return new UnknownLexicalAnalyzer(odataType, name); } + LexicalAnalyzer 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 DeserializeLexicalAnalyzer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LexicalAnalyzer)} 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 UnknownLexicalAnalyzer FromResponse(Response response) @@ -59,7 +126,7 @@ internal static UnknownLexicalAnalyzer DeserializeUnknownLexicalAnalyzer(JsonEle internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalAnalyzer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalAnalyzer.cs index 6e7bb7c85ed4..9022d6481aef 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalAnalyzer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalAnalyzer.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models @@ -15,9 +17,15 @@ internal partial class UnknownLexicalAnalyzer : LexicalAnalyzer /// Initializes a new instance of . /// A URI fragment specifying the type of analyzer. /// The name of the analyzer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - internal UnknownLexicalAnalyzer(string oDataType, string name) : base(oDataType, name) + /// Keeps track of any properties unknown to the library. + internal UnknownLexicalAnalyzer(string oDataType, string name, IDictionary serializedAdditionalRawData) : base(oDataType, name, serializedAdditionalRawData) { ODataType = oDataType ?? "Unknown"; } + + /// Initializes a new instance of for deserialization. + internal UnknownLexicalAnalyzer() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalNormalizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalNormalizer.Serialization.cs index 61a3da87b3b5..18b6440ad5d8 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalNormalizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalNormalizer.Serialization.cs @@ -5,32 +5,63 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models { - internal partial class UnknownLexicalNormalizer : IUtf8JsonSerializable + internal partial class UnknownLexicalNormalizer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); + JsonModelWriteCore(writer, options); writer.WriteEndObject(); } - internal static UnknownLexicalNormalizer DeserializeUnknownLexicalNormalizer(JsonElement element) + /// 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(LexicalNormalizer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + LexicalNormalizer 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(LexicalNormalizer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLexicalNormalizer(document.RootElement, options); + } + + internal static UnknownLexicalNormalizer DeserializeUnknownLexicalNormalizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string odataType = "Unknown"; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@odata.type"u8)) @@ -43,10 +74,46 @@ internal static UnknownLexicalNormalizer DeserializeUnknownLexicalNormalizer(Jso name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownLexicalNormalizer(odataType, name, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(LexicalNormalizer)} does not support writing '{options.Format}' format."); } - return new UnknownLexicalNormalizer(odataType, name); } + LexicalNormalizer 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 DeserializeLexicalNormalizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LexicalNormalizer)} 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 UnknownLexicalNormalizer FromResponse(Response response) @@ -59,7 +126,7 @@ internal static UnknownLexicalNormalizer DeserializeUnknownLexicalNormalizer(Jso internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalNormalizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalNormalizer.cs index 0805ebc85bc6..c2ba70676a2b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalNormalizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalNormalizer.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models @@ -15,9 +17,15 @@ internal partial class UnknownLexicalNormalizer : LexicalNormalizer /// Initializes a new instance of . /// A URI fragment specifying the type of normalizer. /// The name of the normalizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. It cannot end in '.microsoft' nor '.lucene', nor be named 'asciifolding', 'standard', 'lowercase', 'uppercase', or 'elision'. - internal UnknownLexicalNormalizer(string oDataType, string name) : base(oDataType, name) + /// Keeps track of any properties unknown to the library. + internal UnknownLexicalNormalizer(string oDataType, string name, IDictionary serializedAdditionalRawData) : base(oDataType, name, serializedAdditionalRawData) { ODataType = oDataType ?? "Unknown"; } + + /// Initializes a new instance of for deserialization. + internal UnknownLexicalNormalizer() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalTokenizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalTokenizer.Serialization.cs index 2b19106b4303..ecfc4f0fb1d9 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalTokenizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalTokenizer.Serialization.cs @@ -5,32 +5,63 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models { - internal partial class UnknownLexicalTokenizer : IUtf8JsonSerializable + internal partial class UnknownLexicalTokenizer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); + JsonModelWriteCore(writer, options); writer.WriteEndObject(); } - internal static UnknownLexicalTokenizer DeserializeUnknownLexicalTokenizer(JsonElement element) + /// 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(LexicalTokenizer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + LexicalTokenizer 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(LexicalTokenizer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLexicalTokenizer(document.RootElement, options); + } + + internal static UnknownLexicalTokenizer DeserializeUnknownLexicalTokenizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string odataType = "Unknown"; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@odata.type"u8)) @@ -43,10 +74,46 @@ internal static UnknownLexicalTokenizer DeserializeUnknownLexicalTokenizer(JsonE name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownLexicalTokenizer(odataType, name, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(LexicalTokenizer)} does not support writing '{options.Format}' format."); } - return new UnknownLexicalTokenizer(odataType, name); } + LexicalTokenizer 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 DeserializeLexicalTokenizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LexicalTokenizer)} 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 UnknownLexicalTokenizer FromResponse(Response response) @@ -59,7 +126,7 @@ internal static UnknownLexicalTokenizer DeserializeUnknownLexicalTokenizer(JsonE internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalTokenizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalTokenizer.cs index 9226cd60fbe0..f7f03886f241 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalTokenizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownLexicalTokenizer.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models @@ -15,9 +17,15 @@ internal partial class UnknownLexicalTokenizer : LexicalTokenizer /// Initializes a new instance of . /// A URI fragment specifying the type of tokenizer. /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - internal UnknownLexicalTokenizer(string oDataType, string name) : base(oDataType, name) + /// Keeps track of any properties unknown to the library. + internal UnknownLexicalTokenizer(string oDataType, string name, IDictionary serializedAdditionalRawData) : base(oDataType, name, serializedAdditionalRawData) { ODataType = oDataType ?? "Unknown"; } + + /// Initializes a new instance of for deserialization. + internal UnknownLexicalTokenizer() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownScoringFunction.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownScoringFunction.Serialization.cs index 94a745105580..bb94d41d26ea 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownScoringFunction.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownScoringFunction.Serialization.cs @@ -5,33 +5,55 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models { - internal partial class UnknownScoringFunction : IUtf8JsonSerializable + internal partial class UnknownScoringFunction : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - writer.WritePropertyName("fieldName"u8); - writer.WriteStringValue(FieldName); - writer.WritePropertyName("boost"u8); - writer.WriteNumberValue(Boost); - if (Optional.IsDefined(Interpolation)) + 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") { - writer.WritePropertyName("interpolation"u8); - writer.WriteStringValue(Interpolation.Value.ToSerialString()); + throw new FormatException($"The model {nameof(ScoringFunction)} does not support writing '{format}' format."); } - writer.WriteEndObject(); + + base.JsonModelWriteCore(writer, options); + } + + ScoringFunction 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(ScoringFunction)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeScoringFunction(document.RootElement, options); } - internal static UnknownScoringFunction DeserializeUnknownScoringFunction(JsonElement element) + internal static UnknownScoringFunction DeserializeUnknownScoringFunction(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -40,6 +62,8 @@ internal static UnknownScoringFunction DeserializeUnknownScoringFunction(JsonEle string fieldName = default; double boost = default; ScoringFunctionInterpolation? interpolation = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("type"u8)) @@ -66,10 +90,46 @@ internal static UnknownScoringFunction DeserializeUnknownScoringFunction(JsonEle interpolation = property.Value.GetString().ToScoringFunctionInterpolation(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new UnknownScoringFunction(type, fieldName, boost, interpolation); + serializedAdditionalRawData = rawDataDictionary; + return new UnknownScoringFunction(type, fieldName, boost, interpolation, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(ScoringFunction)} does not support writing '{options.Format}' format."); + } + } + + ScoringFunction 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 DeserializeScoringFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ScoringFunction)} 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 UnknownScoringFunction FromResponse(Response response) @@ -82,7 +142,7 @@ internal static UnknownScoringFunction DeserializeUnknownScoringFunction(JsonEle internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownScoringFunction.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownScoringFunction.cs index be7ecea1451b..7bb30514a64f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownScoringFunction.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownScoringFunction.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models @@ -17,9 +19,15 @@ internal partial class UnknownScoringFunction : ScoringFunction /// The name of the field used as input to the scoring function. /// A multiplier for the raw score. Must be a positive number not equal to 1.0. /// A value indicating how boosting will be interpolated across document scores; defaults to "Linear". - internal UnknownScoringFunction(string type, string fieldName, double boost, ScoringFunctionInterpolation? interpolation) : base(type, fieldName, boost, interpolation) + /// Keeps track of any properties unknown to the library. + internal UnknownScoringFunction(string type, string fieldName, double boost, ScoringFunctionInterpolation? interpolation, IDictionary serializedAdditionalRawData) : base(type, fieldName, boost, interpolation, serializedAdditionalRawData) { Type = type ?? "Unknown"; } + + /// Initializes a new instance of for deserialization. + internal UnknownScoringFunction() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSearchIndexerDataIdentity.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSearchIndexerDataIdentity.Serialization.cs index b72d66c1d05b..e3ef11d43ab7 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSearchIndexerDataIdentity.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSearchIndexerDataIdentity.Serialization.cs @@ -5,29 +5,62 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models { - internal partial class UnknownSearchIndexerDataIdentity : IUtf8JsonSerializable + internal partial class UnknownSearchIndexerDataIdentity : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); + JsonModelWriteCore(writer, options); writer.WriteEndObject(); } - internal static UnknownSearchIndexerDataIdentity DeserializeUnknownSearchIndexerDataIdentity(JsonElement element) + /// 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(SearchIndexerDataIdentity)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + SearchIndexerDataIdentity 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(SearchIndexerDataIdentity)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndexerDataIdentity(document.RootElement, options); + } + + internal static UnknownSearchIndexerDataIdentity DeserializeUnknownSearchIndexerDataIdentity(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string odataType = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@odata.type"u8)) @@ -35,10 +68,46 @@ internal static UnknownSearchIndexerDataIdentity DeserializeUnknownSearchIndexer odataType = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownSearchIndexerDataIdentity(odataType, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndexerDataIdentity)} does not support writing '{options.Format}' format."); } - return new UnknownSearchIndexerDataIdentity(odataType); } + SearchIndexerDataIdentity 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 DeserializeSearchIndexerDataIdentity(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndexerDataIdentity)} 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 UnknownSearchIndexerDataIdentity FromResponse(Response response) @@ -51,7 +120,7 @@ internal static UnknownSearchIndexerDataIdentity DeserializeUnknownSearchIndexer internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSearchIndexerDataIdentity.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSearchIndexerDataIdentity.cs index 157a2a33f0ae..6d89cd670c80 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSearchIndexerDataIdentity.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSearchIndexerDataIdentity.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models @@ -14,9 +16,15 @@ internal partial class UnknownSearchIndexerDataIdentity : SearchIndexerDataIdent { /// Initializes a new instance of . /// A URI fragment specifying the type of identity. - internal UnknownSearchIndexerDataIdentity(string oDataType) : base(oDataType) + /// Keeps track of any properties unknown to the library. + internal UnknownSearchIndexerDataIdentity(string oDataType, IDictionary serializedAdditionalRawData) : base(oDataType, serializedAdditionalRawData) { ODataType = oDataType ?? "Unknown"; } + + /// Initializes a new instance of for deserialization. + internal UnknownSearchIndexerDataIdentity() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSearchIndexerSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSearchIndexerSkill.Serialization.cs index d11847d96a18..faf2e397e0ec 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSearchIndexerSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSearchIndexerSkill.Serialization.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; @@ -12,47 +14,46 @@ namespace Azure.Search.Documents.Models { - internal partial class UnknownSearchIndexerSkill : IUtf8JsonSerializable + internal partial class UnknownSearchIndexerSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) + 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") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(SearchIndexerSkill)} does not support writing '{format}' format."); } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + + base.JsonModelWriteCore(writer, options); + } + + SearchIndexerSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(SearchIndexerSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchIndexerSkill(document.RootElement, options); } - internal static UnknownSearchIndexerSkill DeserializeUnknownSearchIndexerSkill(JsonElement element) + internal static UnknownSearchIndexerSkill DeserializeUnknownSearchIndexerSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -63,6 +64,8 @@ internal static UnknownSearchIndexerSkill DeserializeUnknownSearchIndexerSkill(J string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@odata.type"u8)) @@ -90,7 +93,7 @@ internal static UnknownSearchIndexerSkill DeserializeUnknownSearchIndexerSkill(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -100,21 +103,58 @@ internal static UnknownSearchIndexerSkill DeserializeUnknownSearchIndexerSkill(J List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new UnknownSearchIndexerSkill( odataType, name, description, context, inputs, - outputs); + outputs, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SearchIndexerSkill)} does not support writing '{options.Format}' format."); + } + } + + SearchIndexerSkill 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 DeserializeSearchIndexerSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchIndexerSkill)} 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 UnknownSearchIndexerSkill FromResponse(Response response) @@ -127,7 +167,7 @@ internal static UnknownSearchIndexerSkill DeserializeUnknownSearchIndexerSkill(J internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSearchIndexerSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSearchIndexerSkill.cs index b64f1b8f6216..4bab9d09a5c9 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSearchIndexerSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSearchIndexerSkill.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Search.Documents.Indexes.Models; @@ -20,9 +21,15 @@ internal partial class UnknownSearchIndexerSkill : SearchIndexerSkill /// Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. - internal UnknownSearchIndexerSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs) : base(oDataType, name, description, context, inputs, outputs) + /// Keeps track of any properties unknown to the library. + internal UnknownSearchIndexerSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { ODataType = oDataType ?? "Unknown"; } + + /// Initializes a new instance of for deserialization. + internal UnknownSearchIndexerSkill() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSimilarity.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSimilarity.Serialization.cs index 3499b7c9818e..aaea125173aa 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSimilarity.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSimilarity.Serialization.cs @@ -5,29 +5,62 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models { - internal partial class UnknownSimilarity : IUtf8JsonSerializable + internal partial class UnknownSimilarity : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); + JsonModelWriteCore(writer, options); writer.WriteEndObject(); } - internal static UnknownSimilarity DeserializeUnknownSimilarity(JsonElement element) + /// 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(SimilarityAlgorithm)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + SimilarityAlgorithm 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(SimilarityAlgorithm)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSimilarityAlgorithm(document.RootElement, options); + } + + internal static UnknownSimilarity DeserializeUnknownSimilarity(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string odataType = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@odata.type"u8)) @@ -35,10 +68,46 @@ internal static UnknownSimilarity DeserializeUnknownSimilarity(JsonElement eleme odataType = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownSimilarity(odataType, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(SimilarityAlgorithm)} does not support writing '{options.Format}' format."); } - return new UnknownSimilarity(odataType); } + SimilarityAlgorithm 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 DeserializeSimilarityAlgorithm(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SimilarityAlgorithm)} 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 UnknownSimilarity FromResponse(Response response) @@ -51,7 +120,7 @@ internal static UnknownSimilarity DeserializeUnknownSimilarity(JsonElement eleme internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSimilarity.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSimilarity.cs index cd61c179185e..00f2812f61c1 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSimilarity.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownSimilarity.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models @@ -14,9 +16,15 @@ internal partial class UnknownSimilarity : SimilarityAlgorithm { /// Initializes a new instance of . /// - internal UnknownSimilarity(string oDataType) : base(oDataType) + /// Keeps track of any properties unknown to the library. + internal UnknownSimilarity(string oDataType, IDictionary serializedAdditionalRawData) : base(oDataType, serializedAdditionalRawData) { ODataType = oDataType ?? "Unknown"; } + + /// Initializes a new instance of for deserialization. + internal UnknownSimilarity() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownTokenFilter.Serialization.cs index 05977962f831..c87ef889cfeb 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownTokenFilter.Serialization.cs @@ -5,32 +5,63 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models { - internal partial class UnknownTokenFilter : IUtf8JsonSerializable + internal partial class UnknownTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); + JsonModelWriteCore(writer, options); writer.WriteEndObject(); } - internal static UnknownTokenFilter DeserializeUnknownTokenFilter(JsonElement element) + /// 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(TokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + TokenFilter 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(TokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTokenFilter(document.RootElement, options); + } + + internal static UnknownTokenFilter DeserializeUnknownTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string odataType = "Unknown"; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("@odata.type"u8)) @@ -43,10 +74,46 @@ internal static UnknownTokenFilter DeserializeUnknownTokenFilter(JsonElement ele name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownTokenFilter(odataType, name, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(TokenFilter)} does not support writing '{options.Format}' format."); } - return new UnknownTokenFilter(odataType, name); } + TokenFilter 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 DeserializeTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TokenFilter)} 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 UnknownTokenFilter FromResponse(Response response) @@ -59,7 +126,7 @@ internal static UnknownTokenFilter DeserializeUnknownTokenFilter(JsonElement ele internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownTokenFilter.cs index 6e5c1f4dcd72..e3196080fabf 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownTokenFilter.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models @@ -15,9 +17,15 @@ internal partial class UnknownTokenFilter : TokenFilter /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - internal UnknownTokenFilter(string oDataType, string name) : base(oDataType, name) + /// Keeps track of any properties unknown to the library. + internal UnknownTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData) : base(oDataType, name, serializedAdditionalRawData) { ODataType = oDataType ?? "Unknown"; } + + /// Initializes a new instance of for deserialization. + internal UnknownTokenFilter() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorQuery.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorQuery.Serialization.cs index e51b467b59ed..86c866ce7a21 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorQuery.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorQuery.Serialization.cs @@ -5,63 +5,54 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Models { - internal partial class UnknownVectorQuery : IUtf8JsonSerializable + internal partial class UnknownVectorQuery : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); - if (Optional.IsDefined(KNearestNeighborsCount)) - { - writer.WritePropertyName("k"u8); - writer.WriteNumberValue(KNearestNeighborsCount.Value); - } - if (Optional.IsDefined(FieldsRaw)) - { - writer.WritePropertyName("fields"u8); - writer.WriteStringValue(FieldsRaw); - } - if (Optional.IsDefined(Exhaustive)) - { - writer.WritePropertyName("exhaustive"u8); - writer.WriteBooleanValue(Exhaustive.Value); - } - if (Optional.IsDefined(Oversampling)) - { - writer.WritePropertyName("oversampling"u8); - writer.WriteNumberValue(Oversampling.Value); - } - if (Optional.IsDefined(Weight)) - { - writer.WritePropertyName("weight"u8); - writer.WriteNumberValue(Weight.Value); - } - if (Optional.IsDefined(Threshold)) - { - writer.WritePropertyName("threshold"u8); - writer.WriteObjectValue(Threshold); - } - if (Optional.IsDefined(FilterOverride)) + 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") { - writer.WritePropertyName("filterOverride"u8); - writer.WriteStringValue(FilterOverride); + throw new FormatException($"The model {nameof(VectorQuery)} does not support writing '{format}' format."); } - if (Optional.IsDefined(PerDocumentVectorLimit)) + + base.JsonModelWriteCore(writer, options); + } + + VectorQuery IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WritePropertyName("perDocumentVectorLimit"u8); - writer.WriteNumberValue(PerDocumentVectorLimit.Value); + throw new FormatException($"The model {nameof(VectorQuery)} does not support reading '{format}' format."); } - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorQuery(document.RootElement, options); } - internal static UnknownVectorQuery DeserializeUnknownVectorQuery(JsonElement element) + internal static UnknownVectorQuery DeserializeUnknownVectorQuery(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -75,6 +66,8 @@ internal static UnknownVectorQuery DeserializeUnknownVectorQuery(JsonElement ele VectorThreshold threshold = default; string filterOverride = default; int? perDocumentVectorLimit = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("kind"u8)) @@ -129,7 +122,7 @@ internal static UnknownVectorQuery DeserializeUnknownVectorQuery(JsonElement ele { continue; } - threshold = VectorThreshold.DeserializeVectorThreshold(property.Value); + threshold = VectorThreshold.DeserializeVectorThreshold(property.Value, options); continue; } if (property.NameEquals("filterOverride"u8)) @@ -146,7 +139,12 @@ internal static UnknownVectorQuery DeserializeUnknownVectorQuery(JsonElement ele perDocumentVectorLimit = property.Value.GetInt32(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new UnknownVectorQuery( kind, k, @@ -156,9 +154,41 @@ internal static UnknownVectorQuery DeserializeUnknownVectorQuery(JsonElement ele weight, threshold, filterOverride, - perDocumentVectorLimit); + perDocumentVectorLimit, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(VectorQuery)} does not support writing '{options.Format}' format."); + } + } + + VectorQuery 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 DeserializeVectorQuery(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorQuery)} 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 UnknownVectorQuery FromResponse(Response response) @@ -171,7 +201,7 @@ internal static UnknownVectorQuery DeserializeUnknownVectorQuery(JsonElement ele internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorQuery.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorQuery.cs index f547eb43c949..c7b097f1f148 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorQuery.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorQuery.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Models { /// Unknown version of VectorQuery. @@ -24,9 +27,15 @@ internal partial class UnknownVectorQuery : VectorQuery /// /// The OData filter expression to apply to this specific vector query. If no filter expression is defined at the vector level, the expression defined in the top level filter parameter is used instead. /// Controls how many vectors can be matched from each document in a vector search query. Setting it to 1 ensures at most one vector per document is matched, guaranteeing results come from distinct documents. Setting it to 0 (unlimited) allows multiple relevant vectors from the same document to be matched. Default is 0. - internal UnknownVectorQuery(VectorQueryKind kind, int? kNearestNeighborsCount, string fieldsRaw, bool? exhaustive, double? oversampling, float? weight, VectorThreshold threshold, string filterOverride, int? perDocumentVectorLimit) : base(kind, kNearestNeighborsCount, fieldsRaw, exhaustive, oversampling, weight, threshold, filterOverride, perDocumentVectorLimit) + /// Keeps track of any properties unknown to the library. + internal UnknownVectorQuery(VectorQueryKind kind, int? kNearestNeighborsCount, string fieldsRaw, bool? exhaustive, double? oversampling, float? weight, VectorThreshold threshold, string filterOverride, int? perDocumentVectorLimit, IDictionary serializedAdditionalRawData) : base(kind, kNearestNeighborsCount, fieldsRaw, exhaustive, oversampling, weight, threshold, filterOverride, perDocumentVectorLimit, serializedAdditionalRawData) { Kind = kind; } + + /// Initializes a new instance of for deserialization. + internal UnknownVectorQuery() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchAlgorithmConfiguration.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchAlgorithmConfiguration.Serialization.cs index 82607187e8c3..949e6942ed58 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchAlgorithmConfiguration.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchAlgorithmConfiguration.Serialization.cs @@ -5,32 +5,63 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models { - internal partial class UnknownVectorSearchAlgorithmConfiguration : IUtf8JsonSerializable + internal partial class UnknownVectorSearchAlgorithmConfiguration : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); + JsonModelWriteCore(writer, options); writer.WriteEndObject(); } - internal static UnknownVectorSearchAlgorithmConfiguration DeserializeUnknownVectorSearchAlgorithmConfiguration(JsonElement element) + /// 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(VectorSearchAlgorithmConfiguration)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + VectorSearchAlgorithmConfiguration 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(VectorSearchAlgorithmConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorSearchAlgorithmConfiguration(document.RootElement, options); + } + + internal static UnknownVectorSearchAlgorithmConfiguration DeserializeUnknownVectorSearchAlgorithmConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string name = default; VectorSearchAlgorithmKind kind = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -43,10 +74,46 @@ internal static UnknownVectorSearchAlgorithmConfiguration DeserializeUnknownVect kind = new VectorSearchAlgorithmKind(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownVectorSearchAlgorithmConfiguration(name, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(VectorSearchAlgorithmConfiguration)} does not support writing '{options.Format}' format."); } - return new UnknownVectorSearchAlgorithmConfiguration(name, kind); } + VectorSearchAlgorithmConfiguration 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 DeserializeVectorSearchAlgorithmConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorSearchAlgorithmConfiguration)} 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 UnknownVectorSearchAlgorithmConfiguration FromResponse(Response response) @@ -59,7 +126,7 @@ internal static UnknownVectorSearchAlgorithmConfiguration DeserializeUnknownVect internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchAlgorithmConfiguration.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchAlgorithmConfiguration.cs index 0b83b982774a..22592f4aa4bd 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchAlgorithmConfiguration.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchAlgorithmConfiguration.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models @@ -15,9 +17,15 @@ internal partial class UnknownVectorSearchAlgorithmConfiguration : VectorSearchA /// Initializes a new instance of . /// The name to associate with this particular configuration. /// The name of the kind of algorithm being configured for use with vector search. - internal UnknownVectorSearchAlgorithmConfiguration(string name, VectorSearchAlgorithmKind kind) : base(name, kind) + /// Keeps track of any properties unknown to the library. + internal UnknownVectorSearchAlgorithmConfiguration(string name, VectorSearchAlgorithmKind kind, IDictionary serializedAdditionalRawData) : base(name, kind, serializedAdditionalRawData) { Kind = kind; } + + /// Initializes a new instance of for deserialization. + internal UnknownVectorSearchAlgorithmConfiguration() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchCompression.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchCompression.Serialization.cs index 393d0ed3a494..38e177a60eaa 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchCompression.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchCompression.Serialization.cs @@ -5,74 +5,55 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models { - internal partial class UnknownVectorSearchCompression : IUtf8JsonSerializable + internal partial class UnknownVectorSearchCompression : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(CompressionName); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); - if (Optional.IsDefined(RerankWithOriginalVectors)) + 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") { - if (RerankWithOriginalVectors != null) - { - writer.WritePropertyName("rerankWithOriginalVectors"u8); - writer.WriteBooleanValue(RerankWithOriginalVectors.Value); - } - else - { - writer.WriteNull("rerankWithOriginalVectors"); - } + throw new FormatException($"The model {nameof(VectorSearchCompression)} does not support writing '{format}' format."); } - if (Optional.IsDefined(DefaultOversampling)) - { - if (DefaultOversampling != null) - { - writer.WritePropertyName("defaultOversampling"u8); - writer.WriteNumberValue(DefaultOversampling.Value); - } - else - { - writer.WriteNull("defaultOversampling"); - } - } - if (Optional.IsDefined(RescoringOptions)) + + base.JsonModelWriteCore(writer, options); + } + + VectorSearchCompression IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - if (RescoringOptions != null) - { - writer.WritePropertyName("rescoringOptions"u8); - writer.WriteObjectValue(RescoringOptions); - } - else - { - writer.WriteNull("rescoringOptions"); - } + throw new FormatException($"The model {nameof(VectorSearchCompression)} does not support reading '{format}' format."); } - if (Optional.IsDefined(TruncationDimension)) - { - if (TruncationDimension != null) - { - writer.WritePropertyName("truncationDimension"u8); - writer.WriteNumberValue(TruncationDimension.Value); - } - else - { - writer.WriteNull("truncationDimension"); - } - } - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorSearchCompression(document.RootElement, options); } - internal static UnknownVectorSearchCompression DeserializeUnknownVectorSearchCompression(JsonElement element) + internal static UnknownVectorSearchCompression DeserializeUnknownVectorSearchCompression(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -83,6 +64,8 @@ internal static UnknownVectorSearchCompression DeserializeUnknownVectorSearchCom double? defaultOversampling = default; RescoringOptions rescoringOptions = default; int? truncationDimension = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -122,7 +105,7 @@ internal static UnknownVectorSearchCompression DeserializeUnknownVectorSearchCom rescoringOptions = null; continue; } - rescoringOptions = RescoringOptions.DeserializeRescoringOptions(property.Value); + rescoringOptions = RescoringOptions.DeserializeRescoringOptions(property.Value, options); continue; } if (property.NameEquals("truncationDimension"u8)) @@ -135,16 +118,53 @@ internal static UnknownVectorSearchCompression DeserializeUnknownVectorSearchCom truncationDimension = property.Value.GetInt32(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new UnknownVectorSearchCompression( name, kind, rerankWithOriginalVectors, defaultOversampling, rescoringOptions, - truncationDimension); + truncationDimension, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(VectorSearchCompression)} does not support writing '{options.Format}' format."); + } + } + + VectorSearchCompression 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 DeserializeVectorSearchCompression(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorSearchCompression)} 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 UnknownVectorSearchCompression FromResponse(Response response) @@ -157,7 +177,7 @@ internal static UnknownVectorSearchCompression DeserializeUnknownVectorSearchCom internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchCompression.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchCompression.cs index 612fd27720b5..8ac9ba0ec5ec 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchCompression.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchCompression.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models @@ -19,9 +21,15 @@ internal partial class UnknownVectorSearchCompression : VectorSearchCompression /// Default oversampling factor. Oversampling will internally request more documents (specified by this multiplier) in the initial search. This increases the set of results that will be reranked using recomputed similarity scores from full-precision vectors. Minimum value is 1, meaning no oversampling (1x). This parameter can only be set when rerankWithOriginalVectors is true. Higher values improve recall at the expense of latency. /// Contains the options for rescoring. /// The number of dimensions to truncate the vectors to. Truncating the vectors reduces the size of the vectors and the amount of data that needs to be transferred during search. This can save storage cost and improve search performance at the expense of recall. It should be only used for embeddings trained with Matryoshka Representation Learning (MRL) such as OpenAI text-embedding-3-large (small). The default value is null, which means no truncation. - internal UnknownVectorSearchCompression(string compressionName, VectorSearchCompressionKind kind, bool? rerankWithOriginalVectors, double? defaultOversampling, RescoringOptions rescoringOptions, int? truncationDimension) : base(compressionName, kind, rerankWithOriginalVectors, defaultOversampling, rescoringOptions, truncationDimension) + /// Keeps track of any properties unknown to the library. + internal UnknownVectorSearchCompression(string compressionName, VectorSearchCompressionKind kind, bool? rerankWithOriginalVectors, double? defaultOversampling, RescoringOptions rescoringOptions, int? truncationDimension, IDictionary serializedAdditionalRawData) : base(compressionName, kind, rerankWithOriginalVectors, defaultOversampling, rescoringOptions, truncationDimension, serializedAdditionalRawData) { Kind = kind; } + + /// Initializes a new instance of for deserialization. + internal UnknownVectorSearchCompression() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchVectorizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchVectorizer.Serialization.cs index c40b834241ad..fe8a98a7e9ca 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchVectorizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchVectorizer.Serialization.cs @@ -5,32 +5,63 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models { - internal partial class UnknownVectorSearchVectorizer : IUtf8JsonSerializable + internal partial class UnknownVectorSearchVectorizer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(VectorizerName); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); + JsonModelWriteCore(writer, options); writer.WriteEndObject(); } - internal static UnknownVectorSearchVectorizer DeserializeUnknownVectorSearchVectorizer(JsonElement element) + /// 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(VectorSearchVectorizer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + VectorSearchVectorizer 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(VectorSearchVectorizer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorSearchVectorizer(document.RootElement, options); + } + + internal static UnknownVectorSearchVectorizer DeserializeUnknownVectorSearchVectorizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } string name = default; VectorSearchVectorizerKind kind = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -43,10 +74,46 @@ internal static UnknownVectorSearchVectorizer DeserializeUnknownVectorSearchVect kind = new VectorSearchVectorizerKind(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownVectorSearchVectorizer(name, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(VectorSearchVectorizer)} does not support writing '{options.Format}' format."); } - return new UnknownVectorSearchVectorizer(name, kind); } + VectorSearchVectorizer 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 DeserializeVectorSearchVectorizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorSearchVectorizer)} 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 UnknownVectorSearchVectorizer FromResponse(Response response) @@ -59,7 +126,7 @@ internal static UnknownVectorSearchVectorizer DeserializeUnknownVectorSearchVect internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchVectorizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchVectorizer.cs index 6ade9464f87f..ef26ca6b4e3c 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchVectorizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorSearchVectorizer.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Search.Documents.Indexes.Models; namespace Azure.Search.Documents.Models @@ -15,9 +17,15 @@ internal partial class UnknownVectorSearchVectorizer : VectorSearchVectorizer /// Initializes a new instance of . /// The name to associate with this particular vectorization method. /// The name of the kind of vectorization method being configured for use with vector search. - internal UnknownVectorSearchVectorizer(string vectorizerName, VectorSearchVectorizerKind kind) : base(vectorizerName, kind) + /// Keeps track of any properties unknown to the library. + internal UnknownVectorSearchVectorizer(string vectorizerName, VectorSearchVectorizerKind kind, IDictionary serializedAdditionalRawData) : base(vectorizerName, kind, serializedAdditionalRawData) { Kind = kind; } + + /// Initializes a new instance of for deserialization. + internal UnknownVectorSearchVectorizer() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorThreshold.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorThreshold.Serialization.cs index 1ba081a81126..a36f3d425e17 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorThreshold.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorThreshold.Serialization.cs @@ -5,28 +5,61 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Models { - internal partial class UnknownVectorThreshold : IUtf8JsonSerializable + internal partial class UnknownVectorThreshold : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); + JsonModelWriteCore(writer, options); writer.WriteEndObject(); } - internal static UnknownVectorThreshold DeserializeUnknownVectorThreshold(JsonElement element) + /// 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(VectorThreshold)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + VectorThreshold 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(VectorThreshold)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorThreshold(document.RootElement, options); + } + + internal static UnknownVectorThreshold DeserializeUnknownVectorThreshold(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } VectorThresholdKind kind = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("kind"u8)) @@ -34,10 +67,46 @@ internal static UnknownVectorThreshold DeserializeUnknownVectorThreshold(JsonEle kind = new VectorThresholdKind(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownVectorThreshold(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(VectorThreshold)} does not support writing '{options.Format}' format."); } - return new UnknownVectorThreshold(kind); } + VectorThreshold 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 DeserializeVectorThreshold(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorThreshold)} 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 UnknownVectorThreshold FromResponse(Response response) @@ -50,7 +119,7 @@ internal static UnknownVectorThreshold DeserializeUnknownVectorThreshold(JsonEle internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorThreshold.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorThreshold.cs index d67082e14cae..79922b02124b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorThreshold.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/UnknownVectorThreshold.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Models { /// Unknown version of VectorThreshold. @@ -12,9 +15,15 @@ internal partial class UnknownVectorThreshold : VectorThreshold { /// Initializes a new instance of . /// The kind of threshold used to filter vector queries. - internal UnknownVectorThreshold(VectorThresholdKind kind) : base(kind) + /// Keeps track of any properties unknown to the library. + internal UnknownVectorThreshold(VectorThresholdKind kind, IDictionary serializedAdditionalRawData) : base(kind, serializedAdditionalRawData) { Kind = kind; } + + /// Initializes a new instance of for deserialization. + internal UnknownVectorThreshold() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorQuery.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorQuery.Serialization.cs index dbf46e12cfb7..227da52df1a5 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorQuery.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorQuery.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class VectorQuery : IUtf8JsonSerializable + [PersistableModelProxy(typeof(UnknownVectorQuery))] + public partial class VectorQuery : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(VectorQuery)} does not support writing '{format}' format."); + } + writer.WritePropertyName("kind"u8); writer.WriteStringValue(Kind.ToString()); if (Optional.IsDefined(KNearestNeighborsCount)) @@ -45,7 +64,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Threshold)) { writer.WritePropertyName("threshold"u8); - writer.WriteObjectValue(Threshold); + writer.WriteObjectValue(Threshold, options); } if (Optional.IsDefined(FilterOverride)) { @@ -57,11 +76,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("perDocumentVectorLimit"u8); writer.WriteNumberValue(PerDocumentVectorLimit.Value); } - writer.WriteEndObject(); + 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 + } + } } - internal static VectorQuery DeserializeVectorQuery(JsonElement element) + VectorQuery 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(VectorQuery)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorQuery(document.RootElement, options); + } + + internal static VectorQuery DeserializeVectorQuery(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -70,15 +117,46 @@ internal static VectorQuery DeserializeVectorQuery(JsonElement element) { switch (discriminator.GetString()) { - case "imageBinary": return VectorizableImageBinaryQuery.DeserializeVectorizableImageBinaryQuery(element); - case "imageUrl": return VectorizableImageUrlQuery.DeserializeVectorizableImageUrlQuery(element); - case "text": return VectorizableTextQuery.DeserializeVectorizableTextQuery(element); - case "vector": return VectorizedQuery.DeserializeVectorizedQuery(element); + case "imageBinary": return VectorizableImageBinaryQuery.DeserializeVectorizableImageBinaryQuery(element, options); + case "imageUrl": return VectorizableImageUrlQuery.DeserializeVectorizableImageUrlQuery(element, options); + case "text": return VectorizableTextQuery.DeserializeVectorizableTextQuery(element, options); + case "vector": return VectorizedQuery.DeserializeVectorizedQuery(element, options); } } - return UnknownVectorQuery.DeserializeUnknownVectorQuery(element); + return UnknownVectorQuery.DeserializeUnknownVectorQuery(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(VectorQuery)} does not support writing '{options.Format}' format."); + } + } + + VectorQuery 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 DeserializeVectorQuery(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorQuery)} 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 VectorQuery FromResponse(Response response) @@ -91,7 +169,7 @@ internal static VectorQuery FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorQuery.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorQuery.cs index 12a485032f17..a0e49eaf2461 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorQuery.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorQuery.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Models { /// @@ -14,6 +17,38 @@ namespace Azure.Search.Documents.Models /// public abstract partial class VectorQuery { + /// + /// 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 VectorQuery() { @@ -33,7 +68,8 @@ protected VectorQuery() /// /// The OData filter expression to apply to this specific vector query. If no filter expression is defined at the vector level, the expression defined in the top level filter parameter is used instead. /// Controls how many vectors can be matched from each document in a vector search query. Setting it to 1 ensures at most one vector per document is matched, guaranteeing results come from distinct documents. Setting it to 0 (unlimited) allows multiple relevant vectors from the same document to be matched. Default is 0. - internal VectorQuery(VectorQueryKind kind, int? kNearestNeighborsCount, string fieldsRaw, bool? exhaustive, double? oversampling, float? weight, VectorThreshold threshold, string filterOverride, int? perDocumentVectorLimit) + /// Keeps track of any properties unknown to the library. + internal VectorQuery(VectorQueryKind kind, int? kNearestNeighborsCount, string fieldsRaw, bool? exhaustive, double? oversampling, float? weight, VectorThreshold threshold, string filterOverride, int? perDocumentVectorLimit, IDictionary serializedAdditionalRawData) { Kind = kind; KNearestNeighborsCount = kNearestNeighborsCount; @@ -44,6 +80,7 @@ internal VectorQuery(VectorQueryKind kind, int? kNearestNeighborsCount, string f Threshold = threshold; FilterOverride = filterOverride; PerDocumentVectorLimit = perDocumentVectorLimit; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The kind of vector query being performed. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearch.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearch.Serialization.cs index 82c5b739a265..a7fddb4c029d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearch.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearch.Serialization.cs @@ -5,24 +5,42 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class VectorSearch : IUtf8JsonSerializable + public partial class VectorSearch : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(VectorSearch)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Profiles)) { writer.WritePropertyName("profiles"u8); writer.WriteStartArray(); foreach (var item in Profiles) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } @@ -32,7 +50,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in Algorithms) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } @@ -42,7 +60,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in Vectorizers) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } @@ -52,15 +70,43 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in Compressions) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - writer.WriteEndObject(); + 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 + } + } } - internal static VectorSearch DeserializeVectorSearch(JsonElement element) + VectorSearch 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(VectorSearch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorSearch(document.RootElement, options); + } + + internal static VectorSearch DeserializeVectorSearch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -69,6 +115,8 @@ internal static VectorSearch DeserializeVectorSearch(JsonElement element) IList algorithms = default; IList vectorizers = default; IList compressions = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("profiles"u8)) @@ -80,7 +128,7 @@ internal static VectorSearch DeserializeVectorSearch(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(VectorSearchProfile.DeserializeVectorSearchProfile(item)); + array.Add(VectorSearchProfile.DeserializeVectorSearchProfile(item, options)); } profiles = array; continue; @@ -94,7 +142,7 @@ internal static VectorSearch DeserializeVectorSearch(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(VectorSearchAlgorithmConfiguration.DeserializeVectorSearchAlgorithmConfiguration(item)); + array.Add(VectorSearchAlgorithmConfiguration.DeserializeVectorSearchAlgorithmConfiguration(item, options)); } algorithms = array; continue; @@ -108,7 +156,7 @@ internal static VectorSearch DeserializeVectorSearch(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(VectorSearchVectorizer.DeserializeVectorSearchVectorizer(item)); + array.Add(VectorSearchVectorizer.DeserializeVectorSearchVectorizer(item, options)); } vectorizers = array; continue; @@ -122,15 +170,51 @@ internal static VectorSearch DeserializeVectorSearch(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(VectorSearchCompression.DeserializeVectorSearchCompression(item)); + array.Add(VectorSearchCompression.DeserializeVectorSearchCompression(item, options)); } compressions = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorSearch(profiles ?? new ChangeTrackingList(), algorithms ?? new ChangeTrackingList(), vectorizers ?? new ChangeTrackingList(), compressions ?? 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(VectorSearch)} does not support writing '{options.Format}' format."); } - return new VectorSearch(profiles ?? new ChangeTrackingList(), algorithms ?? new ChangeTrackingList(), vectorizers ?? new ChangeTrackingList(), compressions ?? new ChangeTrackingList()); } + VectorSearch 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 DeserializeVectorSearch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorSearch)} 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 VectorSearch FromResponse(Response response) @@ -143,7 +227,7 @@ internal static VectorSearch FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearch.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearch.cs index c54f09fa71c6..fec9b14f58e3 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearch.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearch.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models @@ -12,6 +13,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Contains configuration options related to vector search. public partial class VectorSearch { + /// + /// 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 VectorSearch() { @@ -38,12 +71,14 @@ public VectorSearch() /// 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 . /// - internal VectorSearch(IList profiles, IList algorithms, IList vectorizers, IList compressions) + /// Keeps track of any properties unknown to the library. + internal VectorSearch(IList profiles, IList algorithms, IList vectorizers, IList compressions, IDictionary serializedAdditionalRawData) { Profiles = profiles; Algorithms = algorithms; Vectorizers = vectorizers; Compressions = compressions; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Defines combinations of configurations to use with vector search. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchAlgorithmConfiguration.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchAlgorithmConfiguration.Serialization.cs index 3009dc29d84c..7fa76d50cab2 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchAlgorithmConfiguration.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchAlgorithmConfiguration.Serialization.cs @@ -5,26 +5,73 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Indexes.Models { - public partial class VectorSearchAlgorithmConfiguration : IUtf8JsonSerializable + [PersistableModelProxy(typeof(UnknownVectorSearchAlgorithmConfiguration))] + public partial class VectorSearchAlgorithmConfiguration : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(VectorSearchAlgorithmConfiguration)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); writer.WritePropertyName("kind"u8); writer.WriteStringValue(Kind.ToString()); - writer.WriteEndObject(); + 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 + } + } } - internal static VectorSearchAlgorithmConfiguration DeserializeVectorSearchAlgorithmConfiguration(JsonElement element) + VectorSearchAlgorithmConfiguration 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(VectorSearchAlgorithmConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorSearchAlgorithmConfiguration(document.RootElement, options); + } + + internal static VectorSearchAlgorithmConfiguration DeserializeVectorSearchAlgorithmConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -33,13 +80,44 @@ internal static VectorSearchAlgorithmConfiguration DeserializeVectorSearchAlgori { switch (discriminator.GetString()) { - case "exhaustiveKnn": return ExhaustiveKnnAlgorithmConfiguration.DeserializeExhaustiveKnnAlgorithmConfiguration(element); - case "hnsw": return HnswAlgorithmConfiguration.DeserializeHnswAlgorithmConfiguration(element); + case "exhaustiveKnn": return ExhaustiveKnnAlgorithmConfiguration.DeserializeExhaustiveKnnAlgorithmConfiguration(element, options); + case "hnsw": return HnswAlgorithmConfiguration.DeserializeHnswAlgorithmConfiguration(element, options); } } - return UnknownVectorSearchAlgorithmConfiguration.DeserializeUnknownVectorSearchAlgorithmConfiguration(element); + return UnknownVectorSearchAlgorithmConfiguration.DeserializeUnknownVectorSearchAlgorithmConfiguration(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(VectorSearchAlgorithmConfiguration)} does not support writing '{options.Format}' format."); + } + } + + VectorSearchAlgorithmConfiguration 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 DeserializeVectorSearchAlgorithmConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorSearchAlgorithmConfiguration)} 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 VectorSearchAlgorithmConfiguration FromResponse(Response response) @@ -52,7 +130,7 @@ internal static VectorSearchAlgorithmConfiguration FromResponse(Response respons internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchAlgorithmConfiguration.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchAlgorithmConfiguration.cs index 45e666a245a2..6e6363ae6f7b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchAlgorithmConfiguration.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchAlgorithmConfiguration.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -16,6 +17,38 @@ namespace Azure.Search.Documents.Indexes.Models /// public abstract partial class VectorSearchAlgorithmConfiguration { + /// + /// 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 . /// The name to associate with this particular configuration. /// is null. @@ -29,10 +62,17 @@ protected VectorSearchAlgorithmConfiguration(string name) /// Initializes a new instance of . /// The name to associate with this particular configuration. /// The name of the kind of algorithm being configured for use with vector search. - internal VectorSearchAlgorithmConfiguration(string name, VectorSearchAlgorithmKind kind) + /// Keeps track of any properties unknown to the library. + internal VectorSearchAlgorithmConfiguration(string name, VectorSearchAlgorithmKind kind, IDictionary serializedAdditionalRawData) { Name = name; Kind = kind; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorSearchAlgorithmConfiguration() + { } /// The name to associate with this particular configuration. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchCompression.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchCompression.Serialization.cs index 71de5c7b0d7d..e801aa56fe1f 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchCompression.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchCompression.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Indexes.Models { - public partial class VectorSearchCompression : IUtf8JsonSerializable + [PersistableModelProxy(typeof(UnknownVectorSearchCompression))] + public partial class VectorSearchCompression : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(VectorSearchCompression)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); writer.WriteStringValue(CompressionName); writer.WritePropertyName("kind"u8); @@ -49,7 +68,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (RescoringOptions != null) { writer.WritePropertyName("rescoringOptions"u8); - writer.WriteObjectValue(RescoringOptions); + writer.WriteObjectValue(RescoringOptions, options); } else { @@ -68,11 +87,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNull("truncationDimension"); } } - writer.WriteEndObject(); + 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 + } + } } - internal static VectorSearchCompression DeserializeVectorSearchCompression(JsonElement element) + VectorSearchCompression 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(VectorSearchCompression)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorSearchCompression(document.RootElement, options); + } + + internal static VectorSearchCompression DeserializeVectorSearchCompression(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -81,13 +128,44 @@ internal static VectorSearchCompression DeserializeVectorSearchCompression(JsonE { switch (discriminator.GetString()) { - case "binaryQuantization": return BinaryQuantizationCompression.DeserializeBinaryQuantizationCompression(element); - case "scalarQuantization": return ScalarQuantizationCompression.DeserializeScalarQuantizationCompression(element); + case "binaryQuantization": return BinaryQuantizationCompression.DeserializeBinaryQuantizationCompression(element, options); + case "scalarQuantization": return ScalarQuantizationCompression.DeserializeScalarQuantizationCompression(element, options); } } - return UnknownVectorSearchCompression.DeserializeUnknownVectorSearchCompression(element); + return UnknownVectorSearchCompression.DeserializeUnknownVectorSearchCompression(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(VectorSearchCompression)} does not support writing '{options.Format}' format."); + } + } + + VectorSearchCompression 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 DeserializeVectorSearchCompression(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorSearchCompression)} 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 VectorSearchCompression FromResponse(Response response) @@ -100,7 +178,7 @@ internal static VectorSearchCompression FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchCompression.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchCompression.cs index d0b140a9f607..304104e94c55 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchCompression.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchCompression.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -16,6 +17,38 @@ namespace Azure.Search.Documents.Indexes.Models /// public abstract partial class VectorSearchCompression { + /// + /// 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 . /// The name to associate with this particular configuration. /// is null. @@ -33,7 +66,8 @@ protected VectorSearchCompression(string compressionName) /// Default oversampling factor. Oversampling will internally request more documents (specified by this multiplier) in the initial search. This increases the set of results that will be reranked using recomputed similarity scores from full-precision vectors. Minimum value is 1, meaning no oversampling (1x). This parameter can only be set when rerankWithOriginalVectors is true. Higher values improve recall at the expense of latency. /// Contains the options for rescoring. /// The number of dimensions to truncate the vectors to. Truncating the vectors reduces the size of the vectors and the amount of data that needs to be transferred during search. This can save storage cost and improve search performance at the expense of recall. It should be only used for embeddings trained with Matryoshka Representation Learning (MRL) such as OpenAI text-embedding-3-large (small). The default value is null, which means no truncation. - internal VectorSearchCompression(string compressionName, VectorSearchCompressionKind kind, bool? rerankWithOriginalVectors, double? defaultOversampling, RescoringOptions rescoringOptions, int? truncationDimension) + /// Keeps track of any properties unknown to the library. + internal VectorSearchCompression(string compressionName, VectorSearchCompressionKind kind, bool? rerankWithOriginalVectors, double? defaultOversampling, RescoringOptions rescoringOptions, int? truncationDimension, IDictionary serializedAdditionalRawData) { CompressionName = compressionName; Kind = kind; @@ -41,6 +75,12 @@ internal VectorSearchCompression(string compressionName, VectorSearchCompression DefaultOversampling = defaultOversampling; RescoringOptions = rescoringOptions; TruncationDimension = truncationDimension; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorSearchCompression() + { } /// The name of the kind of compression method being configured for use with vector search. internal VectorSearchCompressionKind Kind { get; set; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchProfile.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchProfile.Serialization.cs index 7d1ecb943e04..9ddecf30b6ac 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchProfile.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchProfile.Serialization.cs @@ -5,16 +5,35 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class VectorSearchProfile : IUtf8JsonSerializable + public partial class VectorSearchProfile : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(VectorSearchProfile)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); writer.WritePropertyName("algorithm"u8); @@ -29,11 +48,39 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("compression"u8); writer.WriteStringValue(CompressionName); } - writer.WriteEndObject(); + 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 + } + } } - internal static VectorSearchProfile DeserializeVectorSearchProfile(JsonElement element) + VectorSearchProfile 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(VectorSearchProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorSearchProfile(document.RootElement, options); + } + + internal static VectorSearchProfile DeserializeVectorSearchProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -42,6 +89,8 @@ internal static VectorSearchProfile DeserializeVectorSearchProfile(JsonElement e string algorithm = default; string vectorizer = default; string compression = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -64,10 +113,46 @@ internal static VectorSearchProfile DeserializeVectorSearchProfile(JsonElement e compression = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new VectorSearchProfile(name, algorithm, vectorizer, compression); + serializedAdditionalRawData = rawDataDictionary; + return new VectorSearchProfile(name, algorithm, vectorizer, compression, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(VectorSearchProfile)} does not support writing '{options.Format}' format."); + } + } + + VectorSearchProfile 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 DeserializeVectorSearchProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorSearchProfile)} 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 VectorSearchProfile FromResponse(Response response) @@ -80,7 +165,7 @@ internal static VectorSearchProfile FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchProfile.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchProfile.cs index fc545f7077ba..7329b2096c60 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchProfile.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchProfile.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// Defines a combination of configurations to use with vector search. public partial class VectorSearchProfile { + /// + /// 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 . /// The name to associate with this particular vector search profile. /// The name of the vector search algorithm configuration that specifies the algorithm and optional parameters. @@ -30,12 +63,19 @@ public VectorSearchProfile(string name, string algorithmConfigurationName) /// The name of the vector search algorithm configuration that specifies the algorithm and optional parameters. /// The name of the vectorization being configured for use with vector search. /// The name of the compression method configuration that specifies the compression method and optional parameters. - internal VectorSearchProfile(string name, string algorithmConfigurationName, string vectorizerName, string compressionName) + /// Keeps track of any properties unknown to the library. + internal VectorSearchProfile(string name, string algorithmConfigurationName, string vectorizerName, string compressionName, IDictionary serializedAdditionalRawData) { Name = name; AlgorithmConfigurationName = algorithmConfigurationName; VectorizerName = vectorizerName; CompressionName = compressionName; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorSearchProfile() + { } /// The name to associate with this particular vector search profile. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchVectorizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchVectorizer.Serialization.cs index ec0d340d8b41..755ac2d5aa72 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchVectorizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchVectorizer.Serialization.cs @@ -5,26 +5,73 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Indexes.Models { - public partial class VectorSearchVectorizer : IUtf8JsonSerializable + [PersistableModelProxy(typeof(UnknownVectorSearchVectorizer))] + public partial class VectorSearchVectorizer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(VectorSearchVectorizer)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); writer.WriteStringValue(VectorizerName); writer.WritePropertyName("kind"u8); writer.WriteStringValue(Kind.ToString()); - writer.WriteEndObject(); + 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 + } + } } - internal static VectorSearchVectorizer DeserializeVectorSearchVectorizer(JsonElement element) + VectorSearchVectorizer 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(VectorSearchVectorizer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorSearchVectorizer(document.RootElement, options); + } + + internal static VectorSearchVectorizer DeserializeVectorSearchVectorizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -33,15 +80,46 @@ internal static VectorSearchVectorizer DeserializeVectorSearchVectorizer(JsonEle { switch (discriminator.GetString()) { - case "aiServicesVision": return AIServicesVisionVectorizer.DeserializeAIServicesVisionVectorizer(element); - case "aml": return AzureMachineLearningVectorizer.DeserializeAzureMachineLearningVectorizer(element); - case "azureOpenAI": return AzureOpenAIVectorizer.DeserializeAzureOpenAIVectorizer(element); - case "customWebApi": return WebApiVectorizer.DeserializeWebApiVectorizer(element); + case "aiServicesVision": return AIServicesVisionVectorizer.DeserializeAIServicesVisionVectorizer(element, options); + case "aml": return AzureMachineLearningVectorizer.DeserializeAzureMachineLearningVectorizer(element, options); + case "azureOpenAI": return AzureOpenAIVectorizer.DeserializeAzureOpenAIVectorizer(element, options); + case "customWebApi": return WebApiVectorizer.DeserializeWebApiVectorizer(element, options); } } - return UnknownVectorSearchVectorizer.DeserializeUnknownVectorSearchVectorizer(element); + return UnknownVectorSearchVectorizer.DeserializeUnknownVectorSearchVectorizer(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(VectorSearchVectorizer)} does not support writing '{options.Format}' format."); + } + } + + VectorSearchVectorizer 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 DeserializeVectorSearchVectorizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorSearchVectorizer)} 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 VectorSearchVectorizer FromResponse(Response response) @@ -54,7 +132,7 @@ internal static VectorSearchVectorizer FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchVectorizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchVectorizer.cs index 06fbd0664c38..3fe1216977a0 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchVectorizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSearchVectorizer.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -16,6 +17,38 @@ namespace Azure.Search.Documents.Indexes.Models /// public abstract partial class VectorSearchVectorizer { + /// + /// 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 . /// The name to associate with this particular vectorization method. /// is null. @@ -29,10 +62,17 @@ protected VectorSearchVectorizer(string vectorizerName) /// Initializes a new instance of . /// The name to associate with this particular vectorization method. /// The name of the kind of vectorization method being configured for use with vector search. - internal VectorSearchVectorizer(string vectorizerName, VectorSearchVectorizerKind kind) + /// Keeps track of any properties unknown to the library. + internal VectorSearchVectorizer(string vectorizerName, VectorSearchVectorizerKind kind, IDictionary serializedAdditionalRawData) { VectorizerName = vectorizerName; Kind = kind; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorSearchVectorizer() + { } /// The name of the kind of vectorization method being configured for use with vector search. internal VectorSearchVectorizerKind Kind { get; set; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSimilarityThreshold.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSimilarityThreshold.Serialization.cs index a9450d15337e..6ae90372afc5 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSimilarityThreshold.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSimilarityThreshold.Serialization.cs @@ -5,31 +5,64 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class VectorSimilarityThreshold : IUtf8JsonSerializable + public partial class VectorSimilarityThreshold : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(VectorSimilarityThreshold)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("value"u8); writer.WriteNumberValue(Value); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); - writer.WriteEndObject(); } - internal static VectorSimilarityThreshold DeserializeVectorSimilarityThreshold(JsonElement element) + VectorSimilarityThreshold 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(VectorSimilarityThreshold)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorSimilarityThreshold(document.RootElement, options); + } + + internal static VectorSimilarityThreshold DeserializeVectorSimilarityThreshold(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } double value = default; VectorThresholdKind kind = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value"u8)) @@ -42,10 +75,46 @@ internal static VectorSimilarityThreshold DeserializeVectorSimilarityThreshold(J kind = new VectorThresholdKind(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorSimilarityThreshold(kind, serializedAdditionalRawData, value); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(VectorSimilarityThreshold)} does not support writing '{options.Format}' format."); } - return new VectorSimilarityThreshold(kind, value); } + VectorSimilarityThreshold 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 DeserializeVectorSimilarityThreshold(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorSimilarityThreshold)} 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 VectorSimilarityThreshold FromResponse(Response response) @@ -58,7 +127,7 @@ internal static VectorSimilarityThreshold DeserializeVectorSimilarityThreshold(J internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSimilarityThreshold.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSimilarityThreshold.cs index 404a47badb0a..c906ba41f1d8 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSimilarityThreshold.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorSimilarityThreshold.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Models { /// The results of the vector query will be filtered based on the vector similarity metric. Note this is the canonical definition of similarity metric, not the 'distance' version. The threshold direction (larger or smaller) will be chosen automatically according to the metric used by the field. @@ -20,13 +23,19 @@ public VectorSimilarityThreshold(double value) /// Initializes a new instance of . /// The kind of threshold used to filter vector queries. + /// Keeps track of any properties unknown to the library. /// The threshold will filter based on the similarity metric value. Note this is the canonical definition of similarity metric, not the 'distance' version. The threshold direction (larger or smaller) will be chosen automatically according to the metric used by the field. - internal VectorSimilarityThreshold(VectorThresholdKind kind, double value) : base(kind) + internal VectorSimilarityThreshold(VectorThresholdKind kind, IDictionary serializedAdditionalRawData, double value) : base(kind, serializedAdditionalRawData) { Value = value; Kind = kind; } + /// Initializes a new instance of for deserialization. + internal VectorSimilarityThreshold() + { + } + /// The threshold will filter based on the similarity metric value. Note this is the canonical definition of similarity metric, not the 'distance' version. The threshold direction (larger or smaller) will be chosen automatically according to the metric used by the field. public double Value { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorThreshold.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorThreshold.Serialization.cs index d83bad7f20ca..5919e6524483 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorThreshold.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorThreshold.Serialization.cs @@ -5,23 +5,70 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class VectorThreshold : IUtf8JsonSerializable + [PersistableModelProxy(typeof(UnknownVectorThreshold))] + public partial class VectorThreshold : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(VectorThreshold)} does not support writing '{format}' format."); + } + writer.WritePropertyName("kind"u8); writer.WriteStringValue(Kind.ToString()); - writer.WriteEndObject(); + 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 + } + } } - internal static VectorThreshold DeserializeVectorThreshold(JsonElement element) + VectorThreshold 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(VectorThreshold)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorThreshold(document.RootElement, options); + } + + internal static VectorThreshold DeserializeVectorThreshold(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -30,13 +77,44 @@ internal static VectorThreshold DeserializeVectorThreshold(JsonElement element) { switch (discriminator.GetString()) { - case "searchScore": return SearchScoreThreshold.DeserializeSearchScoreThreshold(element); - case "vectorSimilarity": return VectorSimilarityThreshold.DeserializeVectorSimilarityThreshold(element); + case "searchScore": return SearchScoreThreshold.DeserializeSearchScoreThreshold(element, options); + case "vectorSimilarity": return VectorSimilarityThreshold.DeserializeVectorSimilarityThreshold(element, options); } } - return UnknownVectorThreshold.DeserializeUnknownVectorThreshold(element); + return UnknownVectorThreshold.DeserializeUnknownVectorThreshold(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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(VectorThreshold)} does not support writing '{options.Format}' format."); + } + } + + VectorThreshold 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 DeserializeVectorThreshold(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorThreshold)} 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 VectorThreshold FromResponse(Response response) @@ -49,7 +127,7 @@ internal static VectorThreshold FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorThreshold.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorThreshold.cs index d02a782f340c..c9644148dc27 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorThreshold.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorThreshold.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Models { /// @@ -14,6 +17,38 @@ namespace Azure.Search.Documents.Models /// public abstract partial class VectorThreshold { + /// + /// 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 VectorThreshold() { @@ -21,9 +56,11 @@ protected VectorThreshold() /// Initializes a new instance of . /// The kind of threshold used to filter vector queries. - internal VectorThreshold(VectorThresholdKind kind) + /// Keeps track of any properties unknown to the library. + internal VectorThreshold(VectorThresholdKind kind, IDictionary serializedAdditionalRawData) { Kind = kind; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The kind of threshold used to filter vector queries. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableImageBinaryQuery.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableImageBinaryQuery.Serialization.cs index da22d72fba54..5407e30e7999 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableImageBinaryQuery.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableImageBinaryQuery.Serialization.cs @@ -5,68 +5,59 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class VectorizableImageBinaryQuery : IUtf8JsonSerializable + public partial class VectorizableImageBinaryQuery : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(VectorizableImageBinaryQuery)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Base64Image)) { writer.WritePropertyName("base64Image"u8); writer.WriteStringValue(Base64Image); } - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); - if (Optional.IsDefined(KNearestNeighborsCount)) - { - writer.WritePropertyName("k"u8); - writer.WriteNumberValue(KNearestNeighborsCount.Value); - } - if (Optional.IsDefined(FieldsRaw)) - { - writer.WritePropertyName("fields"u8); - writer.WriteStringValue(FieldsRaw); - } - if (Optional.IsDefined(Exhaustive)) - { - writer.WritePropertyName("exhaustive"u8); - writer.WriteBooleanValue(Exhaustive.Value); - } - if (Optional.IsDefined(Oversampling)) - { - writer.WritePropertyName("oversampling"u8); - writer.WriteNumberValue(Oversampling.Value); - } - if (Optional.IsDefined(Weight)) - { - writer.WritePropertyName("weight"u8); - writer.WriteNumberValue(Weight.Value); - } - if (Optional.IsDefined(Threshold)) - { - writer.WritePropertyName("threshold"u8); - writer.WriteObjectValue(Threshold); - } - if (Optional.IsDefined(FilterOverride)) - { - writer.WritePropertyName("filterOverride"u8); - writer.WriteStringValue(FilterOverride); - } - if (Optional.IsDefined(PerDocumentVectorLimit)) + } + + VectorizableImageBinaryQuery IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WritePropertyName("perDocumentVectorLimit"u8); - writer.WriteNumberValue(PerDocumentVectorLimit.Value); + throw new FormatException($"The model {nameof(VectorizableImageBinaryQuery)} does not support reading '{format}' format."); } - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorizableImageBinaryQuery(document.RootElement, options); } - internal static VectorizableImageBinaryQuery DeserializeVectorizableImageBinaryQuery(JsonElement element) + internal static VectorizableImageBinaryQuery DeserializeVectorizableImageBinaryQuery(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -81,6 +72,8 @@ internal static VectorizableImageBinaryQuery DeserializeVectorizableImageBinaryQ VectorThreshold threshold = default; string filterOverride = default; int? perDocumentVectorLimit = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("base64Image"u8)) @@ -140,7 +133,7 @@ internal static VectorizableImageBinaryQuery DeserializeVectorizableImageBinaryQ { continue; } - threshold = VectorThreshold.DeserializeVectorThreshold(property.Value); + threshold = VectorThreshold.DeserializeVectorThreshold(property.Value, options); continue; } if (property.NameEquals("filterOverride"u8)) @@ -157,7 +150,12 @@ internal static VectorizableImageBinaryQuery DeserializeVectorizableImageBinaryQ perDocumentVectorLimit = property.Value.GetInt32(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new VectorizableImageBinaryQuery( kind, k, @@ -168,9 +166,41 @@ internal static VectorizableImageBinaryQuery DeserializeVectorizableImageBinaryQ threshold, filterOverride, perDocumentVectorLimit, + serializedAdditionalRawData, base64Image); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(VectorizableImageBinaryQuery)} does not support writing '{options.Format}' format."); + } + } + + VectorizableImageBinaryQuery 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 DeserializeVectorizableImageBinaryQuery(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorizableImageBinaryQuery)} 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 VectorizableImageBinaryQuery FromResponse(Response response) @@ -183,7 +213,7 @@ internal static VectorizableImageBinaryQuery DeserializeVectorizableImageBinaryQ internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableImageBinaryQuery.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableImageBinaryQuery.cs index 47abdc7c1932..957d9e328b8a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableImageBinaryQuery.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableImageBinaryQuery.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Models { /// The query parameters to use for vector search when a base 64 encoded binary of an image that needs to be vectorized is provided. @@ -30,8 +33,9 @@ public VectorizableImageBinaryQuery() /// /// The OData filter expression to apply to this specific vector query. If no filter expression is defined at the vector level, the expression defined in the top level filter parameter is used instead. /// Controls how many vectors can be matched from each document in a vector search query. Setting it to 1 ensures at most one vector per document is matched, guaranteeing results come from distinct documents. Setting it to 0 (unlimited) allows multiple relevant vectors from the same document to be matched. Default is 0. + /// Keeps track of any properties unknown to the library. /// The base 64 encoded binary of an image to be vectorized to perform a vector search query. - internal VectorizableImageBinaryQuery(VectorQueryKind kind, int? kNearestNeighborsCount, string fieldsRaw, bool? exhaustive, double? oversampling, float? weight, VectorThreshold threshold, string filterOverride, int? perDocumentVectorLimit, string base64Image) : base(kind, kNearestNeighborsCount, fieldsRaw, exhaustive, oversampling, weight, threshold, filterOverride, perDocumentVectorLimit) + internal VectorizableImageBinaryQuery(VectorQueryKind kind, int? kNearestNeighborsCount, string fieldsRaw, bool? exhaustive, double? oversampling, float? weight, VectorThreshold threshold, string filterOverride, int? perDocumentVectorLimit, IDictionary serializedAdditionalRawData, string base64Image) : base(kind, kNearestNeighborsCount, fieldsRaw, exhaustive, oversampling, weight, threshold, filterOverride, perDocumentVectorLimit, serializedAdditionalRawData) { Base64Image = base64Image; Kind = kind; diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableImageUrlQuery.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableImageUrlQuery.Serialization.cs index 87a9acbe2fa6..f6eada8a61d5 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableImageUrlQuery.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableImageUrlQuery.Serialization.cs @@ -6,68 +6,58 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class VectorizableImageUrlQuery : IUtf8JsonSerializable + public partial class VectorizableImageUrlQuery : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(VectorizableImageUrlQuery)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Url)) { writer.WritePropertyName("url"u8); writer.WriteStringValue(Url.AbsoluteUri); } - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); - if (Optional.IsDefined(KNearestNeighborsCount)) - { - writer.WritePropertyName("k"u8); - writer.WriteNumberValue(KNearestNeighborsCount.Value); - } - if (Optional.IsDefined(FieldsRaw)) - { - writer.WritePropertyName("fields"u8); - writer.WriteStringValue(FieldsRaw); - } - if (Optional.IsDefined(Exhaustive)) - { - writer.WritePropertyName("exhaustive"u8); - writer.WriteBooleanValue(Exhaustive.Value); - } - if (Optional.IsDefined(Oversampling)) - { - writer.WritePropertyName("oversampling"u8); - writer.WriteNumberValue(Oversampling.Value); - } - if (Optional.IsDefined(Weight)) - { - writer.WritePropertyName("weight"u8); - writer.WriteNumberValue(Weight.Value); - } - if (Optional.IsDefined(Threshold)) - { - writer.WritePropertyName("threshold"u8); - writer.WriteObjectValue(Threshold); - } - if (Optional.IsDefined(FilterOverride)) - { - writer.WritePropertyName("filterOverride"u8); - writer.WriteStringValue(FilterOverride); - } - if (Optional.IsDefined(PerDocumentVectorLimit)) + } + + VectorizableImageUrlQuery IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WritePropertyName("perDocumentVectorLimit"u8); - writer.WriteNumberValue(PerDocumentVectorLimit.Value); + throw new FormatException($"The model {nameof(VectorizableImageUrlQuery)} does not support reading '{format}' format."); } - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorizableImageUrlQuery(document.RootElement, options); } - internal static VectorizableImageUrlQuery DeserializeVectorizableImageUrlQuery(JsonElement element) + internal static VectorizableImageUrlQuery DeserializeVectorizableImageUrlQuery(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -82,6 +72,8 @@ internal static VectorizableImageUrlQuery DeserializeVectorizableImageUrlQuery(J VectorThreshold threshold = default; string filterOverride = default; int? perDocumentVectorLimit = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("url"u8)) @@ -145,7 +137,7 @@ internal static VectorizableImageUrlQuery DeserializeVectorizableImageUrlQuery(J { continue; } - threshold = VectorThreshold.DeserializeVectorThreshold(property.Value); + threshold = VectorThreshold.DeserializeVectorThreshold(property.Value, options); continue; } if (property.NameEquals("filterOverride"u8)) @@ -162,7 +154,12 @@ internal static VectorizableImageUrlQuery DeserializeVectorizableImageUrlQuery(J perDocumentVectorLimit = property.Value.GetInt32(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new VectorizableImageUrlQuery( kind, k, @@ -173,9 +170,41 @@ internal static VectorizableImageUrlQuery DeserializeVectorizableImageUrlQuery(J threshold, filterOverride, perDocumentVectorLimit, + serializedAdditionalRawData, url); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(VectorizableImageUrlQuery)} does not support writing '{options.Format}' format."); + } + } + + VectorizableImageUrlQuery 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 DeserializeVectorizableImageUrlQuery(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorizableImageUrlQuery)} 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 VectorizableImageUrlQuery FromResponse(Response response) @@ -188,7 +217,7 @@ internal static VectorizableImageUrlQuery DeserializeVectorizableImageUrlQuery(J internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableImageUrlQuery.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableImageUrlQuery.cs index f5e9a7c00bdb..e974ac164588 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableImageUrlQuery.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableImageUrlQuery.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Models { @@ -32,8 +33,9 @@ public VectorizableImageUrlQuery() /// /// The OData filter expression to apply to this specific vector query. If no filter expression is defined at the vector level, the expression defined in the top level filter parameter is used instead. /// Controls how many vectors can be matched from each document in a vector search query. Setting it to 1 ensures at most one vector per document is matched, guaranteeing results come from distinct documents. Setting it to 0 (unlimited) allows multiple relevant vectors from the same document to be matched. Default is 0. + /// Keeps track of any properties unknown to the library. /// The URL of an image to be vectorized to perform a vector search query. - internal VectorizableImageUrlQuery(VectorQueryKind kind, int? kNearestNeighborsCount, string fieldsRaw, bool? exhaustive, double? oversampling, float? weight, VectorThreshold threshold, string filterOverride, int? perDocumentVectorLimit, Uri url) : base(kind, kNearestNeighborsCount, fieldsRaw, exhaustive, oversampling, weight, threshold, filterOverride, perDocumentVectorLimit) + internal VectorizableImageUrlQuery(VectorQueryKind kind, int? kNearestNeighborsCount, string fieldsRaw, bool? exhaustive, double? oversampling, float? weight, VectorThreshold threshold, string filterOverride, int? perDocumentVectorLimit, IDictionary serializedAdditionalRawData, Uri url) : base(kind, kNearestNeighborsCount, fieldsRaw, exhaustive, oversampling, weight, threshold, filterOverride, perDocumentVectorLimit, serializedAdditionalRawData) { Url = url; Kind = kind; diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableTextQuery.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableTextQuery.Serialization.cs index 4d7ad6ab77a4..59857fcea097 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableTextQuery.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableTextQuery.Serialization.cs @@ -5,16 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class VectorizableTextQuery : IUtf8JsonSerializable + public partial class VectorizableTextQuery : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(VectorizableTextQuery)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("text"u8); writer.WriteStringValue(Text); if (Optional.IsDefined(QueryRewrites)) @@ -22,53 +42,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("queryRewrites"u8); writer.WriteStringValue(QueryRewrites.Value.ToString()); } - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); - if (Optional.IsDefined(KNearestNeighborsCount)) - { - writer.WritePropertyName("k"u8); - writer.WriteNumberValue(KNearestNeighborsCount.Value); - } - if (Optional.IsDefined(FieldsRaw)) - { - writer.WritePropertyName("fields"u8); - writer.WriteStringValue(FieldsRaw); - } - if (Optional.IsDefined(Exhaustive)) - { - writer.WritePropertyName("exhaustive"u8); - writer.WriteBooleanValue(Exhaustive.Value); - } - if (Optional.IsDefined(Oversampling)) - { - writer.WritePropertyName("oversampling"u8); - writer.WriteNumberValue(Oversampling.Value); - } - if (Optional.IsDefined(Weight)) - { - writer.WritePropertyName("weight"u8); - writer.WriteNumberValue(Weight.Value); - } - if (Optional.IsDefined(Threshold)) - { - writer.WritePropertyName("threshold"u8); - writer.WriteObjectValue(Threshold); - } - if (Optional.IsDefined(FilterOverride)) - { - writer.WritePropertyName("filterOverride"u8); - writer.WriteStringValue(FilterOverride); - } - if (Optional.IsDefined(PerDocumentVectorLimit)) + } + + VectorizableTextQuery IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WritePropertyName("perDocumentVectorLimit"u8); - writer.WriteNumberValue(PerDocumentVectorLimit.Value); + throw new FormatException($"The model {nameof(VectorizableTextQuery)} does not support reading '{format}' format."); } - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorizableTextQuery(document.RootElement, options); } - internal static VectorizableTextQuery DeserializeVectorizableTextQuery(JsonElement element) + internal static VectorizableTextQuery DeserializeVectorizableTextQuery(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -84,6 +75,8 @@ internal static VectorizableTextQuery DeserializeVectorizableTextQuery(JsonEleme VectorThreshold threshold = default; string filterOverride = default; int? perDocumentVectorLimit = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("text"u8)) @@ -152,7 +145,7 @@ internal static VectorizableTextQuery DeserializeVectorizableTextQuery(JsonEleme { continue; } - threshold = VectorThreshold.DeserializeVectorThreshold(property.Value); + threshold = VectorThreshold.DeserializeVectorThreshold(property.Value, options); continue; } if (property.NameEquals("filterOverride"u8)) @@ -169,7 +162,12 @@ internal static VectorizableTextQuery DeserializeVectorizableTextQuery(JsonEleme perDocumentVectorLimit = property.Value.GetInt32(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new VectorizableTextQuery( kind, k, @@ -180,10 +178,42 @@ internal static VectorizableTextQuery DeserializeVectorizableTextQuery(JsonEleme threshold, filterOverride, perDocumentVectorLimit, + serializedAdditionalRawData, text, queryRewrites); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(VectorizableTextQuery)} does not support writing '{options.Format}' format."); + } + } + + VectorizableTextQuery 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 DeserializeVectorizableTextQuery(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorizableTextQuery)} 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 VectorizableTextQuery FromResponse(Response response) @@ -196,7 +226,7 @@ internal static VectorizableTextQuery DeserializeVectorizableTextQuery(JsonEleme internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableTextQuery.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableTextQuery.cs index 18757ddd83b8..bc44ad1c20df 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableTextQuery.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizableTextQuery.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Models { @@ -37,14 +38,20 @@ public VectorizableTextQuery(string text) /// /// The OData filter expression to apply to this specific vector query. If no filter expression is defined at the vector level, the expression defined in the top level filter parameter is used instead. /// Controls how many vectors can be matched from each document in a vector search query. Setting it to 1 ensures at most one vector per document is matched, guaranteeing results come from distinct documents. Setting it to 0 (unlimited) allows multiple relevant vectors from the same document to be matched. Default is 0. + /// Keeps track of any properties unknown to the library. /// The text to be vectorized to perform a vector search query. /// Can be configured to let a generative model rewrite the query before sending it to be vectorized. - internal VectorizableTextQuery(VectorQueryKind kind, int? kNearestNeighborsCount, string fieldsRaw, bool? exhaustive, double? oversampling, float? weight, VectorThreshold threshold, string filterOverride, int? perDocumentVectorLimit, string text, QueryRewritesType? queryRewrites) : base(kind, kNearestNeighborsCount, fieldsRaw, exhaustive, oversampling, weight, threshold, filterOverride, perDocumentVectorLimit) + internal VectorizableTextQuery(VectorQueryKind kind, int? kNearestNeighborsCount, string fieldsRaw, bool? exhaustive, double? oversampling, float? weight, VectorThreshold threshold, string filterOverride, int? perDocumentVectorLimit, IDictionary serializedAdditionalRawData, string text, QueryRewritesType? queryRewrites) : base(kind, kNearestNeighborsCount, fieldsRaw, exhaustive, oversampling, weight, threshold, filterOverride, perDocumentVectorLimit, serializedAdditionalRawData) { Text = text; QueryRewrites = queryRewrites; Kind = kind; } + + /// Initializes a new instance of for deserialization. + internal VectorizableTextQuery() + { + } /// Can be configured to let a generative model rewrite the query before sending it to be vectorized. public QueryRewritesType? QueryRewrites { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizedQuery.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizedQuery.Serialization.cs index 71ffbe9ab06d..6da57782b256 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizedQuery.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizedQuery.Serialization.cs @@ -6,16 +6,35 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class VectorizedQuery : IUtf8JsonSerializable + public partial class VectorizedQuery : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(VectorizedQuery)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("vector"u8); writer.WriteStartArray(); foreach (var item in Vector.Span) @@ -23,53 +42,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteNumberValue(item); } writer.WriteEndArray(); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); - if (Optional.IsDefined(KNearestNeighborsCount)) - { - writer.WritePropertyName("k"u8); - writer.WriteNumberValue(KNearestNeighborsCount.Value); - } - if (Optional.IsDefined(FieldsRaw)) - { - writer.WritePropertyName("fields"u8); - writer.WriteStringValue(FieldsRaw); - } - if (Optional.IsDefined(Exhaustive)) - { - writer.WritePropertyName("exhaustive"u8); - writer.WriteBooleanValue(Exhaustive.Value); - } - if (Optional.IsDefined(Oversampling)) - { - writer.WritePropertyName("oversampling"u8); - writer.WriteNumberValue(Oversampling.Value); - } - if (Optional.IsDefined(Weight)) - { - writer.WritePropertyName("weight"u8); - writer.WriteNumberValue(Weight.Value); - } - if (Optional.IsDefined(Threshold)) - { - writer.WritePropertyName("threshold"u8); - writer.WriteObjectValue(Threshold); - } - if (Optional.IsDefined(FilterOverride)) - { - writer.WritePropertyName("filterOverride"u8); - writer.WriteStringValue(FilterOverride); - } - if (Optional.IsDefined(PerDocumentVectorLimit)) + } + + VectorizedQuery IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WritePropertyName("perDocumentVectorLimit"u8); - writer.WriteNumberValue(PerDocumentVectorLimit.Value); + throw new FormatException($"The model {nameof(VectorizedQuery)} does not support reading '{format}' format."); } - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorizedQuery(document.RootElement, options); } - internal static VectorizedQuery DeserializeVectorizedQuery(JsonElement element) + internal static VectorizedQuery DeserializeVectorizedQuery(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -84,6 +74,8 @@ internal static VectorizedQuery DeserializeVectorizedQuery(JsonElement element) VectorThreshold threshold = default; string filterOverride = default; int? perDocumentVectorLimit = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("vector"u8)) @@ -154,7 +146,7 @@ internal static VectorizedQuery DeserializeVectorizedQuery(JsonElement element) { continue; } - threshold = VectorThreshold.DeserializeVectorThreshold(property.Value); + threshold = VectorThreshold.DeserializeVectorThreshold(property.Value, options); continue; } if (property.NameEquals("filterOverride"u8)) @@ -171,7 +163,12 @@ internal static VectorizedQuery DeserializeVectorizedQuery(JsonElement element) perDocumentVectorLimit = property.Value.GetInt32(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new VectorizedQuery( kind, k, @@ -182,9 +179,41 @@ internal static VectorizedQuery DeserializeVectorizedQuery(JsonElement element) threshold, filterOverride, perDocumentVectorLimit, + serializedAdditionalRawData, vector); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(VectorizedQuery)} does not support writing '{options.Format}' format."); + } + } + + VectorizedQuery 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 DeserializeVectorizedQuery(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorizedQuery)} 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 VectorizedQuery FromResponse(Response response) @@ -197,7 +226,7 @@ internal static VectorizedQuery DeserializeVectorizedQuery(JsonElement element) internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizedQuery.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizedQuery.cs index 744734be2a75..886e652674e3 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizedQuery.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorizedQuery.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Models { @@ -34,11 +35,17 @@ public VectorizedQuery(ReadOnlyMemory vector) /// /// The OData filter expression to apply to this specific vector query. If no filter expression is defined at the vector level, the expression defined in the top level filter parameter is used instead. /// Controls how many vectors can be matched from each document in a vector search query. Setting it to 1 ensures at most one vector per document is matched, guaranteeing results come from distinct documents. Setting it to 0 (unlimited) allows multiple relevant vectors from the same document to be matched. Default is 0. + /// Keeps track of any properties unknown to the library. /// The vector representation of a search query. - internal VectorizedQuery(VectorQueryKind kind, int? kNearestNeighborsCount, string fieldsRaw, bool? exhaustive, double? oversampling, float? weight, VectorThreshold threshold, string filterOverride, int? perDocumentVectorLimit, ReadOnlyMemory vector) : base(kind, kNearestNeighborsCount, fieldsRaw, exhaustive, oversampling, weight, threshold, filterOverride, perDocumentVectorLimit) + internal VectorizedQuery(VectorQueryKind kind, int? kNearestNeighborsCount, string fieldsRaw, bool? exhaustive, double? oversampling, float? weight, VectorThreshold threshold, string filterOverride, int? perDocumentVectorLimit, IDictionary serializedAdditionalRawData, ReadOnlyMemory vector) : base(kind, kNearestNeighborsCount, fieldsRaw, exhaustive, oversampling, weight, threshold, filterOverride, perDocumentVectorLimit, serializedAdditionalRawData) { Vector = vector; Kind = kind; } + + /// Initializes a new instance of for deserialization. + internal VectorizedQuery() + { + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorsDebugInfo.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorsDebugInfo.Serialization.cs index 555d305062bf..25d83cb7a271 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorsDebugInfo.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorsDebugInfo.Serialization.cs @@ -5,19 +5,80 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; +using Azure.Core; namespace Azure.Search.Documents.Models { - public partial class VectorsDebugInfo + public partial class VectorsDebugInfo : IUtf8JsonSerializable, IJsonModel { - internal static VectorsDebugInfo DeserializeVectorsDebugInfo(JsonElement element) + 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(VectorsDebugInfo)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Subscores)) + { + writer.WritePropertyName("subscores"u8); + writer.WriteObjectValue(Subscores, options); + } + 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 + } + } + } + + VectorsDebugInfo 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(VectorsDebugInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorsDebugInfo(document.RootElement, options); + } + + internal static VectorsDebugInfo DeserializeVectorsDebugInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; } QueryResultDocumentSubscores subscores = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("subscores"u8)) @@ -26,13 +87,49 @@ internal static VectorsDebugInfo DeserializeVectorsDebugInfo(JsonElement element { continue; } - subscores = QueryResultDocumentSubscores.DeserializeQueryResultDocumentSubscores(property.Value); + subscores = QueryResultDocumentSubscores.DeserializeQueryResultDocumentSubscores(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorsDebugInfo(subscores, 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(VectorsDebugInfo)} does not support writing '{options.Format}' format."); + } + } + + VectorsDebugInfo 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 DeserializeVectorsDebugInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorsDebugInfo)} does not support reading '{options.Format}' format."); } - return new VectorsDebugInfo(subscores); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static VectorsDebugInfo FromResponse(Response response) @@ -40,5 +137,13 @@ internal static VectorsDebugInfo FromResponse(Response response) using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeVectorsDebugInfo(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/search/Azure.Search.Documents/src/Generated/Models/VectorsDebugInfo.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorsDebugInfo.cs index c0e0cf118564..57b7afc1ff8a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorsDebugInfo.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VectorsDebugInfo.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.Search.Documents.Models { /// The VectorsDebugInfo. public partial class VectorsDebugInfo { + /// + /// 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 . internal VectorsDebugInfo() { @@ -17,9 +52,11 @@ internal VectorsDebugInfo() /// Initializes a new instance of . /// The breakdown of subscores of the document prior to the chosen result set fusion/combination method such as RRF. - internal VectorsDebugInfo(QueryResultDocumentSubscores subscores) + /// Keeps track of any properties unknown to the library. + internal VectorsDebugInfo(QueryResultDocumentSubscores subscores, IDictionary serializedAdditionalRawData) { Subscores = subscores; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The breakdown of subscores of the document prior to the chosen result set fusion/combination method such as RRF. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VisionVectorizeSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VisionVectorizeSkill.Serialization.cs index 7ed64dec432f..1044a08eb87d 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VisionVectorizeSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VisionVectorizeSkill.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class VisionVectorizeSkill : IUtf8JsonSerializable + public partial class VisionVectorizeSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(VisionVectorizeSkill)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (ModelVersion != null) { writer.WritePropertyName("modelVersion"u8); @@ -25,42 +44,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteNull("modelVersion"); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + VisionVectorizeSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(VisionVectorizeSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVisionVectorizeSkill(document.RootElement, options); } - internal static VisionVectorizeSkill DeserializeVisionVectorizeSkill(JsonElement element) + internal static VisionVectorizeSkill DeserializeVisionVectorizeSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -72,6 +73,8 @@ internal static VisionVectorizeSkill DeserializeVisionVectorizeSkill(JsonElement string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("modelVersion"u8)) @@ -109,7 +112,7 @@ internal static VisionVectorizeSkill DeserializeVisionVectorizeSkill(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -119,12 +122,17 @@ internal static VisionVectorizeSkill DeserializeVisionVectorizeSkill(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new VisionVectorizeSkill( odataType, name, @@ -132,9 +140,41 @@ internal static VisionVectorizeSkill DeserializeVisionVectorizeSkill(JsonElement context, inputs, outputs, + serializedAdditionalRawData, modelVersion); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(VisionVectorizeSkill)} does not support writing '{options.Format}' format."); + } + } + + VisionVectorizeSkill 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 DeserializeVisionVectorizeSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VisionVectorizeSkill)} 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 VisionVectorizeSkill FromResponse(Response response) @@ -147,7 +187,7 @@ internal static VisionVectorizeSkill DeserializeVisionVectorizeSkill(JsonElement internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/VisionVectorizeSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/VisionVectorizeSkill.cs index 18d17e3a7e81..528b08739277 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/VisionVectorizeSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/VisionVectorizeSkill.cs @@ -34,13 +34,19 @@ public VisionVectorizeSkill(IEnumerable inputs, IEnumera /// Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// The version of the model to use when calling the AI Services Vision service. It will default to the latest available when not specified. - internal VisionVectorizeSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, string modelVersion) : base(oDataType, name, description, context, inputs, outputs) + internal VisionVectorizeSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, string modelVersion) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { ModelVersion = modelVersion; ODataType = oDataType ?? "#Microsoft.Skills.Vision.VectorizeSkill"; } + /// Initializes a new instance of for deserialization. + internal VisionVectorizeSkill() + { + } + /// The version of the model to use when calling the AI Services Vision service. It will default to the latest available when not specified. public string ModelVersion { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiSkill.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiSkill.Serialization.cs index ca055241b0f0..97236cc6fb00 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiSkill.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiSkill.Serialization.cs @@ -6,17 +6,35 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class WebApiSkill : IUtf8JsonSerializable + public partial class WebApiSkill : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(WebApiSkill)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("uri"u8); writer.WriteStringValue(Uri); if (Optional.IsCollectionDefined(HttpHeaders)) @@ -95,49 +113,31 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (AuthIdentity != null) { writer.WritePropertyName("authIdentity"u8); - writer.WriteObjectValue(AuthIdentity); + writer.WriteObjectValue(AuthIdentity, options); } else { writer.WriteNull("authIdentity"); } } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - if (Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (Optional.IsDefined(Context)) - { - writer.WritePropertyName("context"u8); - writer.WriteStringValue(Context); - } - writer.WritePropertyName("inputs"u8); - writer.WriteStartArray(); - foreach (var item in Inputs) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + } + + WebApiSkill IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - writer.WriteObjectValue(item); + throw new FormatException($"The model {nameof(WebApiSkill)} does not support reading '{format}' format."); } - writer.WriteEndArray(); - writer.WriteEndObject(); + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWebApiSkill(document.RootElement, options); } - internal static WebApiSkill DeserializeWebApiSkill(JsonElement element) + internal static WebApiSkill DeserializeWebApiSkill(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -146,7 +146,7 @@ internal static WebApiSkill DeserializeWebApiSkill(JsonElement element) { switch (discriminator.GetString()) { - case "#Microsoft.Skills.Custom.ChatCompletionSkill": return ChatCompletionSkill.DeserializeChatCompletionSkill(element); + case "#Microsoft.Skills.Custom.ChatCompletionSkill": return ChatCompletionSkill.DeserializeChatCompletionSkill(element, options); } } string uri = default; @@ -163,6 +163,8 @@ internal static WebApiSkill DeserializeWebApiSkill(JsonElement element) string context = default; IList inputs = default; IList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("uri"u8)) @@ -237,7 +239,7 @@ internal static WebApiSkill DeserializeWebApiSkill(JsonElement element) authIdentity = null; continue; } - authIdentity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value); + authIdentity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value, options); continue; } if (property.NameEquals("@odata.type"u8)) @@ -265,7 +267,7 @@ internal static WebApiSkill DeserializeWebApiSkill(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); + array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item, options)); } inputs = array; continue; @@ -275,12 +277,17 @@ internal static WebApiSkill DeserializeWebApiSkill(JsonElement element) List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); + array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item, options)); } outputs = array; continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new WebApiSkill( odataType, name, @@ -288,6 +295,7 @@ internal static WebApiSkill DeserializeWebApiSkill(JsonElement element) context, inputs, outputs, + serializedAdditionalRawData, uri, httpHeaders ?? new ChangeTrackingDictionary(), httpMethod, @@ -298,6 +306,37 @@ internal static WebApiSkill DeserializeWebApiSkill(JsonElement element) authIdentity); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(WebApiSkill)} does not support writing '{options.Format}' format."); + } + } + + WebApiSkill 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 DeserializeWebApiSkill(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WebApiSkill)} 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 WebApiSkill FromResponse(Response response) @@ -310,7 +349,7 @@ internal static WebApiSkill DeserializeWebApiSkill(JsonElement element) internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiSkill.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiSkill.cs index 8855c8fc8ef1..f42865dc6042 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiSkill.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiSkill.cs @@ -41,6 +41,7 @@ public WebApiSkill(IEnumerable inputs, IEnumerable Represents the level at which operations take place, such as the document root or document content (for example, /document or /document/content). The default is /document. /// Inputs of the skills could be a column in the source data set, or the output of an upstream skill. /// The output of a skill is either a field in a search index, or a value that can be consumed as an input by another skill. + /// Keeps track of any properties unknown to the library. /// The url for the Web API. /// The headers required to make the http request. /// The method for the http request. @@ -53,7 +54,7 @@ public WebApiSkill(IEnumerable inputs, IEnumerable 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 . /// - internal WebApiSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, string uri, IDictionary httpHeaders, string httpMethod, TimeSpan? timeout, int? batchSize, int? degreeOfParallelism, ResourceIdentifier authResourceId, SearchIndexerDataIdentity authIdentity) : base(oDataType, name, description, context, inputs, outputs) + internal WebApiSkill(string oDataType, string name, string description, string context, IList inputs, IList outputs, IDictionary serializedAdditionalRawData, string uri, IDictionary httpHeaders, string httpMethod, TimeSpan? timeout, int? batchSize, int? degreeOfParallelism, ResourceIdentifier authResourceId, SearchIndexerDataIdentity authIdentity) : base(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData) { Uri = uri; HttpHeaders = httpHeaders; @@ -65,6 +66,11 @@ internal WebApiSkill(string oDataType, string name, string description, string c AuthIdentity = authIdentity; ODataType = oDataType ?? "#Microsoft.Skills.Custom.WebApiSkill"; } + + /// Initializes a new instance of for deserialization. + internal WebApiSkill() + { + } /// The method for the http request. public string HttpMethod { get; set; } /// The desired timeout for the request. Default is 30 seconds. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiVectorizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiVectorizer.Serialization.cs index e0c56920b66c..0118979213d0 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiVectorizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiVectorizer.Serialization.cs @@ -5,30 +5,59 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class WebApiVectorizer : IUtf8JsonSerializable + public partial class WebApiVectorizer : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(WebApiVectorizer)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Parameters)) { writer.WritePropertyName("customWebApiParameters"u8); - writer.WriteObjectValue(Parameters); + writer.WriteObjectValue(Parameters, options); } - writer.WritePropertyName("name"u8); - writer.WriteStringValue(VectorizerName); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); - writer.WriteEndObject(); } - internal static WebApiVectorizer DeserializeWebApiVectorizer(JsonElement element) + WebApiVectorizer 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(WebApiVectorizer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWebApiVectorizer(document.RootElement, options); + } + + internal static WebApiVectorizer DeserializeWebApiVectorizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -36,6 +65,8 @@ internal static WebApiVectorizer DeserializeWebApiVectorizer(JsonElement element WebApiVectorizerParameters customWebApiParameters = default; string name = default; VectorSearchVectorizerKind kind = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("customWebApiParameters"u8)) @@ -44,7 +75,7 @@ internal static WebApiVectorizer DeserializeWebApiVectorizer(JsonElement element { continue; } - customWebApiParameters = WebApiVectorizerParameters.DeserializeWebApiVectorizerParameters(property.Value); + customWebApiParameters = WebApiVectorizerParameters.DeserializeWebApiVectorizerParameters(property.Value, options); continue; } if (property.NameEquals("name"u8)) @@ -57,10 +88,46 @@ internal static WebApiVectorizer DeserializeWebApiVectorizer(JsonElement element kind = new VectorSearchVectorizerKind(property.Value.GetString()); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WebApiVectorizer(name, kind, serializedAdditionalRawData, customWebApiParameters); + } + + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(WebApiVectorizer)} does not support writing '{options.Format}' format."); + } + } + + WebApiVectorizer 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 DeserializeWebApiVectorizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WebApiVectorizer)} does not support reading '{options.Format}' format."); } - return new WebApiVectorizer(name, kind, customWebApiParameters); } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + /// Deserializes the model from a raw response. /// The response to deserialize the model from. internal static new WebApiVectorizer FromResponse(Response response) @@ -73,7 +140,7 @@ internal static WebApiVectorizer DeserializeWebApiVectorizer(JsonElement element internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiVectorizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiVectorizer.cs index e605e98da9a7..92365721f3f4 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiVectorizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiVectorizer.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { @@ -25,13 +26,19 @@ public WebApiVectorizer(string vectorizerName) : base(vectorizerName) /// Initializes a new instance of . /// The name to associate with this particular vectorization method. /// The name of the kind of vectorization method being configured for use with vector search. + /// Keeps track of any properties unknown to the library. /// Specifies the properties of the user-defined vectorizer. - internal WebApiVectorizer(string vectorizerName, VectorSearchVectorizerKind kind, WebApiVectorizerParameters parameters) : base(vectorizerName, kind) + internal WebApiVectorizer(string vectorizerName, VectorSearchVectorizerKind kind, IDictionary serializedAdditionalRawData, WebApiVectorizerParameters parameters) : base(vectorizerName, kind, serializedAdditionalRawData) { Parameters = parameters; Kind = kind; } + /// Initializes a new instance of for deserialization. + internal WebApiVectorizer() + { + } + /// Specifies the properties of the user-defined vectorizer. public WebApiVectorizerParameters Parameters { get; set; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiVectorizerParameters.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiVectorizerParameters.Serialization.cs index 64f34d846693..577a08f3b1d8 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiVectorizerParameters.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiVectorizerParameters.Serialization.cs @@ -6,17 +6,34 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class WebApiVectorizerParameters : IUtf8JsonSerializable + public partial class WebApiVectorizerParameters : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(WebApiVectorizerParameters)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Uri)) { writer.WritePropertyName("uri"u8); @@ -60,18 +77,46 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (AuthIdentity != null) { writer.WritePropertyName("authIdentity"u8); - writer.WriteObjectValue(AuthIdentity); + writer.WriteObjectValue(AuthIdentity, options); } else { writer.WriteNull("authIdentity"); } } - writer.WriteEndObject(); + 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 + } + } + } + + WebApiVectorizerParameters 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(WebApiVectorizerParameters)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWebApiVectorizerParameters(document.RootElement, options); } - internal static WebApiVectorizerParameters DeserializeWebApiVectorizerParameters(JsonElement element) + internal static WebApiVectorizerParameters DeserializeWebApiVectorizerParameters(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -82,6 +127,8 @@ internal static WebApiVectorizerParameters DeserializeWebApiVectorizerParameters TimeSpan? timeout = default; ResourceIdentifier authResourceId = default; SearchIndexerDataIdentity authIdentity = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("uri"u8)) @@ -138,19 +185,56 @@ internal static WebApiVectorizerParameters DeserializeWebApiVectorizerParameters authIdentity = null; continue; } - authIdentity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value); + authIdentity = SearchIndexerDataIdentity.DeserializeSearchIndexerDataIdentity(property.Value, options); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new WebApiVectorizerParameters( uri, httpHeaders ?? new ChangeTrackingDictionary(), httpMethod, timeout, authResourceId, - authIdentity); + authIdentity, + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(WebApiVectorizerParameters)} does not support writing '{options.Format}' format."); + } + } + + WebApiVectorizerParameters 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 DeserializeWebApiVectorizerParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WebApiVectorizerParameters)} 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 WebApiVectorizerParameters FromResponse(Response response) @@ -163,7 +247,7 @@ internal static WebApiVectorizerParameters FromResponse(Response response) internal virtual RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiVectorizerParameters.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiVectorizerParameters.cs index 8290bcf42674..405becc69644 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiVectorizerParameters.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/WebApiVectorizerParameters.cs @@ -14,6 +14,38 @@ namespace Azure.Search.Documents.Indexes.Models /// Specifies the properties for connecting to a user-defined vectorizer. public partial class WebApiVectorizerParameters { + /// + /// 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 WebApiVectorizerParameters() { @@ -31,7 +63,8 @@ public WebApiVectorizerParameters() /// 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 . /// - internal WebApiVectorizerParameters(Uri uri, IDictionary httpHeaders, string httpMethod, TimeSpan? timeout, ResourceIdentifier authResourceId, SearchIndexerDataIdentity authIdentity) + /// Keeps track of any properties unknown to the library. + internal WebApiVectorizerParameters(Uri uri, IDictionary httpHeaders, string httpMethod, TimeSpan? timeout, ResourceIdentifier authResourceId, SearchIndexerDataIdentity authIdentity, IDictionary serializedAdditionalRawData) { Uri = uri; HttpHeaders = httpHeaders; @@ -39,6 +72,7 @@ internal WebApiVectorizerParameters(Uri uri, IDictionary httpHea Timeout = timeout; AuthResourceId = authResourceId; AuthIdentity = authIdentity; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The URI of the Web API providing the vectorizer. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/WordDelimiterTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/WordDelimiterTokenFilter.Serialization.cs index b1668e1a03bd..4cda0ff9d9c0 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/WordDelimiterTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/WordDelimiterTokenFilter.Serialization.cs @@ -5,17 +5,36 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class WordDelimiterTokenFilter : IUtf8JsonSerializable + public partial class WordDelimiterTokenFilter : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + 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(WordDelimiterTokenFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(GenerateWordParts)) { writer.WritePropertyName("generateWordParts"u8); @@ -71,15 +90,24 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WriteEndArray(); } - writer.WritePropertyName("@odata.type"u8); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WriteEndObject(); } - internal static WordDelimiterTokenFilter DeserializeWordDelimiterTokenFilter(JsonElement element) + WordDelimiterTokenFilter 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(WordDelimiterTokenFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWordDelimiterTokenFilter(document.RootElement, options); + } + + internal static WordDelimiterTokenFilter DeserializeWordDelimiterTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -96,6 +124,8 @@ internal static WordDelimiterTokenFilter DeserializeWordDelimiterTokenFilter(Jso IList protectedWords = default; string odataType = default; string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("generateWordParts"u8)) @@ -203,10 +233,16 @@ internal static WordDelimiterTokenFilter DeserializeWordDelimiterTokenFilter(Jso name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } + serializedAdditionalRawData = rawDataDictionary; return new WordDelimiterTokenFilter( odataType, name, + serializedAdditionalRawData, generateWordParts, generateNumberParts, catenateWords, @@ -219,6 +255,37 @@ internal static WordDelimiterTokenFilter DeserializeWordDelimiterTokenFilter(Jso protectedWords ?? new ChangeTrackingList()); } + 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, AzureSearchDocumentsContext.Default); + default: + throw new FormatException($"The model {nameof(WordDelimiterTokenFilter)} does not support writing '{options.Format}' format."); + } + } + + WordDelimiterTokenFilter 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 DeserializeWordDelimiterTokenFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WordDelimiterTokenFilter)} 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 WordDelimiterTokenFilter FromResponse(Response response) @@ -231,7 +298,7 @@ internal static WordDelimiterTokenFilter DeserializeWordDelimiterTokenFilter(Jso internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/WordDelimiterTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/WordDelimiterTokenFilter.cs index f0fc22e07f02..feb18ee97b79 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/WordDelimiterTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/WordDelimiterTokenFilter.cs @@ -27,6 +27,7 @@ public WordDelimiterTokenFilter(string name) : base(name) /// Initializes a new instance of . /// A URI fragment specifying the type of token filter. /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + /// Keeps track of any properties unknown to the library. /// A value indicating whether to generate part words. If set, causes parts of words to be generated; for example "AzureSearch" becomes "Azure" "Search". Default is true. /// A value indicating whether to generate number subwords. Default is true. /// A value indicating whether maximum runs of word parts will be catenated. For example, if this is set to true, "Azure-Search" becomes "AzureSearch". Default is false. @@ -37,7 +38,7 @@ public WordDelimiterTokenFilter(string name) : base(name) /// A value indicating whether to split on numbers. For example, if this is set to true, "Azure1Search" becomes "Azure" "1" "Search". Default is true. /// A value indicating whether to remove trailing "'s" for each subword. Default is true. /// A list of tokens to protect from being delimited. - internal WordDelimiterTokenFilter(string oDataType, string name, bool? generateWordParts, bool? generateNumberParts, bool? catenateWords, bool? catenateNumbers, bool? catenateAll, bool? splitOnCaseChange, bool? preserveOriginal, bool? splitOnNumerics, bool? stemEnglishPossessive, IList protectedWords) : base(oDataType, name) + internal WordDelimiterTokenFilter(string oDataType, string name, IDictionary serializedAdditionalRawData, bool? generateWordParts, bool? generateNumberParts, bool? catenateWords, bool? catenateNumbers, bool? catenateAll, bool? splitOnCaseChange, bool? preserveOriginal, bool? splitOnNumerics, bool? stemEnglishPossessive, IList protectedWords) : base(oDataType, name, serializedAdditionalRawData) { GenerateWordParts = generateWordParts; GenerateNumberParts = generateNumberParts; @@ -52,6 +53,11 @@ internal WordDelimiterTokenFilter(string oDataType, string name, bool? generateW ODataType = oDataType ?? "#Microsoft.Azure.Search.WordDelimiterTokenFilter"; } + /// Initializes a new instance of for deserialization. + internal WordDelimiterTokenFilter() + { + } + /// A value indicating whether to generate part words. If set, causes parts of words to be generated; for example "AzureSearch" becomes "Azure" "Search". Default is true. public bool? GenerateWordParts { get; set; } /// A value indicating whether to generate number subwords. Default is true. diff --git a/sdk/search/Azure.Search.Documents/src/Generated/SearchModelFactory.cs b/sdk/search/Azure.Search.Documents/src/Generated/SearchModelFactory.cs index a77fe0f7149e..cdc3e45eb1aa 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/SearchModelFactory.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/SearchModelFactory.cs @@ -49,7 +49,7 @@ public static QueryAnswerResult QueryAnswerResult(double? score = null, string k /// A new instance for mocking. public static DebugInfo DebugInfo(QueryRewritesDebugInfo queryRewrites = null) { - return new DebugInfo(queryRewrites); + return new DebugInfo(queryRewrites, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -60,7 +60,7 @@ public static QueryRewritesDebugInfo QueryRewritesDebugInfo(QueryRewritesValuesD { vectors ??= new List(); - return new QueryRewritesDebugInfo(text, vectors?.ToList()); + return new QueryRewritesDebugInfo(text, vectors?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -71,7 +71,7 @@ public static QueryRewritesValuesDebugInfo QueryRewritesValuesDebugInfo(string i { rewrites ??= new List(); - return new QueryRewritesValuesDebugInfo(inputQuery, rewrites?.ToList()); + return new QueryRewritesValuesDebugInfo(inputQuery, rewrites?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -95,7 +95,7 @@ public static DocumentDebugInfo DocumentDebugInfo(SemanticDebugInfo semantic = n { innerHits ??= new Dictionary>(); - return new DocumentDebugInfo(semantic, vectors, innerHits); + return new DocumentDebugInfo(semantic, vectors, innerHits, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -109,7 +109,7 @@ public static SemanticDebugInfo SemanticDebugInfo(QueryResultDocumentSemanticFie contentFields ??= new List(); keywordFields ??= new List(); - return new SemanticDebugInfo(titleField, contentFields?.ToList(), keywordFields?.ToList(), rerankerInput); + return new SemanticDebugInfo(titleField, contentFields?.ToList(), keywordFields?.ToList(), rerankerInput, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -118,7 +118,7 @@ public static SemanticDebugInfo SemanticDebugInfo(QueryResultDocumentSemanticFie /// A new instance for mocking. public static QueryResultDocumentSemanticField QueryResultDocumentSemanticField(string name = null, SemanticFieldState? state = null) { - return new QueryResultDocumentSemanticField(name, state); + return new QueryResultDocumentSemanticField(name, state, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -128,7 +128,7 @@ public static QueryResultDocumentSemanticField QueryResultDocumentSemanticField( /// A new instance for mocking. public static QueryResultDocumentRerankerInput QueryResultDocumentRerankerInput(string title = null, string content = null, string keywords = null) { - return new QueryResultDocumentRerankerInput(title, content, keywords); + return new QueryResultDocumentRerankerInput(title, content, keywords, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -136,7 +136,7 @@ public static QueryResultDocumentRerankerInput QueryResultDocumentRerankerInput( /// A new instance for mocking. public static VectorsDebugInfo VectorsDebugInfo(QueryResultDocumentSubscores subscores = null) { - return new VectorsDebugInfo(subscores); + return new VectorsDebugInfo(subscores, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -148,7 +148,7 @@ public static QueryResultDocumentSubscores QueryResultDocumentSubscores(TextResu { vectors ??= new List>(); - return new QueryResultDocumentSubscores(text, vectors?.ToList(), documentBoost); + return new QueryResultDocumentSubscores(text, vectors?.ToList(), documentBoost, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -156,7 +156,7 @@ public static QueryResultDocumentSubscores QueryResultDocumentSubscores(TextResu /// A new instance for mocking. public static TextResult TextResult(double? searchScore = null) { - return new TextResult(searchScore); + return new TextResult(searchScore, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -165,7 +165,7 @@ public static TextResult TextResult(double? searchScore = null) /// A new instance for mocking. public static SingleVectorFieldResult SingleVectorFieldResult(double? searchScore = null, double? vectorSimilarity = null) { - return new SingleVectorFieldResult(searchScore, vectorSimilarity); + return new SingleVectorFieldResult(searchScore, vectorSimilarity, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -176,7 +176,7 @@ public static QueryResultDocumentInnerHit QueryResultDocumentInnerHit(long? ordi { vectors ??= new List>(); - return new QueryResultDocumentInnerHit(ordinal, vectors?.ToList()); + return new QueryResultDocumentInnerHit(ordinal, vectors?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -187,7 +187,7 @@ public static AutocompleteResults AutocompleteResults(double? coverage = null, I { results ??= new List(); - return new AutocompleteResults(coverage, results?.ToList()); + return new AutocompleteResults(coverage, results?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -201,7 +201,13 @@ public static SearchIndexerStatus SearchIndexerStatus(IndexerStatus status = def { executionHistory ??= new List(); - return new SearchIndexerStatus(status, lastResult, executionHistory?.ToList(), limits, currentState); + return new SearchIndexerStatus( + status, + lastResult, + executionHistory?.ToList(), + limits, + currentState, + serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -235,7 +241,8 @@ public static IndexerExecutionResult IndexerExecutionResult(IndexerExecutionStat itemCount, failedItemCount, initialTrackingState, - finalTrackingState); + finalTrackingState, + serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -263,7 +270,8 @@ public static IndexerState IndexerState(IndexingMode? mode = null, string allDoc resetDocumentKeys?.ToList(), resetDataSourceDocumentIds?.ToList(), resyncInitialTrackingState, - resyncFinalTrackingState); + resyncFinalTrackingState, + serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -273,7 +281,30 @@ public static IndexerState IndexerState(IndexingMode? mode = null, string allDoc /// A new instance for mocking. public static SearchIndexStatistics SearchIndexStatistics(long documentCount = default, long storageSize = default, long vectorIndexSize = default) { - return new SearchIndexStatistics(documentCount, storageSize, vectorIndexSize); + return new SearchIndexStatistics(documentCount, storageSize, vectorIndexSize, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The text to break into tokens. + /// The name of the analyzer to use to break the given text. If this parameter is not specified, you must specify a tokenizer instead. The tokenizer and analyzer parameters are mutually exclusive. + /// The name of the tokenizer to use to break the given text. If this parameter is not specified, you must specify an analyzer instead. The tokenizer and analyzer parameters are mutually exclusive. + /// The name of the normalizer to use to normalize the given text. + /// An optional list of token filters to use when breaking the given text. This parameter can only be set when using the tokenizer parameter. + /// An optional list of character filters to use when breaking the given text. This parameter can only be set when using the tokenizer parameter. + /// A new instance for mocking. + public static AnalyzeTextOptions AnalyzeTextOptions(string text = null, LexicalAnalyzerName? analyzerName = null, LexicalTokenizerName? tokenizerName = null, LexicalNormalizerName? normalizerName = null, IEnumerable tokenFilters = null, IEnumerable charFilters = null) + { + tokenFilters ??= new List(); + charFilters ??= new List(); + + return new AnalyzeTextOptions( + text, + analyzerName, + tokenizerName, + normalizerName, + tokenFilters?.ToList(), + charFilters?.ToList(), + serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -286,47 +317,9 @@ public static SearchIndexStatistics SearchIndexStatistics(long documentCount = d /// Total number of synonym maps. /// Total number of skillsets. /// Total memory consumption of all vector indexes within the service, in bytes. - /// , , , , , , , or is null. /// A new instance for mocking. public static SearchServiceCounters SearchServiceCounters(SearchResourceCounter aliasCounter = null, SearchResourceCounter documentCounter = null, SearchResourceCounter indexCounter = null, SearchResourceCounter indexerCounter = null, SearchResourceCounter dataSourceCounter = null, SearchResourceCounter storageSizeCounter = null, SearchResourceCounter synonymMapCounter = null, SearchResourceCounter skillsetCounter = null, SearchResourceCounter vectorIndexSizeCounter = null) { - if (aliasCounter == null) - { - throw new ArgumentNullException(nameof(aliasCounter)); - } - if (documentCounter == null) - { - throw new ArgumentNullException(nameof(documentCounter)); - } - if (indexCounter == null) - { - throw new ArgumentNullException(nameof(indexCounter)); - } - if (indexerCounter == null) - { - throw new ArgumentNullException(nameof(indexerCounter)); - } - if (dataSourceCounter == null) - { - throw new ArgumentNullException(nameof(dataSourceCounter)); - } - if (storageSizeCounter == null) - { - throw new ArgumentNullException(nameof(storageSizeCounter)); - } - if (synonymMapCounter == null) - { - throw new ArgumentNullException(nameof(synonymMapCounter)); - } - if (skillsetCounter == null) - { - throw new ArgumentNullException(nameof(skillsetCounter)); - } - if (vectorIndexSizeCounter == null) - { - throw new ArgumentNullException(nameof(vectorIndexSizeCounter)); - } - return new SearchServiceCounters( aliasCounter, documentCounter, @@ -336,7 +329,8 @@ public static SearchServiceCounters SearchServiceCounters(SearchResourceCounter storageSizeCounter, synonymMapCounter, skillsetCounter, - vectorIndexSizeCounter); + vectorIndexSizeCounter, + serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -348,7 +342,13 @@ public static SearchServiceCounters SearchServiceCounters(SearchResourceCounter /// A new instance for mocking. public static SearchServiceLimits SearchServiceLimits(int? maxFieldsPerIndex = null, int? maxFieldNestingDepthPerIndex = null, int? maxComplexCollectionFieldsPerIndex = null, int? maxComplexObjectsInCollectionsPerDocument = null, long? maxStoragePerIndexInBytes = null) { - return new SearchServiceLimits(maxFieldsPerIndex, maxFieldNestingDepthPerIndex, maxComplexCollectionFieldsPerIndex, maxComplexObjectsInCollectionsPerDocument, maxStoragePerIndexInBytes); + return new SearchServiceLimits( + maxFieldsPerIndex, + maxFieldNestingDepthPerIndex, + maxComplexCollectionFieldsPerIndex, + maxComplexObjectsInCollectionsPerDocument, + maxStoragePerIndexInBytes, + serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -358,7 +358,7 @@ public static ListIndexStatsSummary ListIndexStatsSummary(IEnumerable(); - return new ListIndexStatsSummary(indexesStatistics?.ToList()); + return new ListIndexStatsSummary(indexesStatistics?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -366,16 +366,10 @@ public static ListIndexStatsSummary ListIndexStatsSummary(IEnumerable The number of documents in the index. /// The amount of storage in bytes consumed by the index. /// The amount of memory in bytes consumed by vectors in the index. - /// is null. /// A new instance for mocking. public static IndexStatisticsSummary IndexStatisticsSummary(string name = null, long documentCount = default, long storageSize = default, long vectorIndexSize = default) { - if (name == null) - { - throw new ArgumentNullException(nameof(name)); - } - - return new IndexStatisticsSummary(name, documentCount, storageSize, vectorIndexSize); + return new IndexStatisticsSummary(name, documentCount, storageSize, vectorIndexSize, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -397,7 +391,7 @@ public static KnowledgeAgentRetrievalResponse KnowledgeAgentRetrievalResponse(IE activity ??= new List(); references ??= new List(); - return new KnowledgeAgentRetrievalResponse(response?.ToList(), activity?.ToList(), references?.ToList()); + return new KnowledgeAgentRetrievalResponse(response?.ToList(), activity?.ToList(), references?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -406,7 +400,7 @@ public static KnowledgeAgentRetrievalResponse KnowledgeAgentRetrievalResponse(IE /// A new instance for mocking. public static KnowledgeAgentActivityRecord KnowledgeAgentActivityRecord(int id = default, string type = null) { - return new UnknownKnowledgeAgentActivityRecord(id, type); + return new UnknownKnowledgeAgentActivityRecord(id, type, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -416,7 +410,7 @@ public static KnowledgeAgentActivityRecord KnowledgeAgentActivityRecord(int id = /// A new instance for mocking. public static KnowledgeAgentReference KnowledgeAgentReference(string type = null, string id = null, int activitySource = default) { - return new UnknownKnowledgeAgentReference(type, id, activitySource); + return new UnknownKnowledgeAgentReference(type, id, activitySource, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -432,6 +426,7 @@ public static KnowledgeAgentSearchActivityRecord KnowledgeAgentSearchActivityRec return new KnowledgeAgentSearchActivityRecord( id, "AzureSearchQuery", + serializedAdditionalRawData: null, targetIndex, query, queryTime, @@ -445,7 +440,7 @@ public static KnowledgeAgentSearchActivityRecord KnowledgeAgentSearchActivityRec /// A new instance for mocking. public static KnowledgeAgentSearchActivityRecordQuery KnowledgeAgentSearchActivityRecordQuery(string search = null, string filter = null) { - return new KnowledgeAgentSearchActivityRecordQuery(search, filter); + return new KnowledgeAgentSearchActivityRecordQuery(search, filter, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -456,7 +451,13 @@ public static KnowledgeAgentSearchActivityRecordQuery KnowledgeAgentSearchActivi /// A new instance for mocking. public static KnowledgeAgentModelQueryPlanningActivityRecord KnowledgeAgentModelQueryPlanningActivityRecord(int id = default, int? inputTokens = null, int? outputTokens = null, int? elapsedMs = null) { - return new KnowledgeAgentModelQueryPlanningActivityRecord(id, "ModelQueryPlanning", inputTokens, outputTokens, elapsedMs); + return new KnowledgeAgentModelQueryPlanningActivityRecord( + id, + "ModelQueryPlanning", + serializedAdditionalRawData: null, + inputTokens, + outputTokens, + elapsedMs); } /// Initializes a new instance of . @@ -466,7 +467,7 @@ public static KnowledgeAgentModelQueryPlanningActivityRecord KnowledgeAgentModel /// A new instance for mocking. public static KnowledgeAgentSemanticRankerActivityRecord KnowledgeAgentSemanticRankerActivityRecord(int id = default, int? inputTokens = null, int? elapsedMs = null) { - return new KnowledgeAgentSemanticRankerActivityRecord(id, "AzureSearchSemanticRanker", inputTokens, elapsedMs); + return new KnowledgeAgentSemanticRankerActivityRecord(id, "AzureSearchSemanticRanker", serializedAdditionalRawData: null, inputTokens, elapsedMs); } /// Initializes a new instance of . @@ -479,7 +480,13 @@ public static KnowledgeAgentAzureSearchDocReference KnowledgeAgentAzureSearchDoc { sourceData ??= new Dictionary(); - return new KnowledgeAgentAzureSearchDocReference("AzureSearchDoc", id, activitySource, docKey, sourceData); + return new KnowledgeAgentAzureSearchDocReference( + "AzureSearchDoc", + id, + activitySource, + serializedAdditionalRawData: null, + docKey, + sourceData); } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/SkillsetsRestClient.cs b/sdk/search/Azure.Search.Documents/src/Generated/SkillsetsRestClient.cs index 7c47f025bf6e..806d69034857 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/SkillsetsRestClient.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/SkillsetsRestClient.cs @@ -74,7 +74,7 @@ internal HttpMessage CreateCreateOrUpdateRequest(string skillsetName, SearchInde request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(skillset); + content.JsonWriter.WriteObjectValue(skillset, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } @@ -370,7 +370,7 @@ internal HttpMessage CreateCreateRequest(SearchIndexerSkillset skillset) request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(skillset); + content.JsonWriter.WriteObjectValue(skillset, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } @@ -444,7 +444,7 @@ internal HttpMessage CreateResetSkillsRequest(string skillsetName, ResetSkillsOp request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(resetSkillsOptions); + content.JsonWriter.WriteObjectValue(resetSkillsOptions, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/SynonymMapsRestClient.cs b/sdk/search/Azure.Search.Documents/src/Generated/SynonymMapsRestClient.cs index 5497a46e74bd..cd10c1980b2c 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/SynonymMapsRestClient.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/SynonymMapsRestClient.cs @@ -65,7 +65,7 @@ internal HttpMessage CreateCreateOrUpdateRequest(string synonymMapName, SynonymM request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(synonymMap); + content.JsonWriter.WriteObjectValue(synonymMap, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } @@ -357,7 +357,7 @@ internal HttpMessage CreateCreateRequest(SynonymMap synonymMap) request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(synonymMap); + content.JsonWriter.WriteObjectValue(synonymMap, ModelSerializationExtensions.WireOptions); request.Content = content; return message; } diff --git a/sdk/search/Azure.Search.Documents/src/Indexes/Models/CognitiveServicesAccount.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/CognitiveServicesAccount.cs index a551b1c053cb..7d91f0128c2a 100644 --- a/sdk/search/Azure.Search.Documents/src/Indexes/Models/CognitiveServicesAccount.cs +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/CognitiveServicesAccount.cs @@ -6,7 +6,7 @@ namespace Azure.Search.Documents.Indexes.Models public partial class CognitiveServicesAccount { /// Initializes a new instance of CognitiveServicesAccount. - private protected CognitiveServicesAccount() + internal CognitiveServicesAccount() { } } diff --git a/sdk/search/Azure.Search.Documents/src/Indexes/Models/DataChangeDetectionPolicy.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/DataChangeDetectionPolicy.cs index 47b0cad043d7..3a093bd49f28 100644 --- a/sdk/search/Azure.Search.Documents/src/Indexes/Models/DataChangeDetectionPolicy.cs +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/DataChangeDetectionPolicy.cs @@ -6,7 +6,7 @@ namespace Azure.Search.Documents.Indexes.Models public partial class DataChangeDetectionPolicy { /// Initializes a new instance of DataChangeDetectionPolicy. - private protected DataChangeDetectionPolicy() + internal DataChangeDetectionPolicy() { } } diff --git a/sdk/search/Azure.Search.Documents/src/Indexes/Models/DataDeletionDetectionPolicy.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/DataDeletionDetectionPolicy.cs index 302bb3f6d364..a7a4e30447d3 100644 --- a/sdk/search/Azure.Search.Documents/src/Indexes/Models/DataDeletionDetectionPolicy.cs +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/DataDeletionDetectionPolicy.cs @@ -6,7 +6,7 @@ namespace Azure.Search.Documents.Indexes.Models public partial class DataDeletionDetectionPolicy { /// Initializes a new instance of DataDeletionDetectionPolicy. - private protected DataDeletionDetectionPolicy() + internal DataDeletionDetectionPolicy() { } } diff --git a/sdk/search/Azure.Search.Documents/src/Indexes/Models/EdgeNGramTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/EdgeNGramTokenFilter.cs index 4c3a248a2b39..6eb51bb437e7 100644 --- a/sdk/search/Azure.Search.Documents/src/Indexes/Models/EdgeNGramTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/EdgeNGramTokenFilter.cs @@ -7,7 +7,6 @@ namespace Azure.Search.Documents.Indexes.Models { [CodeGenModel("EdgeNGramTokenFilterV2")] - [CodeGenSuppress(nameof(EdgeNGramTokenFilter), typeof(string), typeof(string), typeof(int?), typeof(int?), typeof(EdgeNGramTokenFilterSide?))] public partial class EdgeNGramTokenFilter : IUtf8JsonSerializable { /// Initializes a new instance of EdgeNGramTokenFilter. diff --git a/sdk/search/Azure.Search.Documents/src/Indexes/Models/KeywordTokenizer.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/KeywordTokenizer.cs index 306c825a2782..b1c283c248a9 100644 --- a/sdk/search/Azure.Search.Documents/src/Indexes/Models/KeywordTokenizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/KeywordTokenizer.cs @@ -7,7 +7,7 @@ namespace Azure.Search.Documents.Indexes.Models { [CodeGenModel("KeywordTokenizerV2")] - [CodeGenSuppress(nameof(KeywordTokenizer), typeof(string), typeof(string), typeof(int?))] + [CodeGenSerialization(nameof(BufferSize), "bufferSize")] public partial class KeywordTokenizer : IUtf8JsonSerializable { /// diff --git a/sdk/search/Azure.Search.Documents/src/Indexes/Models/LexicalTokenizer.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/LexicalTokenizer.cs index 7cfff18a9dd3..e8e71ac408cc 100644 --- a/sdk/search/Azure.Search.Documents/src/Indexes/Models/LexicalTokenizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/LexicalTokenizer.cs @@ -2,6 +2,9 @@ // Licensed under the MIT License. using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Indexes.Models { @@ -14,5 +17,34 @@ private protected LexicalTokenizer(string name) { Name = name ?? throw new ArgumentNullException(nameof(name)); } + + internal static LexicalTokenizer DeserializeLexicalTokenizer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("@odata.type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "#Microsoft.Azure.Search.ClassicTokenizer": return ClassicTokenizer.DeserializeClassicTokenizer(element, options); + case "#Microsoft.Azure.Search.EdgeNGramTokenizer": return EdgeNGramTokenizer.DeserializeEdgeNGramTokenizer(element, options); + case "#Microsoft.Azure.Search.KeywordTokenizer": return KeywordTokenizer.DeserializeKeywordTokenizer(element, options); + case "#Microsoft.Azure.Search.KeywordTokenizerV2": return KeywordTokenizer.DeserializeKeywordTokenizer(element, options); + case "#Microsoft.Azure.Search.MicrosoftLanguageStemmingTokenizer": return MicrosoftLanguageStemmingTokenizer.DeserializeMicrosoftLanguageStemmingTokenizer(element, options); + case "#Microsoft.Azure.Search.MicrosoftLanguageTokenizer": return MicrosoftLanguageTokenizer.DeserializeMicrosoftLanguageTokenizer(element, options); + case "#Microsoft.Azure.Search.NGramTokenizer": return NGramTokenizer.DeserializeNGramTokenizer(element, options); + case "#Microsoft.Azure.Search.PathHierarchyTokenizerV2": return PathHierarchyTokenizer.DeserializePathHierarchyTokenizer(element, options); + case "#Microsoft.Azure.Search.PatternTokenizer": return PatternTokenizer.DeserializePatternTokenizer(element, options); + case "#Microsoft.Azure.Search.StandardTokenizer": return LuceneStandardTokenizer.DeserializeLuceneStandardTokenizer(element, options); + case "#Microsoft.Azure.Search.StandardTokenizerV2": return LuceneStandardTokenizer.DeserializeLuceneStandardTokenizer(element, options); + case "#Microsoft.Azure.Search.UaxUrlEmailTokenizer": return UaxUrlEmailTokenizer.DeserializeUaxUrlEmailTokenizer(element, options); + } + } + return UnknownLexicalTokenizer.DeserializeUnknownLexicalTokenizer(element, options); + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Indexes/Models/LuceneStandardTokenizer.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/LuceneStandardTokenizer.cs index fd24d1668ccc..0b37d8d4d69c 100644 --- a/sdk/search/Azure.Search.Documents/src/Indexes/Models/LuceneStandardTokenizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/LuceneStandardTokenizer.cs @@ -7,7 +7,6 @@ namespace Azure.Search.Documents.Indexes.Models { [CodeGenModel("LuceneStandardTokenizerV2")] - [CodeGenSuppress(nameof(LuceneStandardTokenizer), typeof(string), typeof(string), typeof(int?))] public partial class LuceneStandardTokenizer : IUtf8JsonSerializable { /// diff --git a/sdk/search/Azure.Search.Documents/src/Indexes/Models/NGramTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/NGramTokenFilter.cs index 1c6bfd7675de..2871b56e8ae3 100644 --- a/sdk/search/Azure.Search.Documents/src/Indexes/Models/NGramTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/NGramTokenFilter.cs @@ -7,7 +7,6 @@ namespace Azure.Search.Documents.Indexes.Models { [CodeGenModel("NGramTokenFilterV2")] - [CodeGenSuppress(nameof(NGramTokenFilter), typeof(string), typeof(string), typeof(int?), typeof(int?))] public partial class NGramTokenFilter : IUtf8JsonSerializable { /// diff --git a/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchIndexerDataSourceConnection.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchIndexerDataSourceConnection.cs index f867669873a3..1b120f934d37 100644 --- a/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchIndexerDataSourceConnection.cs +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchIndexerDataSourceConnection.cs @@ -53,7 +53,7 @@ private DataSourceCredentials CredentialsInternal { get { - return new DataSourceCredentials(ConnectionString ?? DataSourceCredentials.UnchangedValue); + return new DataSourceCredentials(ConnectionString ?? DataSourceCredentials.UnchangedValue, serializedAdditionalRawData: null); } set diff --git a/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchResourceEncryptionKey.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchResourceEncryptionKey.cs index 369ebec05144..aba50fb7e0dc 100644 --- a/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchResourceEncryptionKey.cs +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchResourceEncryptionKey.cs @@ -73,7 +73,7 @@ private AzureActiveDirectoryApplicationCredentials AccessCredentialsInternal { if (ApplicationId != null || ApplicationSecret != null) { - return new AzureActiveDirectoryApplicationCredentials(ApplicationId, ApplicationSecret); + return new AzureActiveDirectoryApplicationCredentials(ApplicationId, ApplicationSecret, serializedAdditionalRawData: null); } return null; diff --git a/sdk/search/Azure.Search.Documents/src/Indexes/Models/SimilarityAlgorithm.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/SimilarityAlgorithm.cs index 9b8aaa8d849b..a8308447ec8d 100644 --- a/sdk/search/Azure.Search.Documents/src/Indexes/Models/SimilarityAlgorithm.cs +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/SimilarityAlgorithm.cs @@ -9,7 +9,7 @@ namespace Azure.Search.Documents.Indexes.Models public partial class SimilarityAlgorithm { /// Initializes a new instance of SimilarityAlgorithm. - private protected SimilarityAlgorithm() + internal SimilarityAlgorithm() { } } diff --git a/sdk/search/Azure.Search.Documents/src/Indexes/Models/TokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/TokenFilter.cs index fc98f70d5ad8..36a4525ed0f9 100644 --- a/sdk/search/Azure.Search.Documents/src/Indexes/Models/TokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/TokenFilter.cs @@ -2,6 +2,9 @@ // Licensed under the MIT License. using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Search.Documents.Models; namespace Azure.Search.Documents.Indexes.Models { @@ -14,5 +17,47 @@ private protected TokenFilter(string name) { Name = name ?? throw new ArgumentNullException(nameof(name)); } + + internal static TokenFilter DeserializeTokenFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("@odata.type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "#Microsoft.Azure.Search.AsciiFoldingTokenFilter": return AsciiFoldingTokenFilter.DeserializeAsciiFoldingTokenFilter(element, options); + case "#Microsoft.Azure.Search.CjkBigramTokenFilter": return CjkBigramTokenFilter.DeserializeCjkBigramTokenFilter(element, options); + case "#Microsoft.Azure.Search.CommonGramTokenFilter": return CommonGramTokenFilter.DeserializeCommonGramTokenFilter(element, options); + case "#Microsoft.Azure.Search.DictionaryDecompounderTokenFilter": return DictionaryDecompounderTokenFilter.DeserializeDictionaryDecompounderTokenFilter(element, options); + case "#Microsoft.Azure.Search.EdgeNGramTokenFilter": return EdgeNGramTokenFilter.DeserializeEdgeNGramTokenFilter(element, options); + case "#Microsoft.Azure.Search.EdgeNGramTokenFilterV2": return EdgeNGramTokenFilter.DeserializeEdgeNGramTokenFilter(element, options); + case "#Microsoft.Azure.Search.ElisionTokenFilter": return ElisionTokenFilter.DeserializeElisionTokenFilter(element, options); + case "#Microsoft.Azure.Search.KeepTokenFilter": return KeepTokenFilter.DeserializeKeepTokenFilter(element, options); + case "#Microsoft.Azure.Search.KeywordMarkerTokenFilter": return KeywordMarkerTokenFilter.DeserializeKeywordMarkerTokenFilter(element, options); + case "#Microsoft.Azure.Search.LengthTokenFilter": return LengthTokenFilter.DeserializeLengthTokenFilter(element, options); + case "#Microsoft.Azure.Search.LimitTokenFilter": return LimitTokenFilter.DeserializeLimitTokenFilter(element, options); + case "#Microsoft.Azure.Search.NGramTokenFilter": return NGramTokenFilter.DeserializeNGramTokenFilter(element, options); + case "#Microsoft.Azure.Search.NGramTokenFilterV2": return NGramTokenFilter.DeserializeNGramTokenFilter(element, options); + case "#Microsoft.Azure.Search.PatternCaptureTokenFilter": return PatternCaptureTokenFilter.DeserializePatternCaptureTokenFilter(element, options); + case "#Microsoft.Azure.Search.PatternReplaceTokenFilter": return PatternReplaceTokenFilter.DeserializePatternReplaceTokenFilter(element, options); + case "#Microsoft.Azure.Search.PhoneticTokenFilter": return PhoneticTokenFilter.DeserializePhoneticTokenFilter(element, options); + case "#Microsoft.Azure.Search.ShingleTokenFilter": return ShingleTokenFilter.DeserializeShingleTokenFilter(element, options); + case "#Microsoft.Azure.Search.SnowballTokenFilter": return SnowballTokenFilter.DeserializeSnowballTokenFilter(element, options); + case "#Microsoft.Azure.Search.StemmerOverrideTokenFilter": return StemmerOverrideTokenFilter.DeserializeStemmerOverrideTokenFilter(element, options); + case "#Microsoft.Azure.Search.StemmerTokenFilter": return StemmerTokenFilter.DeserializeStemmerTokenFilter(element, options); + case "#Microsoft.Azure.Search.StopwordsTokenFilter": return StopwordsTokenFilter.DeserializeStopwordsTokenFilter(element, options); + case "#Microsoft.Azure.Search.SynonymTokenFilter": return SynonymTokenFilter.DeserializeSynonymTokenFilter(element, options); + case "#Microsoft.Azure.Search.TruncateTokenFilter": return TruncateTokenFilter.DeserializeTruncateTokenFilter(element, options); + case "#Microsoft.Azure.Search.UniqueTokenFilter": return UniqueTokenFilter.DeserializeUniqueTokenFilter(element, options); + case "#Microsoft.Azure.Search.WordDelimiterTokenFilter": return WordDelimiterTokenFilter.DeserializeWordDelimiterTokenFilter(element, options); + } + } + return UnknownTokenFilter.DeserializeUnknownTokenFilter(element, options); + } } } diff --git a/sdk/search/Azure.Search.Documents/src/Models/AzureSearchDocumentsContext.Custom.cs b/sdk/search/Azure.Search.Documents/src/Models/AzureSearchDocumentsContext.Custom.cs deleted file mode 100644 index 4047f2acc5bb..000000000000 --- a/sdk/search/Azure.Search.Documents/src/Models/AzureSearchDocumentsContext.Custom.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.ClientModel.Primitives; -using System.ComponentModel; - -namespace Azure.Search.Documents -{ - /// - /// Context class which will be filled in by the System.ClientModel.SourceGeneration. - /// For more information see 'https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/src/docs/ModelReaderWriterContext.md' - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public partial class AzureSearchDocumentsContext : ModelReaderWriterContext - { - private AzureSearchDocumentsContext _azureSearchDocumentsContext; - - /// Gets the default instance - [EditorBrowsable(EditorBrowsableState.Never)] - public AzureSearchDocumentsContext Default => _azureSearchDocumentsContext ??= new(); - } -} diff --git a/sdk/search/Azure.Search.Documents/src/Models/SearchModelFactory.cs b/sdk/search/Azure.Search.Documents/src/Models/SearchModelFactory.cs index 3fda2a696d8f..e7d8f3243d8c 100644 --- a/sdk/search/Azure.Search.Documents/src/Models/SearchModelFactory.cs +++ b/sdk/search/Azure.Search.Documents/src/Models/SearchModelFactory.cs @@ -36,7 +36,7 @@ public static AnalyzedTokenInfo AnalyzedTokenInfo( public static CharFilter CharFilter( string oDataType, string name) => - new CharFilter(oDataType, name); + new CharFilter(oDataType, name, serializedAdditionalRawData: null); /// Initializes a new instance of CognitiveServicesAccount. /// Identifies the concrete type of the cognitive service resource attached to a skillset. @@ -44,19 +44,19 @@ public static CharFilter CharFilter( public static CognitiveServicesAccount CognitiveServicesAccount( string oDataType, string description) => - new CognitiveServicesAccount(oDataType, description); + new CognitiveServicesAccount(oDataType, description, serializedAdditionalRawData: null); /// Initializes a new instance of DataChangeDetectionPolicy. /// Identifies the concrete type of the data change detection policy. public static DataChangeDetectionPolicy DataChangeDetectionPolicy( string oDataType) => - new DataChangeDetectionPolicy(oDataType); + new DataChangeDetectionPolicy(oDataType, serializedAdditionalRawData: null); /// Initializes a new instance of DataDeletionDetectionPolicy. /// Identifies the concrete type of the data deletion detection policy. public static DataDeletionDetectionPolicy DataDeletionDetectionPolicy( string oDataType) => - new DataDeletionDetectionPolicy(oDataType); + new DataDeletionDetectionPolicy(oDataType, serializedAdditionalRawData: null); /// Initializes a new instance of IndexerExecutionResult. /// The outcome of this indexer execution. @@ -82,7 +82,7 @@ public static IndexerExecutionResult IndexerExecutionResult( int failedItemCount, string initialTrackingState, string finalTrackingState) => - new IndexerExecutionResult(status, null, null, errorMessage, startTime, endTime, errors, warnings, itemCount, failedItemCount, initialTrackingState, finalTrackingState); + new IndexerExecutionResult(status, null, null, errorMessage, startTime, endTime, errors, warnings, itemCount, failedItemCount, initialTrackingState, finalTrackingState, serializedAdditionalRawData: null); /// Initializes a new instance of IndexerExecutionResult. /// The outcome of this indexer execution. @@ -112,7 +112,7 @@ public static IndexerExecutionResult IndexerExecutionResult( errors ??= new List(); warnings ??= new List(); - return new IndexerExecutionResult(status, null, null, errorMessage, startTime, endTime, errors?.ToList(), warnings?.ToList(), itemCount, failedItemCount, initialTrackingState, finalTrackingState); + return new IndexerExecutionResult(status, null, null, errorMessage, startTime, endTime, errors?.ToList(), warnings?.ToList(), itemCount, failedItemCount, initialTrackingState, finalTrackingState, serializedAdditionalRawData: null); } /// Initializes a new instance of LexicalAnalyzer. @@ -121,7 +121,7 @@ public static IndexerExecutionResult IndexerExecutionResult( public static LexicalAnalyzer LexicalAnalyzer( string oDataType, string name) => - new LexicalAnalyzer(oDataType, name); + new LexicalAnalyzer(oDataType, name, serializedAdditionalRawData: null); /// Initializes a new instance of LexicalTokenizer. /// Identifies the concrete type of the tokenizer. @@ -129,7 +129,7 @@ public static LexicalAnalyzer LexicalAnalyzer( public static LexicalTokenizer LexicalTokenizer( string oDataType, string name) => - new LexicalTokenizer(oDataType, name); + new LexicalTokenizer(oDataType, name, serializedAdditionalRawData: null); /// Initializes a new instance of ScoringFunction. /// Indicates the type of function to use. Valid values include magnitude, freshness, distance, and tag. The function type must be lower case. @@ -141,7 +141,7 @@ public static ScoringFunction ScoringFunction( string fieldName, double boost, ScoringFunctionInterpolation? interpolation) => - new ScoringFunction(type, fieldName, boost, interpolation); + new ScoringFunction(type, fieldName, boost, interpolation, serializedAdditionalRawData: null); /// Initializes a new instance of SearchIndexerError. /// The key of the item for which indexing failed. @@ -158,7 +158,7 @@ public static SearchIndexerError SearchIndexerError( string name, string details, string documentationLink) => - new SearchIndexerError(key, errorMessage, statusCode, name, details, documentationLink); + new SearchIndexerError(key, errorMessage, statusCode, name, details, documentationLink, serializedAdditionalRawData: null); /// Initializes a new instance of SearchIndexerLimits. /// The maximum duration that the indexer is permitted to run for one execution. @@ -169,7 +169,7 @@ public static SearchIndexerLimits SearchIndexerLimits( TimeSpan? maxRunTime, long? maxDocumentExtractionSize, long? maxDocumentContentCharactersToExtract) => - new SearchIndexerLimits(maxRunTime, maxDocumentExtractionSize, maxDocumentContentCharactersToExtract); + new SearchIndexerLimits(maxRunTime, maxDocumentExtractionSize, maxDocumentContentCharactersToExtract, serializedAdditionalRawData: null); /// Initializes a new instance of SearchIndexerSkill. /// Identifies the concrete type of the skill. @@ -185,7 +185,7 @@ public static SearchIndexerSkill SearchIndexerSkill( string context, IList inputs, IList outputs) => - new SearchIndexerSkill(oDataType, name, description, context, inputs, outputs); + new SearchIndexerSkill(oDataType, name, description, context, inputs, outputs, serializedAdditionalRawData: null); /// Initializes a new instance of SearchIndexerStatus. /// Overall indexer status. @@ -199,7 +199,7 @@ public static SearchIndexerStatus SearchIndexerStatus( IndexerExecutionResult lastResult, IReadOnlyList executionHistory, SearchIndexerLimits limits) => - new SearchIndexerStatus(status, lastResult, executionHistory, limits, default); + new SearchIndexerStatus(status, lastResult, executionHistory, limits, default, serializedAdditionalRawData: null); /// Initializes a new instance of . /// Overall indexer status. @@ -212,7 +212,7 @@ public static SearchIndexerStatus SearchIndexerStatus(IndexerStatus status = def { executionHistory ??= new List(); - return new SearchIndexerStatus(status, lastResult, executionHistory?.ToList(), limits, default); + return new SearchIndexerStatus(status, lastResult, executionHistory?.ToList(), limits, default, serializedAdditionalRawData: null); } /// Initializes a new instance of SearchIndexerWarning. @@ -228,7 +228,7 @@ public static SearchIndexerWarning SearchIndexerWarning( string name, string details, string documentationLink) => - new SearchIndexerWarning(key, message, name, details, documentationLink); + new SearchIndexerWarning(key, message, name, details, documentationLink, serializedAdditionalRawData: null); /// Initializes a new instance of SearchIndexStatistics. /// The number of documents in the index. @@ -247,7 +247,7 @@ public static SearchIndexStatistics SearchIndexStatistics( public static SearchResourceCounter SearchResourceCounter( long usage, long? quota) => - new SearchResourceCounter(usage, quota); + new SearchResourceCounter(usage, quota, serializedAdditionalRawData: null); /// Initializes a new instance of SearchServiceCounters. /// Total number of documents across all indexes in the service. @@ -321,7 +321,7 @@ public static SearchServiceLimits SearchServiceLimits( int? maxFieldNestingDepthPerIndex, int? maxComplexCollectionFieldsPerIndex, int? maxComplexObjectsInCollectionsPerDocument) => - new SearchServiceLimits(maxFieldsPerIndex, maxFieldNestingDepthPerIndex, maxComplexCollectionFieldsPerIndex, maxComplexObjectsInCollectionsPerDocument, null); + new SearchServiceLimits(maxFieldsPerIndex, maxFieldNestingDepthPerIndex, maxComplexCollectionFieldsPerIndex, maxComplexObjectsInCollectionsPerDocument, null, serializedAdditionalRawData: null); /// Initializes a new instance of SearchServiceStatistics. /// Service level resource counters. @@ -336,7 +336,7 @@ public static SearchServiceStatistics SearchServiceStatistics( /// . public static SimilarityAlgorithm SimilarityAlgorithm( string oDataType) => - new SimilarityAlgorithm(oDataType); + new SimilarityAlgorithm(oDataType, serializedAdditionalRawData: null); /// Initializes a new instance of TokenFilter. /// Identifies the concrete type of the token filter. @@ -344,7 +344,7 @@ public static SimilarityAlgorithm SimilarityAlgorithm( public static TokenFilter TokenFilter( string oDataType, string name) => - new TokenFilter(oDataType, name); + new TokenFilter(oDataType, name, serializedAdditionalRawData: null); /// Initializes a new instance of AutocompleteResults. /// A value indicating the percentage of the index that was considered by the autocomplete request, or null if minimumCoverage was not specified in the request. @@ -354,7 +354,7 @@ public static TokenFilter TokenFilter( public static AutocompleteResults AutocompleteResults( double? coverage, IReadOnlyList results) => - new AutocompleteResults(coverage, results); + new AutocompleteResults(coverage, results, serializedAdditionalRawData: null); /// Initializes a new instance of AutocompleteItem. /// The completed term. @@ -411,7 +411,7 @@ public static IndexingResult IndexingResult( string errorMessage, bool succeeded, int status) => - new IndexingResult(key, errorMessage, succeeded, status); + new IndexingResult(key, errorMessage, succeeded, status, serializedAdditionalRawData: null); /// Initializes a new instance of IndexerState. /// The mode the indexer is running in. diff --git a/sdk/search/Azure.Search.Documents/src/autorest.md b/sdk/search/Azure.Search.Documents/src/autorest.md index 5e9b65bca049..913b998dd6e2 100644 --- a/sdk/search/Azure.Search.Documents/src/autorest.md +++ b/sdk/search/Azure.Search.Documents/src/autorest.md @@ -7,6 +7,10 @@ See the [Contributing guidelines](https://github.com/Azure/azure-sdk-for-net/blo ## AutoRest Configuration > see https://aka.ms/autorest +```yaml +use-model-reader-writer: true +``` + ## Swagger Source(s) ```yaml title: SearchServiceClient @@ -81,6 +85,19 @@ directive: $["x-namespace"] = "Azure.Search.Documents.Agents.Models" ``` +### Remove models that have newer versions + +These classes have `CodeGenModel` pointing to newer models. Don't try to generate the +old models into the same class. + +```yaml +directive: + - remove-model: EdgeNGramTokenFilter + - remove-model: KeywordTokenizer + - remove-model: LuceneStandardTokenizer + - remove-model: NGramTokenFilter +``` + ## Renaming models after the AI Studio rebrand to AI Foundry These should eventually be fixed in the swagger files. ```yaml diff --git a/sdk/search/Azure.Search.Documents/tests/Models/DataSourceTests.cs b/sdk/search/Azure.Search.Documents/tests/Models/DataSourceTests.cs index dc53322054a9..c5ef8e94c732 100644 --- a/sdk/search/Azure.Search.Documents/tests/Models/DataSourceTests.cs +++ b/sdk/search/Azure.Search.Documents/tests/Models/DataSourceTests.cs @@ -13,7 +13,7 @@ public class DataSourceTests [TestCase("\"0123abcd\"", "\"0123abcd\"")] public void ParsesETag(string value, string expected) { - SearchIndexerDataSourceConnection sut = new(null, null, SearchIndexerDataSourceType.AzureBlob, null, null, null, null, null, null, value, null); + SearchIndexerDataSourceConnection sut = new(null, null, SearchIndexerDataSourceType.AzureBlob, null, null, null, null, null, null, value, null, serializedAdditionalRawData: null); Assert.AreEqual(expected, sut.ETag?.ToString()); } } diff --git a/sdk/search/Azure.Search.Documents/tests/Models/SearchIndexTests.cs b/sdk/search/Azure.Search.Documents/tests/Models/SearchIndexTests.cs index df9bb86a9044..05bb064ca44f 100644 --- a/sdk/search/Azure.Search.Documents/tests/Models/SearchIndexTests.cs +++ b/sdk/search/Azure.Search.Documents/tests/Models/SearchIndexTests.cs @@ -14,7 +14,7 @@ public class SearchIndexTests [TestCase("\"0123abcd\"", "\"0123abcd\"")] public void ParsesETag(string value, string expected) { - SearchIndex sut = new SearchIndex(null, null, new SearchField[0], null, null, null, null, null, null, null, null, null, null, null, null, null, null, value); + SearchIndex sut = new SearchIndex(null, null, new SearchField[0], null, null, null, null, null, null, null, null, null, null, null, null, null, null, value, serializedAdditionalRawData: null); Assert.AreEqual(expected, sut.ETag?.ToString()); } diff --git a/sdk/search/Azure.Search.Documents/tests/Models/SearchIndexerTests.cs b/sdk/search/Azure.Search.Documents/tests/Models/SearchIndexerTests.cs index dfdda90105cd..b5bcf82abff6 100644 --- a/sdk/search/Azure.Search.Documents/tests/Models/SearchIndexerTests.cs +++ b/sdk/search/Azure.Search.Documents/tests/Models/SearchIndexerTests.cs @@ -13,7 +13,7 @@ public class SearchIndexerTests [TestCase("\"0123abcd\"", "\"0123abcd\"")] public void ParsesETag(string value, string expected) { - SearchIndexer sut = new SearchIndexer(null, null, null, null, null, null, null, null, null, null, value, null, null); + SearchIndexer sut = new SearchIndexer(null, null, null, null, null, null, null, null, null, null, value, null, null, serializedAdditionalRawData: null); Assert.AreEqual(expected, sut.ETag?.ToString()); } } diff --git a/sdk/search/Azure.Search.Documents/tests/Models/SkillsetTests.cs b/sdk/search/Azure.Search.Documents/tests/Models/SkillsetTests.cs index b39e74fec8c1..0a297194ec0a 100644 --- a/sdk/search/Azure.Search.Documents/tests/Models/SkillsetTests.cs +++ b/sdk/search/Azure.Search.Documents/tests/Models/SkillsetTests.cs @@ -13,7 +13,7 @@ public class SkillsetTests [TestCase("\"0123abcd\"", "\"0123abcd\"")] public void ParsesETag(string value, string expected) { - SearchIndexerSkillset sut = new(name: null, description: null, skills: null, cognitiveServicesAccount: null, knowledgeStore: null, indexProjection: null, etag: value, encryptionKey: null); + SearchIndexerSkillset sut = new(name: null, description: null, skills: null, cognitiveServicesAccount: null, knowledgeStore: null, indexProjection: null, etag: value, encryptionKey: null, serializedAdditionalRawData: null); Assert.AreEqual(expected, sut.ETag?.ToString()); } diff --git a/sdk/search/Azure.Search.Documents/tests/Models/SynonymMapTests.cs b/sdk/search/Azure.Search.Documents/tests/Models/SynonymMapTests.cs index 72110ef3dcce..f5bffa3cdc42 100644 --- a/sdk/search/Azure.Search.Documents/tests/Models/SynonymMapTests.cs +++ b/sdk/search/Azure.Search.Documents/tests/Models/SynonymMapTests.cs @@ -53,7 +53,7 @@ public void SynonymsFromTextReader() [TestCase("\"0123abcd\"", "\"0123abcd\"")] public void ParsesETag(string value, string expected) { - SynonymMap sut = new SynonymMap(null, null, null, null, value); + SynonymMap sut = new SynonymMap(null, null, null, null, value, serializedAdditionalRawData: null); Assert.AreEqual(expected, sut.ETag?.ToString()); } } diff --git a/sdk/search/Azure.Search.Documents/tests/SearchIndexerClientTests.cs b/sdk/search/Azure.Search.Documents/tests/SearchIndexerClientTests.cs index 2551f203fc35..aba60374367c 100644 --- a/sdk/search/Azure.Search.Documents/tests/SearchIndexerClientTests.cs +++ b/sdk/search/Azure.Search.Documents/tests/SearchIndexerClientTests.cs @@ -641,7 +641,7 @@ public async Task RoundtripAllSkills() SearchIndexerSkill CreateSkill(Type t, string[] inputNames, string[] outputNames) { var inputs = inputNames.Select(input => new InputFieldMappingEntry(input) { Source = "/document/content" }).ToList(); - var outputs = outputNames.Select(output => new OutputFieldMappingEntry(output, targetName: Recording.Random.GetName())).ToList(); + var outputs = outputNames.Select(output => new OutputFieldMappingEntry(output, targetName: Recording.Random.GetName(), serializedAdditionalRawData: null)).ToList(); return t switch { @@ -663,7 +663,7 @@ SearchIndexerSkill CreateSkill(Type t, string[] inputNames, string[] outputNames EntityRecognitionSkill CreateEntityRecognitionSkill(EntityRecognitionSkill.SkillVersion skillVersion) { var inputs = new[] { "languageCode", "text" }.Select(input => new InputFieldMappingEntry(input) { Source = "/document/content" }).ToList(); - var outputs = new[] { "persons" }.Select(output => new OutputFieldMappingEntry(output, targetName: Recording.Random.GetName())).ToList(); + var outputs = new[] { "persons" }.Select(output => new OutputFieldMappingEntry(output, targetName: Recording.Random.GetName(), serializedAdditionalRawData: null)).ToList(); if (skillVersion == EntityRecognitionSkill.SkillVersion.V1) { @@ -684,13 +684,13 @@ SentimentSkill CreateSentimentSkill(SentimentSkill.SkillVersion skillVersion) if (skillVersion == SentimentSkill.SkillVersion.V1) { var outputs = new[] { "score" }. - Select(output => new OutputFieldMappingEntry(output, targetName: Recording.Random.GetName())).ToList(); + Select(output => new OutputFieldMappingEntry(output, targetName: Recording.Random.GetName(), serializedAdditionalRawData: null)).ToList(); return new SentimentSkill(inputs, outputs); } if (skillVersion == SentimentSkill.SkillVersion.V3) { var outputs = new[] { "sentiment", "confidenceScores", "sentences" }. - Select(output => new OutputFieldMappingEntry(output, targetName: Recording.Random.GetName())).ToList(); + Select(output => new OutputFieldMappingEntry(output, targetName: Recording.Random.GetName(), serializedAdditionalRawData: null)).ToList(); return new SentimentSkill(inputs, outputs, skillVersion); }