| | 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 SearchIndexerSkill : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | writer.WritePropertyName("@odata.type"); |
| 0 | 20 | | writer.WriteStringValue(ODataType); |
| 0 | 21 | | if (Optional.IsDefined(Name)) |
| | 22 | | { |
| 0 | 23 | | writer.WritePropertyName("name"); |
| 0 | 24 | | writer.WriteStringValue(Name); |
| | 25 | | } |
| 0 | 26 | | if (Optional.IsDefined(Description)) |
| | 27 | | { |
| 0 | 28 | | writer.WritePropertyName("description"); |
| 0 | 29 | | writer.WriteStringValue(Description); |
| | 30 | | } |
| 0 | 31 | | if (Optional.IsDefined(Context)) |
| | 32 | | { |
| 0 | 33 | | writer.WritePropertyName("context"); |
| 0 | 34 | | writer.WriteStringValue(Context); |
| | 35 | | } |
| 0 | 36 | | writer.WritePropertyName("inputs"); |
| 0 | 37 | | writer.WriteStartArray(); |
| 0 | 38 | | foreach (var item in Inputs) |
| | 39 | | { |
| 0 | 40 | | writer.WriteObjectValue(item); |
| | 41 | | } |
| 0 | 42 | | writer.WriteEndArray(); |
| 0 | 43 | | writer.WritePropertyName("outputs"); |
| 0 | 44 | | writer.WriteStartArray(); |
| 0 | 45 | | foreach (var item in Outputs) |
| | 46 | | { |
| 0 | 47 | | writer.WriteObjectValue(item); |
| | 48 | | } |
| 0 | 49 | | writer.WriteEndArray(); |
| 0 | 50 | | writer.WriteEndObject(); |
| 0 | 51 | | } |
| | 52 | |
|
| | 53 | | internal static SearchIndexerSkill DeserializeSearchIndexerSkill(JsonElement element) |
| | 54 | | { |
| 32 | 55 | | if (element.TryGetProperty("@odata.type", out JsonElement discriminator)) |
| | 56 | | { |
| 32 | 57 | | switch (discriminator.GetString()) |
| | 58 | | { |
| 0 | 59 | | case "#Microsoft.Skills.Custom.WebApiSkill": return WebApiSkill.DeserializeWebApiSkill(element); |
| 0 | 60 | | case "#Microsoft.Skills.Text.EntityRecognitionSkill": return EntityRecognitionSkill.DeserializeEntit |
| 6 | 61 | | case "#Microsoft.Skills.Text.KeyPhraseExtractionSkill": return KeyPhraseExtractionSkill.DeserializeK |
| 6 | 62 | | case "#Microsoft.Skills.Text.LanguageDetectionSkill": return LanguageDetectionSkill.DeserializeLangu |
| 0 | 63 | | case "#Microsoft.Skills.Text.MergeSkill": return MergeSkill.DeserializeMergeSkill(element); |
| 6 | 64 | | case "#Microsoft.Skills.Text.SentimentSkill": return SentimentSkill.DeserializeSentimentSkill(elemen |
| 6 | 65 | | case "#Microsoft.Skills.Text.SplitSkill": return SplitSkill.DeserializeSplitSkill(element); |
| 1 | 66 | | case "#Microsoft.Skills.Text.TranslationSkill": return TextTranslationSkill.DeserializeTextTranslati |
| 1 | 67 | | case "#Microsoft.Skills.Util.ConditionalSkill": return ConditionalSkill.DeserializeConditionalSkill( |
| 6 | 68 | | case "#Microsoft.Skills.Util.ShaperSkill": return ShaperSkill.DeserializeShaperSkill(element); |
| 0 | 69 | | case "#Microsoft.Skills.Vision.ImageAnalysisSkill": return ImageAnalysisSkill.DeserializeImageAnalys |
| 0 | 70 | | case "#Microsoft.Skills.Vision.OcrSkill": return OcrSkill.DeserializeOcrSkill(element); |
| | 71 | | } |
| | 72 | | } |
| 0 | 73 | | string odataType = default; |
| 0 | 74 | | Optional<string> name = default; |
| 0 | 75 | | Optional<string> description = default; |
| 0 | 76 | | Optional<string> context = default; |
| 0 | 77 | | IList<InputFieldMappingEntry> inputs = default; |
| 0 | 78 | | IList<OutputFieldMappingEntry> outputs = default; |
| 0 | 79 | | foreach (var property in element.EnumerateObject()) |
| | 80 | | { |
| 0 | 81 | | if (property.NameEquals("@odata.type")) |
| | 82 | | { |
| 0 | 83 | | odataType = property.Value.GetString(); |
| 0 | 84 | | continue; |
| | 85 | | } |
| 0 | 86 | | if (property.NameEquals("name")) |
| | 87 | | { |
| 0 | 88 | | name = property.Value.GetString(); |
| 0 | 89 | | continue; |
| | 90 | | } |
| 0 | 91 | | if (property.NameEquals("description")) |
| | 92 | | { |
| 0 | 93 | | description = property.Value.GetString(); |
| 0 | 94 | | continue; |
| | 95 | | } |
| 0 | 96 | | if (property.NameEquals("context")) |
| | 97 | | { |
| 0 | 98 | | context = property.Value.GetString(); |
| 0 | 99 | | continue; |
| | 100 | | } |
| 0 | 101 | | if (property.NameEquals("inputs")) |
| | 102 | | { |
| 0 | 103 | | List<InputFieldMappingEntry> array = new List<InputFieldMappingEntry>(); |
| 0 | 104 | | foreach (var item in property.Value.EnumerateArray()) |
| | 105 | | { |
| 0 | 106 | | array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); |
| | 107 | | } |
| 0 | 108 | | inputs = array; |
| 0 | 109 | | continue; |
| | 110 | | } |
| 0 | 111 | | if (property.NameEquals("outputs")) |
| | 112 | | { |
| 0 | 113 | | List<OutputFieldMappingEntry> array = new List<OutputFieldMappingEntry>(); |
| 0 | 114 | | foreach (var item in property.Value.EnumerateArray()) |
| | 115 | | { |
| 0 | 116 | | array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); |
| | 117 | | } |
| 0 | 118 | | outputs = array; |
| | 119 | | continue; |
| | 120 | | } |
| | 121 | | } |
| 0 | 122 | | return new SearchIndexerSkill(odataType, name.Value, description.Value, context.Value, inputs, outputs); |
| | 123 | | } |
| | 124 | | } |
| | 125 | | } |