// Code generated by azure-service-operator-codegen. DO NOT EDIT.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package compat

import (
	v20231001s "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20231001/storage"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
	"github.com/pkg/errors"
)

// Storage version of v1api20230202preview.ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS
type ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS struct {
	ControlledValues *string                `json:"controlledValues,omitempty"`
	Enabled          *bool                  `json:"enabled,omitempty"`
	PropertyBag      genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	UpdateMode       *string                `json:"updateMode,omitempty"`
}

// AssignProperties_From_ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS populates our ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS from the provided source ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS
func (autoscaler *ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS) AssignProperties_From_ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS(source *v20231001s.ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

	// ControlledValues
	if propertyBag.Contains("ControlledValues") {
		var controlledValue string
		err := propertyBag.Pull("ControlledValues", &controlledValue)
		if err != nil {
			return errors.Wrap(err, "pulling 'ControlledValues' from propertyBag")
		}

		autoscaler.ControlledValues = &controlledValue
	} else {
		autoscaler.ControlledValues = nil
	}

	// Enabled
	if source.Enabled != nil {
		enabled := *source.Enabled
		autoscaler.Enabled = &enabled
	} else {
		autoscaler.Enabled = nil
	}

	// UpdateMode
	if propertyBag.Contains("UpdateMode") {
		var updateMode string
		err := propertyBag.Pull("UpdateMode", &updateMode)
		if err != nil {
			return errors.Wrap(err, "pulling 'UpdateMode' from propertyBag")
		}

		autoscaler.UpdateMode = &updateMode
	} else {
		autoscaler.UpdateMode = nil
	}

	// Update the property bag
	if len(propertyBag) > 0 {
		autoscaler.PropertyBag = propertyBag
	} else {
		autoscaler.PropertyBag = nil
	}

	// Invoke the augmentConversionForManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS interface (if implemented) to customize the conversion
	var autoscalerAsAny any = autoscaler
	if augmentedAutoscaler, ok := autoscalerAsAny.(augmentConversionForManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS); ok {
		err := augmentedAutoscaler.AssignPropertiesFrom(source)
		if err != nil {
			return errors.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// No error
	return nil
}

// AssignProperties_To_ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS populates the provided destination ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS from our ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS
func (autoscaler *ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS) AssignProperties_To_ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS(destination *v20231001s.ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(autoscaler.PropertyBag)

	// ControlledValues
	if autoscaler.ControlledValues != nil {
		propertyBag.Add("ControlledValues", *autoscaler.ControlledValues)
	} else {
		propertyBag.Remove("ControlledValues")
	}

	// Enabled
	if autoscaler.Enabled != nil {
		enabled := *autoscaler.Enabled
		destination.Enabled = &enabled
	} else {
		destination.Enabled = nil
	}

	// UpdateMode
	if autoscaler.UpdateMode != nil {
		propertyBag.Add("UpdateMode", *autoscaler.UpdateMode)
	} else {
		propertyBag.Remove("UpdateMode")
	}

	// Update the property bag
	if len(propertyBag) > 0 {
		destination.PropertyBag = propertyBag
	} else {
		destination.PropertyBag = nil
	}

	// Invoke the augmentConversionForManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS interface (if implemented) to customize the conversion
	var autoscalerAsAny any = autoscaler
	if augmentedAutoscaler, ok := autoscalerAsAny.(augmentConversionForManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS); ok {
		err := augmentedAutoscaler.AssignPropertiesTo(destination)
		if err != nil {
			return errors.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

type augmentConversionForManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS interface {
	AssignPropertiesFrom(src *v20231001s.ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS) error
	AssignPropertiesTo(dst *v20231001s.ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler_STATUS) error
}
