| | 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 SearchIndexer : 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("dataSourceName"); |
| 5 | 27 | | writer.WriteStringValue(DataSourceName); |
| 5 | 28 | | if (Optional.IsDefined(SkillsetName)) |
| | 29 | | { |
| 1 | 30 | | writer.WritePropertyName("skillsetName"); |
| 1 | 31 | | writer.WriteStringValue(SkillsetName); |
| | 32 | | } |
| 5 | 33 | | writer.WritePropertyName("targetIndexName"); |
| 5 | 34 | | writer.WriteStringValue(TargetIndexName); |
| 5 | 35 | | if (Optional.IsDefined(Schedule)) |
| | 36 | | { |
| 0 | 37 | | if (Schedule != null) |
| | 38 | | { |
| 0 | 39 | | writer.WritePropertyName("schedule"); |
| 0 | 40 | | writer.WriteObjectValue(Schedule); |
| | 41 | | } |
| | 42 | | else |
| | 43 | | { |
| 0 | 44 | | writer.WriteNull("schedule"); |
| | 45 | | } |
| | 46 | | } |
| 5 | 47 | | if (Optional.IsDefined(Parameters)) |
| | 48 | | { |
| 1 | 49 | | if (Parameters != null) |
| | 50 | | { |
| 1 | 51 | | writer.WritePropertyName("parameters"); |
| 1 | 52 | | writer.WriteObjectValue(Parameters); |
| | 53 | | } |
| | 54 | | else |
| | 55 | | { |
| 0 | 56 | | writer.WriteNull("parameters"); |
| | 57 | | } |
| | 58 | | } |
| 5 | 59 | | if (Optional.IsCollectionDefined(FieldMappings)) |
| | 60 | | { |
| 3 | 61 | | writer.WritePropertyName("fieldMappings"); |
| 3 | 62 | | writer.WriteStartArray(); |
| 16 | 63 | | foreach (var item in FieldMappings) |
| | 64 | | { |
| 5 | 65 | | writer.WriteObjectValue(item); |
| | 66 | | } |
| 3 | 67 | | writer.WriteEndArray(); |
| | 68 | | } |
| 5 | 69 | | if (Optional.IsCollectionDefined(OutputFieldMappings)) |
| | 70 | | { |
| 3 | 71 | | writer.WritePropertyName("outputFieldMappings"); |
| 3 | 72 | | writer.WriteStartArray(); |
| 8 | 73 | | foreach (var item in OutputFieldMappings) |
| | 74 | | { |
| 1 | 75 | | writer.WriteObjectValue(item); |
| | 76 | | } |
| 3 | 77 | | writer.WriteEndArray(); |
| | 78 | | } |
| 5 | 79 | | if (Optional.IsDefined(IsDisabled)) |
| | 80 | | { |
| 0 | 81 | | if (IsDisabled != null) |
| | 82 | | { |
| 0 | 83 | | writer.WritePropertyName("disabled"); |
| 0 | 84 | | writer.WriteBooleanValue(IsDisabled.Value); |
| | 85 | | } |
| | 86 | | else |
| | 87 | | { |
| 0 | 88 | | writer.WriteNull("disabled"); |
| | 89 | | } |
| | 90 | | } |
| 5 | 91 | | if (Optional.IsDefined(_etag)) |
| | 92 | | { |
| 2 | 93 | | writer.WritePropertyName("@odata.etag"); |
| 2 | 94 | | writer.WriteStringValue(_etag); |
| | 95 | | } |
| 5 | 96 | | writer.WriteEndObject(); |
| 5 | 97 | | } |
| | 98 | |
|
| | 99 | | internal static SearchIndexer DeserializeSearchIndexer(JsonElement element) |
| | 100 | | { |
| 5 | 101 | | string name = default; |
| 5 | 102 | | Optional<string> description = default; |
| 5 | 103 | | string dataSourceName = default; |
| 5 | 104 | | Optional<string> skillsetName = default; |
| 5 | 105 | | string targetIndexName = default; |
| 5 | 106 | | Optional<IndexingSchedule> schedule = default; |
| 5 | 107 | | Optional<IndexingParameters> parameters = default; |
| 5 | 108 | | Optional<IList<FieldMapping>> fieldMappings = default; |
| 5 | 109 | | Optional<IList<FieldMapping>> outputFieldMappings = default; |
| 5 | 110 | | Optional<bool?> disabled = default; |
| 5 | 111 | | Optional<string> odataEtag = default; |
| 140 | 112 | | foreach (var property in element.EnumerateObject()) |
| | 113 | | { |
| 65 | 114 | | if (property.NameEquals("name")) |
| | 115 | | { |
| 5 | 116 | | name = property.Value.GetString(); |
| 5 | 117 | | continue; |
| | 118 | | } |
| 60 | 119 | | if (property.NameEquals("description")) |
| | 120 | | { |
| 5 | 121 | | description = property.Value.GetString(); |
| 5 | 122 | | continue; |
| | 123 | | } |
| 55 | 124 | | if (property.NameEquals("dataSourceName")) |
| | 125 | | { |
| 5 | 126 | | dataSourceName = property.Value.GetString(); |
| 5 | 127 | | continue; |
| | 128 | | } |
| 50 | 129 | | if (property.NameEquals("skillsetName")) |
| | 130 | | { |
| 5 | 131 | | skillsetName = property.Value.GetString(); |
| 5 | 132 | | continue; |
| | 133 | | } |
| 45 | 134 | | if (property.NameEquals("targetIndexName")) |
| | 135 | | { |
| 5 | 136 | | targetIndexName = property.Value.GetString(); |
| 5 | 137 | | continue; |
| | 138 | | } |
| 40 | 139 | | if (property.NameEquals("schedule")) |
| | 140 | | { |
| 5 | 141 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 142 | | { |
| 5 | 143 | | schedule = null; |
| 5 | 144 | | continue; |
| | 145 | | } |
| 0 | 146 | | schedule = IndexingSchedule.DeserializeIndexingSchedule(property.Value); |
| 0 | 147 | | continue; |
| | 148 | | } |
| 35 | 149 | | if (property.NameEquals("parameters")) |
| | 150 | | { |
| 5 | 151 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 152 | | { |
| 4 | 153 | | parameters = null; |
| 4 | 154 | | continue; |
| | 155 | | } |
| 1 | 156 | | parameters = IndexingParameters.DeserializeIndexingParameters(property.Value); |
| 1 | 157 | | continue; |
| | 158 | | } |
| 30 | 159 | | if (property.NameEquals("fieldMappings")) |
| | 160 | | { |
| 5 | 161 | | List<FieldMapping> array = new List<FieldMapping>(); |
| 20 | 162 | | foreach (var item in property.Value.EnumerateArray()) |
| | 163 | | { |
| 5 | 164 | | array.Add(FieldMapping.DeserializeFieldMapping(item)); |
| | 165 | | } |
| 5 | 166 | | fieldMappings = array; |
| 5 | 167 | | continue; |
| | 168 | | } |
| 25 | 169 | | if (property.NameEquals("outputFieldMappings")) |
| | 170 | | { |
| 5 | 171 | | List<FieldMapping> array = new List<FieldMapping>(); |
| 12 | 172 | | foreach (var item in property.Value.EnumerateArray()) |
| | 173 | | { |
| 1 | 174 | | array.Add(FieldMapping.DeserializeFieldMapping(item)); |
| | 175 | | } |
| 5 | 176 | | outputFieldMappings = array; |
| 5 | 177 | | continue; |
| | 178 | | } |
| 20 | 179 | | if (property.NameEquals("disabled")) |
| | 180 | | { |
| 5 | 181 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 182 | | { |
| 5 | 183 | | disabled = null; |
| 5 | 184 | | continue; |
| | 185 | | } |
| 0 | 186 | | disabled = property.Value.GetBoolean(); |
| 0 | 187 | | continue; |
| | 188 | | } |
| 15 | 189 | | if (property.NameEquals("@odata.etag")) |
| | 190 | | { |
| 5 | 191 | | odataEtag = property.Value.GetString(); |
| | 192 | | continue; |
| | 193 | | } |
| | 194 | | } |
| 5 | 195 | | return new SearchIndexer(name, description.Value, dataSourceName, skillsetName.Value, targetIndexName, sched |
| | 196 | | } |
| | 197 | | } |
| | 198 | | } |