| | 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 EntityRecognitionSkill : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Optional.IsCollectionDefined(Categories)) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("categories"); |
| 0 | 22 | | writer.WriteStartArray(); |
| 0 | 23 | | foreach (var item in Categories) |
| | 24 | | { |
| 0 | 25 | | writer.WriteStringValue(item.ToString()); |
| | 26 | | } |
| 0 | 27 | | writer.WriteEndArray(); |
| | 28 | | } |
| 0 | 29 | | if (Optional.IsDefined(DefaultLanguageCode)) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("defaultLanguageCode"); |
| 0 | 32 | | writer.WriteStringValue(DefaultLanguageCode.Value.ToString()); |
| | 33 | | } |
| 0 | 34 | | if (Optional.IsDefined(IncludeTypelessEntities)) |
| | 35 | | { |
| 0 | 36 | | if (IncludeTypelessEntities != null) |
| | 37 | | { |
| 0 | 38 | | writer.WritePropertyName("includeTypelessEntities"); |
| 0 | 39 | | writer.WriteBooleanValue(IncludeTypelessEntities.Value); |
| | 40 | | } |
| | 41 | | else |
| | 42 | | { |
| 0 | 43 | | writer.WriteNull("includeTypelessEntities"); |
| | 44 | | } |
| | 45 | | } |
| 0 | 46 | | if (Optional.IsDefined(MinimumPrecision)) |
| | 47 | | { |
| 0 | 48 | | if (MinimumPrecision != null) |
| | 49 | | { |
| 0 | 50 | | writer.WritePropertyName("minimumPrecision"); |
| 0 | 51 | | writer.WriteNumberValue(MinimumPrecision.Value); |
| | 52 | | } |
| | 53 | | else |
| | 54 | | { |
| 0 | 55 | | writer.WriteNull("minimumPrecision"); |
| | 56 | | } |
| | 57 | | } |
| 0 | 58 | | writer.WritePropertyName("@odata.type"); |
| 0 | 59 | | writer.WriteStringValue(ODataType); |
| 0 | 60 | | if (Optional.IsDefined(Name)) |
| | 61 | | { |
| 0 | 62 | | writer.WritePropertyName("name"); |
| 0 | 63 | | writer.WriteStringValue(Name); |
| | 64 | | } |
| 0 | 65 | | if (Optional.IsDefined(Description)) |
| | 66 | | { |
| 0 | 67 | | writer.WritePropertyName("description"); |
| 0 | 68 | | writer.WriteStringValue(Description); |
| | 69 | | } |
| 0 | 70 | | if (Optional.IsDefined(Context)) |
| | 71 | | { |
| 0 | 72 | | writer.WritePropertyName("context"); |
| 0 | 73 | | writer.WriteStringValue(Context); |
| | 74 | | } |
| 0 | 75 | | writer.WritePropertyName("inputs"); |
| 0 | 76 | | writer.WriteStartArray(); |
| 0 | 77 | | foreach (var item in Inputs) |
| | 78 | | { |
| 0 | 79 | | writer.WriteObjectValue(item); |
| | 80 | | } |
| 0 | 81 | | writer.WriteEndArray(); |
| 0 | 82 | | writer.WritePropertyName("outputs"); |
| 0 | 83 | | writer.WriteStartArray(); |
| 0 | 84 | | foreach (var item in Outputs) |
| | 85 | | { |
| 0 | 86 | | writer.WriteObjectValue(item); |
| | 87 | | } |
| 0 | 88 | | writer.WriteEndArray(); |
| 0 | 89 | | writer.WriteEndObject(); |
| 0 | 90 | | } |
| | 91 | |
|
| | 92 | | internal static EntityRecognitionSkill DeserializeEntityRecognitionSkill(JsonElement element) |
| | 93 | | { |
| 0 | 94 | | Optional<IList<EntityCategory>> categories = default; |
| 0 | 95 | | Optional<EntityRecognitionSkillLanguage> defaultLanguageCode = default; |
| 0 | 96 | | Optional<bool?> includeTypelessEntities = default; |
| 0 | 97 | | Optional<double?> minimumPrecision = default; |
| 0 | 98 | | string odataType = default; |
| 0 | 99 | | Optional<string> name = default; |
| 0 | 100 | | Optional<string> description = default; |
| 0 | 101 | | Optional<string> context = default; |
| 0 | 102 | | IList<InputFieldMappingEntry> inputs = default; |
| 0 | 103 | | IList<OutputFieldMappingEntry> outputs = default; |
| 0 | 104 | | foreach (var property in element.EnumerateObject()) |
| | 105 | | { |
| 0 | 106 | | if (property.NameEquals("categories")) |
| | 107 | | { |
| 0 | 108 | | List<EntityCategory> array = new List<EntityCategory>(); |
| 0 | 109 | | foreach (var item in property.Value.EnumerateArray()) |
| | 110 | | { |
| 0 | 111 | | array.Add(new EntityCategory(item.GetString())); |
| | 112 | | } |
| 0 | 113 | | categories = array; |
| 0 | 114 | | continue; |
| | 115 | | } |
| 0 | 116 | | if (property.NameEquals("defaultLanguageCode")) |
| | 117 | | { |
| 0 | 118 | | defaultLanguageCode = new EntityRecognitionSkillLanguage(property.Value.GetString()); |
| 0 | 119 | | continue; |
| | 120 | | } |
| 0 | 121 | | if (property.NameEquals("includeTypelessEntities")) |
| | 122 | | { |
| 0 | 123 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 124 | | { |
| 0 | 125 | | includeTypelessEntities = null; |
| 0 | 126 | | continue; |
| | 127 | | } |
| 0 | 128 | | includeTypelessEntities = property.Value.GetBoolean(); |
| 0 | 129 | | continue; |
| | 130 | | } |
| 0 | 131 | | if (property.NameEquals("minimumPrecision")) |
| | 132 | | { |
| 0 | 133 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 134 | | { |
| 0 | 135 | | minimumPrecision = null; |
| 0 | 136 | | continue; |
| | 137 | | } |
| 0 | 138 | | minimumPrecision = property.Value.GetDouble(); |
| 0 | 139 | | continue; |
| | 140 | | } |
| 0 | 141 | | if (property.NameEquals("@odata.type")) |
| | 142 | | { |
| 0 | 143 | | odataType = property.Value.GetString(); |
| 0 | 144 | | continue; |
| | 145 | | } |
| 0 | 146 | | if (property.NameEquals("name")) |
| | 147 | | { |
| 0 | 148 | | name = property.Value.GetString(); |
| 0 | 149 | | continue; |
| | 150 | | } |
| 0 | 151 | | if (property.NameEquals("description")) |
| | 152 | | { |
| 0 | 153 | | description = property.Value.GetString(); |
| 0 | 154 | | continue; |
| | 155 | | } |
| 0 | 156 | | if (property.NameEquals("context")) |
| | 157 | | { |
| 0 | 158 | | context = property.Value.GetString(); |
| 0 | 159 | | continue; |
| | 160 | | } |
| 0 | 161 | | if (property.NameEquals("inputs")) |
| | 162 | | { |
| 0 | 163 | | List<InputFieldMappingEntry> array = new List<InputFieldMappingEntry>(); |
| 0 | 164 | | foreach (var item in property.Value.EnumerateArray()) |
| | 165 | | { |
| 0 | 166 | | array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); |
| | 167 | | } |
| 0 | 168 | | inputs = array; |
| 0 | 169 | | continue; |
| | 170 | | } |
| 0 | 171 | | if (property.NameEquals("outputs")) |
| | 172 | | { |
| 0 | 173 | | List<OutputFieldMappingEntry> array = new List<OutputFieldMappingEntry>(); |
| 0 | 174 | | foreach (var item in property.Value.EnumerateArray()) |
| | 175 | | { |
| 0 | 176 | | array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); |
| | 177 | | } |
| 0 | 178 | | outputs = array; |
| | 179 | | continue; |
| | 180 | | } |
| | 181 | | } |
| 0 | 182 | | return new EntityRecognitionSkill(odataType, name.Value, description.Value, context.Value, inputs, outputs, |
| | 183 | | } |
| | 184 | | } |
| | 185 | | } |