| | 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; |
| | 9 | | using System.Collections.Generic; |
| | 10 | | using System.Text.Json; |
| | 11 | | using Azure.Core; |
| | 12 | |
|
| | 13 | | namespace Azure.ResourceManager.EventHubs.Models |
| | 14 | | { |
| | 15 | | public partial class Eventhub : IUtf8JsonSerializable |
| | 16 | | { |
| | 17 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 18 | | { |
| 64 | 19 | | writer.WriteStartObject(); |
| 64 | 20 | | if (Id != null) |
| | 21 | | { |
| 4 | 22 | | writer.WritePropertyName("id"); |
| 4 | 23 | | writer.WriteStringValue(Id); |
| | 24 | | } |
| 64 | 25 | | if (Name != null) |
| | 26 | | { |
| 4 | 27 | | writer.WritePropertyName("name"); |
| 4 | 28 | | writer.WriteStringValue(Name); |
| | 29 | | } |
| 64 | 30 | | if (Type != null) |
| | 31 | | { |
| 4 | 32 | | writer.WritePropertyName("type"); |
| 4 | 33 | | writer.WriteStringValue(Type); |
| | 34 | | } |
| 64 | 35 | | writer.WritePropertyName("properties"); |
| 64 | 36 | | writer.WriteStartObject(); |
| 64 | 37 | | if (PartitionIds != null) |
| | 38 | | { |
| 4 | 39 | | writer.WritePropertyName("partitionIds"); |
| 4 | 40 | | writer.WriteStartArray(); |
| 40 | 41 | | foreach (var item in PartitionIds) |
| | 42 | | { |
| 16 | 43 | | writer.WriteStringValue(item); |
| | 44 | | } |
| 4 | 45 | | writer.WriteEndArray(); |
| | 46 | | } |
| 64 | 47 | | if (CreatedAt != null) |
| | 48 | | { |
| 4 | 49 | | writer.WritePropertyName("createdAt"); |
| 4 | 50 | | writer.WriteStringValue(CreatedAt.Value, "O"); |
| | 51 | | } |
| 64 | 52 | | if (UpdatedAt != null) |
| | 53 | | { |
| 4 | 54 | | writer.WritePropertyName("updatedAt"); |
| 4 | 55 | | writer.WriteStringValue(UpdatedAt.Value, "O"); |
| | 56 | | } |
| 64 | 57 | | if (MessageRetentionInDays != null) |
| | 58 | | { |
| 24 | 59 | | writer.WritePropertyName("messageRetentionInDays"); |
| 24 | 60 | | writer.WriteNumberValue(MessageRetentionInDays.Value); |
| | 61 | | } |
| 64 | 62 | | if (PartitionCount != null) |
| | 63 | | { |
| 8 | 64 | | writer.WritePropertyName("partitionCount"); |
| 8 | 65 | | writer.WriteNumberValue(PartitionCount.Value); |
| | 66 | | } |
| 64 | 67 | | if (Status != null) |
| | 68 | | { |
| 8 | 69 | | writer.WritePropertyName("status"); |
| 8 | 70 | | writer.WriteStringValue(Status.Value.ToSerialString()); |
| | 71 | | } |
| 64 | 72 | | if (CaptureDescription != null) |
| | 73 | | { |
| 8 | 74 | | writer.WritePropertyName("captureDescription"); |
| 8 | 75 | | writer.WriteObjectValue(CaptureDescription); |
| | 76 | | } |
| 64 | 77 | | writer.WriteEndObject(); |
| 64 | 78 | | writer.WriteEndObject(); |
| 64 | 79 | | } |
| | 80 | |
|
| | 81 | | internal static Eventhub DeserializeEventhub(JsonElement element) |
| | 82 | | { |
| 152 | 83 | | string id = default; |
| 152 | 84 | | string name = default; |
| 152 | 85 | | string type = default; |
| 152 | 86 | | IList<string> partitionIds = default; |
| 152 | 87 | | DateTimeOffset? createdAt = default; |
| 152 | 88 | | DateTimeOffset? updatedAt = default; |
| 152 | 89 | | long? messageRetentionInDays = default; |
| 152 | 90 | | long? partitionCount = default; |
| 152 | 91 | | EntityStatus? status = default; |
| 152 | 92 | | CaptureDescription captureDescription = default; |
| 1824 | 93 | | foreach (var property in element.EnumerateObject()) |
| | 94 | | { |
| 760 | 95 | | if (property.NameEquals("id")) |
| | 96 | | { |
| 152 | 97 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 98 | | { |
| | 99 | | continue; |
| | 100 | | } |
| 152 | 101 | | id = property.Value.GetString(); |
| 152 | 102 | | continue; |
| | 103 | | } |
| 608 | 104 | | if (property.NameEquals("name")) |
| | 105 | | { |
| 152 | 106 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 107 | | { |
| | 108 | | continue; |
| | 109 | | } |
| 152 | 110 | | name = property.Value.GetString(); |
| 152 | 111 | | continue; |
| | 112 | | } |
| 456 | 113 | | if (property.NameEquals("type")) |
| | 114 | | { |
| 152 | 115 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 116 | | { |
| | 117 | | continue; |
| | 118 | | } |
| 152 | 119 | | type = property.Value.GetString(); |
| 152 | 120 | | continue; |
| | 121 | | } |
| 304 | 122 | | if (property.NameEquals("properties")) |
| | 123 | | { |
| 2168 | 124 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 125 | | { |
| 932 | 126 | | if (property0.NameEquals("partitionIds")) |
| | 127 | | { |
| 152 | 128 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 129 | | { |
| | 130 | | continue; |
| | 131 | | } |
| 152 | 132 | | List<string> array = new List<string>(); |
| 1488 | 133 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 134 | | { |
| 592 | 135 | | if (item.ValueKind == JsonValueKind.Null) |
| | 136 | | { |
| 0 | 137 | | array.Add(null); |
| | 138 | | } |
| | 139 | | else |
| | 140 | | { |
| 592 | 141 | | array.Add(item.GetString()); |
| | 142 | | } |
| | 143 | | } |
| 152 | 144 | | partitionIds = array; |
| 152 | 145 | | continue; |
| | 146 | | } |
| 780 | 147 | | if (property0.NameEquals("createdAt")) |
| | 148 | | { |
| 152 | 149 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 150 | | { |
| | 151 | | continue; |
| | 152 | | } |
| 152 | 153 | | createdAt = property0.Value.GetDateTimeOffset("O"); |
| 152 | 154 | | continue; |
| | 155 | | } |
| 628 | 156 | | if (property0.NameEquals("updatedAt")) |
| | 157 | | { |
| 152 | 158 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 159 | | { |
| | 160 | | continue; |
| | 161 | | } |
| 152 | 162 | | updatedAt = property0.Value.GetDateTimeOffset("O"); |
| 152 | 163 | | continue; |
| | 164 | | } |
| 476 | 165 | | if (property0.NameEquals("messageRetentionInDays")) |
| | 166 | | { |
| 152 | 167 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 168 | | { |
| | 169 | | continue; |
| | 170 | | } |
| 152 | 171 | | messageRetentionInDays = property0.Value.GetInt64(); |
| 152 | 172 | | continue; |
| | 173 | | } |
| 324 | 174 | | if (property0.NameEquals("partitionCount")) |
| | 175 | | { |
| 152 | 176 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 177 | | { |
| | 178 | | continue; |
| | 179 | | } |
| 152 | 180 | | partitionCount = property0.Value.GetInt64(); |
| 152 | 181 | | continue; |
| | 182 | | } |
| 172 | 183 | | if (property0.NameEquals("status")) |
| | 184 | | { |
| 152 | 185 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 186 | | { |
| | 187 | | continue; |
| | 188 | | } |
| 152 | 189 | | status = property0.Value.GetString().ToEntityStatus(); |
| 152 | 190 | | continue; |
| | 191 | | } |
| 20 | 192 | | if (property0.NameEquals("captureDescription")) |
| | 193 | | { |
| 20 | 194 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 195 | | { |
| | 196 | | continue; |
| | 197 | | } |
| 20 | 198 | | captureDescription = CaptureDescription.DeserializeCaptureDescription(property0.Value); |
| | 199 | | continue; |
| | 200 | | } |
| | 201 | | } |
| | 202 | | continue; |
| | 203 | | } |
| | 204 | | } |
| 152 | 205 | | return new Eventhub(id, name, type, partitionIds, createdAt, updatedAt, messageRetentionInDays, partitionCou |
| | 206 | | } |
| | 207 | | } |
| | 208 | | } |