Example #1
0
        internal static UpgradePolicy DeserializeUpgradePolicy(JsonElement element)
        {
            Optional <UpgradeMode>              mode = default;
            Optional <RollingUpgradePolicy>     rollingUpgradePolicy     = default;
            Optional <AutomaticOSUpgradePolicy> automaticOSUpgradePolicy = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("mode"))
                {
                    mode = property.Value.GetString().ToUpgradeMode();
                    continue;
                }
                if (property.NameEquals("rollingUpgradePolicy"))
                {
                    rollingUpgradePolicy = RollingUpgradePolicy.DeserializeRollingUpgradePolicy(property.Value);
                    continue;
                }
                if (property.NameEquals("automaticOSUpgradePolicy"))
                {
                    automaticOSUpgradePolicy = AutomaticOSUpgradePolicy.DeserializeAutomaticOSUpgradePolicy(property.Value);
                    continue;
                }
            }
            return(new UpgradePolicy(Optional.ToNullable(mode), rollingUpgradePolicy.Value, automaticOSUpgradePolicy.Value));
        }
        internal static UpgradePolicy DeserializeUpgradePolicy(JsonElement element)
        {
            UpgradeMode?             mode = default;
            RollingUpgradePolicy     rollingUpgradePolicy     = default;
            AutomaticOSUpgradePolicy automaticOSUpgradePolicy = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("mode"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    mode = property.Value.GetString().ToUpgradeMode();
                    continue;
                }
                if (property.NameEquals("rollingUpgradePolicy"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    rollingUpgradePolicy = RollingUpgradePolicy.DeserializeRollingUpgradePolicy(property.Value);
                    continue;
                }
                if (property.NameEquals("automaticOSUpgradePolicy"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    automaticOSUpgradePolicy = AutomaticOSUpgradePolicy.DeserializeAutomaticOSUpgradePolicy(property.Value);
                    continue;
                }
            }
            return(new UpgradePolicy(mode, rollingUpgradePolicy, automaticOSUpgradePolicy));
        }