diff --git a/sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.net8.0.cs b/sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.net8.0.cs index 545f8461f4b6..f6d8cb22734f 100644 --- a/sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.net8.0.cs +++ b/sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.net8.0.cs @@ -6,6 +6,17 @@ internal AzureAITranslationDocumentContext() { } public static Azure.AI.Translation.Document.AzureAITranslationDocumentContext Default { get { throw null; } } protected override bool TryGetTypeBuilderCore(System.Type type, out System.ClientModel.Primitives.ModelReaderWriterTypeBuilder builder) { throw null; } } + public partial class BatchOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BatchOptions() { } + public bool? TranslateTextWithinImage { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Translation.Document.BatchOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Translation.Document.BatchOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } public partial class DocumentFilterOrder { public DocumentFilterOrder(Azure.AI.Translation.Document.DocumentFilterProperty property, bool ascending = true) { } @@ -26,6 +37,8 @@ internal DocumentStatusResult() { } public System.DateTimeOffset LastModified { get { throw null; } } public System.Uri SourceDocumentUri { get { throw null; } } public Azure.AI.Translation.Document.DocumentTranslationStatus Status { get { throw null; } } + public int? TotalImageScansFailed { get { throw null; } } + public int? TotalImageScansSucceeded { get { throw null; } } public System.Uri TranslatedDocumentUri { get { throw null; } } public string TranslatedToLanguageCode { get { throw null; } } public float TranslationProgressPercentage { get { throw null; } } @@ -121,11 +134,12 @@ public DocumentTranslationClient(System.Uri endpoint, Azure.Core.TokenCredential } public partial class DocumentTranslationClientOptions : Azure.Core.ClientOptions { - public DocumentTranslationClientOptions(Azure.AI.Translation.Document.DocumentTranslationClientOptions.ServiceVersion version = Azure.AI.Translation.Document.DocumentTranslationClientOptions.ServiceVersion.V2024_05_01) { } + public DocumentTranslationClientOptions(Azure.AI.Translation.Document.DocumentTranslationClientOptions.ServiceVersion version = Azure.AI.Translation.Document.DocumentTranslationClientOptions.ServiceVersion.V2024_11_01_Preview) { } public Azure.AI.Translation.Document.DocumentTranslationAudience? Audience { get { throw null; } set { } } public enum ServiceVersion { V2024_05_01 = 1, + V2024_11_01_Preview = 2, } } public partial class DocumentTranslationFileFormat : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel @@ -281,10 +295,10 @@ public SingleDocumentTranslationClient(System.Uri endpoint, Azure.AzureKeyCreden public SingleDocumentTranslationClient(System.Uri endpoint, Azure.Core.TokenCredential credential) { } public SingleDocumentTranslationClient(System.Uri endpoint, Azure.Core.TokenCredential credential, Azure.AI.Translation.Document.DocumentTranslationClientOptions options) { } public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } } - public virtual Azure.Response Translate(string targetLanguage, Azure.AI.Translation.Document.DocumentTranslateContent documentTranslateContent, string sourceLanguage = null, string category = null, bool? allowFallback = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response Translate(string targetLanguage, Azure.Core.RequestContent content, string contentType, string sourceLanguage = null, string category = null, bool? allowFallback = default(bool?), Azure.RequestContext context = null) { throw null; } - public virtual System.Threading.Tasks.Task> TranslateAsync(string targetLanguage, Azure.AI.Translation.Document.DocumentTranslateContent documentTranslateContent, string sourceLanguage = null, string category = null, bool? allowFallback = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task TranslateAsync(string targetLanguage, Azure.Core.RequestContent content, string contentType, string sourceLanguage = null, string category = null, bool? allowFallback = default(bool?), Azure.RequestContext context = null) { throw null; } + public virtual Azure.Response Translate(string targetLanguage, Azure.AI.Translation.Document.DocumentTranslateContent documentTranslateContent, string sourceLanguage = null, string category = null, bool? allowFallback = default(bool?), bool? translateTextWithinImage = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Translate(string targetLanguage, Azure.Core.RequestContent content, string contentType, string sourceLanguage = null, string category = null, bool? allowFallback = default(bool?), bool? translateTextWithinImage = default(bool?), Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task> TranslateAsync(string targetLanguage, Azure.AI.Translation.Document.DocumentTranslateContent documentTranslateContent, string sourceLanguage = null, string category = null, bool? allowFallback = default(bool?), bool? translateTextWithinImage = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task TranslateAsync(string targetLanguage, Azure.Core.RequestContent content, string contentType, string sourceLanguage = null, string category = null, bool? allowFallback = default(bool?), bool? translateTextWithinImage = default(bool?), Azure.RequestContext context = null) { throw null; } } public enum StorageInputUriKind { @@ -306,6 +320,7 @@ public partial class TranslationBatch : System.ClientModel.Primitives.IJsonModel { public TranslationBatch(System.Collections.Generic.IEnumerable inputs) { } public System.Collections.Generic.IList Inputs { get { throw null; } } + public Azure.AI.Translation.Document.BatchOptions Options { get { throw null; } set { } } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.TranslationBatch System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } diff --git a/sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.netstandard2.0.cs b/sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.netstandard2.0.cs index 545f8461f4b6..f6d8cb22734f 100644 --- a/sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.netstandard2.0.cs +++ b/sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.netstandard2.0.cs @@ -6,6 +6,17 @@ internal AzureAITranslationDocumentContext() { } public static Azure.AI.Translation.Document.AzureAITranslationDocumentContext Default { get { throw null; } } protected override bool TryGetTypeBuilderCore(System.Type type, out System.ClientModel.Primitives.ModelReaderWriterTypeBuilder builder) { throw null; } } + public partial class BatchOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BatchOptions() { } + public bool? TranslateTextWithinImage { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Translation.Document.BatchOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Translation.Document.BatchOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } public partial class DocumentFilterOrder { public DocumentFilterOrder(Azure.AI.Translation.Document.DocumentFilterProperty property, bool ascending = true) { } @@ -26,6 +37,8 @@ internal DocumentStatusResult() { } public System.DateTimeOffset LastModified { get { throw null; } } public System.Uri SourceDocumentUri { get { throw null; } } public Azure.AI.Translation.Document.DocumentTranslationStatus Status { get { throw null; } } + public int? TotalImageScansFailed { get { throw null; } } + public int? TotalImageScansSucceeded { get { throw null; } } public System.Uri TranslatedDocumentUri { get { throw null; } } public string TranslatedToLanguageCode { get { throw null; } } public float TranslationProgressPercentage { get { throw null; } } @@ -121,11 +134,12 @@ public DocumentTranslationClient(System.Uri endpoint, Azure.Core.TokenCredential } public partial class DocumentTranslationClientOptions : Azure.Core.ClientOptions { - public DocumentTranslationClientOptions(Azure.AI.Translation.Document.DocumentTranslationClientOptions.ServiceVersion version = Azure.AI.Translation.Document.DocumentTranslationClientOptions.ServiceVersion.V2024_05_01) { } + public DocumentTranslationClientOptions(Azure.AI.Translation.Document.DocumentTranslationClientOptions.ServiceVersion version = Azure.AI.Translation.Document.DocumentTranslationClientOptions.ServiceVersion.V2024_11_01_Preview) { } public Azure.AI.Translation.Document.DocumentTranslationAudience? Audience { get { throw null; } set { } } public enum ServiceVersion { V2024_05_01 = 1, + V2024_11_01_Preview = 2, } } public partial class DocumentTranslationFileFormat : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel @@ -281,10 +295,10 @@ public SingleDocumentTranslationClient(System.Uri endpoint, Azure.AzureKeyCreden public SingleDocumentTranslationClient(System.Uri endpoint, Azure.Core.TokenCredential credential) { } public SingleDocumentTranslationClient(System.Uri endpoint, Azure.Core.TokenCredential credential, Azure.AI.Translation.Document.DocumentTranslationClientOptions options) { } public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } } - public virtual Azure.Response Translate(string targetLanguage, Azure.AI.Translation.Document.DocumentTranslateContent documentTranslateContent, string sourceLanguage = null, string category = null, bool? allowFallback = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response Translate(string targetLanguage, Azure.Core.RequestContent content, string contentType, string sourceLanguage = null, string category = null, bool? allowFallback = default(bool?), Azure.RequestContext context = null) { throw null; } - public virtual System.Threading.Tasks.Task> TranslateAsync(string targetLanguage, Azure.AI.Translation.Document.DocumentTranslateContent documentTranslateContent, string sourceLanguage = null, string category = null, bool? allowFallback = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task TranslateAsync(string targetLanguage, Azure.Core.RequestContent content, string contentType, string sourceLanguage = null, string category = null, bool? allowFallback = default(bool?), Azure.RequestContext context = null) { throw null; } + public virtual Azure.Response Translate(string targetLanguage, Azure.AI.Translation.Document.DocumentTranslateContent documentTranslateContent, string sourceLanguage = null, string category = null, bool? allowFallback = default(bool?), bool? translateTextWithinImage = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Translate(string targetLanguage, Azure.Core.RequestContent content, string contentType, string sourceLanguage = null, string category = null, bool? allowFallback = default(bool?), bool? translateTextWithinImage = default(bool?), Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task> TranslateAsync(string targetLanguage, Azure.AI.Translation.Document.DocumentTranslateContent documentTranslateContent, string sourceLanguage = null, string category = null, bool? allowFallback = default(bool?), bool? translateTextWithinImage = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task TranslateAsync(string targetLanguage, Azure.Core.RequestContent content, string contentType, string sourceLanguage = null, string category = null, bool? allowFallback = default(bool?), bool? translateTextWithinImage = default(bool?), Azure.RequestContext context = null) { throw null; } } public enum StorageInputUriKind { @@ -306,6 +320,7 @@ public partial class TranslationBatch : System.ClientModel.Primitives.IJsonModel { public TranslationBatch(System.Collections.Generic.IEnumerable inputs) { } public System.Collections.Generic.IList Inputs { get { throw null; } } + public Azure.AI.Translation.Document.BatchOptions Options { get { throw null; } set { } } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.TranslationBatch System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } diff --git a/sdk/translation/Azure.AI.Translation.Text/src/Generated/TranslatedTextAlignment.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/BatchOptions.Serialization.cs similarity index 60% rename from sdk/translation/Azure.AI.Translation.Text/src/Generated/TranslatedTextAlignment.Serialization.cs rename to sdk/translation/Azure.AI.Translation.Document/src/Generated/BatchOptions.Serialization.cs index 77a62593fc33..63b40bd6ab24 100644 --- a/sdk/translation/Azure.AI.Translation.Text/src/Generated/TranslatedTextAlignment.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/BatchOptions.Serialization.cs @@ -11,13 +11,13 @@ using System.Text.Json; using Azure.Core; -namespace Azure.AI.Translation.Text +namespace Azure.AI.Translation.Document { - public partial class TranslatedTextAlignment : IUtf8JsonSerializable, IJsonModel + public partial class BatchOptions : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,14 +28,17 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade /// 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; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(TranslatedTextAlignment)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(BatchOptions)} does not support writing '{format}' format."); } - writer.WritePropertyName("proj"u8); - writer.WriteStringValue(Projections); + if (Optional.IsDefined(TranslateTextWithinImage)) + { + writer.WritePropertyName("translateTextWithinImage"u8); + writer.WriteBooleanValue(TranslateTextWithinImage.Value); + } if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -53,19 +56,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TranslatedTextAlignment IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + BatchOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(TranslatedTextAlignment)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(BatchOptions)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeTranslatedTextAlignment(document.RootElement, options); + return DeserializeBatchOptions(document.RootElement, options); } - internal static TranslatedTextAlignment DeserializeTranslatedTextAlignment(JsonElement element, ModelReaderWriterOptions options = null) + internal static BatchOptions DeserializeBatchOptions(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -73,14 +76,18 @@ internal static TranslatedTextAlignment DeserializeTranslatedTextAlignment(JsonE { return null; } - string proj = default; + bool? translateTextWithinImage = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("proj"u8)) + if (property.NameEquals("translateTextWithinImage"u8)) { - proj = property.Value.GetString(); + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + translateTextWithinImage = property.Value.GetBoolean(); continue; } if (options.Format != "W") @@ -89,46 +96,46 @@ internal static TranslatedTextAlignment DeserializeTranslatedTextAlignment(JsonE } } serializedAdditionalRawData = rawDataDictionary; - return new TranslatedTextAlignment(proj, serializedAdditionalRawData); + return new BatchOptions(translateTextWithinImage, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": - return ModelReaderWriter.Write(this, options, AzureAITranslationTextContext.Default); + return ModelReaderWriter.Write(this, options, AzureAITranslationDocumentContext.Default); default: - throw new FormatException($"The model {nameof(TranslatedTextAlignment)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(BatchOptions)} does not support writing '{options.Format}' format."); } } - TranslatedTextAlignment IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + BatchOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTranslatedTextAlignment(document.RootElement, options); + return DeserializeBatchOptions(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(TranslatedTextAlignment)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(BatchOptions)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static TranslatedTextAlignment FromResponse(Response response) + internal static BatchOptions FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTranslatedTextAlignment(document.RootElement); + return DeserializeBatchOptions(document.RootElement); } /// Convert into a . diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/BatchOptions.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/BatchOptions.cs new file mode 100644 index 000000000000..8ddbbf8d7ceb --- /dev/null +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/BatchOptions.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Translation.Document +{ + /// Translation batch request options. + public partial class BatchOptions + { + /// + /// 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 BatchOptions() + { + } + + /// Initializes a new instance of . + /// Translation text within an image option. + /// Keeps track of any properties unknown to the library. + internal BatchOptions(bool? translateTextWithinImage, IDictionary serializedAdditionalRawData) + { + TranslateTextWithinImage = translateTextWithinImage; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Translation text within an image option. + public bool? TranslateTextWithinImage { get; set; } + } +} diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentStatusResult.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentStatusResult.Serialization.cs index 450aa2cdbf5e..aabaa99afba0 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentStatusResult.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentStatusResult.Serialization.cs @@ -60,6 +60,16 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WriteStringValue(Id); writer.WritePropertyName("characterCharged"u8); writer.WriteNumberValue(CharactersCharged); + if (Optional.IsDefined(TotalImageScansSucceeded)) + { + writer.WritePropertyName("totalImageScansSucceeded"u8); + writer.WriteNumberValue(TotalImageScansSucceeded.Value); + } + if (Optional.IsDefined(TotalImageScansFailed)) + { + writer.WritePropertyName("totalImageScansFailed"u8); + writer.WriteNumberValue(TotalImageScansFailed.Value); + } if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -107,6 +117,8 @@ internal static DocumentStatusResult DeserializeDocumentStatusResult(JsonElement float progress = default; string id = default; long characterCharged = default; + int? totalImageScansSucceeded = default; + int? totalImageScansFailed = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -169,6 +181,24 @@ internal static DocumentStatusResult DeserializeDocumentStatusResult(JsonElement characterCharged = property.Value.GetInt64(); continue; } + if (property.NameEquals("totalImageScansSucceeded"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + totalImageScansSucceeded = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("totalImageScansFailed"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + totalImageScansFailed = property.Value.GetInt32(); + continue; + } if (options.Format != "W") { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); @@ -186,6 +216,8 @@ internal static DocumentStatusResult DeserializeDocumentStatusResult(JsonElement progress, id, characterCharged, + totalImageScansSucceeded, + totalImageScansFailed, serializedAdditionalRawData); } diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentStatusResult.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentStatusResult.cs index ad2734f53e62..70297a750585 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentStatusResult.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentStatusResult.cs @@ -84,8 +84,10 @@ internal DocumentStatusResult(Uri sourceDocumentUri, DateTimeOffset createdOn, D /// Progress of the translation if available. /// Document Id. /// Character charged by the API. + /// Total image scans charged by the API. + /// Total image scans failed. /// Keeps track of any properties unknown to the library. - internal DocumentStatusResult(Uri translatedDocumentUri, Uri sourceDocumentUri, DateTimeOffset createdOn, DateTimeOffset lastModified, DocumentTranslationStatus status, string translatedToLanguageCode, JsonElement error, float progress, string id, long charactersCharged, IDictionary serializedAdditionalRawData) + internal DocumentStatusResult(Uri translatedDocumentUri, Uri sourceDocumentUri, DateTimeOffset createdOn, DateTimeOffset lastModified, DocumentTranslationStatus status, string translatedToLanguageCode, JsonElement error, float progress, string id, long charactersCharged, int? totalImageScansSucceeded, int? totalImageScansFailed, IDictionary serializedAdditionalRawData) { TranslatedDocumentUri = translatedDocumentUri; SourceDocumentUri = sourceDocumentUri; @@ -97,6 +99,8 @@ internal DocumentStatusResult(Uri translatedDocumentUri, Uri sourceDocumentUri, Progress = progress; Id = id; CharactersCharged = charactersCharged; + TotalImageScansSucceeded = totalImageScansSucceeded; + TotalImageScansFailed = totalImageScansFailed; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -104,5 +108,9 @@ internal DocumentStatusResult(Uri translatedDocumentUri, Uri sourceDocumentUri, internal DocumentStatusResult() { } + /// Total image scans charged by the API. + public int? TotalImageScansSucceeded { get; } + /// Total image scans failed. + public int? TotalImageScansFailed { get; } } } diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentTranslationClientOptions.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentTranslationClientOptions.cs index fc44e6926c9c..973affa55f5d 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentTranslationClientOptions.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentTranslationClientOptions.cs @@ -13,13 +13,15 @@ namespace Azure.AI.Translation.Document /// Client options for Azure.AI.Translation.Document library clients. public partial class DocumentTranslationClientOptions : ClientOptions { - private const ServiceVersion LatestVersion = ServiceVersion.V2024_05_01; + private const ServiceVersion LatestVersion = ServiceVersion.V2024_11_01_Preview; /// The version of the service to use. public enum ServiceVersion { /// Service version "2024-05-01". V2024_05_01 = 1, + /// Service version "2024-11-01-preview". + V2024_11_01_Preview = 2, } internal string Version { get; } diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/SingleDocumentTranslationClient.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/SingleDocumentTranslationClient.cs index 2f99db2b3d0d..25acf7194b2f 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/SingleDocumentTranslationClient.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/SingleDocumentTranslationClient.cs @@ -109,17 +109,18 @@ public SingleDocumentTranslationClient(Uri endpoint, TokenCredential credential, /// Specifies that the service is allowed to fall back to a general system when a custom system doesn't exist. /// Possible values are: true (default) or false. /// + /// Optional boolean parameter to translate text within an image in the document. /// The cancellation token to use. /// or is null. /// Use this API to submit a single translation request to the Document Translation Service. - public virtual async Task> TranslateAsync(string targetLanguage, DocumentTranslateContent documentTranslateContent, string sourceLanguage = null, string category = null, bool? allowFallback = null, CancellationToken cancellationToken = default) + public virtual async Task> TranslateAsync(string targetLanguage, DocumentTranslateContent documentTranslateContent, string sourceLanguage = null, string category = null, bool? allowFallback = null, bool? translateTextWithinImage = null, CancellationToken cancellationToken = default) { Argument.AssertNotNull(targetLanguage, nameof(targetLanguage)); Argument.AssertNotNull(documentTranslateContent, nameof(documentTranslateContent)); using MultipartFormDataRequestContent content = documentTranslateContent.ToMultipartRequestContent(); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await TranslateAsync(targetLanguage, content, content.ContentType, sourceLanguage, category, allowFallback, context).ConfigureAwait(false); + Response response = await TranslateAsync(targetLanguage, content, content.ContentType, sourceLanguage, category, allowFallback, translateTextWithinImage, context).ConfigureAwait(false); return Response.FromValue(response.Content, response); } @@ -144,17 +145,18 @@ public virtual async Task> TranslateAsync(string targetLang /// Specifies that the service is allowed to fall back to a general system when a custom system doesn't exist. /// Possible values are: true (default) or false. /// + /// Optional boolean parameter to translate text within an image in the document. /// The cancellation token to use. /// or is null. /// Use this API to submit a single translation request to the Document Translation Service. - public virtual Response Translate(string targetLanguage, DocumentTranslateContent documentTranslateContent, string sourceLanguage = null, string category = null, bool? allowFallback = null, CancellationToken cancellationToken = default) + public virtual Response Translate(string targetLanguage, DocumentTranslateContent documentTranslateContent, string sourceLanguage = null, string category = null, bool? allowFallback = null, bool? translateTextWithinImage = null, CancellationToken cancellationToken = default) { Argument.AssertNotNull(targetLanguage, nameof(targetLanguage)); Argument.AssertNotNull(documentTranslateContent, nameof(documentTranslateContent)); using MultipartFormDataRequestContent content = documentTranslateContent.ToMultipartRequestContent(); RequestContext context = FromCancellationToken(cancellationToken); - Response response = Translate(targetLanguage, content, content.ContentType, sourceLanguage, category, allowFallback, context); + Response response = Translate(targetLanguage, content, content.ContentType, sourceLanguage, category, allowFallback, translateTextWithinImage, context); return Response.FromValue(response.Content, response); } @@ -168,7 +170,7 @@ public virtual Response Translate(string targetLanguage, DocumentTra /// /// /// - /// Please try the simpler convenience overload with strongly typed models first. + /// Please try the simpler convenience overload with strongly typed models first. /// /// /// @@ -194,11 +196,12 @@ public virtual Response Translate(string targetLanguage, DocumentTra /// Specifies that the service is allowed to fall back to a general system when a custom system doesn't exist. /// Possible values are: true (default) or false. /// + /// Optional boolean parameter to translate text within an image in the document. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// or is null. /// Service returned a non-success status code. /// The response returned from the service. - public virtual async Task TranslateAsync(string targetLanguage, RequestContent content, string contentType, string sourceLanguage = null, string category = null, bool? allowFallback = null, RequestContext context = null) + public virtual async Task TranslateAsync(string targetLanguage, RequestContent content, string contentType, string sourceLanguage = null, string category = null, bool? allowFallback = null, bool? translateTextWithinImage = null, RequestContext context = null) { Argument.AssertNotNull(targetLanguage, nameof(targetLanguage)); Argument.AssertNotNull(content, nameof(content)); @@ -207,7 +210,7 @@ public virtual async Task TranslateAsync(string targetLanguage, Reques scope.Start(); try { - using HttpMessage message = CreateTranslateRequest(targetLanguage, content, contentType, sourceLanguage, category, allowFallback, context); + using HttpMessage message = CreateTranslateRequest(targetLanguage, content, contentType, sourceLanguage, category, allowFallback, translateTextWithinImage, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -227,7 +230,7 @@ public virtual async Task TranslateAsync(string targetLanguage, Reques /// /// /// - /// Please try the simpler convenience overload with strongly typed models first. + /// Please try the simpler convenience overload with strongly typed models first. /// /// /// @@ -253,11 +256,12 @@ public virtual async Task TranslateAsync(string targetLanguage, Reques /// Specifies that the service is allowed to fall back to a general system when a custom system doesn't exist. /// Possible values are: true (default) or false. /// + /// Optional boolean parameter to translate text within an image in the document. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// or is null. /// Service returned a non-success status code. /// The response returned from the service. - public virtual Response Translate(string targetLanguage, RequestContent content, string contentType, string sourceLanguage = null, string category = null, bool? allowFallback = null, RequestContext context = null) + public virtual Response Translate(string targetLanguage, RequestContent content, string contentType, string sourceLanguage = null, string category = null, bool? allowFallback = null, bool? translateTextWithinImage = null, RequestContext context = null) { Argument.AssertNotNull(targetLanguage, nameof(targetLanguage)); Argument.AssertNotNull(content, nameof(content)); @@ -266,7 +270,7 @@ public virtual Response Translate(string targetLanguage, RequestContent content, scope.Start(); try { - using HttpMessage message = CreateTranslateRequest(targetLanguage, content, contentType, sourceLanguage, category, allowFallback, context); + using HttpMessage message = CreateTranslateRequest(targetLanguage, content, contentType, sourceLanguage, category, allowFallback, translateTextWithinImage, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -276,7 +280,7 @@ public virtual Response Translate(string targetLanguage, RequestContent content, } } - internal HttpMessage CreateTranslateRequest(string targetLanguage, RequestContent content, string contentType, string sourceLanguage, string category, bool? allowFallback, RequestContext context) + internal HttpMessage CreateTranslateRequest(string targetLanguage, RequestContent content, string contentType, string sourceLanguage, string category, bool? allowFallback, bool? translateTextWithinImage, RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier200); var request = message.Request; @@ -299,6 +303,10 @@ internal HttpMessage CreateTranslateRequest(string targetLanguage, RequestConten { uri.AppendQuery("allowFallback", allowFallback.Value, true); } + if (translateTextWithinImage != null) + { + uri.AppendQuery("translateTextWithinImage", translateTextWithinImage.Value, true); + } request.Uri = uri; request.Headers.Add("Accept", "application/octet-stream"); request.Headers.Add("Content-Type", contentType); diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationBatch.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationBatch.Serialization.cs index 7a20c5f761d6..24c2baa78dd3 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationBatch.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationBatch.Serialization.cs @@ -41,6 +41,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WriteObjectValue(item, options); } writer.WriteEndArray(); + if (Optional.IsDefined(Options)) + { + writer.WritePropertyName("options"u8); + writer.WriteObjectValue(Options, options); + } if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -79,6 +84,7 @@ internal static TranslationBatch DeserializeTranslationBatch(JsonElement element return null; } IList inputs = default; + BatchOptions options0 = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -93,13 +99,22 @@ internal static TranslationBatch DeserializeTranslationBatch(JsonElement element inputs = array; continue; } + if (property.NameEquals("options"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + options0 = BatchOptions.DeserializeBatchOptions(property.Value, options); + continue; + } if (options.Format != "W") { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } serializedAdditionalRawData = rawDataDictionary; - return new TranslationBatch(inputs, serializedAdditionalRawData); + return new TranslationBatch(inputs, options0, serializedAdditionalRawData); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationBatch.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationBatch.cs index 82b309b8ec6a..5309362b29dc 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationBatch.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationBatch.cs @@ -58,10 +58,12 @@ public TranslationBatch(IEnumerable inputs) /// Initializes a new instance of . /// The input list of documents or folders containing documents. + /// The batch operation options. /// Keeps track of any properties unknown to the library. - internal TranslationBatch(IList inputs, IDictionary serializedAdditionalRawData) + internal TranslationBatch(IList inputs, BatchOptions options, IDictionary serializedAdditionalRawData) { Inputs = inputs; + Options = options; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -72,5 +74,7 @@ internal TranslationBatch() /// The input list of documents or folders containing documents. public IList Inputs { get; } + /// The batch operation options. + public BatchOptions Options { get; set; } } } diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationStatusSummary.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationStatusSummary.Serialization.cs index 0381f5e650f5..b9185314505b 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationStatusSummary.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationStatusSummary.Serialization.cs @@ -48,6 +48,16 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WriteNumberValue(Cancelled); writer.WritePropertyName("totalCharacterCharged"u8); writer.WriteNumberValue(TotalCharacterCharged); + if (Optional.IsDefined(TotalImageScansSucceeded)) + { + writer.WritePropertyName("totalImageScansSucceeded"u8); + writer.WriteNumberValue(TotalImageScansSucceeded.Value); + } + if (Optional.IsDefined(TotalImageScansFailed)) + { + writer.WritePropertyName("totalImageScansFailed"u8); + writer.WriteNumberValue(TotalImageScansFailed.Value); + } if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -92,6 +102,8 @@ internal static TranslationStatusSummary DeserializeTranslationStatusSummary(Jso int notYetStarted = default; int cancelled = default; long totalCharacterCharged = default; + int? totalImageScansSucceeded = default; + int? totalImageScansFailed = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -131,6 +143,24 @@ internal static TranslationStatusSummary DeserializeTranslationStatusSummary(Jso totalCharacterCharged = property.Value.GetInt64(); continue; } + if (property.NameEquals("totalImageScansSucceeded"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + totalImageScansSucceeded = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("totalImageScansFailed"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + totalImageScansFailed = property.Value.GetInt32(); + continue; + } if (options.Format != "W") { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); @@ -145,6 +175,8 @@ internal static TranslationStatusSummary DeserializeTranslationStatusSummary(Jso notYetStarted, cancelled, totalCharacterCharged, + totalImageScansSucceeded, + totalImageScansFailed, serializedAdditionalRawData); } diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationStatusSummary.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationStatusSummary.cs index 624bb2883520..b855d6e543b7 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationStatusSummary.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationStatusSummary.cs @@ -72,8 +72,10 @@ internal TranslationStatusSummary(int total, int failed, int success, int inProg /// Count of not yet started. /// Number of cancelled. /// Total characters charged by the API. + /// Total image scans charged by the API. + /// Total image scans failed. /// Keeps track of any properties unknown to the library. - internal TranslationStatusSummary(int total, int failed, int success, int inProgress, int notYetStarted, int cancelled, long totalCharacterCharged, IDictionary serializedAdditionalRawData) + internal TranslationStatusSummary(int total, int failed, int success, int inProgress, int notYetStarted, int cancelled, long totalCharacterCharged, int? totalImageScansSucceeded, int? totalImageScansFailed, IDictionary serializedAdditionalRawData) { Total = total; Failed = failed; @@ -82,6 +84,8 @@ internal TranslationStatusSummary(int total, int failed, int success, int inProg NotYetStarted = notYetStarted; Cancelled = cancelled; TotalCharacterCharged = totalCharacterCharged; + TotalImageScansSucceeded = totalImageScansSucceeded; + TotalImageScansFailed = totalImageScansFailed; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -104,5 +108,9 @@ internal TranslationStatusSummary() public int Cancelled { get; } /// Total characters charged by the API. public long TotalCharacterCharged { get; } + /// Total image scans charged by the API. + public int? TotalImageScansSucceeded { get; } + /// Total image scans failed. + public int? TotalImageScansFailed { get; } } } diff --git a/sdk/translation/Azure.AI.Translation.Document/tsp-location.yaml b/sdk/translation/Azure.AI.Translation.Document/tsp-location.yaml index 6acb879247c8..5efd68e45c79 100644 --- a/sdk/translation/Azure.AI.Translation.Document/tsp-location.yaml +++ b/sdk/translation/Azure.AI.Translation.Document/tsp-location.yaml @@ -1,3 +1,4 @@ directory: specification/translation/Azure.AI.DocumentTranslation -commit: dde20d195ffc89fab6f08b58a368e353cd89ac06 +commit: fd1acec611e742a931327cba26fd87a7ea559735 repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/translation/Azure.AI.Translation.Text/src/Generated/AITranslationTextModelFactory.cs b/sdk/translation/Azure.AI.Translation.Text/src/Generated/AITranslationTextModelFactory.cs index 2348b6d02f3d..dbc3e9fe7b93 100644 --- a/sdk/translation/Azure.AI.Translation.Text/src/Generated/AITranslationTextModelFactory.cs +++ b/sdk/translation/Azure.AI.Translation.Text/src/Generated/AITranslationTextModelFactory.cs @@ -30,11 +30,11 @@ public static GetSupportedLanguagesResult GetSupportedLanguagesResult(IReadOnlyD /// Initializes a new instance of . /// Display name of the language in the locale requested via Accept-Language header. /// Display name of the language in the locale native for this language. - /// Directionality, which is rtl for right-to-left languages or ltr for left-to-right languages. + /// Directionality, which is rtl for right-to-left languages or ltr for left-to-right languages. /// A new instance for mocking. - public static TranslationLanguage TranslationLanguage(string name = null, string nativeName = null, LanguageDirectionality directionality = default) + public static TranslationLanguage TranslationLanguage(string name = null, string nativeName = null, LanguageDirectionality dir = default) { - return new TranslationLanguage(name, nativeName, directionality, serializedAdditionalRawData: null); + return new TranslationLanguage(name, nativeName, dir, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -53,55 +53,85 @@ public static TransliterationLanguage TransliterationLanguage(string name = null /// Code identifying the script. /// Display name of the script in the locale requested via Accept-Language header. /// Display name of the language in the locale native for the language. - /// Directionality, which is rtl for right-to-left languages or ltr for left-to-right languages. - /// List of scripts available to convert text to. + /// Directionality, which is rtl for right-to-left languages or ltr for left-to-right languages. + /// List of scripts available to convert text to. /// A new instance for mocking. - public static TransliterableScript TransliterableScript(string code = null, string name = null, string nativeName = null, LanguageDirectionality directionality = default, IEnumerable targetLanguageScripts = null) + public static TransliterableScript TransliterableScript(string code = null, string name = null, string nativeName = null, LanguageDirectionality dir = default, IEnumerable toScripts = null) { - targetLanguageScripts ??= new List(); + toScripts ??= new List(); return new TransliterableScript( code, name, nativeName, - directionality, + dir, serializedAdditionalRawData: null, - targetLanguageScripts?.ToList()); + toScripts?.ToList()); } /// Initializes a new instance of . /// Code identifying the script. /// Display name of the script in the locale requested via Accept-Language header. /// Display name of the language in the locale native for the language. - /// Directionality, which is rtl for right-to-left languages or ltr for left-to-right languages. + /// Directionality, which is rtl for right-to-left languages or ltr for left-to-right languages. /// A new instance for mocking. - public static LanguageScript LanguageScript(string code = null, string name = null, string nativeName = null, LanguageDirectionality directionality = default) + public static LanguageScript LanguageScript(string code = null, string name = null, string nativeName = null, LanguageDirectionality dir = default) { - return new LanguageScript(code, name, nativeName, directionality, serializedAdditionalRawData: null); + return new LanguageScript(code, name, nativeName, dir, serializedAdditionalRawData: null); } /// Initializes a new instance of . /// Display name of the language in the locale requested via Accept-Language header. /// Display name of the language in the locale native for this language. - /// Directionality, which is rtl for right-to-left languages or ltr for left-to-right languages. + /// Directionality, which is rtl for right-to-left languages or ltr for left-to-right languages. /// List of languages with alterative translations and examples for the query expressed in the source language. /// A new instance for mocking. - public static SourceDictionaryLanguage SourceDictionaryLanguage(string name = null, string nativeName = null, LanguageDirectionality directionality = default, IEnumerable translations = null) + public static SourceDictionaryLanguage SourceDictionaryLanguage(string name = null, string nativeName = null, LanguageDirectionality dir = default, IEnumerable translations = null) { translations ??= new List(); - return new SourceDictionaryLanguage(name, nativeName, directionality, translations?.ToList(), serializedAdditionalRawData: null); + return new SourceDictionaryLanguage(name, nativeName, dir, translations?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . /// Display name of the language in the locale requested via Accept-Language header. /// Display name of the language in the locale native for this language. - /// Directionality, which is rtl for right-to-left languages or ltr for left-to-right languages. + /// Directionality, which is rtl for right-to-left languages or ltr for left-to-right languages. /// Language code identifying the target language. /// A new instance for mocking. - public static TargetDictionaryLanguage TargetDictionaryLanguage(string name = null, string nativeName = null, LanguageDirectionality directionality = default, string code = null) + public static TargetDictionaryLanguage TargetDictionaryLanguage(string name = null, string nativeName = null, LanguageDirectionality dir = default, string code = null) { - return new TargetDictionaryLanguage(name, nativeName, directionality, code, serializedAdditionalRawData: null); + return new TargetDictionaryLanguage(name, nativeName, dir, code, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Specifies the text string to be translated in the translate API. + /// Specifies the script of the input text. + /// + /// Specifies the language of the input text. Find which languages are available to translate by + /// looking up supported languages using the translation scope. If the language parameter isn't + /// specified, automatic language detection is applied to determine the source language. + /// + /// You must use the language parameter rather than autodetection when using the dynamic dictionary feature. + /// Note: the dynamic dictionary feature is case-sensitive. + /// + /// + /// Defines whether the text being translated is plain text or HTML text. Any HTML needs to be a well-formed, + /// complete element. Possible values are: plain (default) or html. + /// + /// Translation target parameters. + /// A new instance for mocking. + public static TranslateBodyDetails TranslateBodyDetails(string text = null, string script = null, string language = null, TextType? textType = null, IEnumerable targets = null) + { + targets ??= new List(); + + return new TranslateBodyDetails( + text, + script, + language, + textType, + targets?.ToList(), + serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -126,32 +156,24 @@ public static TranslatedTextItem TranslatedTextItem(DetectedLanguage detectedLan /// Initializes a new instance of . /// A string representing the code of the detected language. - /// + /// /// A float value indicating the confidence in the result. /// The score is between zero and one and a low score indicates a low confidence. /// /// A new instance for mocking. - public static DetectedLanguage DetectedLanguage(string language = null, float confidence = default) + public static DetectedLanguage DetectedLanguage(string language = null, float score = default) { - return new DetectedLanguage(language, confidence, serializedAdditionalRawData: null); + return new DetectedLanguage(language, score, serializedAdditionalRawData: null); } /// Initializes a new instance of . - /// A string representing the language code of the target language. + /// A string representing the language code of the target language. /// A string giving the translated text. /// An object giving the translated text in the script specified by the toScript parameter. - /// Alignment information. - /// Sentence boundaries in the input and output texts. /// A new instance for mocking. - public static TranslationText TranslationText(string targetLanguage = null, string text = null, TransliteratedText transliteration = null, TranslatedTextAlignment alignment = null, SentenceBoundaries sentenceBoundaries = null) + public static TranslationText TranslationText(string to = null, string text = null, TransliteratedText transliteration = null) { - return new TranslationText( - targetLanguage, - text, - transliteration, - alignment, - sentenceBoundaries, - serializedAdditionalRawData: null); + return new TranslationText(to, text, transliteration, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -163,39 +185,6 @@ public static TransliteratedText TransliteratedText(string text = null, string s return new TransliteratedText(text, script, serializedAdditionalRawData: null); } - /// Initializes a new instance of . - /// - /// Maps input text to translated text. The alignment information is only provided when the request - /// parameter includeAlignment is true. Alignment is returned as a string value of the following - /// format: [[SourceTextStartIndex]:[SourceTextEndIndex]–[TgtTextStartIndex]:[TgtTextEndIndex]]. - /// The colon separates start and end index, the dash separates the languages, and space separates the words. - /// One word may align with zero, one, or multiple words in the other language, and the aligned words may - /// be non-contiguous. When no alignment information is available, the alignment element will be empty. - /// - /// A new instance for mocking. - public static TranslatedTextAlignment TranslatedTextAlignment(string projections = null) - { - return new TranslatedTextAlignment(projections, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// - /// An integer array representing the lengths of the sentences in the input text. - /// The length of the array is the number of sentences, and the values are the length of each sentence. - /// - /// - /// An integer array representing the lengths of the sentences in the translated text. - /// The length of the array is the number of sentences, and the values are the length of each sentence. - /// - /// A new instance for mocking. - public static SentenceBoundaries SentenceBoundaries(IEnumerable sourceSentencesLengths = null, IEnumerable translatedSentencesLengths = null) - { - sourceSentencesLengths ??= new List(); - translatedSentencesLengths ??= new List(); - - return new SentenceBoundaries(sourceSentencesLengths?.ToList(), translatedSentencesLengths?.ToList(), serializedAdditionalRawData: null); - } - /// Initializes a new instance of . /// Input text in the default script of the source language. /// A new instance for mocking. @@ -203,162 +192,5 @@ public static SourceText SourceText(string text = null) { return new SourceText(text, serializedAdditionalRawData: null); } - - /// Initializes a new instance of . - /// The detectedLanguage property is only present in the result object when language auto-detection is requested. - /// - /// An integer array representing the lengths of the sentences in the input text. - /// The length of the array is the number of sentences, and the values are the length of each sentence. - /// - /// A new instance for mocking. - public static BreakSentenceItem BreakSentenceItem(DetectedLanguage detectedLanguage = null, IEnumerable sentencesLengths = null) - { - sentencesLengths ??= new List(); - - return new BreakSentenceItem(detectedLanguage, sentencesLengths?.ToList(), serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// - /// A string giving the normalized form of the source term. - /// For example, if the request is "JOHN", the normalized form will be "john". - /// The content of this field becomes the input to lookup examples. - /// - /// - /// A string giving the source term in a form best suited for end-user display. - /// For example, if the input is "JOHN", the display form will reflect the usual - /// spelling of the name: "John". - /// - /// A list of translations for the source term. - /// A new instance for mocking. - public static DictionaryLookupItem DictionaryLookupItem(string normalizedSource = null, string displaySource = null, IEnumerable translations = null) - { - translations ??= new List(); - - return new DictionaryLookupItem(normalizedSource, displaySource, translations?.ToList(), serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// - /// A string giving the normalized form of this term in the target language. - /// This value should be used as input to lookup examples. - /// - /// - /// A string giving the term in the target language and in a form best suited - /// for end-user display. Generally, this will only differ from the normalizedTarget - /// in terms of capitalization. For example, a proper noun like "Juan" will have - /// normalizedTarget = "juan" and displayTarget = "Juan". - /// - /// A string associating this term with a part-of-speech tag. - /// - /// A value between 0.0 and 1.0 which represents the "confidence" - /// (or perhaps more accurately, "probability in the training data") of that translation pair. - /// The sum of confidence scores for one source word may or may not sum to 1.0. - /// - /// - /// A string giving the word to display as a prefix of the translation. Currently, - /// this is the gendered determiner of nouns, in languages that have gendered determiners. - /// For example, the prefix of the Spanish word "mosca" is "la", since "mosca" is a feminine noun in Spanish. - /// This is only dependent on the translation, and not on the source. - /// If there is no prefix, it will be the empty string. - /// - /// - /// A list of "back translations" of the target. For example, source words that the target can translate to. - /// The list is guaranteed to contain the source word that was requested (e.g., if the source word being - /// looked up is "fly", then it is guaranteed that "fly" will be in the backTranslations list). - /// However, it is not guaranteed to be in the first position, and often will not be. - /// - /// A new instance for mocking. - public static DictionaryTranslation DictionaryTranslation(string normalizedTarget = null, string displayTarget = null, string posTag = null, float confidence = default, string prefixWord = null, IEnumerable backTranslations = null) - { - backTranslations ??= new List(); - - return new DictionaryTranslation( - normalizedTarget, - displayTarget, - posTag, - confidence, - prefixWord, - backTranslations?.ToList(), - serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// - /// A string giving the normalized form of the source term that is a back-translation of the target. - /// This value should be used as input to lookup examples. - /// - /// - /// A string giving the source term that is a back-translation of the target in a form best - /// suited for end-user display. - /// - /// - /// An integer representing the number of examples that are available for this translation pair. - /// Actual examples must be retrieved with a separate call to lookup examples. The number is mostly - /// intended to facilitate display in a UX. For example, a user interface may add a hyperlink - /// to the back-translation if the number of examples is greater than zero and show the back-translation - /// as plain text if there are no examples. Note that the actual number of examples returned - /// by a call to lookup examples may be less than numExamples, because additional filtering may be - /// applied on the fly to remove "bad" examples. - /// - /// - /// An integer representing the frequency of this translation pair in the data. The main purpose of this - /// field is to provide a user interface with a means to sort back-translations so the most frequent terms are first. - /// - /// A new instance for mocking. - public static BackTranslation BackTranslation(string normalizedText = null, string displayText = null, int examplesCount = default, int frequencyCount = default) - { - return new BackTranslation(normalizedText, displayText, examplesCount, frequencyCount, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// - /// A string giving the normalized form of the source term. Generally, this should be identical - /// to the value of the Text field at the matching list index in the body of the request. - /// - /// - /// A string giving the normalized form of the target term. Generally, this should be identical - /// to the value of the Translation field at the matching list index in the body of the request. - /// - /// A list of examples for the (source term, target term) pair. - /// A new instance for mocking. - public static DictionaryExampleItem DictionaryExampleItem(string normalizedSource = null, string normalizedTarget = null, IEnumerable examples = null) - { - examples ??= new List(); - - return new DictionaryExampleItem(normalizedSource, normalizedTarget, examples?.ToList(), serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// - /// The string to concatenate before the value of sourceTerm to form a complete example. - /// Do not add a space character, since it is already there when it should be. - /// This value may be an empty string. - /// - /// - /// A string equal to the actual term looked up. The string is added with sourcePrefix - /// and sourceSuffix to form the complete example. Its value is separated so it can be - /// marked in a user interface, e.g., by bolding it. - /// - /// - /// The string to concatenate after the value of sourceTerm to form a complete example. - /// Do not add a space character, since it is already there when it should be. - /// This value may be an empty string. - /// - /// A string similar to sourcePrefix but for the target. - /// A string similar to sourceTerm but for the target. - /// A string similar to sourceSuffix but for the target. - /// A new instance for mocking. - public static DictionaryExample DictionaryExample(string sourcePrefix = null, string sourceTerm = null, string sourceSuffix = null, string targetPrefix = null, string targetTerm = null, string targetSuffix = null) - { - return new DictionaryExample( - sourcePrefix, - sourceTerm, - sourceSuffix, - targetPrefix, - targetTerm, - targetSuffix, - serializedAdditionalRawData: null); - } } } diff --git a/sdk/translation/Azure.AI.Translation.Text/src/Generated/BackTranslation.Serialization.cs b/sdk/translation/Azure.AI.Translation.Text/src/Generated/BackTranslation.Serialization.cs deleted file mode 100644 index f6adad28a965..000000000000 --- a/sdk/translation/Azure.AI.Translation.Text/src/Generated/BackTranslation.Serialization.cs +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Translation.Text -{ - public partial class BackTranslation : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(BackTranslation)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("normalizedText"u8); - writer.WriteStringValue(NormalizedText); - writer.WritePropertyName("displayText"u8); - writer.WriteStringValue(DisplayText); - writer.WritePropertyName("numExamples"u8); - writer.WriteNumberValue(ExamplesCount); - writer.WritePropertyName("frequencyCount"u8); - writer.WriteNumberValue(FrequencyCount); - 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 - } - } - } - - BackTranslation 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(BackTranslation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeBackTranslation(document.RootElement, options); - } - - internal static BackTranslation DeserializeBackTranslation(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string normalizedText = default; - string displayText = default; - int numExamples = default; - int frequencyCount = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("normalizedText"u8)) - { - normalizedText = property.Value.GetString(); - continue; - } - if (property.NameEquals("displayText"u8)) - { - displayText = property.Value.GetString(); - continue; - } - if (property.NameEquals("numExamples"u8)) - { - numExamples = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("frequencyCount"u8)) - { - frequencyCount = property.Value.GetInt32(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new BackTranslation(normalizedText, displayText, numExamples, frequencyCount, 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, AzureAITranslationTextContext.Default); - default: - throw new FormatException($"The model {nameof(BackTranslation)} does not support writing '{options.Format}' format."); - } - } - - BackTranslation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeBackTranslation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(BackTranslation)} 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 BackTranslation FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeBackTranslation(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/translation/Azure.AI.Translation.Text/src/Generated/BackTranslation.cs b/sdk/translation/Azure.AI.Translation.Text/src/Generated/BackTranslation.cs deleted file mode 100644 index 5eeb74c3c083..000000000000 --- a/sdk/translation/Azure.AI.Translation.Text/src/Generated/BackTranslation.cs +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Translation.Text -{ - /// Back Translation. - public partial class BackTranslation - { - /// - /// 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 string giving the normalized form of the source term that is a back-translation of the target. - /// This value should be used as input to lookup examples. - /// - /// - /// A string giving the source term that is a back-translation of the target in a form best - /// suited for end-user display. - /// - /// - /// An integer representing the number of examples that are available for this translation pair. - /// Actual examples must be retrieved with a separate call to lookup examples. The number is mostly - /// intended to facilitate display in a UX. For example, a user interface may add a hyperlink - /// to the back-translation if the number of examples is greater than zero and show the back-translation - /// as plain text if there are no examples. Note that the actual number of examples returned - /// by a call to lookup examples may be less than numExamples, because additional filtering may be - /// applied on the fly to remove "bad" examples. - /// - /// - /// An integer representing the frequency of this translation pair in the data. The main purpose of this - /// field is to provide a user interface with a means to sort back-translations so the most frequent terms are first. - /// - /// or is null. - internal BackTranslation(string normalizedText, string displayText, int examplesCount, int frequencyCount) - { - Argument.AssertNotNull(normalizedText, nameof(normalizedText)); - Argument.AssertNotNull(displayText, nameof(displayText)); - - NormalizedText = normalizedText; - DisplayText = displayText; - ExamplesCount = examplesCount; - FrequencyCount = frequencyCount; - } - - /// Initializes a new instance of . - /// - /// A string giving the normalized form of the source term that is a back-translation of the target. - /// This value should be used as input to lookup examples. - /// - /// - /// A string giving the source term that is a back-translation of the target in a form best - /// suited for end-user display. - /// - /// - /// An integer representing the number of examples that are available for this translation pair. - /// Actual examples must be retrieved with a separate call to lookup examples. The number is mostly - /// intended to facilitate display in a UX. For example, a user interface may add a hyperlink - /// to the back-translation if the number of examples is greater than zero and show the back-translation - /// as plain text if there are no examples. Note that the actual number of examples returned - /// by a call to lookup examples may be less than numExamples, because additional filtering may be - /// applied on the fly to remove "bad" examples. - /// - /// - /// An integer representing the frequency of this translation pair in the data. The main purpose of this - /// field is to provide a user interface with a means to sort back-translations so the most frequent terms are first. - /// - /// Keeps track of any properties unknown to the library. - internal BackTranslation(string normalizedText, string displayText, int examplesCount, int frequencyCount, IDictionary serializedAdditionalRawData) - { - NormalizedText = normalizedText; - DisplayText = displayText; - ExamplesCount = examplesCount; - FrequencyCount = frequencyCount; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal BackTranslation() - { - } - - /// - /// A string giving the normalized form of the source term that is a back-translation of the target. - /// This value should be used as input to lookup examples. - /// - public string NormalizedText { get; } - /// - /// A string giving the source term that is a back-translation of the target in a form best - /// suited for end-user display. - /// - public string DisplayText { get; } - /// - /// An integer representing the number of examples that are available for this translation pair. - /// Actual examples must be retrieved with a separate call to lookup examples. The number is mostly - /// intended to facilitate display in a UX. For example, a user interface may add a hyperlink - /// to the back-translation if the number of examples is greater than zero and show the back-translation - /// as plain text if there are no examples. Note that the actual number of examples returned - /// by a call to lookup examples may be less than numExamples, because additional filtering may be - /// applied on the fly to remove "bad" examples. - /// - public int ExamplesCount { get; } - /// - /// An integer representing the frequency of this translation pair in the data. The main purpose of this - /// field is to provide a user interface with a means to sort back-translations so the most frequent terms are first. - /// - public int FrequencyCount { get; } - } -} diff --git a/sdk/translation/Azure.AI.Translation.Text/src/Generated/BreakSentenceItem.Serialization.cs b/sdk/translation/Azure.AI.Translation.Text/src/Generated/BreakSentenceItem.Serialization.cs deleted file mode 100644 index 3798c2a1beee..000000000000 --- a/sdk/translation/Azure.AI.Translation.Text/src/Generated/BreakSentenceItem.Serialization.cs +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Translation.Text -{ - public partial class BreakSentenceItem : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(BreakSentenceItem)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(DetectedLanguage)) - { - writer.WritePropertyName("detectedLanguage"u8); - writer.WriteObjectValue(DetectedLanguage, options); - } - writer.WritePropertyName("sentLen"u8); - writer.WriteStartArray(); - foreach (var item in SentencesLengths) - { - writer.WriteNumberValue(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 - } - } - } - - BreakSentenceItem 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(BreakSentenceItem)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeBreakSentenceItem(document.RootElement, options); - } - - internal static BreakSentenceItem DeserializeBreakSentenceItem(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - DetectedLanguage detectedLanguage = default; - IReadOnlyList sentLen = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("detectedLanguage"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - detectedLanguage = DetectedLanguage.DeserializeDetectedLanguage(property.Value, options); - continue; - } - if (property.NameEquals("sentLen"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetInt32()); - } - sentLen = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new BreakSentenceItem(detectedLanguage, sentLen, 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, AzureAITranslationTextContext.Default); - default: - throw new FormatException($"The model {nameof(BreakSentenceItem)} does not support writing '{options.Format}' format."); - } - } - - BreakSentenceItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeBreakSentenceItem(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(BreakSentenceItem)} 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 BreakSentenceItem FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeBreakSentenceItem(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/translation/Azure.AI.Translation.Text/src/Generated/BreakSentenceItem.cs b/sdk/translation/Azure.AI.Translation.Text/src/Generated/BreakSentenceItem.cs deleted file mode 100644 index c1d283a64f86..000000000000 --- a/sdk/translation/Azure.AI.Translation.Text/src/Generated/BreakSentenceItem.cs +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Azure.AI.Translation.Text -{ - /// Item containing break sentence result. - public partial class BreakSentenceItem - { - /// - /// 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 integer array representing the lengths of the sentences in the input text. - /// The length of the array is the number of sentences, and the values are the length of each sentence. - /// - /// is null. - internal BreakSentenceItem(IEnumerable sentencesLengths) - { - Argument.AssertNotNull(sentencesLengths, nameof(sentencesLengths)); - - SentencesLengths = sentencesLengths.ToList(); - } - - /// Initializes a new instance of . - /// The detectedLanguage property is only present in the result object when language auto-detection is requested. - /// - /// An integer array representing the lengths of the sentences in the input text. - /// The length of the array is the number of sentences, and the values are the length of each sentence. - /// - /// Keeps track of any properties unknown to the library. - internal BreakSentenceItem(DetectedLanguage detectedLanguage, IReadOnlyList sentencesLengths, IDictionary serializedAdditionalRawData) - { - DetectedLanguage = detectedLanguage; - SentencesLengths = sentencesLengths; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal BreakSentenceItem() - { - } - - /// The detectedLanguage property is only present in the result object when language auto-detection is requested. - public DetectedLanguage DetectedLanguage { get; } - /// - /// An integer array representing the lengths of the sentences in the input text. - /// The length of the array is the number of sentences, and the values are the length of each sentence. - /// - public IReadOnlyList SentencesLengths { get; } - } -} diff --git a/sdk/translation/Azure.AI.Translation.Text/src/Generated/DetectedLanguage.Serialization.cs b/sdk/translation/Azure.AI.Translation.Text/src/Generated/DetectedLanguage.Serialization.cs index a26a23f36cc5..cbe2c88d4c94 100644 --- a/sdk/translation/Azure.AI.Translation.Text/src/Generated/DetectedLanguage.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Text/src/Generated/DetectedLanguage.Serialization.cs @@ -37,7 +37,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("language"u8); writer.WriteStringValue(Language); writer.WritePropertyName("score"u8); - writer.WriteNumberValue(Confidence); + writer.WriteNumberValue(Score); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) diff --git a/sdk/translation/Azure.AI.Translation.Text/src/Generated/DetectedLanguage.cs b/sdk/translation/Azure.AI.Translation.Text/src/Generated/DetectedLanguage.cs index 22b9c2194b90..3be254c3db19 100644 --- a/sdk/translation/Azure.AI.Translation.Text/src/Generated/DetectedLanguage.cs +++ b/sdk/translation/Azure.AI.Translation.Text/src/Generated/DetectedLanguage.cs @@ -47,30 +47,30 @@ public partial class DetectedLanguage /// Initializes a new instance of . /// A string representing the code of the detected language. - /// + /// /// A float value indicating the confidence in the result. /// The score is between zero and one and a low score indicates a low confidence. /// /// is null. - internal DetectedLanguage(string language, float confidence) + internal DetectedLanguage(string language, float score) { Argument.AssertNotNull(language, nameof(language)); Language = language; - Confidence = confidence; + Score = score; } /// Initializes a new instance of . /// A string representing the code of the detected language. - /// + /// /// A float value indicating the confidence in the result. /// The score is between zero and one and a low score indicates a low confidence. /// /// Keeps track of any properties unknown to the library. - internal DetectedLanguage(string language, float confidence, IDictionary serializedAdditionalRawData) + internal DetectedLanguage(string language, float score, IDictionary serializedAdditionalRawData) { Language = language; - Confidence = confidence; + Score = score; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -85,6 +85,6 @@ internal DetectedLanguage() /// A float value indicating the confidence in the result. /// The score is between zero and one and a low score indicates a low confidence. /// - public float Confidence { get; } + public float Score { get; } } } diff --git a/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryExample.Serialization.cs b/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryExample.Serialization.cs deleted file mode 100644 index e7afe740f463..000000000000 --- a/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryExample.Serialization.cs +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Translation.Text -{ - public partial class DictionaryExample : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(DictionaryExample)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("sourcePrefix"u8); - writer.WriteStringValue(SourcePrefix); - writer.WritePropertyName("sourceTerm"u8); - writer.WriteStringValue(SourceTerm); - writer.WritePropertyName("sourceSuffix"u8); - writer.WriteStringValue(SourceSuffix); - writer.WritePropertyName("targetPrefix"u8); - writer.WriteStringValue(TargetPrefix); - writer.WritePropertyName("targetTerm"u8); - writer.WriteStringValue(TargetTerm); - writer.WritePropertyName("targetSuffix"u8); - writer.WriteStringValue(TargetSuffix); - 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 - } - } - } - - DictionaryExample 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(DictionaryExample)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeDictionaryExample(document.RootElement, options); - } - - internal static DictionaryExample DeserializeDictionaryExample(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string sourcePrefix = default; - string sourceTerm = default; - string sourceSuffix = default; - string targetPrefix = default; - string targetTerm = default; - string targetSuffix = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("sourcePrefix"u8)) - { - sourcePrefix = property.Value.GetString(); - continue; - } - if (property.NameEquals("sourceTerm"u8)) - { - sourceTerm = property.Value.GetString(); - continue; - } - if (property.NameEquals("sourceSuffix"u8)) - { - sourceSuffix = property.Value.GetString(); - continue; - } - if (property.NameEquals("targetPrefix"u8)) - { - targetPrefix = property.Value.GetString(); - continue; - } - if (property.NameEquals("targetTerm"u8)) - { - targetTerm = property.Value.GetString(); - continue; - } - if (property.NameEquals("targetSuffix"u8)) - { - targetSuffix = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new DictionaryExample( - sourcePrefix, - sourceTerm, - sourceSuffix, - targetPrefix, - targetTerm, - targetSuffix, - 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, AzureAITranslationTextContext.Default); - default: - throw new FormatException($"The model {nameof(DictionaryExample)} does not support writing '{options.Format}' format."); - } - } - - DictionaryExample IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeDictionaryExample(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(DictionaryExample)} 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 DictionaryExample FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeDictionaryExample(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/translation/Azure.AI.Translation.Text/src/Generated/DictionaryExample.cs b/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryExample.cs deleted file mode 100644 index f273add1258e..000000000000 --- a/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryExample.cs +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Translation.Text -{ - /// Dictionary Example. - public partial class DictionaryExample - { - /// - /// 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 string to concatenate before the value of sourceTerm to form a complete example. - /// Do not add a space character, since it is already there when it should be. - /// This value may be an empty string. - /// - /// - /// A string equal to the actual term looked up. The string is added with sourcePrefix - /// and sourceSuffix to form the complete example. Its value is separated so it can be - /// marked in a user interface, e.g., by bolding it. - /// - /// - /// The string to concatenate after the value of sourceTerm to form a complete example. - /// Do not add a space character, since it is already there when it should be. - /// This value may be an empty string. - /// - /// A string similar to sourcePrefix but for the target. - /// A string similar to sourceTerm but for the target. - /// A string similar to sourceSuffix but for the target. - /// , , , , or is null. - internal DictionaryExample(string sourcePrefix, string sourceTerm, string sourceSuffix, string targetPrefix, string targetTerm, string targetSuffix) - { - Argument.AssertNotNull(sourcePrefix, nameof(sourcePrefix)); - Argument.AssertNotNull(sourceTerm, nameof(sourceTerm)); - Argument.AssertNotNull(sourceSuffix, nameof(sourceSuffix)); - Argument.AssertNotNull(targetPrefix, nameof(targetPrefix)); - Argument.AssertNotNull(targetTerm, nameof(targetTerm)); - Argument.AssertNotNull(targetSuffix, nameof(targetSuffix)); - - SourcePrefix = sourcePrefix; - SourceTerm = sourceTerm; - SourceSuffix = sourceSuffix; - TargetPrefix = targetPrefix; - TargetTerm = targetTerm; - TargetSuffix = targetSuffix; - } - - /// Initializes a new instance of . - /// - /// The string to concatenate before the value of sourceTerm to form a complete example. - /// Do not add a space character, since it is already there when it should be. - /// This value may be an empty string. - /// - /// - /// A string equal to the actual term looked up. The string is added with sourcePrefix - /// and sourceSuffix to form the complete example. Its value is separated so it can be - /// marked in a user interface, e.g., by bolding it. - /// - /// - /// The string to concatenate after the value of sourceTerm to form a complete example. - /// Do not add a space character, since it is already there when it should be. - /// This value may be an empty string. - /// - /// A string similar to sourcePrefix but for the target. - /// A string similar to sourceTerm but for the target. - /// A string similar to sourceSuffix but for the target. - /// Keeps track of any properties unknown to the library. - internal DictionaryExample(string sourcePrefix, string sourceTerm, string sourceSuffix, string targetPrefix, string targetTerm, string targetSuffix, IDictionary serializedAdditionalRawData) - { - SourcePrefix = sourcePrefix; - SourceTerm = sourceTerm; - SourceSuffix = sourceSuffix; - TargetPrefix = targetPrefix; - TargetTerm = targetTerm; - TargetSuffix = targetSuffix; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DictionaryExample() - { - } - - /// - /// The string to concatenate before the value of sourceTerm to form a complete example. - /// Do not add a space character, since it is already there when it should be. - /// This value may be an empty string. - /// - public string SourcePrefix { get; } - /// - /// A string equal to the actual term looked up. The string is added with sourcePrefix - /// and sourceSuffix to form the complete example. Its value is separated so it can be - /// marked in a user interface, e.g., by bolding it. - /// - public string SourceTerm { get; } - /// - /// The string to concatenate after the value of sourceTerm to form a complete example. - /// Do not add a space character, since it is already there when it should be. - /// This value may be an empty string. - /// - public string SourceSuffix { get; } - /// A string similar to sourcePrefix but for the target. - public string TargetPrefix { get; } - /// A string similar to sourceTerm but for the target. - public string TargetTerm { get; } - /// A string similar to sourceSuffix but for the target. - public string TargetSuffix { get; } - } -} diff --git a/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryExampleItem.cs b/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryExampleItem.cs deleted file mode 100644 index e966305aaa81..000000000000 --- a/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryExampleItem.cs +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Azure.AI.Translation.Text -{ - /// Dictionary Example element. - public partial class DictionaryExampleItem - { - /// - /// 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 string giving the normalized form of the source term. Generally, this should be identical - /// to the value of the Text field at the matching list index in the body of the request. - /// - /// - /// A string giving the normalized form of the target term. Generally, this should be identical - /// to the value of the Translation field at the matching list index in the body of the request. - /// - /// A list of examples for the (source term, target term) pair. - /// , or is null. - internal DictionaryExampleItem(string normalizedSource, string normalizedTarget, IEnumerable examples) - { - Argument.AssertNotNull(normalizedSource, nameof(normalizedSource)); - Argument.AssertNotNull(normalizedTarget, nameof(normalizedTarget)); - Argument.AssertNotNull(examples, nameof(examples)); - - NormalizedSource = normalizedSource; - NormalizedTarget = normalizedTarget; - Examples = examples.ToList(); - } - - /// Initializes a new instance of . - /// - /// A string giving the normalized form of the source term. Generally, this should be identical - /// to the value of the Text field at the matching list index in the body of the request. - /// - /// - /// A string giving the normalized form of the target term. Generally, this should be identical - /// to the value of the Translation field at the matching list index in the body of the request. - /// - /// A list of examples for the (source term, target term) pair. - /// Keeps track of any properties unknown to the library. - internal DictionaryExampleItem(string normalizedSource, string normalizedTarget, IReadOnlyList examples, IDictionary serializedAdditionalRawData) - { - NormalizedSource = normalizedSource; - NormalizedTarget = normalizedTarget; - Examples = examples; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DictionaryExampleItem() - { - } - - /// - /// A string giving the normalized form of the source term. Generally, this should be identical - /// to the value of the Text field at the matching list index in the body of the request. - /// - public string NormalizedSource { get; } - /// - /// A string giving the normalized form of the target term. Generally, this should be identical - /// to the value of the Translation field at the matching list index in the body of the request. - /// - public string NormalizedTarget { get; } - /// A list of examples for the (source term, target term) pair. - public IReadOnlyList Examples { get; } - } -} diff --git a/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryExampleTextItem.Serialization.cs b/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryExampleTextItem.Serialization.cs deleted file mode 100644 index 937462d8f137..000000000000 --- a/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryExampleTextItem.Serialization.cs +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Translation.Text -{ - public partial class DictionaryExampleTextItem : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(DictionaryExampleTextItem)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("translation"u8); - writer.WriteStringValue(Translation); - } - - DictionaryExampleTextItem 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(DictionaryExampleTextItem)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeDictionaryExampleTextItem(document.RootElement, options); - } - - internal static DictionaryExampleTextItem DeserializeDictionaryExampleTextItem(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string translation = default; - string text = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("translation"u8)) - { - translation = property.Value.GetString(); - continue; - } - if (property.NameEquals("text"u8)) - { - text = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new DictionaryExampleTextItem(text, serializedAdditionalRawData, translation); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureAITranslationTextContext.Default); - default: - throw new FormatException($"The model {nameof(DictionaryExampleTextItem)} does not support writing '{options.Format}' format."); - } - } - - DictionaryExampleTextItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeDictionaryExampleTextItem(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(DictionaryExampleTextItem)} 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 DictionaryExampleTextItem FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeDictionaryExampleTextItem(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/translation/Azure.AI.Translation.Text/src/Generated/DictionaryExampleTextItem.cs b/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryExampleTextItem.cs deleted file mode 100644 index 17dbd8f016c5..000000000000 --- a/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryExampleTextItem.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Translation.Text -{ - /// Element containing the text with translation. - public partial class DictionaryExampleTextItem : InputTextItem - { - /// Initializes a new instance of . - /// Text to translate. - /// - /// A string specifying the translated text previously returned by the Dictionary lookup operation. - /// This should be the value from the normalizedTarget field in the translations list of the Dictionary - /// lookup response. The service will return examples for the specific source-target word-pair. - /// - /// or is null. - public DictionaryExampleTextItem(string text, string translation) : base(text) - { - Argument.AssertNotNull(text, nameof(text)); - Argument.AssertNotNull(translation, nameof(translation)); - - Translation = translation; - } - - /// Initializes a new instance of . - /// Text to translate. - /// Keeps track of any properties unknown to the library. - /// - /// A string specifying the translated text previously returned by the Dictionary lookup operation. - /// This should be the value from the normalizedTarget field in the translations list of the Dictionary - /// lookup response. The service will return examples for the specific source-target word-pair. - /// - internal DictionaryExampleTextItem(string text, IDictionary serializedAdditionalRawData, string translation) : base(text, serializedAdditionalRawData) - { - Translation = translation; - } - - /// Initializes a new instance of for deserialization. - internal DictionaryExampleTextItem() - { - } - - /// - /// A string specifying the translated text previously returned by the Dictionary lookup operation. - /// This should be the value from the normalizedTarget field in the translations list of the Dictionary - /// lookup response. The service will return examples for the specific source-target word-pair. - /// - public string Translation { get; } - } -} diff --git a/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryLookupItem.cs b/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryLookupItem.cs deleted file mode 100644 index b4f0318142cf..000000000000 --- a/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryLookupItem.cs +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Azure.AI.Translation.Text -{ - /// Dictionary Lookup Element. - public partial class DictionaryLookupItem - { - /// - /// 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 string giving the normalized form of the source term. - /// For example, if the request is "JOHN", the normalized form will be "john". - /// The content of this field becomes the input to lookup examples. - /// - /// - /// A string giving the source term in a form best suited for end-user display. - /// For example, if the input is "JOHN", the display form will reflect the usual - /// spelling of the name: "John". - /// - /// A list of translations for the source term. - /// , or is null. - internal DictionaryLookupItem(string normalizedSource, string displaySource, IEnumerable translations) - { - Argument.AssertNotNull(normalizedSource, nameof(normalizedSource)); - Argument.AssertNotNull(displaySource, nameof(displaySource)); - Argument.AssertNotNull(translations, nameof(translations)); - - NormalizedSource = normalizedSource; - DisplaySource = displaySource; - Translations = translations.ToList(); - } - - /// Initializes a new instance of . - /// - /// A string giving the normalized form of the source term. - /// For example, if the request is "JOHN", the normalized form will be "john". - /// The content of this field becomes the input to lookup examples. - /// - /// - /// A string giving the source term in a form best suited for end-user display. - /// For example, if the input is "JOHN", the display form will reflect the usual - /// spelling of the name: "John". - /// - /// A list of translations for the source term. - /// Keeps track of any properties unknown to the library. - internal DictionaryLookupItem(string normalizedSource, string displaySource, IReadOnlyList translations, IDictionary serializedAdditionalRawData) - { - NormalizedSource = normalizedSource; - DisplaySource = displaySource; - Translations = translations; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DictionaryLookupItem() - { - } - - /// - /// A string giving the normalized form of the source term. - /// For example, if the request is "JOHN", the normalized form will be "john". - /// The content of this field becomes the input to lookup examples. - /// - public string NormalizedSource { get; } - /// - /// A string giving the source term in a form best suited for end-user display. - /// For example, if the input is "JOHN", the display form will reflect the usual - /// spelling of the name: "John". - /// - public string DisplaySource { get; } - /// A list of translations for the source term. - public IReadOnlyList Translations { get; } - } -} diff --git a/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryTranslation.Serialization.cs b/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryTranslation.Serialization.cs deleted file mode 100644 index 2aa6ee959c5e..000000000000 --- a/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryTranslation.Serialization.cs +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Translation.Text -{ - public partial class DictionaryTranslation : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(DictionaryTranslation)} does not support writing '{format}' format."); - } - - writer.WritePropertyName("normalizedTarget"u8); - writer.WriteStringValue(NormalizedTarget); - writer.WritePropertyName("displayTarget"u8); - writer.WriteStringValue(DisplayTarget); - writer.WritePropertyName("posTag"u8); - writer.WriteStringValue(PosTag); - writer.WritePropertyName("confidence"u8); - writer.WriteNumberValue(Confidence); - writer.WritePropertyName("prefixWord"u8); - writer.WriteStringValue(PrefixWord); - writer.WritePropertyName("backTranslations"u8); - writer.WriteStartArray(); - foreach (var item in BackTranslations) - { - 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 - } - } - } - - DictionaryTranslation 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(DictionaryTranslation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeDictionaryTranslation(document.RootElement, options); - } - - internal static DictionaryTranslation DeserializeDictionaryTranslation(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string normalizedTarget = default; - string displayTarget = default; - string posTag = default; - float confidence = default; - string prefixWord = default; - IReadOnlyList backTranslations = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("normalizedTarget"u8)) - { - normalizedTarget = property.Value.GetString(); - continue; - } - if (property.NameEquals("displayTarget"u8)) - { - displayTarget = property.Value.GetString(); - continue; - } - if (property.NameEquals("posTag"u8)) - { - posTag = property.Value.GetString(); - continue; - } - if (property.NameEquals("confidence"u8)) - { - confidence = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("prefixWord"u8)) - { - prefixWord = property.Value.GetString(); - continue; - } - if (property.NameEquals("backTranslations"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(BackTranslation.DeserializeBackTranslation(item, options)); - } - backTranslations = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new DictionaryTranslation( - normalizedTarget, - displayTarget, - posTag, - confidence, - prefixWord, - backTranslations, - 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, AzureAITranslationTextContext.Default); - default: - throw new FormatException($"The model {nameof(DictionaryTranslation)} does not support writing '{options.Format}' format."); - } - } - - DictionaryTranslation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeDictionaryTranslation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(DictionaryTranslation)} 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 DictionaryTranslation FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeDictionaryTranslation(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/translation/Azure.AI.Translation.Text/src/Generated/DictionaryTranslation.cs b/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryTranslation.cs deleted file mode 100644 index 39974ef7659c..000000000000 --- a/sdk/translation/Azure.AI.Translation.Text/src/Generated/DictionaryTranslation.cs +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Azure.AI.Translation.Text -{ - /// Translation source term. - public partial class DictionaryTranslation - { - /// - /// 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 string giving the normalized form of this term in the target language. - /// This value should be used as input to lookup examples. - /// - /// - /// A string giving the term in the target language and in a form best suited - /// for end-user display. Generally, this will only differ from the normalizedTarget - /// in terms of capitalization. For example, a proper noun like "Juan" will have - /// normalizedTarget = "juan" and displayTarget = "Juan". - /// - /// A string associating this term with a part-of-speech tag. - /// - /// A value between 0.0 and 1.0 which represents the "confidence" - /// (or perhaps more accurately, "probability in the training data") of that translation pair. - /// The sum of confidence scores for one source word may or may not sum to 1.0. - /// - /// - /// A string giving the word to display as a prefix of the translation. Currently, - /// this is the gendered determiner of nouns, in languages that have gendered determiners. - /// For example, the prefix of the Spanish word "mosca" is "la", since "mosca" is a feminine noun in Spanish. - /// This is only dependent on the translation, and not on the source. - /// If there is no prefix, it will be the empty string. - /// - /// - /// A list of "back translations" of the target. For example, source words that the target can translate to. - /// The list is guaranteed to contain the source word that was requested (e.g., if the source word being - /// looked up is "fly", then it is guaranteed that "fly" will be in the backTranslations list). - /// However, it is not guaranteed to be in the first position, and often will not be. - /// - /// , , , or is null. - internal DictionaryTranslation(string normalizedTarget, string displayTarget, string posTag, float confidence, string prefixWord, IEnumerable backTranslations) - { - Argument.AssertNotNull(normalizedTarget, nameof(normalizedTarget)); - Argument.AssertNotNull(displayTarget, nameof(displayTarget)); - Argument.AssertNotNull(posTag, nameof(posTag)); - Argument.AssertNotNull(prefixWord, nameof(prefixWord)); - Argument.AssertNotNull(backTranslations, nameof(backTranslations)); - - NormalizedTarget = normalizedTarget; - DisplayTarget = displayTarget; - PosTag = posTag; - Confidence = confidence; - PrefixWord = prefixWord; - BackTranslations = backTranslations.ToList(); - } - - /// Initializes a new instance of . - /// - /// A string giving the normalized form of this term in the target language. - /// This value should be used as input to lookup examples. - /// - /// - /// A string giving the term in the target language and in a form best suited - /// for end-user display. Generally, this will only differ from the normalizedTarget - /// in terms of capitalization. For example, a proper noun like "Juan" will have - /// normalizedTarget = "juan" and displayTarget = "Juan". - /// - /// A string associating this term with a part-of-speech tag. - /// - /// A value between 0.0 and 1.0 which represents the "confidence" - /// (or perhaps more accurately, "probability in the training data") of that translation pair. - /// The sum of confidence scores for one source word may or may not sum to 1.0. - /// - /// - /// A string giving the word to display as a prefix of the translation. Currently, - /// this is the gendered determiner of nouns, in languages that have gendered determiners. - /// For example, the prefix of the Spanish word "mosca" is "la", since "mosca" is a feminine noun in Spanish. - /// This is only dependent on the translation, and not on the source. - /// If there is no prefix, it will be the empty string. - /// - /// - /// A list of "back translations" of the target. For example, source words that the target can translate to. - /// The list is guaranteed to contain the source word that was requested (e.g., if the source word being - /// looked up is "fly", then it is guaranteed that "fly" will be in the backTranslations list). - /// However, it is not guaranteed to be in the first position, and often will not be. - /// - /// Keeps track of any properties unknown to the library. - internal DictionaryTranslation(string normalizedTarget, string displayTarget, string posTag, float confidence, string prefixWord, IReadOnlyList backTranslations, IDictionary serializedAdditionalRawData) - { - NormalizedTarget = normalizedTarget; - DisplayTarget = displayTarget; - PosTag = posTag; - Confidence = confidence; - PrefixWord = prefixWord; - BackTranslations = backTranslations; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DictionaryTranslation() - { - } - - /// - /// A string giving the normalized form of this term in the target language. - /// This value should be used as input to lookup examples. - /// - public string NormalizedTarget { get; } - /// - /// A string giving the term in the target language and in a form best suited - /// for end-user display. Generally, this will only differ from the normalizedTarget - /// in terms of capitalization. For example, a proper noun like "Juan" will have - /// normalizedTarget = "juan" and displayTarget = "Juan". - /// - public string DisplayTarget { get; } - /// A string associating this term with a part-of-speech tag. - public string PosTag { get; } - /// - /// A value between 0.0 and 1.0 which represents the "confidence" - /// (or perhaps more accurately, "probability in the training data") of that translation pair. - /// The sum of confidence scores for one source word may or may not sum to 1.0. - /// - public float Confidence { get; } - /// - /// A string giving the word to display as a prefix of the translation. Currently, - /// this is the gendered determiner of nouns, in languages that have gendered determiners. - /// For example, the prefix of the Spanish word "mosca" is "la", since "mosca" is a feminine noun in Spanish. - /// This is only dependent on the translation, and not on the source. - /// If there is no prefix, it will be the empty string. - /// - public string PrefixWord { get; } - /// - /// A list of "back translations" of the target. For example, source words that the target can translate to. - /// The list is guaranteed to contain the source word that was requested (e.g., if the source word being - /// looked up is "fly", then it is guaranteed that "fly" will be in the backTranslations list). - /// However, it is not guaranteed to be in the first position, and often will not be. - /// - public IReadOnlyList BackTranslations { get; } - } -} diff --git a/sdk/translation/Azure.AI.Translation.Text/src/Generated/Docs/TextTranslationClient.xml b/sdk/translation/Azure.AI.Translation.Text/src/Generated/Docs/TextTranslationClient.xml index 75fdeb76b84f..7c65e39dfdc2 100644 --- a/sdk/translation/Azure.AI.Translation.Text/src/Generated/Docs/TextTranslationClient.xml +++ b/sdk/translation/Azure.AI.Translation.Text/src/Generated/Docs/TextTranslationClient.xml @@ -79,6 +79,266 @@ Response response = client.GetSupportedLanguages(null, null, null, null, null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call Translate2Async. +"); +TextTranslationClient client = new TextTranslationClient(endpoint); + +Response> response = await client.Translate2Async(new TranslateBodyDetails[] +{ + new TranslateBodyDetails("", new TranslateTarget[] + { + new TranslateTarget(new string[]{""}) + }) +}); +]]> +This sample shows how to call Translate2Async with all parameters. +"); +TextTranslationClient client = new TextTranslationClient(endpoint); + +Response> response = await client.Translate2Async(new TranslateBodyDetails[] +{ + new TranslateBodyDetails("", new TranslateTarget[] + { + new TranslateTarget(new string[]{""}) + { + Script = "