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