| | 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 SearchIndexerSkillset : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 5 | 18 | | writer.WriteStartObject(); |
| 5 | 19 | | writer.WritePropertyName("name"); |
| 5 | 20 | | writer.WriteStringValue(Name); |
| 5 | 21 | | if (Optional.IsDefined(Description)) |
| | 22 | | { |
| 2 | 23 | | writer.WritePropertyName("description"); |
| 2 | 24 | | writer.WriteStringValue(Description); |
| | 25 | | } |
| 5 | 26 | | writer.WritePropertyName("skills"); |
| 5 | 27 | | writer.WriteStartArray(); |
| 54 | 28 | | foreach (var item in Skills) |
| | 29 | | { |
| 22 | 30 | | writer.WriteObjectValue(item); |
| | 31 | | } |
| 5 | 32 | | writer.WriteEndArray(); |
| 5 | 33 | | if (Optional.IsDefined(CognitiveServicesAccount)) |
| | 34 | | { |
| 5 | 35 | | writer.WritePropertyName("cognitiveServices"); |
| 5 | 36 | | writer.WriteObjectValue(CognitiveServicesAccount); |
| | 37 | | } |
| 5 | 38 | | if (Optional.IsDefined(_etag)) |
| | 39 | | { |
| 2 | 40 | | writer.WritePropertyName("@odata.etag"); |
| 2 | 41 | | writer.WriteStringValue(_etag); |
| | 42 | | } |
| 5 | 43 | | writer.WriteEndObject(); |
| 5 | 44 | | } |
| | 45 | |
|
| | 46 | | internal static SearchIndexerSkillset DeserializeSearchIndexerSkillset(JsonElement element) |
| | 47 | | { |
| 9 | 48 | | string name = default; |
| 9 | 49 | | Optional<string> description = default; |
| 9 | 50 | | IList<SearchIndexerSkill> skills = default; |
| 9 | 51 | | Optional<CognitiveServicesAccount> cognitiveServices = default; |
| 9 | 52 | | Optional<string> odataEtag = default; |
| 134 | 53 | | foreach (var property in element.EnumerateObject()) |
| | 54 | | { |
| 58 | 55 | | if (property.NameEquals("name")) |
| | 56 | | { |
| 9 | 57 | | name = property.Value.GetString(); |
| 9 | 58 | | continue; |
| | 59 | | } |
| 49 | 60 | | if (property.NameEquals("description")) |
| | 61 | | { |
| 7 | 62 | | description = property.Value.GetString(); |
| 7 | 63 | | continue; |
| | 64 | | } |
| 42 | 65 | | if (property.NameEquals("skills")) |
| | 66 | | { |
| 7 | 67 | | List<SearchIndexerSkill> array = new List<SearchIndexerSkill>(); |
| 78 | 68 | | foreach (var item in property.Value.EnumerateArray()) |
| | 69 | | { |
| 32 | 70 | | array.Add(SearchIndexerSkill.DeserializeSearchIndexerSkill(item)); |
| | 71 | | } |
| 7 | 72 | | skills = array; |
| 7 | 73 | | continue; |
| | 74 | | } |
| 35 | 75 | | if (property.NameEquals("cognitiveServices")) |
| | 76 | | { |
| 7 | 77 | | cognitiveServices = CognitiveServicesAccount.DeserializeCognitiveServicesAccount(property.Value); |
| 7 | 78 | | continue; |
| | 79 | | } |
| 28 | 80 | | if (property.NameEquals("@odata.etag")) |
| | 81 | | { |
| 7 | 82 | | odataEtag = property.Value.GetString(); |
| | 83 | | continue; |
| | 84 | | } |
| | 85 | | } |
| 9 | 86 | | return new SearchIndexerSkillset(name, description.Value, skills, cognitiveServices.Value, odataEtag.Value); |
| | 87 | | } |
| | 88 | | } |
| | 89 | | } |