| | 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 ImageAnalysisSkill : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Optional.IsDefined(DefaultLanguageCode)) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("defaultLanguageCode"); |
| 0 | 22 | | writer.WriteStringValue(DefaultLanguageCode.Value.ToString()); |
| | 23 | | } |
| 0 | 24 | | if (Optional.IsCollectionDefined(VisualFeatures)) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("visualFeatures"); |
| 0 | 27 | | writer.WriteStartArray(); |
| 0 | 28 | | foreach (var item in VisualFeatures) |
| | 29 | | { |
| 0 | 30 | | writer.WriteStringValue(item.ToString()); |
| | 31 | | } |
| 0 | 32 | | writer.WriteEndArray(); |
| | 33 | | } |
| 0 | 34 | | if (Optional.IsCollectionDefined(Details)) |
| | 35 | | { |
| 0 | 36 | | writer.WritePropertyName("details"); |
| 0 | 37 | | writer.WriteStartArray(); |
| 0 | 38 | | foreach (var item in Details) |
| | 39 | | { |
| 0 | 40 | | writer.WriteStringValue(item.ToString()); |
| | 41 | | } |
| 0 | 42 | | writer.WriteEndArray(); |
| | 43 | | } |
| 0 | 44 | | writer.WritePropertyName("@odata.type"); |
| 0 | 45 | | writer.WriteStringValue(ODataType); |
| 0 | 46 | | if (Optional.IsDefined(Name)) |
| | 47 | | { |
| 0 | 48 | | writer.WritePropertyName("name"); |
| 0 | 49 | | writer.WriteStringValue(Name); |
| | 50 | | } |
| 0 | 51 | | if (Optional.IsDefined(Description)) |
| | 52 | | { |
| 0 | 53 | | writer.WritePropertyName("description"); |
| 0 | 54 | | writer.WriteStringValue(Description); |
| | 55 | | } |
| 0 | 56 | | if (Optional.IsDefined(Context)) |
| | 57 | | { |
| 0 | 58 | | writer.WritePropertyName("context"); |
| 0 | 59 | | writer.WriteStringValue(Context); |
| | 60 | | } |
| 0 | 61 | | writer.WritePropertyName("inputs"); |
| 0 | 62 | | writer.WriteStartArray(); |
| 0 | 63 | | foreach (var item in Inputs) |
| | 64 | | { |
| 0 | 65 | | writer.WriteObjectValue(item); |
| | 66 | | } |
| 0 | 67 | | writer.WriteEndArray(); |
| 0 | 68 | | writer.WritePropertyName("outputs"); |
| 0 | 69 | | writer.WriteStartArray(); |
| 0 | 70 | | foreach (var item in Outputs) |
| | 71 | | { |
| 0 | 72 | | writer.WriteObjectValue(item); |
| | 73 | | } |
| 0 | 74 | | writer.WriteEndArray(); |
| 0 | 75 | | writer.WriteEndObject(); |
| 0 | 76 | | } |
| | 77 | |
|
| | 78 | | internal static ImageAnalysisSkill DeserializeImageAnalysisSkill(JsonElement element) |
| | 79 | | { |
| 0 | 80 | | Optional<ImageAnalysisSkillLanguage> defaultLanguageCode = default; |
| 0 | 81 | | Optional<IList<VisualFeature>> visualFeatures = default; |
| 0 | 82 | | Optional<IList<ImageDetail>> details = default; |
| 0 | 83 | | string odataType = default; |
| 0 | 84 | | Optional<string> name = default; |
| 0 | 85 | | Optional<string> description = default; |
| 0 | 86 | | Optional<string> context = default; |
| 0 | 87 | | IList<InputFieldMappingEntry> inputs = default; |
| 0 | 88 | | IList<OutputFieldMappingEntry> outputs = default; |
| 0 | 89 | | foreach (var property in element.EnumerateObject()) |
| | 90 | | { |
| 0 | 91 | | if (property.NameEquals("defaultLanguageCode")) |
| | 92 | | { |
| 0 | 93 | | defaultLanguageCode = new ImageAnalysisSkillLanguage(property.Value.GetString()); |
| 0 | 94 | | continue; |
| | 95 | | } |
| 0 | 96 | | if (property.NameEquals("visualFeatures")) |
| | 97 | | { |
| 0 | 98 | | List<VisualFeature> array = new List<VisualFeature>(); |
| 0 | 99 | | foreach (var item in property.Value.EnumerateArray()) |
| | 100 | | { |
| 0 | 101 | | array.Add(new VisualFeature(item.GetString())); |
| | 102 | | } |
| 0 | 103 | | visualFeatures = array; |
| 0 | 104 | | continue; |
| | 105 | | } |
| 0 | 106 | | if (property.NameEquals("details")) |
| | 107 | | { |
| 0 | 108 | | List<ImageDetail> array = new List<ImageDetail>(); |
| 0 | 109 | | foreach (var item in property.Value.EnumerateArray()) |
| | 110 | | { |
| 0 | 111 | | array.Add(new ImageDetail(item.GetString())); |
| | 112 | | } |
| 0 | 113 | | details = array; |
| 0 | 114 | | continue; |
| | 115 | | } |
| 0 | 116 | | if (property.NameEquals("@odata.type")) |
| | 117 | | { |
| 0 | 118 | | odataType = property.Value.GetString(); |
| 0 | 119 | | continue; |
| | 120 | | } |
| 0 | 121 | | if (property.NameEquals("name")) |
| | 122 | | { |
| 0 | 123 | | name = property.Value.GetString(); |
| 0 | 124 | | continue; |
| | 125 | | } |
| 0 | 126 | | if (property.NameEquals("description")) |
| | 127 | | { |
| 0 | 128 | | description = property.Value.GetString(); |
| 0 | 129 | | continue; |
| | 130 | | } |
| 0 | 131 | | if (property.NameEquals("context")) |
| | 132 | | { |
| 0 | 133 | | context = property.Value.GetString(); |
| 0 | 134 | | continue; |
| | 135 | | } |
| 0 | 136 | | if (property.NameEquals("inputs")) |
| | 137 | | { |
| 0 | 138 | | List<InputFieldMappingEntry> array = new List<InputFieldMappingEntry>(); |
| 0 | 139 | | foreach (var item in property.Value.EnumerateArray()) |
| | 140 | | { |
| 0 | 141 | | array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); |
| | 142 | | } |
| 0 | 143 | | inputs = array; |
| 0 | 144 | | continue; |
| | 145 | | } |
| 0 | 146 | | if (property.NameEquals("outputs")) |
| | 147 | | { |
| 0 | 148 | | List<OutputFieldMappingEntry> array = new List<OutputFieldMappingEntry>(); |
| 0 | 149 | | foreach (var item in property.Value.EnumerateArray()) |
| | 150 | | { |
| 0 | 151 | | array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); |
| | 152 | | } |
| 0 | 153 | | outputs = array; |
| | 154 | | continue; |
| | 155 | | } |
| | 156 | | } |
| 0 | 157 | | return new ImageAnalysisSkill(odataType, name.Value, description.Value, context.Value, inputs, outputs, Opti |
| | 158 | | } |
| | 159 | | } |
| | 160 | | } |