| | 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.Text.Json; |
| | 9 | | using Azure.Core; |
| | 10 | |
|
| | 11 | | namespace Azure.ResourceManager.Compute.Models |
| | 12 | | { |
| | 13 | | public partial class UpgradePolicy : IUtf8JsonSerializable |
| | 14 | | { |
| | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 16 | | { |
| 364 | 17 | | writer.WriteStartObject(); |
| 364 | 18 | | if (Mode != null) |
| | 19 | | { |
| 364 | 20 | | writer.WritePropertyName("mode"); |
| 364 | 21 | | writer.WriteStringValue(Mode.Value.ToSerialString()); |
| | 22 | | } |
| 364 | 23 | | if (RollingUpgradePolicy != null) |
| | 24 | | { |
| 0 | 25 | | writer.WritePropertyName("rollingUpgradePolicy"); |
| 0 | 26 | | writer.WriteObjectValue(RollingUpgradePolicy); |
| | 27 | | } |
| 364 | 28 | | if (AutomaticOSUpgradePolicy != null) |
| | 29 | | { |
| 0 | 30 | | writer.WritePropertyName("automaticOSUpgradePolicy"); |
| 0 | 31 | | writer.WriteObjectValue(AutomaticOSUpgradePolicy); |
| | 32 | | } |
| 364 | 33 | | writer.WriteEndObject(); |
| 364 | 34 | | } |
| | 35 | |
|
| | 36 | | internal static UpgradePolicy DeserializeUpgradePolicy(JsonElement element) |
| | 37 | | { |
| 448 | 38 | | UpgradeMode? mode = default; |
| 448 | 39 | | RollingUpgradePolicy rollingUpgradePolicy = default; |
| 448 | 40 | | AutomaticOSUpgradePolicy automaticOSUpgradePolicy = default; |
| 1792 | 41 | | foreach (var property in element.EnumerateObject()) |
| | 42 | | { |
| 448 | 43 | | if (property.NameEquals("mode")) |
| | 44 | | { |
| 448 | 45 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 46 | | { |
| | 47 | | continue; |
| | 48 | | } |
| 448 | 49 | | mode = property.Value.GetString().ToUpgradeMode(); |
| 448 | 50 | | continue; |
| | 51 | | } |
| 0 | 52 | | if (property.NameEquals("rollingUpgradePolicy")) |
| | 53 | | { |
| 0 | 54 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 55 | | { |
| | 56 | | continue; |
| | 57 | | } |
| 0 | 58 | | rollingUpgradePolicy = RollingUpgradePolicy.DeserializeRollingUpgradePolicy(property.Value); |
| 0 | 59 | | continue; |
| | 60 | | } |
| 0 | 61 | | if (property.NameEquals("automaticOSUpgradePolicy")) |
| | 62 | | { |
| 0 | 63 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 64 | | { |
| | 65 | | continue; |
| | 66 | | } |
| 0 | 67 | | automaticOSUpgradePolicy = AutomaticOSUpgradePolicy.DeserializeAutomaticOSUpgradePolicy(property.Val |
| | 68 | | continue; |
| | 69 | | } |
| | 70 | | } |
| 448 | 71 | | return new UpgradePolicy(mode, rollingUpgradePolicy, automaticOSUpgradePolicy); |
| | 72 | | } |
| | 73 | | } |
| | 74 | | } |