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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/sql/v1api20211101/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/sql/v1api20211101/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,sql}
// +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: /sql/resource-manager/Microsoft.Sql/stable/2021-11-01/ServerVulnerabilityAssessments.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/default
type ServersVulnerabilityAssessment struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              ServersVulnerabilityAssessment_Spec   `json:"spec,omitempty"`
	Status            ServersVulnerabilityAssessment_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &ServersVulnerabilityAssessment{}

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

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

var _ conversion.Convertible = &ServersVulnerabilityAssessment{}

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

	return assessment.AssignProperties_From_ServersVulnerabilityAssessment(source)
}

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

	return assessment.AssignProperties_To_ServersVulnerabilityAssessment(destination)
}

var _ configmaps.Exporter = &ServersVulnerabilityAssessment{}

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

var _ secrets.Exporter = &ServersVulnerabilityAssessment{}

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

var _ genruntime.ImportableResource = &ServersVulnerabilityAssessment{}

// InitializeSpec initializes the spec for this resource from the given status
func (assessment *ServersVulnerabilityAssessment) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*ServersVulnerabilityAssessment_STATUS); ok {
		return assessment.Spec.Initialize_From_ServersVulnerabilityAssessment_STATUS(s)
	}

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

var _ genruntime.KubernetesResource = &ServersVulnerabilityAssessment{}

// AzureName returns the Azure name of the resource (always "default")
func (assessment *ServersVulnerabilityAssessment) AzureName() string {
	return "default"
}

// GetAPIVersion returns the ARM API version of the resource. This is always "2021-11-01"
func (assessment ServersVulnerabilityAssessment) GetAPIVersion() string {
	return "2021-11-01"
}

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Sql/servers/vulnerabilityAssessments"
func (assessment *ServersVulnerabilityAssessment) GetType() string {
	return "Microsoft.Sql/servers/vulnerabilityAssessments"
}

// NewEmptyStatus returns a new empty (blank) status
func (assessment *ServersVulnerabilityAssessment) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &ServersVulnerabilityAssessment_STATUS{}
}

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

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

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

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

	assessment.Status = st
	return nil
}

// AssignProperties_From_ServersVulnerabilityAssessment populates our ServersVulnerabilityAssessment from the provided source ServersVulnerabilityAssessment
func (assessment *ServersVulnerabilityAssessment) AssignProperties_From_ServersVulnerabilityAssessment(source *storage.ServersVulnerabilityAssessment) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_ServersVulnerabilityAssessment populates the provided destination ServersVulnerabilityAssessment from our ServersVulnerabilityAssessment
func (assessment *ServersVulnerabilityAssessment) AssignProperties_To_ServersVulnerabilityAssessment(destination *storage.ServersVulnerabilityAssessment) error {

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

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

	// Status
	var status storage.ServersVulnerabilityAssessment_STATUS
	err = assessment.Status.AssignProperties_To_ServersVulnerabilityAssessment_STATUS(&status)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_To_ServersVulnerabilityAssessment_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 (assessment *ServersVulnerabilityAssessment) OriginalGVK() *schema.GroupVersionKind {
	return &schema.GroupVersionKind{
		Group:   GroupVersion.Group,
		Version: assessment.Spec.OriginalVersion(),
		Kind:    "ServersVulnerabilityAssessment",
	}
}

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /sql/resource-manager/Microsoft.Sql/stable/2021-11-01/ServerVulnerabilityAssessments.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/default
type ServersVulnerabilityAssessmentList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []ServersVulnerabilityAssessment `json:"items"`
}

type ServersVulnerabilityAssessment_Spec struct {
	// OperatorSpec: The specification for configuring operator behavior. This field is interpreted by the operator and not
	// passed directly to Azure
	OperatorSpec *ServersVulnerabilityAssessmentOperatorSpec `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 sql.azure.com/Server resource
	Owner *genruntime.KnownResourceReference `group:"sql.azure.com" json:"owner,omitempty" kind:"Server"`

	// RecurringScans: The recurring scans settings
	RecurringScans *VulnerabilityAssessmentRecurringScansProperties `json:"recurringScans,omitempty"`

	// StorageAccountAccessKey: Specifies the identifier key of the storage account for vulnerability assessment scan results.
	// If 'StorageContainerSasKey' isn't specified, storageAccountAccessKey is required. Applies only if the storage account is
	// not behind a Vnet or a firewall
	StorageAccountAccessKey *genruntime.SecretReference `json:"storageAccountAccessKey,omitempty"`

	// StorageContainerPath: A blob storage container path to hold the scan results (e.g.
	// https://myStorage.blob.core.windows.net/VaScans/).
	StorageContainerPath *string `json:"storageContainerPath,omitempty" optionalConfigMapPair:"StorageContainerPath"`

	// StorageContainerPathFromConfig: A blob storage container path to hold the scan results (e.g.
	// https://myStorage.blob.core.windows.net/VaScans/).
	StorageContainerPathFromConfig *genruntime.ConfigMapReference `json:"storageContainerPathFromConfig,omitempty" optionalConfigMapPair:"StorageContainerPath"`

	// StorageContainerSasKey: A shared access signature (SAS Key) that has write access to the blob container specified in
	// 'storageContainerPath' parameter. If 'storageAccountAccessKey' isn't specified, StorageContainerSasKey is required.
	// Applies only if the storage account is not behind a Vnet or a firewall
	StorageContainerSasKey *genruntime.SecretReference `json:"storageContainerSasKey,omitempty"`
}

var _ genruntime.ARMTransformer = &ServersVulnerabilityAssessment_Spec{}

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

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

	// Set property "Properties":
	if assessment.RecurringScans != nil ||
		assessment.StorageAccountAccessKey != nil ||
		assessment.StorageContainerPath != nil ||
		assessment.StorageContainerPathFromConfig != nil ||
		assessment.StorageContainerSasKey != nil {
		result.Properties = &arm.ServerVulnerabilityAssessmentProperties{}
	}
	if assessment.RecurringScans != nil {
		recurringScans_ARM, err := assessment.RecurringScans.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		recurringScans := *recurringScans_ARM.(*arm.VulnerabilityAssessmentRecurringScansProperties)
		result.Properties.RecurringScans = &recurringScans
	}
	if assessment.StorageAccountAccessKey != nil {
		storageAccountAccessKeySecret, err := resolved.ResolvedSecrets.Lookup(*assessment.StorageAccountAccessKey)
		if err != nil {
			return nil, eris.Wrap(err, "looking up secret for property StorageAccountAccessKey")
		}
		storageAccountAccessKey := storageAccountAccessKeySecret
		result.Properties.StorageAccountAccessKey = &storageAccountAccessKey
	}
	if assessment.StorageContainerPath != nil {
		storageContainerPath := *assessment.StorageContainerPath
		result.Properties.StorageContainerPath = &storageContainerPath
	}
	if assessment.StorageContainerPathFromConfig != nil {
		storageContainerPathValue, err := resolved.ResolvedConfigMaps.Lookup(*assessment.StorageContainerPathFromConfig)
		if err != nil {
			return nil, eris.Wrap(err, "looking up configmap for property StorageContainerPath")
		}
		storageContainerPath := storageContainerPathValue
		result.Properties.StorageContainerPath = &storageContainerPath
	}
	if assessment.StorageContainerSasKey != nil {
		storageContainerSasKeySecret, err := resolved.ResolvedSecrets.Lookup(*assessment.StorageContainerSasKey)
		if err != nil {
			return nil, eris.Wrap(err, "looking up secret for property StorageContainerSasKey")
		}
		storageContainerSasKey := storageContainerSasKeySecret
		result.Properties.StorageContainerSasKey = &storageContainerSasKey
	}
	return result, nil
}

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

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

	// no assignment for property "OperatorSpec"

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

	// Set property "RecurringScans":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.RecurringScans != nil {
			var recurringScans1 VulnerabilityAssessmentRecurringScansProperties
			err := recurringScans1.PopulateFromARM(owner, *typedInput.Properties.RecurringScans)
			if err != nil {
				return err
			}
			recurringScans := recurringScans1
			assessment.RecurringScans = &recurringScans
		}
	}

	// no assignment for property "StorageAccountAccessKey"

	// Set property "StorageContainerPath":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.StorageContainerPath != nil {
			storageContainerPath := *typedInput.Properties.StorageContainerPath
			assessment.StorageContainerPath = &storageContainerPath
		}
	}

	// no assignment for property "StorageContainerPathFromConfig"

	// no assignment for property "StorageContainerSasKey"

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &ServersVulnerabilityAssessment_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.ServersVulnerabilityAssessment_Spec{}
	err := assessment.AssignProperties_To_ServersVulnerabilityAssessment_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_ServersVulnerabilityAssessment_Spec populates our ServersVulnerabilityAssessment_Spec from the provided source ServersVulnerabilityAssessment_Spec
func (assessment *ServersVulnerabilityAssessment_Spec) AssignProperties_From_ServersVulnerabilityAssessment_Spec(source *storage.ServersVulnerabilityAssessment_Spec) error {

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

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

	// RecurringScans
	if source.RecurringScans != nil {
		var recurringScan VulnerabilityAssessmentRecurringScansProperties
		err := recurringScan.AssignProperties_From_VulnerabilityAssessmentRecurringScansProperties(source.RecurringScans)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_VulnerabilityAssessmentRecurringScansProperties() to populate field RecurringScans")
		}
		assessment.RecurringScans = &recurringScan
	} else {
		assessment.RecurringScans = nil
	}

	// StorageAccountAccessKey
	if source.StorageAccountAccessKey != nil {
		storageAccountAccessKey := source.StorageAccountAccessKey.Copy()
		assessment.StorageAccountAccessKey = &storageAccountAccessKey
	} else {
		assessment.StorageAccountAccessKey = nil
	}

	// StorageContainerPath
	assessment.StorageContainerPath = genruntime.ClonePointerToString(source.StorageContainerPath)

	// StorageContainerPathFromConfig
	if source.StorageContainerPathFromConfig != nil {
		storageContainerPathFromConfig := source.StorageContainerPathFromConfig.Copy()
		assessment.StorageContainerPathFromConfig = &storageContainerPathFromConfig
	} else {
		assessment.StorageContainerPathFromConfig = nil
	}

	// StorageContainerSasKey
	if source.StorageContainerSasKey != nil {
		storageContainerSasKey := source.StorageContainerSasKey.Copy()
		assessment.StorageContainerSasKey = &storageContainerSasKey
	} else {
		assessment.StorageContainerSasKey = nil
	}

	// No error
	return nil
}

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

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

	// OriginalVersion
	destination.OriginalVersion = assessment.OriginalVersion()

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

	// RecurringScans
	if assessment.RecurringScans != nil {
		var recurringScan storage.VulnerabilityAssessmentRecurringScansProperties
		err := assessment.RecurringScans.AssignProperties_To_VulnerabilityAssessmentRecurringScansProperties(&recurringScan)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_VulnerabilityAssessmentRecurringScansProperties() to populate field RecurringScans")
		}
		destination.RecurringScans = &recurringScan
	} else {
		destination.RecurringScans = nil
	}

	// StorageAccountAccessKey
	if assessment.StorageAccountAccessKey != nil {
		storageAccountAccessKey := assessment.StorageAccountAccessKey.Copy()
		destination.StorageAccountAccessKey = &storageAccountAccessKey
	} else {
		destination.StorageAccountAccessKey = nil
	}

	// StorageContainerPath
	destination.StorageContainerPath = genruntime.ClonePointerToString(assessment.StorageContainerPath)

	// StorageContainerPathFromConfig
	if assessment.StorageContainerPathFromConfig != nil {
		storageContainerPathFromConfig := assessment.StorageContainerPathFromConfig.Copy()
		destination.StorageContainerPathFromConfig = &storageContainerPathFromConfig
	} else {
		destination.StorageContainerPathFromConfig = nil
	}

	// StorageContainerSasKey
	if assessment.StorageContainerSasKey != nil {
		storageContainerSasKey := assessment.StorageContainerSasKey.Copy()
		destination.StorageContainerSasKey = &storageContainerSasKey
	} else {
		destination.StorageContainerSasKey = nil
	}

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

	// No error
	return nil
}

// Initialize_From_ServersVulnerabilityAssessment_STATUS populates our ServersVulnerabilityAssessment_Spec from the provided source ServersVulnerabilityAssessment_STATUS
func (assessment *ServersVulnerabilityAssessment_Spec) Initialize_From_ServersVulnerabilityAssessment_STATUS(source *ServersVulnerabilityAssessment_STATUS) error {

	// RecurringScans
	if source.RecurringScans != nil {
		var recurringScan VulnerabilityAssessmentRecurringScansProperties
		err := recurringScan.Initialize_From_VulnerabilityAssessmentRecurringScansProperties_STATUS(source.RecurringScans)
		if err != nil {
			return eris.Wrap(err, "calling Initialize_From_VulnerabilityAssessmentRecurringScansProperties_STATUS() to populate field RecurringScans")
		}
		assessment.RecurringScans = &recurringScan
	} else {
		assessment.RecurringScans = nil
	}

	// StorageContainerPath
	assessment.StorageContainerPath = genruntime.ClonePointerToString(source.StorageContainerPath)

	// No error
	return nil
}

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

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

	// Id: Resource ID.
	Id *string `json:"id,omitempty"`

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

	// RecurringScans: The recurring scans settings
	RecurringScans *VulnerabilityAssessmentRecurringScansProperties_STATUS `json:"recurringScans,omitempty"`

	// StorageContainerPath: A blob storage container path to hold the scan results (e.g.
	// https://myStorage.blob.core.windows.net/VaScans/).
	StorageContainerPath *string `json:"storageContainerPath,omitempty"`

	// Type: Resource type.
	Type *string `json:"type,omitempty"`
}

var _ genruntime.ConvertibleStatus = &ServersVulnerabilityAssessment_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.ServersVulnerabilityAssessment_STATUS{}
	err := assessment.AssignProperties_To_ServersVulnerabilityAssessment_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 = &ServersVulnerabilityAssessment_STATUS{}

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

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

	// no assignment for property "Conditions"

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

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

	// Set property "RecurringScans":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.RecurringScans != nil {
			var recurringScans1 VulnerabilityAssessmentRecurringScansProperties_STATUS
			err := recurringScans1.PopulateFromARM(owner, *typedInput.Properties.RecurringScans)
			if err != nil {
				return err
			}
			recurringScans := recurringScans1
			assessment.RecurringScans = &recurringScans
		}
	}

	// Set property "StorageContainerPath":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.StorageContainerPath != nil {
			storageContainerPath := *typedInput.Properties.StorageContainerPath
			assessment.StorageContainerPath = &storageContainerPath
		}
	}

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

	// No error
	return nil
}

// AssignProperties_From_ServersVulnerabilityAssessment_STATUS populates our ServersVulnerabilityAssessment_STATUS from the provided source ServersVulnerabilityAssessment_STATUS
func (assessment *ServersVulnerabilityAssessment_STATUS) AssignProperties_From_ServersVulnerabilityAssessment_STATUS(source *storage.ServersVulnerabilityAssessment_STATUS) error {

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

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

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

	// RecurringScans
	if source.RecurringScans != nil {
		var recurringScan VulnerabilityAssessmentRecurringScansProperties_STATUS
		err := recurringScan.AssignProperties_From_VulnerabilityAssessmentRecurringScansProperties_STATUS(source.RecurringScans)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_VulnerabilityAssessmentRecurringScansProperties_STATUS() to populate field RecurringScans")
		}
		assessment.RecurringScans = &recurringScan
	} else {
		assessment.RecurringScans = nil
	}

	// StorageContainerPath
	assessment.StorageContainerPath = genruntime.ClonePointerToString(source.StorageContainerPath)

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

	// No error
	return nil
}

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

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

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

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

	// RecurringScans
	if assessment.RecurringScans != nil {
		var recurringScan storage.VulnerabilityAssessmentRecurringScansProperties_STATUS
		err := assessment.RecurringScans.AssignProperties_To_VulnerabilityAssessmentRecurringScansProperties_STATUS(&recurringScan)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_VulnerabilityAssessmentRecurringScansProperties_STATUS() to populate field RecurringScans")
		}
		destination.RecurringScans = &recurringScan
	} else {
		destination.RecurringScans = nil
	}

	// StorageContainerPath
	destination.StorageContainerPath = genruntime.ClonePointerToString(assessment.StorageContainerPath)

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

	// 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 ServersVulnerabilityAssessmentOperatorSpec 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_ServersVulnerabilityAssessmentOperatorSpec populates our ServersVulnerabilityAssessmentOperatorSpec from the provided source ServersVulnerabilityAssessmentOperatorSpec
func (operator *ServersVulnerabilityAssessmentOperatorSpec) AssignProperties_From_ServersVulnerabilityAssessmentOperatorSpec(source *storage.ServersVulnerabilityAssessmentOperatorSpec) 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_ServersVulnerabilityAssessmentOperatorSpec populates the provided destination ServersVulnerabilityAssessmentOperatorSpec from our ServersVulnerabilityAssessmentOperatorSpec
func (operator *ServersVulnerabilityAssessmentOperatorSpec) AssignProperties_To_ServersVulnerabilityAssessmentOperatorSpec(destination *storage.ServersVulnerabilityAssessmentOperatorSpec) 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(&ServersVulnerabilityAssessment{}, &ServersVulnerabilityAssessmentList{})
}
