| | 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.ResourceManager.Compute.Models |
| | 13 | | { |
| | 14 | | public partial class AvailabilitySet : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 148 | 18 | | writer.WriteStartObject(); |
| 148 | 19 | | if (Sku != null) |
| | 20 | | { |
| 116 | 21 | | writer.WritePropertyName("sku"); |
| 116 | 22 | | writer.WriteObjectValue(Sku); |
| | 23 | | } |
| 148 | 24 | | if (Id != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("id"); |
| 0 | 27 | | writer.WriteStringValue(Id); |
| | 28 | | } |
| 148 | 29 | | if (Name != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("name"); |
| 0 | 32 | | writer.WriteStringValue(Name); |
| | 33 | | } |
| 148 | 34 | | if (Type != null) |
| | 35 | | { |
| 0 | 36 | | writer.WritePropertyName("type"); |
| 0 | 37 | | writer.WriteStringValue(Type); |
| | 38 | | } |
| 148 | 39 | | writer.WritePropertyName("location"); |
| 148 | 40 | | writer.WriteStringValue(Location); |
| 148 | 41 | | if (Tags != null) |
| | 42 | | { |
| 148 | 43 | | writer.WritePropertyName("tags"); |
| 148 | 44 | | writer.WriteStartObject(); |
| 888 | 45 | | foreach (var item in Tags) |
| | 46 | | { |
| 296 | 47 | | writer.WritePropertyName(item.Key); |
| 296 | 48 | | writer.WriteStringValue(item.Value); |
| | 49 | | } |
| 148 | 50 | | writer.WriteEndObject(); |
| | 51 | | } |
| 148 | 52 | | writer.WritePropertyName("properties"); |
| 148 | 53 | | writer.WriteStartObject(); |
| 148 | 54 | | if (PlatformUpdateDomainCount != null) |
| | 55 | | { |
| 128 | 56 | | writer.WritePropertyName("platformUpdateDomainCount"); |
| 128 | 57 | | writer.WriteNumberValue(PlatformUpdateDomainCount.Value); |
| | 58 | | } |
| 148 | 59 | | if (PlatformFaultDomainCount != null) |
| | 60 | | { |
| 136 | 61 | | writer.WritePropertyName("platformFaultDomainCount"); |
| 136 | 62 | | writer.WriteNumberValue(PlatformFaultDomainCount.Value); |
| | 63 | | } |
| 148 | 64 | | if (VirtualMachines != null) |
| | 65 | | { |
| 0 | 66 | | writer.WritePropertyName("virtualMachines"); |
| 0 | 67 | | writer.WriteStartArray(); |
| 0 | 68 | | foreach (var item in VirtualMachines) |
| | 69 | | { |
| 0 | 70 | | writer.WriteObjectValue(item); |
| | 71 | | } |
| 0 | 72 | | writer.WriteEndArray(); |
| | 73 | | } |
| 148 | 74 | | if (ProximityPlacementGroup != null) |
| | 75 | | { |
| 0 | 76 | | writer.WritePropertyName("proximityPlacementGroup"); |
| 0 | 77 | | writer.WriteObjectValue(ProximityPlacementGroup); |
| | 78 | | } |
| 148 | 79 | | if (Statuses != null) |
| | 80 | | { |
| 0 | 81 | | writer.WritePropertyName("statuses"); |
| 0 | 82 | | writer.WriteStartArray(); |
| 0 | 83 | | foreach (var item in Statuses) |
| | 84 | | { |
| 0 | 85 | | writer.WriteObjectValue(item); |
| | 86 | | } |
| 0 | 87 | | writer.WriteEndArray(); |
| | 88 | | } |
| 148 | 89 | | writer.WriteEndObject(); |
| 148 | 90 | | writer.WriteEndObject(); |
| 148 | 91 | | } |
| | 92 | |
|
| | 93 | | internal static AvailabilitySet DeserializeAvailabilitySet(JsonElement element) |
| | 94 | | { |
| 180 | 95 | | Sku sku = default; |
| 180 | 96 | | string id = default; |
| 180 | 97 | | string name = default; |
| 180 | 98 | | string type = default; |
| 180 | 99 | | string location = default; |
| 180 | 100 | | IDictionary<string, string> tags = default; |
| 180 | 101 | | int? platformUpdateDomainCount = default; |
| 180 | 102 | | int? platformFaultDomainCount = default; |
| 180 | 103 | | IList<SubResource> virtualMachines = default; |
| 180 | 104 | | SubResource proximityPlacementGroup = default; |
| 180 | 105 | | IList<InstanceViewStatus> statuses = default; |
| 2880 | 106 | | foreach (var property in element.EnumerateObject()) |
| | 107 | | { |
| 1260 | 108 | | if (property.NameEquals("sku")) |
| | 109 | | { |
| 180 | 110 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 111 | | { |
| | 112 | | continue; |
| | 113 | | } |
| 180 | 114 | | sku = Sku.DeserializeSku(property.Value); |
| 180 | 115 | | continue; |
| | 116 | | } |
| 1080 | 117 | | if (property.NameEquals("id")) |
| | 118 | | { |
| 180 | 119 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 120 | | { |
| | 121 | | continue; |
| | 122 | | } |
| 180 | 123 | | id = property.Value.GetString(); |
| 180 | 124 | | continue; |
| | 125 | | } |
| 900 | 126 | | if (property.NameEquals("name")) |
| | 127 | | { |
| 180 | 128 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 129 | | { |
| | 130 | | continue; |
| | 131 | | } |
| 180 | 132 | | name = property.Value.GetString(); |
| 180 | 133 | | continue; |
| | 134 | | } |
| 720 | 135 | | if (property.NameEquals("type")) |
| | 136 | | { |
| 180 | 137 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 138 | | { |
| | 139 | | continue; |
| | 140 | | } |
| 180 | 141 | | type = property.Value.GetString(); |
| 180 | 142 | | continue; |
| | 143 | | } |
| 540 | 144 | | if (property.NameEquals("location")) |
| | 145 | | { |
| 180 | 146 | | location = property.Value.GetString(); |
| 180 | 147 | | continue; |
| | 148 | | } |
| 360 | 149 | | if (property.NameEquals("tags")) |
| | 150 | | { |
| 180 | 151 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 152 | | { |
| | 153 | | continue; |
| | 154 | | } |
| 180 | 155 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 1096 | 156 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 157 | | { |
| 368 | 158 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 159 | | { |
| 0 | 160 | | dictionary.Add(property0.Name, null); |
| | 161 | | } |
| | 162 | | else |
| | 163 | | { |
| 368 | 164 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | 165 | | } |
| | 166 | | } |
| 180 | 167 | | tags = dictionary; |
| 180 | 168 | | continue; |
| | 169 | | } |
| 180 | 170 | | if (property.NameEquals("properties")) |
| | 171 | | { |
| 1144 | 172 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 173 | | { |
| 392 | 174 | | if (property0.NameEquals("platformUpdateDomainCount")) |
| | 175 | | { |
| 180 | 176 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 177 | | { |
| | 178 | | continue; |
| | 179 | | } |
| 180 | 180 | | platformUpdateDomainCount = property0.Value.GetInt32(); |
| 180 | 181 | | continue; |
| | 182 | | } |
| 212 | 183 | | if (property0.NameEquals("platformFaultDomainCount")) |
| | 184 | | { |
| 180 | 185 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 186 | | { |
| | 187 | | continue; |
| | 188 | | } |
| 180 | 189 | | platformFaultDomainCount = property0.Value.GetInt32(); |
| 180 | 190 | | continue; |
| | 191 | | } |
| 32 | 192 | | if (property0.NameEquals("virtualMachines")) |
| | 193 | | { |
| 32 | 194 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 195 | | { |
| | 196 | | continue; |
| | 197 | | } |
| 32 | 198 | | List<SubResource> array = new List<SubResource>(); |
| 0 | 199 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 200 | | { |
| 0 | 201 | | if (item.ValueKind == JsonValueKind.Null) |
| | 202 | | { |
| 0 | 203 | | array.Add(null); |
| | 204 | | } |
| | 205 | | else |
| | 206 | | { |
| 0 | 207 | | array.Add(SubResource.DeserializeSubResource(item)); |
| | 208 | | } |
| | 209 | | } |
| 32 | 210 | | virtualMachines = array; |
| 32 | 211 | | continue; |
| | 212 | | } |
| 0 | 213 | | if (property0.NameEquals("proximityPlacementGroup")) |
| | 214 | | { |
| 0 | 215 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 216 | | { |
| | 217 | | continue; |
| | 218 | | } |
| 0 | 219 | | proximityPlacementGroup = SubResource.DeserializeSubResource(property0.Value); |
| 0 | 220 | | continue; |
| | 221 | | } |
| 0 | 222 | | if (property0.NameEquals("statuses")) |
| | 223 | | { |
| 0 | 224 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 225 | | { |
| | 226 | | continue; |
| | 227 | | } |
| 0 | 228 | | List<InstanceViewStatus> array = new List<InstanceViewStatus>(); |
| 0 | 229 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 230 | | { |
| 0 | 231 | | if (item.ValueKind == JsonValueKind.Null) |
| | 232 | | { |
| 0 | 233 | | array.Add(null); |
| | 234 | | } |
| | 235 | | else |
| | 236 | | { |
| 0 | 237 | | array.Add(InstanceViewStatus.DeserializeInstanceViewStatus(item)); |
| | 238 | | } |
| | 239 | | } |
| 0 | 240 | | statuses = array; |
| | 241 | | continue; |
| | 242 | | } |
| | 243 | | } |
| | 244 | | continue; |
| | 245 | | } |
| | 246 | | } |
| 180 | 247 | | return new AvailabilitySet(id, name, type, location, tags, sku, platformUpdateDomainCount, platformFaultDoma |
| | 248 | | } |
| | 249 | | } |
| | 250 | | } |