| | 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 AutomaticRepairsPolicy : IUtf8JsonSerializable |
| | 14 | | { |
| | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 16 | | { |
| 32 | 17 | | writer.WriteStartObject(); |
| 32 | 18 | | if (Enabled != null) |
| | 19 | | { |
| 32 | 20 | | writer.WritePropertyName("enabled"); |
| 32 | 21 | | writer.WriteBooleanValue(Enabled.Value); |
| | 22 | | } |
| 32 | 23 | | if (GracePeriod != null) |
| | 24 | | { |
| 8 | 25 | | writer.WritePropertyName("gracePeriod"); |
| 8 | 26 | | writer.WriteStringValue(GracePeriod); |
| | 27 | | } |
| 32 | 28 | | writer.WriteEndObject(); |
| 32 | 29 | | } |
| | 30 | |
|
| | 31 | | internal static AutomaticRepairsPolicy DeserializeAutomaticRepairsPolicy(JsonElement element) |
| | 32 | | { |
| 40 | 33 | | bool? enabled = default; |
| 40 | 34 | | string gracePeriod = default; |
| 240 | 35 | | foreach (var property in element.EnumerateObject()) |
| | 36 | | { |
| 80 | 37 | | if (property.NameEquals("enabled")) |
| | 38 | | { |
| 40 | 39 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 40 | | { |
| | 41 | | continue; |
| | 42 | | } |
| 40 | 43 | | enabled = property.Value.GetBoolean(); |
| 40 | 44 | | continue; |
| | 45 | | } |
| 40 | 46 | | if (property.NameEquals("gracePeriod")) |
| | 47 | | { |
| 40 | 48 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 49 | | { |
| | 50 | | continue; |
| | 51 | | } |
| 40 | 52 | | gracePeriod = property.Value.GetString(); |
| | 53 | | continue; |
| | 54 | | } |
| | 55 | | } |
| 40 | 56 | | return new AutomaticRepairsPolicy(enabled, gracePeriod); |
| | 57 | | } |
| | 58 | | } |
| | 59 | | } |