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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/insights/v1api20171001/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/insights/v1api20171001/storage"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime/conditions"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime/configmaps"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime/core"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime/secrets"
	"github.com/rotisserie/eris"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime/schema"
	"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,insights}
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
// +kubebuilder:printcolumn:name="Severity",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].severity"
// +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].reason"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].message"
// Generator information:
// - Generated from: /applicationinsights/resource-manager/Microsoft.Insights/preview/2017-10-01/componentFeaturesAndPricing_API.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/pricingPlans/current
type PricingPlan struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              PricingPlan_Spec   `json:"spec,omitempty"`
	Status            PricingPlan_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &PricingPlan{}

// GetConditions returns the conditions of the resource
func (plan *PricingPlan) GetConditions() conditions.Conditions {
	return plan.Status.Conditions
}

// SetConditions sets the conditions on the resource status
func (plan *PricingPlan) SetConditions(conditions conditions.Conditions) {
	plan.Status.Conditions = conditions
}

var _ conversion.Convertible = &PricingPlan{}

// ConvertFrom populates our PricingPlan from the provided hub PricingPlan
func (plan *PricingPlan) ConvertFrom(hub conversion.Hub) error {
	source, ok := hub.(*storage.PricingPlan)
	if !ok {
		return fmt.Errorf("expected insights/v1api20171001/storage/PricingPlan but received %T instead", hub)
	}

	return plan.AssignProperties_From_PricingPlan(source)
}

// ConvertTo populates the provided hub PricingPlan from our PricingPlan
func (plan *PricingPlan) ConvertTo(hub conversion.Hub) error {
	destination, ok := hub.(*storage.PricingPlan)
	if !ok {
		return fmt.Errorf("expected insights/v1api20171001/storage/PricingPlan but received %T instead", hub)
	}

	return plan.AssignProperties_To_PricingPlan(destination)
}

var _ configmaps.Exporter = &PricingPlan{}

// ConfigMapDestinationExpressions returns the Spec.OperatorSpec.ConfigMapExpressions property
func (plan *PricingPlan) ConfigMapDestinationExpressions() []*core.DestinationExpression {
	if plan.Spec.OperatorSpec == nil {
		return nil
	}
	return plan.Spec.OperatorSpec.ConfigMapExpressions
}

var _ secrets.Exporter = &PricingPlan{}

// SecretDestinationExpressions returns the Spec.OperatorSpec.SecretExpressions property
func (plan *PricingPlan) SecretDestinationExpressions() []*core.DestinationExpression {
	if plan.Spec.OperatorSpec == nil {
		return nil
	}
	return plan.Spec.OperatorSpec.SecretExpressions
}

var _ genruntime.ImportableResource = &PricingPlan{}

// InitializeSpec initializes the spec for this resource from the given status
func (plan *PricingPlan) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*PricingPlan_STATUS); ok {
		return plan.Spec.Initialize_From_PricingPlan_STATUS(s)
	}

	return fmt.Errorf("expected Status of type PricingPlan_STATUS but received %T instead", status)
}

var _ genruntime.KubernetesResource = &PricingPlan{}

// AzureName returns the Azure name of the resource (always "current")
func (plan *PricingPlan) AzureName() string {
	return "current"
}

// GetAPIVersion returns the ARM API version of the resource. This is always "2017-10-01"
func (plan PricingPlan) GetAPIVersion() string {
	return "2017-10-01"
}

// GetResourceScope returns the scope of the resource
func (plan *PricingPlan) GetResourceScope() genruntime.ResourceScope {
	return genruntime.ResourceScopeResourceGroup
}

// GetSpec returns the specification of this resource
func (plan *PricingPlan) GetSpec() genruntime.ConvertibleSpec {
	return &plan.Spec
}

// GetStatus returns the status of this resource
func (plan *PricingPlan) GetStatus() genruntime.ConvertibleStatus {
	return &plan.Status
}

// GetSupportedOperations returns the operations supported by the resource
func (plan *PricingPlan) GetSupportedOperations() []genruntime.ResourceOperation {
	return []genruntime.ResourceOperation{
		genruntime.ResourceOperationGet,
		genruntime.ResourceOperationPut,
	}
}

// GetType returns the ARM Type of the resource. This is always "microsoft.insights/components/pricingPlans"
func (plan *PricingPlan) GetType() string {
	return "microsoft.insights/components/pricingPlans"
}

// NewEmptyStatus returns a new empty (blank) status
func (plan *PricingPlan) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &PricingPlan_STATUS{}
}

// Owner returns the ResourceReference of the owner
func (plan *PricingPlan) Owner() *genruntime.ResourceReference {
	if plan.Spec.Owner == nil {
		return nil
	}

	group, kind := genruntime.LookupOwnerGroupKind(plan.Spec)
	return plan.Spec.Owner.AsResourceReference(group, kind)
}

// SetStatus sets the status of this resource
func (plan *PricingPlan) SetStatus(status genruntime.ConvertibleStatus) error {
	// If we have exactly the right type of status, assign it
	if st, ok := status.(*PricingPlan_STATUS); ok {
		plan.Status = *st
		return nil
	}

	// Convert status to required version
	var st PricingPlan_STATUS
	err := status.ConvertStatusTo(&st)
	if err != nil {
		return eris.Wrap(err, "failed to convert status")
	}

	plan.Status = st
	return nil
}

// AssignProperties_From_PricingPlan populates our PricingPlan from the provided source PricingPlan
func (plan *PricingPlan) AssignProperties_From_PricingPlan(source *storage.PricingPlan) error {

	// ObjectMeta
	plan.ObjectMeta = *source.ObjectMeta.DeepCopy()

	// Spec
	var spec PricingPlan_Spec
	err := spec.AssignProperties_From_PricingPlan_Spec(&source.Spec)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_From_PricingPlan_Spec() to populate field Spec")
	}
	plan.Spec = spec

	// Status
	var status PricingPlan_STATUS
	err = status.AssignProperties_From_PricingPlan_STATUS(&source.Status)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_From_PricingPlan_STATUS() to populate field Status")
	}
	plan.Status = status

	// No error
	return nil
}

// AssignProperties_To_PricingPlan populates the provided destination PricingPlan from our PricingPlan
func (plan *PricingPlan) AssignProperties_To_PricingPlan(destination *storage.PricingPlan) error {

	// ObjectMeta
	destination.ObjectMeta = *plan.ObjectMeta.DeepCopy()

	// Spec
	var spec storage.PricingPlan_Spec
	err := plan.Spec.AssignProperties_To_PricingPlan_Spec(&spec)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_To_PricingPlan_Spec() to populate field Spec")
	}
	destination.Spec = spec

	// Status
	var status storage.PricingPlan_STATUS
	err = plan.Status.AssignProperties_To_PricingPlan_STATUS(&status)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_To_PricingPlan_STATUS() to populate field Status")
	}
	destination.Status = status

	// No error
	return nil
}

// OriginalGVK returns a GroupValueKind for the original API version used to create the resource
func (plan *PricingPlan) OriginalGVK() *schema.GroupVersionKind {
	return &schema.GroupVersionKind{
		Group:   GroupVersion.Group,
		Version: plan.Spec.OriginalVersion(),
		Kind:    "PricingPlan",
	}
}

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /applicationinsights/resource-manager/Microsoft.Insights/preview/2017-10-01/componentFeaturesAndPricing_API.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/pricingPlans/current
type PricingPlanList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []PricingPlan `json:"items"`
}

// +kubebuilder:validation:Enum={"2017-10-01"}
type APIVersion string

const APIVersion_Value = APIVersion("2017-10-01")

type PricingPlan_Spec struct {
	// Cap: Daily data volume cap in GB.
	Cap *float64 `json:"cap,omitempty"`

	// OperatorSpec: The specification for configuring operator behavior. This field is interpreted by the operator and not
	// passed directly to Azure
	OperatorSpec *PricingPlanOperatorSpec `json:"operatorSpec,omitempty"`

	// +kubebuilder:validation:Required
	// Owner: The owner of the resource. The owner controls where the resource goes when it is deployed. The owner also
	// controls the resources lifecycle. When the owner is deleted the resource will also be deleted. Owner is expected to be a
	// reference to a insights.azure.com/Component resource
	Owner *genruntime.KnownResourceReference `group:"insights.azure.com" json:"owner,omitempty" kind:"Component"`

	// PlanType: Pricing Plan Type Name.
	PlanType *string `json:"planType,omitempty"`

	// StopSendNotificationWhenHitCap: Do not send a notification email when the daily data volume cap is met.
	StopSendNotificationWhenHitCap *bool `json:"stopSendNotificationWhenHitCap,omitempty"`

	// StopSendNotificationWhenHitThreshold: Reserved, not used for now.
	StopSendNotificationWhenHitThreshold *bool `json:"stopSendNotificationWhenHitThreshold,omitempty"`

	// WarningThreshold: Reserved, not used for now.
	WarningThreshold *int `json:"warningThreshold,omitempty"`
}

var _ genruntime.ARMTransformer = &PricingPlan_Spec{}

// ConvertToARM converts from a Kubernetes CRD object to an ARM object
func (plan *PricingPlan_Spec) ConvertToARM(resolved genruntime.ConvertToARMResolvedDetails) (interface{}, error) {
	if plan == nil {
		return nil, nil
	}
	result := &arm.PricingPlan_Spec{}

	// Set property "Name":
	result.Name = resolved.Name

	// Set property "Properties":
	if plan.Cap != nil ||
		plan.PlanType != nil ||
		plan.StopSendNotificationWhenHitCap != nil ||
		plan.StopSendNotificationWhenHitThreshold != nil ||
		plan.WarningThreshold != nil {
		result.Properties = &arm.PricingPlanProperties{}
	}
	if plan.Cap != nil {
		cap := *plan.Cap
		result.Properties.Cap = &cap
	}
	if plan.PlanType != nil {
		planType := *plan.PlanType
		result.Properties.PlanType = &planType
	}
	if plan.StopSendNotificationWhenHitCap != nil {
		stopSendNotificationWhenHitCap := *plan.StopSendNotificationWhenHitCap
		result.Properties.StopSendNotificationWhenHitCap = &stopSendNotificationWhenHitCap
	}
	if plan.StopSendNotificationWhenHitThreshold != nil {
		stopSendNotificationWhenHitThreshold := *plan.StopSendNotificationWhenHitThreshold
		result.Properties.StopSendNotificationWhenHitThreshold = &stopSendNotificationWhenHitThreshold
	}
	if plan.WarningThreshold != nil {
		warningThreshold := *plan.WarningThreshold
		result.Properties.WarningThreshold = &warningThreshold
	}
	return result, nil
}

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (plan *PricingPlan_Spec) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &arm.PricingPlan_Spec{}
}

// PopulateFromARM populates a Kubernetes CRD object from an Azure ARM object
func (plan *PricingPlan_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, armInput interface{}) error {
	typedInput, ok := armInput.(arm.PricingPlan_Spec)
	if !ok {
		return fmt.Errorf("unexpected type supplied for PopulateFromARM() function. Expected arm.PricingPlan_Spec, got %T", armInput)
	}

	// Set property "Cap":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Cap != nil {
			cap := *typedInput.Properties.Cap
			plan.Cap = &cap
		}
	}

	// no assignment for property "OperatorSpec"

	// Set property "Owner":
	plan.Owner = &genruntime.KnownResourceReference{
		Name:  owner.Name,
		ARMID: owner.ARMID,
	}

	// Set property "PlanType":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.PlanType != nil {
			planType := *typedInput.Properties.PlanType
			plan.PlanType = &planType
		}
	}

	// Set property "StopSendNotificationWhenHitCap":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.StopSendNotificationWhenHitCap != nil {
			stopSendNotificationWhenHitCap := *typedInput.Properties.StopSendNotificationWhenHitCap
			plan.StopSendNotificationWhenHitCap = &stopSendNotificationWhenHitCap
		}
	}

	// Set property "StopSendNotificationWhenHitThreshold":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.StopSendNotificationWhenHitThreshold != nil {
			stopSendNotificationWhenHitThreshold := *typedInput.Properties.StopSendNotificationWhenHitThreshold
			plan.StopSendNotificationWhenHitThreshold = &stopSendNotificationWhenHitThreshold
		}
	}

	// Set property "WarningThreshold":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.WarningThreshold != nil {
			warningThreshold := *typedInput.Properties.WarningThreshold
			plan.WarningThreshold = &warningThreshold
		}
	}

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &PricingPlan_Spec{}

// ConvertSpecFrom populates our PricingPlan_Spec from the provided source
func (plan *PricingPlan_Spec) ConvertSpecFrom(source genruntime.ConvertibleSpec) error {
	src, ok := source.(*storage.PricingPlan_Spec)
	if ok {
		// Populate our instance from source
		return plan.AssignProperties_From_PricingPlan_Spec(src)
	}

	// Convert to an intermediate form
	src = &storage.PricingPlan_Spec{}
	err := src.ConvertSpecFrom(source)
	if err != nil {
		return eris.Wrap(err, "initial step of conversion in ConvertSpecFrom()")
	}

	// Update our instance from src
	err = plan.AssignProperties_From_PricingPlan_Spec(src)
	if err != nil {
		return eris.Wrap(err, "final step of conversion in ConvertSpecFrom()")
	}

	return nil
}

// ConvertSpecTo populates the provided destination from our PricingPlan_Spec
func (plan *PricingPlan_Spec) ConvertSpecTo(destination genruntime.ConvertibleSpec) error {
	dst, ok := destination.(*storage.PricingPlan_Spec)
	if ok {
		// Populate destination from our instance
		return plan.AssignProperties_To_PricingPlan_Spec(dst)
	}

	// Convert to an intermediate form
	dst = &storage.PricingPlan_Spec{}
	err := plan.AssignProperties_To_PricingPlan_Spec(dst)
	if err != nil {
		return eris.Wrap(err, "initial step of conversion in ConvertSpecTo()")
	}

	// Update dst from our instance
	err = dst.ConvertSpecTo(destination)
	if err != nil {
		return eris.Wrap(err, "final step of conversion in ConvertSpecTo()")
	}

	return nil
}

// AssignProperties_From_PricingPlan_Spec populates our PricingPlan_Spec from the provided source PricingPlan_Spec
func (plan *PricingPlan_Spec) AssignProperties_From_PricingPlan_Spec(source *storage.PricingPlan_Spec) error {

	// Cap
	if source.Cap != nil {
		cap := *source.Cap
		plan.Cap = &cap
	} else {
		plan.Cap = nil
	}

	// OperatorSpec
	if source.OperatorSpec != nil {
		var operatorSpec PricingPlanOperatorSpec
		err := operatorSpec.AssignProperties_From_PricingPlanOperatorSpec(source.OperatorSpec)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_PricingPlanOperatorSpec() to populate field OperatorSpec")
		}
		plan.OperatorSpec = &operatorSpec
	} else {
		plan.OperatorSpec = nil
	}

	// Owner
	if source.Owner != nil {
		owner := source.Owner.Copy()
		plan.Owner = &owner
	} else {
		plan.Owner = nil
	}

	// PlanType
	plan.PlanType = genruntime.ClonePointerToString(source.PlanType)

	// StopSendNotificationWhenHitCap
	if source.StopSendNotificationWhenHitCap != nil {
		stopSendNotificationWhenHitCap := *source.StopSendNotificationWhenHitCap
		plan.StopSendNotificationWhenHitCap = &stopSendNotificationWhenHitCap
	} else {
		plan.StopSendNotificationWhenHitCap = nil
	}

	// StopSendNotificationWhenHitThreshold
	if source.StopSendNotificationWhenHitThreshold != nil {
		stopSendNotificationWhenHitThreshold := *source.StopSendNotificationWhenHitThreshold
		plan.StopSendNotificationWhenHitThreshold = &stopSendNotificationWhenHitThreshold
	} else {
		plan.StopSendNotificationWhenHitThreshold = nil
	}

	// WarningThreshold
	plan.WarningThreshold = genruntime.ClonePointerToInt(source.WarningThreshold)

	// No error
	return nil
}

// AssignProperties_To_PricingPlan_Spec populates the provided destination PricingPlan_Spec from our PricingPlan_Spec
func (plan *PricingPlan_Spec) AssignProperties_To_PricingPlan_Spec(destination *storage.PricingPlan_Spec) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// Cap
	if plan.Cap != nil {
		cap := *plan.Cap
		destination.Cap = &cap
	} else {
		destination.Cap = nil
	}

	// OperatorSpec
	if plan.OperatorSpec != nil {
		var operatorSpec storage.PricingPlanOperatorSpec
		err := plan.OperatorSpec.AssignProperties_To_PricingPlanOperatorSpec(&operatorSpec)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_PricingPlanOperatorSpec() to populate field OperatorSpec")
		}
		destination.OperatorSpec = &operatorSpec
	} else {
		destination.OperatorSpec = nil
	}

	// OriginalVersion
	destination.OriginalVersion = plan.OriginalVersion()

	// Owner
	if plan.Owner != nil {
		owner := plan.Owner.Copy()
		destination.Owner = &owner
	} else {
		destination.Owner = nil
	}

	// PlanType
	destination.PlanType = genruntime.ClonePointerToString(plan.PlanType)

	// StopSendNotificationWhenHitCap
	if plan.StopSendNotificationWhenHitCap != nil {
		stopSendNotificationWhenHitCap := *plan.StopSendNotificationWhenHitCap
		destination.StopSendNotificationWhenHitCap = &stopSendNotificationWhenHitCap
	} else {
		destination.StopSendNotificationWhenHitCap = nil
	}

	// StopSendNotificationWhenHitThreshold
	if plan.StopSendNotificationWhenHitThreshold != nil {
		stopSendNotificationWhenHitThreshold := *plan.StopSendNotificationWhenHitThreshold
		destination.StopSendNotificationWhenHitThreshold = &stopSendNotificationWhenHitThreshold
	} else {
		destination.StopSendNotificationWhenHitThreshold = nil
	}

	// WarningThreshold
	destination.WarningThreshold = genruntime.ClonePointerToInt(plan.WarningThreshold)

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

	// No error
	return nil
}

// Initialize_From_PricingPlan_STATUS populates our PricingPlan_Spec from the provided source PricingPlan_STATUS
func (plan *PricingPlan_Spec) Initialize_From_PricingPlan_STATUS(source *PricingPlan_STATUS) error {

	// Cap
	if source.Cap != nil {
		cap := *source.Cap
		plan.Cap = &cap
	} else {
		plan.Cap = nil
	}

	// PlanType
	plan.PlanType = genruntime.ClonePointerToString(source.PlanType)

	// StopSendNotificationWhenHitCap
	if source.StopSendNotificationWhenHitCap != nil {
		stopSendNotificationWhenHitCap := *source.StopSendNotificationWhenHitCap
		plan.StopSendNotificationWhenHitCap = &stopSendNotificationWhenHitCap
	} else {
		plan.StopSendNotificationWhenHitCap = nil
	}

	// StopSendNotificationWhenHitThreshold
	if source.StopSendNotificationWhenHitThreshold != nil {
		stopSendNotificationWhenHitThreshold := *source.StopSendNotificationWhenHitThreshold
		plan.StopSendNotificationWhenHitThreshold = &stopSendNotificationWhenHitThreshold
	} else {
		plan.StopSendNotificationWhenHitThreshold = nil
	}

	// WarningThreshold
	plan.WarningThreshold = genruntime.ClonePointerToInt(source.WarningThreshold)

	// No error
	return nil
}

// OriginalVersion returns the original API version used to create the resource.
func (plan *PricingPlan_Spec) OriginalVersion() string {
	return GroupVersion.Version
}

type PricingPlan_STATUS struct {
	// Cap: Daily data volume cap in GB.
	Cap *float64 `json:"cap,omitempty"`

	// Conditions: The observed state of the resource
	Conditions []conditions.Condition `json:"conditions,omitempty"`

	// Id: Azure resource Id.
	Id *string `json:"id,omitempty"`

	// MaxHistoryCap: Maximum daily data volume cap that the user can set for this component.
	MaxHistoryCap *float64 `json:"maxHistoryCap,omitempty"`

	// Name: Azure resource name.
	Name *string `json:"name,omitempty"`

	// PlanType: Pricing Plan Type Name.
	PlanType *string `json:"planType,omitempty"`

	// ResetHour: Daily data volume cap UTC reset hour.
	ResetHour *int `json:"resetHour,omitempty"`

	// StopSendNotificationWhenHitCap: Do not send a notification email when the daily data volume cap is met.
	StopSendNotificationWhenHitCap *bool `json:"stopSendNotificationWhenHitCap,omitempty"`

	// StopSendNotificationWhenHitThreshold: Reserved, not used for now.
	StopSendNotificationWhenHitThreshold *bool `json:"stopSendNotificationWhenHitThreshold,omitempty"`

	// Type: Azure resource type.
	Type *string `json:"type,omitempty"`

	// WarningThreshold: Reserved, not used for now.
	WarningThreshold *int `json:"warningThreshold,omitempty"`
}

var _ genruntime.ConvertibleStatus = &PricingPlan_STATUS{}

// ConvertStatusFrom populates our PricingPlan_STATUS from the provided source
func (plan *PricingPlan_STATUS) ConvertStatusFrom(source genruntime.ConvertibleStatus) error {
	src, ok := source.(*storage.PricingPlan_STATUS)
	if ok {
		// Populate our instance from source
		return plan.AssignProperties_From_PricingPlan_STATUS(src)
	}

	// Convert to an intermediate form
	src = &storage.PricingPlan_STATUS{}
	err := src.ConvertStatusFrom(source)
	if err != nil {
		return eris.Wrap(err, "initial step of conversion in ConvertStatusFrom()")
	}

	// Update our instance from src
	err = plan.AssignProperties_From_PricingPlan_STATUS(src)
	if err != nil {
		return eris.Wrap(err, "final step of conversion in ConvertStatusFrom()")
	}

	return nil
}

// ConvertStatusTo populates the provided destination from our PricingPlan_STATUS
func (plan *PricingPlan_STATUS) ConvertStatusTo(destination genruntime.ConvertibleStatus) error {
	dst, ok := destination.(*storage.PricingPlan_STATUS)
	if ok {
		// Populate destination from our instance
		return plan.AssignProperties_To_PricingPlan_STATUS(dst)
	}

	// Convert to an intermediate form
	dst = &storage.PricingPlan_STATUS{}
	err := plan.AssignProperties_To_PricingPlan_STATUS(dst)
	if err != nil {
		return eris.Wrap(err, "initial step of conversion in ConvertStatusTo()")
	}

	// Update dst from our instance
	err = dst.ConvertStatusTo(destination)
	if err != nil {
		return eris.Wrap(err, "final step of conversion in ConvertStatusTo()")
	}

	return nil
}

var _ genruntime.FromARMConverter = &PricingPlan_STATUS{}

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (plan *PricingPlan_STATUS) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &arm.PricingPlan_STATUS{}
}

// PopulateFromARM populates a Kubernetes CRD object from an Azure ARM object
func (plan *PricingPlan_STATUS) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, armInput interface{}) error {
	typedInput, ok := armInput.(arm.PricingPlan_STATUS)
	if !ok {
		return fmt.Errorf("unexpected type supplied for PopulateFromARM() function. Expected arm.PricingPlan_STATUS, got %T", armInput)
	}

	// Set property "Cap":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Cap != nil {
			cap := *typedInput.Properties.Cap
			plan.Cap = &cap
		}
	}

	// no assignment for property "Conditions"

	// Set property "Id":
	if typedInput.Id != nil {
		id := *typedInput.Id
		plan.Id = &id
	}

	// Set property "MaxHistoryCap":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.MaxHistoryCap != nil {
			maxHistoryCap := *typedInput.Properties.MaxHistoryCap
			plan.MaxHistoryCap = &maxHistoryCap
		}
	}

	// Set property "Name":
	if typedInput.Name != nil {
		name := *typedInput.Name
		plan.Name = &name
	}

	// Set property "PlanType":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.PlanType != nil {
			planType := *typedInput.Properties.PlanType
			plan.PlanType = &planType
		}
	}

	// Set property "ResetHour":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ResetHour != nil {
			resetHour := *typedInput.Properties.ResetHour
			plan.ResetHour = &resetHour
		}
	}

	// Set property "StopSendNotificationWhenHitCap":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.StopSendNotificationWhenHitCap != nil {
			stopSendNotificationWhenHitCap := *typedInput.Properties.StopSendNotificationWhenHitCap
			plan.StopSendNotificationWhenHitCap = &stopSendNotificationWhenHitCap
		}
	}

	// Set property "StopSendNotificationWhenHitThreshold":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.StopSendNotificationWhenHitThreshold != nil {
			stopSendNotificationWhenHitThreshold := *typedInput.Properties.StopSendNotificationWhenHitThreshold
			plan.StopSendNotificationWhenHitThreshold = &stopSendNotificationWhenHitThreshold
		}
	}

	// Set property "Type":
	if typedInput.Type != nil {
		typeVar := *typedInput.Type
		plan.Type = &typeVar
	}

	// Set property "WarningThreshold":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.WarningThreshold != nil {
			warningThreshold := *typedInput.Properties.WarningThreshold
			plan.WarningThreshold = &warningThreshold
		}
	}

	// No error
	return nil
}

// AssignProperties_From_PricingPlan_STATUS populates our PricingPlan_STATUS from the provided source PricingPlan_STATUS
func (plan *PricingPlan_STATUS) AssignProperties_From_PricingPlan_STATUS(source *storage.PricingPlan_STATUS) error {

	// Cap
	if source.Cap != nil {
		cap := *source.Cap
		plan.Cap = &cap
	} else {
		plan.Cap = nil
	}

	// Conditions
	plan.Conditions = genruntime.CloneSliceOfCondition(source.Conditions)

	// Id
	plan.Id = genruntime.ClonePointerToString(source.Id)

	// MaxHistoryCap
	if source.MaxHistoryCap != nil {
		maxHistoryCap := *source.MaxHistoryCap
		plan.MaxHistoryCap = &maxHistoryCap
	} else {
		plan.MaxHistoryCap = nil
	}

	// Name
	plan.Name = genruntime.ClonePointerToString(source.Name)

	// PlanType
	plan.PlanType = genruntime.ClonePointerToString(source.PlanType)

	// ResetHour
	plan.ResetHour = genruntime.ClonePointerToInt(source.ResetHour)

	// StopSendNotificationWhenHitCap
	if source.StopSendNotificationWhenHitCap != nil {
		stopSendNotificationWhenHitCap := *source.StopSendNotificationWhenHitCap
		plan.StopSendNotificationWhenHitCap = &stopSendNotificationWhenHitCap
	} else {
		plan.StopSendNotificationWhenHitCap = nil
	}

	// StopSendNotificationWhenHitThreshold
	if source.StopSendNotificationWhenHitThreshold != nil {
		stopSendNotificationWhenHitThreshold := *source.StopSendNotificationWhenHitThreshold
		plan.StopSendNotificationWhenHitThreshold = &stopSendNotificationWhenHitThreshold
	} else {
		plan.StopSendNotificationWhenHitThreshold = nil
	}

	// Type
	plan.Type = genruntime.ClonePointerToString(source.Type)

	// WarningThreshold
	plan.WarningThreshold = genruntime.ClonePointerToInt(source.WarningThreshold)

	// No error
	return nil
}

// AssignProperties_To_PricingPlan_STATUS populates the provided destination PricingPlan_STATUS from our PricingPlan_STATUS
func (plan *PricingPlan_STATUS) AssignProperties_To_PricingPlan_STATUS(destination *storage.PricingPlan_STATUS) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// Cap
	if plan.Cap != nil {
		cap := *plan.Cap
		destination.Cap = &cap
	} else {
		destination.Cap = nil
	}

	// Conditions
	destination.Conditions = genruntime.CloneSliceOfCondition(plan.Conditions)

	// Id
	destination.Id = genruntime.ClonePointerToString(plan.Id)

	// MaxHistoryCap
	if plan.MaxHistoryCap != nil {
		maxHistoryCap := *plan.MaxHistoryCap
		destination.MaxHistoryCap = &maxHistoryCap
	} else {
		destination.MaxHistoryCap = nil
	}

	// Name
	destination.Name = genruntime.ClonePointerToString(plan.Name)

	// PlanType
	destination.PlanType = genruntime.ClonePointerToString(plan.PlanType)

	// ResetHour
	destination.ResetHour = genruntime.ClonePointerToInt(plan.ResetHour)

	// StopSendNotificationWhenHitCap
	if plan.StopSendNotificationWhenHitCap != nil {
		stopSendNotificationWhenHitCap := *plan.StopSendNotificationWhenHitCap
		destination.StopSendNotificationWhenHitCap = &stopSendNotificationWhenHitCap
	} else {
		destination.StopSendNotificationWhenHitCap = nil
	}

	// StopSendNotificationWhenHitThreshold
	if plan.StopSendNotificationWhenHitThreshold != nil {
		stopSendNotificationWhenHitThreshold := *plan.StopSendNotificationWhenHitThreshold
		destination.StopSendNotificationWhenHitThreshold = &stopSendNotificationWhenHitThreshold
	} else {
		destination.StopSendNotificationWhenHitThreshold = nil
	}

	// Type
	destination.Type = genruntime.ClonePointerToString(plan.Type)

	// WarningThreshold
	destination.WarningThreshold = genruntime.ClonePointerToInt(plan.WarningThreshold)

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

	// No error
	return nil
}

// Details for configuring operator behavior. Fields in this struct are interpreted by the operator directly rather than being passed to Azure
type PricingPlanOperatorSpec struct {
	// ConfigMapExpressions: configures where to place operator written dynamic ConfigMaps (created with CEL expressions).
	ConfigMapExpressions []*core.DestinationExpression `json:"configMapExpressions,omitempty"`

	// SecretExpressions: configures where to place operator written dynamic secrets (created with CEL expressions).
	SecretExpressions []*core.DestinationExpression `json:"secretExpressions,omitempty"`
}

// AssignProperties_From_PricingPlanOperatorSpec populates our PricingPlanOperatorSpec from the provided source PricingPlanOperatorSpec
func (operator *PricingPlanOperatorSpec) AssignProperties_From_PricingPlanOperatorSpec(source *storage.PricingPlanOperatorSpec) error {

	// ConfigMapExpressions
	if source.ConfigMapExpressions != nil {
		configMapExpressionList := make([]*core.DestinationExpression, len(source.ConfigMapExpressions))
		for configMapExpressionIndex, configMapExpressionItem := range source.ConfigMapExpressions {
			if configMapExpressionItem != nil {
				configMapExpression := *configMapExpressionItem.DeepCopy()
				configMapExpressionList[configMapExpressionIndex] = &configMapExpression
			} else {
				configMapExpressionList[configMapExpressionIndex] = nil
			}
		}
		operator.ConfigMapExpressions = configMapExpressionList
	} else {
		operator.ConfigMapExpressions = nil
	}

	// SecretExpressions
	if source.SecretExpressions != nil {
		secretExpressionList := make([]*core.DestinationExpression, len(source.SecretExpressions))
		for secretExpressionIndex, secretExpressionItem := range source.SecretExpressions {
			if secretExpressionItem != nil {
				secretExpression := *secretExpressionItem.DeepCopy()
				secretExpressionList[secretExpressionIndex] = &secretExpression
			} else {
				secretExpressionList[secretExpressionIndex] = nil
			}
		}
		operator.SecretExpressions = secretExpressionList
	} else {
		operator.SecretExpressions = nil
	}

	// No error
	return nil
}

// AssignProperties_To_PricingPlanOperatorSpec populates the provided destination PricingPlanOperatorSpec from our PricingPlanOperatorSpec
func (operator *PricingPlanOperatorSpec) AssignProperties_To_PricingPlanOperatorSpec(destination *storage.PricingPlanOperatorSpec) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// ConfigMapExpressions
	if operator.ConfigMapExpressions != nil {
		configMapExpressionList := make([]*core.DestinationExpression, len(operator.ConfigMapExpressions))
		for configMapExpressionIndex, configMapExpressionItem := range operator.ConfigMapExpressions {
			if configMapExpressionItem != nil {
				configMapExpression := *configMapExpressionItem.DeepCopy()
				configMapExpressionList[configMapExpressionIndex] = &configMapExpression
			} else {
				configMapExpressionList[configMapExpressionIndex] = nil
			}
		}
		destination.ConfigMapExpressions = configMapExpressionList
	} else {
		destination.ConfigMapExpressions = nil
	}

	// SecretExpressions
	if operator.SecretExpressions != nil {
		secretExpressionList := make([]*core.DestinationExpression, len(operator.SecretExpressions))
		for secretExpressionIndex, secretExpressionItem := range operator.SecretExpressions {
			if secretExpressionItem != nil {
				secretExpression := *secretExpressionItem.DeepCopy()
				secretExpressionList[secretExpressionIndex] = &secretExpression
			} else {
				secretExpressionList[secretExpressionIndex] = nil
			}
		}
		destination.SecretExpressions = secretExpressionList
	} else {
		destination.SecretExpressions = nil
	}

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

	// No error
	return nil
}

func init() {
	SchemeBuilder.Register(&PricingPlan{}, &PricingPlanList{})
}
