|
23 | 23 |
|
24 | 24 | namespace Elastic.Clients.Elasticsearch.Core.Bulk;
|
25 | 25 |
|
| 26 | +internal sealed partial class ResponseItemConverter : System.Text.Json.Serialization.JsonConverter<Elastic.Clients.Elasticsearch.Core.Bulk.ResponseItem> |
| 27 | +{ |
| 28 | + private static readonly System.Text.Json.JsonEncodedText PropError = System.Text.Json.JsonEncodedText.Encode("error"); |
| 29 | + private static readonly System.Text.Json.JsonEncodedText PropFailureStore = System.Text.Json.JsonEncodedText.Encode("failure_store"); |
| 30 | + private static readonly System.Text.Json.JsonEncodedText PropForcedRefresh = System.Text.Json.JsonEncodedText.Encode("forced_refresh"); |
| 31 | + private static readonly System.Text.Json.JsonEncodedText PropGet = System.Text.Json.JsonEncodedText.Encode("get"); |
| 32 | + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); |
| 33 | + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); |
| 34 | + private static readonly System.Text.Json.JsonEncodedText PropPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("_primary_term"); |
| 35 | + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); |
| 36 | + private static readonly System.Text.Json.JsonEncodedText PropSeqNo = System.Text.Json.JsonEncodedText.Encode("_seq_no"); |
| 37 | + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); |
| 38 | + private static readonly System.Text.Json.JsonEncodedText PropStatus = System.Text.Json.JsonEncodedText.Encode("status"); |
| 39 | + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("_version"); |
| 40 | + |
| 41 | + public override Elastic.Clients.Elasticsearch.Core.Bulk.ResponseItem Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) |
| 42 | + { |
| 43 | + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); |
| 44 | + LocalJsonValue<Elastic.Clients.Elasticsearch.ErrorCause?> propError = default; |
| 45 | + LocalJsonValue<Elastic.Clients.Elasticsearch.Core.Bulk.FailureStoreStatus?> propFailureStore = default; |
| 46 | + LocalJsonValue<bool?> propForcedRefresh = default; |
| 47 | + LocalJsonValue<Elastic.Clients.Elasticsearch.InlineGet<System.Collections.Generic.IReadOnlyDictionary<string, object>>?> propGet = default; |
| 48 | + LocalJsonValue<string?> propId = default; |
| 49 | + LocalJsonValue<string> propIndex = default; |
| 50 | + LocalJsonValue<long?> propPrimaryTerm = default; |
| 51 | + LocalJsonValue<string?> propResult = default; |
| 52 | + LocalJsonValue<long?> propSeqNo = default; |
| 53 | + LocalJsonValue<Elastic.Clients.Elasticsearch.ShardStatistics?> propShards = default; |
| 54 | + LocalJsonValue<int> propStatus = default; |
| 55 | + LocalJsonValue<long?> propVersion = default; |
| 56 | + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) |
| 57 | + { |
| 58 | + if (propError.TryReadProperty(ref reader, options, PropError, null)) |
| 59 | + { |
| 60 | + continue; |
| 61 | + } |
| 62 | + |
| 63 | + if (propFailureStore.TryReadProperty(ref reader, options, PropFailureStore, static Elastic.Clients.Elasticsearch.Core.Bulk.FailureStoreStatus? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadNullableValue<Elastic.Clients.Elasticsearch.Core.Bulk.FailureStoreStatus>(o))) |
| 64 | + { |
| 65 | + continue; |
| 66 | + } |
| 67 | + |
| 68 | + if (propForcedRefresh.TryReadProperty(ref reader, options, PropForcedRefresh, static bool? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadNullableValue<bool>(o))) |
| 69 | + { |
| 70 | + continue; |
| 71 | + } |
| 72 | + |
| 73 | + if (propGet.TryReadProperty(ref reader, options, PropGet, null)) |
| 74 | + { |
| 75 | + continue; |
| 76 | + } |
| 77 | + |
| 78 | + if (propId.TryReadProperty(ref reader, options, PropId, null)) |
| 79 | + { |
| 80 | + continue; |
| 81 | + } |
| 82 | + |
| 83 | + if (propIndex.TryReadProperty(ref reader, options, PropIndex, null)) |
| 84 | + { |
| 85 | + continue; |
| 86 | + } |
| 87 | + |
| 88 | + if (propPrimaryTerm.TryReadProperty(ref reader, options, PropPrimaryTerm, static long? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadNullableValue<long>(o))) |
| 89 | + { |
| 90 | + continue; |
| 91 | + } |
| 92 | + |
| 93 | + if (propResult.TryReadProperty(ref reader, options, PropResult, null)) |
| 94 | + { |
| 95 | + continue; |
| 96 | + } |
| 97 | + |
| 98 | + if (propSeqNo.TryReadProperty(ref reader, options, PropSeqNo, static long? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadNullableValue<long>(o))) |
| 99 | + { |
| 100 | + continue; |
| 101 | + } |
| 102 | + |
| 103 | + if (propShards.TryReadProperty(ref reader, options, PropShards, null)) |
| 104 | + { |
| 105 | + continue; |
| 106 | + } |
| 107 | + |
| 108 | + if (propStatus.TryReadProperty(ref reader, options, PropStatus, null)) |
| 109 | + { |
| 110 | + continue; |
| 111 | + } |
| 112 | + |
| 113 | + if (propVersion.TryReadProperty(ref reader, options, PropVersion, static long? (ref System.Text.Json.Utf8JsonReader r, System.Text.Json.JsonSerializerOptions o) => r.ReadNullableValue<long>(o))) |
| 114 | + { |
| 115 | + continue; |
| 116 | + } |
| 117 | + |
| 118 | + if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) |
| 119 | + { |
| 120 | + reader.Skip(); |
| 121 | + continue; |
| 122 | + } |
| 123 | + |
| 124 | + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); |
| 125 | + } |
| 126 | + |
| 127 | + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); |
| 128 | + return new Elastic.Clients.Elasticsearch.Core.Bulk.ResponseItem(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance) |
| 129 | + { |
| 130 | + Error = propError.Value, |
| 131 | + FailureStore = propFailureStore.Value, |
| 132 | + ForcedRefresh = propForcedRefresh.Value, |
| 133 | + Get = propGet.Value, |
| 134 | + Id = propId.Value, |
| 135 | + Index = propIndex.Value, |
| 136 | + PrimaryTerm = propPrimaryTerm.Value, |
| 137 | + Result = propResult.Value, |
| 138 | + SeqNo = propSeqNo.Value, |
| 139 | + Shards = propShards.Value, |
| 140 | + Status = propStatus.Value, |
| 141 | + Version = propVersion.Value |
| 142 | + }; |
| 143 | + } |
| 144 | + |
| 145 | + public override void Write(System.Text.Json.Utf8JsonWriter writer, Elastic.Clients.Elasticsearch.Core.Bulk.ResponseItem value, System.Text.Json.JsonSerializerOptions options) |
| 146 | + { |
| 147 | + writer.WriteStartObject(); |
| 148 | + writer.WriteProperty(options, PropError, value.Error, null, null); |
| 149 | + writer.WriteProperty(options, PropFailureStore, value.FailureStore, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, Elastic.Clients.Elasticsearch.Core.Bulk.FailureStoreStatus? v) => w.WriteNullableValue<Elastic.Clients.Elasticsearch.Core.Bulk.FailureStoreStatus>(o, v)); |
| 150 | + writer.WriteProperty(options, PropForcedRefresh, value.ForcedRefresh, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, bool? v) => w.WriteNullableValue<bool>(o, v)); |
| 151 | + writer.WriteProperty(options, PropGet, value.Get, null, null); |
| 152 | + writer.WriteProperty(options, PropId, value.Id, null, null); |
| 153 | + writer.WriteProperty(options, PropIndex, value.Index, null, null); |
| 154 | + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, long? v) => w.WriteNullableValue<long>(o, v)); |
| 155 | + writer.WriteProperty(options, PropResult, value.Result, null, null); |
| 156 | + writer.WriteProperty(options, PropSeqNo, value.SeqNo, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, long? v) => w.WriteNullableValue<long>(o, v)); |
| 157 | + writer.WriteProperty(options, PropShards, value.Shards, null, null); |
| 158 | + writer.WriteProperty(options, PropStatus, value.Status, null, null); |
| 159 | + writer.WriteProperty(options, PropVersion, value.Version, null, static (System.Text.Json.Utf8JsonWriter w, System.Text.Json.JsonSerializerOptions o, long? v) => w.WriteNullableValue<long>(o, v)); |
| 160 | + writer.WriteEndObject(); |
| 161 | + } |
| 162 | +} |
| 163 | + |
| 164 | +[System.Text.Json.Serialization.JsonConverter(typeof(Elastic.Clients.Elasticsearch.Core.Bulk.ResponseItemConverter))] |
26 | 165 | public abstract partial class ResponseItem
|
27 | 166 | {
|
28 | 167 | [System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
|
|
0 commit comments