| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System.Collections.Generic; |
| | 9 | | using System.Text.Json; |
| | 10 | | using Azure.Core; |
| | 11 | |
|
| | 12 | | namespace Azure.Search.Documents.Indexes.Models |
| | 13 | | { |
| | 14 | | public partial class TextTranslationSkill : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 1 | 18 | | writer.WriteStartObject(); |
| 1 | 19 | | writer.WritePropertyName("defaultToLanguageCode"); |
| 1 | 20 | | writer.WriteStringValue(DefaultToLanguageCode.ToString()); |
| 1 | 21 | | if (Optional.IsDefined(DefaultFromLanguageCode)) |
| | 22 | | { |
| 1 | 23 | | writer.WritePropertyName("defaultFromLanguageCode"); |
| 1 | 24 | | writer.WriteStringValue(DefaultFromLanguageCode.Value.ToString()); |
| | 25 | | } |
| 1 | 26 | | if (Optional.IsDefined(SuggestedFrom)) |
| | 27 | | { |
| 0 | 28 | | if (SuggestedFrom != null) |
| | 29 | | { |
| 0 | 30 | | writer.WritePropertyName("suggestedFrom"); |
| 0 | 31 | | writer.WriteStringValue(SuggestedFrom.Value.ToString()); |
| | 32 | | } |
| | 33 | | else |
| | 34 | | { |
| 0 | 35 | | writer.WriteNull("suggestedFrom"); |
| | 36 | | } |
| | 37 | | } |
| 1 | 38 | | writer.WritePropertyName("@odata.type"); |
| 1 | 39 | | writer.WriteStringValue(ODataType); |
| 1 | 40 | | if (Optional.IsDefined(Name)) |
| | 41 | | { |
| 1 | 42 | | writer.WritePropertyName("name"); |
| 1 | 43 | | writer.WriteStringValue(Name); |
| | 44 | | } |
| 1 | 45 | | if (Optional.IsDefined(Description)) |
| | 46 | | { |
| 0 | 47 | | writer.WritePropertyName("description"); |
| 0 | 48 | | writer.WriteStringValue(Description); |
| | 49 | | } |
| 1 | 50 | | if (Optional.IsDefined(Context)) |
| | 51 | | { |
| 1 | 52 | | writer.WritePropertyName("context"); |
| 1 | 53 | | writer.WriteStringValue(Context); |
| | 54 | | } |
| 1 | 55 | | writer.WritePropertyName("inputs"); |
| 1 | 56 | | writer.WriteStartArray(); |
| 4 | 57 | | foreach (var item in Inputs) |
| | 58 | | { |
| 1 | 59 | | writer.WriteObjectValue(item); |
| | 60 | | } |
| 1 | 61 | | writer.WriteEndArray(); |
| 1 | 62 | | writer.WritePropertyName("outputs"); |
| 1 | 63 | | writer.WriteStartArray(); |
| 4 | 64 | | foreach (var item in Outputs) |
| | 65 | | { |
| 1 | 66 | | writer.WriteObjectValue(item); |
| | 67 | | } |
| 1 | 68 | | writer.WriteEndArray(); |
| 1 | 69 | | writer.WriteEndObject(); |
| 1 | 70 | | } |
| | 71 | |
|
| | 72 | | internal static TextTranslationSkill DeserializeTextTranslationSkill(JsonElement element) |
| | 73 | | { |
| 1 | 74 | | TextTranslationSkillLanguage defaultToLanguageCode = default; |
| 1 | 75 | | Optional<TextTranslationSkillLanguage> defaultFromLanguageCode = default; |
| 1 | 76 | | Optional<TextTranslationSkillLanguage?> suggestedFrom = default; |
| 1 | 77 | | string odataType = default; |
| 1 | 78 | | Optional<string> name = default; |
| 1 | 79 | | Optional<string> description = default; |
| 1 | 80 | | Optional<string> context = default; |
| 1 | 81 | | IList<InputFieldMappingEntry> inputs = default; |
| 1 | 82 | | IList<OutputFieldMappingEntry> outputs = default; |
| 20 | 83 | | foreach (var property in element.EnumerateObject()) |
| | 84 | | { |
| 9 | 85 | | if (property.NameEquals("defaultToLanguageCode")) |
| | 86 | | { |
| 1 | 87 | | defaultToLanguageCode = new TextTranslationSkillLanguage(property.Value.GetString()); |
| 1 | 88 | | continue; |
| | 89 | | } |
| 8 | 90 | | if (property.NameEquals("defaultFromLanguageCode")) |
| | 91 | | { |
| 1 | 92 | | defaultFromLanguageCode = new TextTranslationSkillLanguage(property.Value.GetString()); |
| 1 | 93 | | continue; |
| | 94 | | } |
| 7 | 95 | | if (property.NameEquals("suggestedFrom")) |
| | 96 | | { |
| 1 | 97 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 98 | | { |
| 1 | 99 | | suggestedFrom = null; |
| 1 | 100 | | continue; |
| | 101 | | } |
| 0 | 102 | | suggestedFrom = new TextTranslationSkillLanguage(property.Value.GetString()); |
| 0 | 103 | | continue; |
| | 104 | | } |
| 6 | 105 | | if (property.NameEquals("@odata.type")) |
| | 106 | | { |
| 1 | 107 | | odataType = property.Value.GetString(); |
| 1 | 108 | | continue; |
| | 109 | | } |
| 5 | 110 | | if (property.NameEquals("name")) |
| | 111 | | { |
| 1 | 112 | | name = property.Value.GetString(); |
| 1 | 113 | | continue; |
| | 114 | | } |
| 4 | 115 | | if (property.NameEquals("description")) |
| | 116 | | { |
| 1 | 117 | | description = property.Value.GetString(); |
| 1 | 118 | | continue; |
| | 119 | | } |
| 3 | 120 | | if (property.NameEquals("context")) |
| | 121 | | { |
| 1 | 122 | | context = property.Value.GetString(); |
| 1 | 123 | | continue; |
| | 124 | | } |
| 2 | 125 | | if (property.NameEquals("inputs")) |
| | 126 | | { |
| 1 | 127 | | List<InputFieldMappingEntry> array = new List<InputFieldMappingEntry>(); |
| 4 | 128 | | foreach (var item in property.Value.EnumerateArray()) |
| | 129 | | { |
| 1 | 130 | | array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); |
| | 131 | | } |
| 1 | 132 | | inputs = array; |
| 1 | 133 | | continue; |
| | 134 | | } |
| 1 | 135 | | if (property.NameEquals("outputs")) |
| | 136 | | { |
| 1 | 137 | | List<OutputFieldMappingEntry> array = new List<OutputFieldMappingEntry>(); |
| 4 | 138 | | foreach (var item in property.Value.EnumerateArray()) |
| | 139 | | { |
| 1 | 140 | | array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); |
| | 141 | | } |
| 1 | 142 | | outputs = array; |
| | 143 | | continue; |
| | 144 | | } |
| | 145 | | } |
| 1 | 146 | | return new TextTranslationSkill(odataType, name.Value, description.Value, context.Value, inputs, outputs, de |
| | 147 | | } |
| | 148 | | } |
| | 149 | | } |