| | 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 IndexingParameters : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 2 | 18 | | writer.WriteStartObject(); |
| 2 | 19 | | if (Optional.IsDefined(BatchSize)) |
| | 20 | | { |
| 0 | 21 | | if (BatchSize != null) |
| | 22 | | { |
| 0 | 23 | | writer.WritePropertyName("batchSize"); |
| 0 | 24 | | writer.WriteNumberValue(BatchSize.Value); |
| | 25 | | } |
| | 26 | | else |
| | 27 | | { |
| 0 | 28 | | writer.WriteNull("batchSize"); |
| | 29 | | } |
| | 30 | | } |
| 2 | 31 | | if (Optional.IsDefined(MaxFailedItems)) |
| | 32 | | { |
| 0 | 33 | | if (MaxFailedItems != null) |
| | 34 | | { |
| 0 | 35 | | writer.WritePropertyName("maxFailedItems"); |
| 0 | 36 | | writer.WriteNumberValue(MaxFailedItems.Value); |
| | 37 | | } |
| | 38 | | else |
| | 39 | | { |
| 0 | 40 | | writer.WriteNull("maxFailedItems"); |
| | 41 | | } |
| | 42 | | } |
| 2 | 43 | | if (Optional.IsDefined(MaxFailedItemsPerBatch)) |
| | 44 | | { |
| 0 | 45 | | if (MaxFailedItemsPerBatch != null) |
| | 46 | | { |
| 0 | 47 | | writer.WritePropertyName("maxFailedItemsPerBatch"); |
| 0 | 48 | | writer.WriteNumberValue(MaxFailedItemsPerBatch.Value); |
| | 49 | | } |
| | 50 | | else |
| | 51 | | { |
| 0 | 52 | | writer.WriteNull("maxFailedItemsPerBatch"); |
| | 53 | | } |
| | 54 | | } |
| 2 | 55 | | if (Optional.IsCollectionDefined(Configuration)) |
| | 56 | | { |
| 1 | 57 | | writer.WritePropertyName("configuration"); |
| 1 | 58 | | writer.WriteStartObject(); |
| 4 | 59 | | foreach (var item in Configuration) |
| | 60 | | { |
| 1 | 61 | | writer.WritePropertyName(item.Key); |
| 1 | 62 | | writer.WriteObjectValue(item.Value); |
| | 63 | | } |
| 1 | 64 | | writer.WriteEndObject(); |
| | 65 | | } |
| 2 | 66 | | writer.WriteEndObject(); |
| 2 | 67 | | } |
| | 68 | |
|
| | 69 | | internal static IndexingParameters DeserializeIndexingParameters(JsonElement element) |
| | 70 | | { |
| 1 | 71 | | Optional<int?> batchSize = default; |
| 1 | 72 | | Optional<int?> maxFailedItems = default; |
| 1 | 73 | | Optional<int?> maxFailedItemsPerBatch = default; |
| 1 | 74 | | Optional<IDictionary<string, object>> configuration = default; |
| 12 | 75 | | foreach (var property in element.EnumerateObject()) |
| | 76 | | { |
| 5 | 77 | | if (property.NameEquals("batchSize")) |
| | 78 | | { |
| 1 | 79 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 80 | | { |
| 1 | 81 | | batchSize = null; |
| 1 | 82 | | continue; |
| | 83 | | } |
| 0 | 84 | | batchSize = property.Value.GetInt32(); |
| 0 | 85 | | continue; |
| | 86 | | } |
| 4 | 87 | | if (property.NameEquals("maxFailedItems")) |
| | 88 | | { |
| 1 | 89 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 90 | | { |
| 1 | 91 | | maxFailedItems = null; |
| 1 | 92 | | continue; |
| | 93 | | } |
| 0 | 94 | | maxFailedItems = property.Value.GetInt32(); |
| 0 | 95 | | continue; |
| | 96 | | } |
| 3 | 97 | | if (property.NameEquals("maxFailedItemsPerBatch")) |
| | 98 | | { |
| 1 | 99 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 100 | | { |
| 1 | 101 | | maxFailedItemsPerBatch = null; |
| 1 | 102 | | continue; |
| | 103 | | } |
| 0 | 104 | | maxFailedItemsPerBatch = property.Value.GetInt32(); |
| 0 | 105 | | continue; |
| | 106 | | } |
| 2 | 107 | | if (property.NameEquals("configuration")) |
| | 108 | | { |
| 1 | 109 | | Dictionary<string, object> dictionary = new Dictionary<string, object>(); |
| 4 | 110 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 111 | | { |
| 1 | 112 | | dictionary.Add(property0.Name, property0.Value.GetObject()); |
| | 113 | | } |
| 1 | 114 | | configuration = dictionary; |
| | 115 | | continue; |
| | 116 | | } |
| | 117 | | } |
| 1 | 118 | | return new IndexingParameters(Optional.ToNullable(batchSize), Optional.ToNullable(maxFailedItems), Optional. |
| | 119 | | } |
| | 120 | | } |
| | 121 | | } |