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