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

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/insights/v1api20210501preview/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/insights/v1api20210501preview/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: /monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/diagnosticsSettings_API.json
// - ARM URI: /{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}
type DiagnosticSetting struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              DiagnosticSetting_Spec   `json:"spec,omitempty"`
	Status            DiagnosticSetting_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &DiagnosticSetting{}

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

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

var _ conversion.Convertible = &DiagnosticSetting{}

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

	return setting.AssignProperties_From_DiagnosticSetting(source)
}

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

	return setting.AssignProperties_To_DiagnosticSetting(destination)
}

var _ configmaps.Exporter = &DiagnosticSetting{}

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

var _ secrets.Exporter = &DiagnosticSetting{}

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

var _ genruntime.ImportableResource = &DiagnosticSetting{}

// InitializeSpec initializes the spec for this resource from the given status
func (setting *DiagnosticSetting) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*DiagnosticSetting_STATUS); ok {
		return setting.Spec.Initialize_From_DiagnosticSetting_STATUS(s)
	}

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

var _ genruntime.KubernetesResource = &DiagnosticSetting{}

// AzureName returns the Azure name of the resource
func (setting *DiagnosticSetting) AzureName() string {
	return setting.Spec.AzureName
}

// GetAPIVersion returns the ARM API version of the resource. This is always "2021-05-01-preview"
func (setting DiagnosticSetting) GetAPIVersion() string {
	return "2021-05-01-preview"
}

// GetResourceScope returns the scope of the resource
func (setting *DiagnosticSetting) GetResourceScope() genruntime.ResourceScope {
	return genruntime.ResourceScopeExtension
}

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Insights/diagnosticSettings"
func (setting *DiagnosticSetting) GetType() string {
	return "Microsoft.Insights/diagnosticSettings"
}

// NewEmptyStatus returns a new empty (blank) status
func (setting *DiagnosticSetting) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &DiagnosticSetting_STATUS{}
}

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

	return setting.Spec.Owner.AsResourceReference()
}

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

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

	setting.Status = st
	return nil
}

// AssignProperties_From_DiagnosticSetting populates our DiagnosticSetting from the provided source DiagnosticSetting
func (setting *DiagnosticSetting) AssignProperties_From_DiagnosticSetting(source *storage.DiagnosticSetting) error {

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

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

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

	// No error
	return nil
}

// AssignProperties_To_DiagnosticSetting populates the provided destination DiagnosticSetting from our DiagnosticSetting
func (setting *DiagnosticSetting) AssignProperties_To_DiagnosticSetting(destination *storage.DiagnosticSetting) error {

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

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

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

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/diagnosticsSettings_API.json
// - ARM URI: /{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}
type DiagnosticSettingList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []DiagnosticSetting `json:"items"`
}

// +kubebuilder:validation:Enum={"2021-05-01-preview"}
type APIVersion string

const APIVersion_Value = APIVersion("2021-05-01-preview")

type DiagnosticSetting_Spec struct {
	// AzureName: The name of the resource in Azure. This is often the same as the name of the resource in Kubernetes but it
	// doesn't have to be.
	AzureName string `json:"azureName,omitempty"`

	// EventHubAuthorizationRuleReference: The resource Id for the event hub authorization rule.
	EventHubAuthorizationRuleReference *genruntime.ResourceReference `armReference:"EventHubAuthorizationRuleId" json:"eventHubAuthorizationRuleReference,omitempty"`

	// EventHubName: The name of the event hub. If none is specified, the default event hub will be selected.
	EventHubName *string `json:"eventHubName,omitempty"`

	// LogAnalyticsDestinationType: A string indicating whether the export to Log Analytics should use the default destination
	// type, i.e. AzureDiagnostics, or use a destination type constructed as follows: <normalized service identity>_<normalized
	// category name>. Possible values are: Dedicated and null (null is default.)
	LogAnalyticsDestinationType *string `json:"logAnalyticsDestinationType,omitempty"`

	// Logs: The list of logs settings.
	Logs []LogSettings `json:"logs,omitempty"`

	// MarketplacePartnerReference: The full ARM resource ID of the Marketplace resource to which you would like to send
	// Diagnostic Logs.
	MarketplacePartnerReference *genruntime.ResourceReference `armReference:"MarketplacePartnerId" json:"marketplacePartnerReference,omitempty"`

	// Metrics: The list of metric settings.
	Metrics []MetricSettings `json:"metrics,omitempty"`

	// OperatorSpec: The specification for configuring operator behavior. This field is interpreted by the operator and not
	// passed directly to Azure
	OperatorSpec *DiagnosticSettingOperatorSpec `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. This resource is an
	// extension resource, which means that any other Azure resource can be its owner.
	Owner *genruntime.ArbitraryOwnerReference `json:"owner,omitempty"`

	// ServiceBusRuleId: The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility.
	ServiceBusRuleId *string `json:"serviceBusRuleId,omitempty"`

	// StorageAccountReference: The resource ID of the storage account to which you would like to send Diagnostic Logs.
	StorageAccountReference *genruntime.ResourceReference `armReference:"StorageAccountId" json:"storageAccountReference,omitempty"`

	// WorkspaceReference: The full ARM resource ID of the Log Analytics workspace to which you would like to send Diagnostic
	// Logs. Example:
	// /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2
	WorkspaceReference *genruntime.ResourceReference `armReference:"WorkspaceId" json:"workspaceReference,omitempty"`
}

var _ genruntime.ARMTransformer = &DiagnosticSetting_Spec{}

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

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

	// Set property "Properties":
	if setting.EventHubAuthorizationRuleReference != nil ||
		setting.EventHubName != nil ||
		setting.LogAnalyticsDestinationType != nil ||
		setting.Logs != nil ||
		setting.MarketplacePartnerReference != nil ||
		setting.Metrics != nil ||
		setting.ServiceBusRuleId != nil ||
		setting.StorageAccountReference != nil ||
		setting.WorkspaceReference != nil {
		result.Properties = &arm.DiagnosticSettings{}
	}
	if setting.EventHubAuthorizationRuleReference != nil {
		eventHubAuthorizationRuleIdARMID, err := resolved.ResolvedReferences.Lookup(*setting.EventHubAuthorizationRuleReference)
		if err != nil {
			return nil, err
		}
		eventHubAuthorizationRuleId := eventHubAuthorizationRuleIdARMID
		result.Properties.EventHubAuthorizationRuleId = &eventHubAuthorizationRuleId
	}
	if setting.EventHubName != nil {
		eventHubName := *setting.EventHubName
		result.Properties.EventHubName = &eventHubName
	}
	if setting.LogAnalyticsDestinationType != nil {
		logAnalyticsDestinationType := *setting.LogAnalyticsDestinationType
		result.Properties.LogAnalyticsDestinationType = &logAnalyticsDestinationType
	}
	for _, item := range setting.Logs {
		item_ARM, err := item.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		result.Properties.Logs = append(result.Properties.Logs, *item_ARM.(*arm.LogSettings))
	}
	if setting.MarketplacePartnerReference != nil {
		marketplacePartnerIdARMID, err := resolved.ResolvedReferences.Lookup(*setting.MarketplacePartnerReference)
		if err != nil {
			return nil, err
		}
		marketplacePartnerId := marketplacePartnerIdARMID
		result.Properties.MarketplacePartnerId = &marketplacePartnerId
	}
	for _, item := range setting.Metrics {
		item_ARM, err := item.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		result.Properties.Metrics = append(result.Properties.Metrics, *item_ARM.(*arm.MetricSettings))
	}
	if setting.ServiceBusRuleId != nil {
		serviceBusRuleId := *setting.ServiceBusRuleId
		result.Properties.ServiceBusRuleId = &serviceBusRuleId
	}
	if setting.StorageAccountReference != nil {
		storageAccountIdARMID, err := resolved.ResolvedReferences.Lookup(*setting.StorageAccountReference)
		if err != nil {
			return nil, err
		}
		storageAccountId := storageAccountIdARMID
		result.Properties.StorageAccountId = &storageAccountId
	}
	if setting.WorkspaceReference != nil {
		workspaceIdARMID, err := resolved.ResolvedReferences.Lookup(*setting.WorkspaceReference)
		if err != nil {
			return nil, err
		}
		workspaceId := workspaceIdARMID
		result.Properties.WorkspaceId = &workspaceId
	}
	return result, nil
}

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

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

	// Set property "AzureName":
	setting.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name))

	// no assignment for property "EventHubAuthorizationRuleReference"

	// Set property "EventHubName":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.EventHubName != nil {
			eventHubName := *typedInput.Properties.EventHubName
			setting.EventHubName = &eventHubName
		}
	}

	// Set property "LogAnalyticsDestinationType":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.LogAnalyticsDestinationType != nil {
			logAnalyticsDestinationType := *typedInput.Properties.LogAnalyticsDestinationType
			setting.LogAnalyticsDestinationType = &logAnalyticsDestinationType
		}
	}

	// Set property "Logs":
	// copying flattened property:
	if typedInput.Properties != nil {
		for _, item := range typedInput.Properties.Logs {
			var item1 LogSettings
			err := item1.PopulateFromARM(owner, item)
			if err != nil {
				return err
			}
			setting.Logs = append(setting.Logs, item1)
		}
	}

	// no assignment for property "MarketplacePartnerReference"

	// Set property "Metrics":
	// copying flattened property:
	if typedInput.Properties != nil {
		for _, item := range typedInput.Properties.Metrics {
			var item1 MetricSettings
			err := item1.PopulateFromARM(owner, item)
			if err != nil {
				return err
			}
			setting.Metrics = append(setting.Metrics, item1)
		}
	}

	// no assignment for property "OperatorSpec"

	// Set property "Owner":
	setting.Owner = &owner

	// Set property "ServiceBusRuleId":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ServiceBusRuleId != nil {
			serviceBusRuleId := *typedInput.Properties.ServiceBusRuleId
			setting.ServiceBusRuleId = &serviceBusRuleId
		}
	}

	// no assignment for property "StorageAccountReference"

	// no assignment for property "WorkspaceReference"

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &DiagnosticSetting_Spec{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.DiagnosticSetting_Spec{}
	err := setting.AssignProperties_To_DiagnosticSetting_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_DiagnosticSetting_Spec populates our DiagnosticSetting_Spec from the provided source DiagnosticSetting_Spec
func (setting *DiagnosticSetting_Spec) AssignProperties_From_DiagnosticSetting_Spec(source *storage.DiagnosticSetting_Spec) error {

	// AzureName
	setting.AzureName = source.AzureName

	// EventHubAuthorizationRuleReference
	if source.EventHubAuthorizationRuleReference != nil {
		eventHubAuthorizationRuleReference := source.EventHubAuthorizationRuleReference.Copy()
		setting.EventHubAuthorizationRuleReference = &eventHubAuthorizationRuleReference
	} else {
		setting.EventHubAuthorizationRuleReference = nil
	}

	// EventHubName
	setting.EventHubName = genruntime.ClonePointerToString(source.EventHubName)

	// LogAnalyticsDestinationType
	setting.LogAnalyticsDestinationType = genruntime.ClonePointerToString(source.LogAnalyticsDestinationType)

	// Logs
	if source.Logs != nil {
		logList := make([]LogSettings, len(source.Logs))
		for logIndex, logItem := range source.Logs {
			var log LogSettings
			err := log.AssignProperties_From_LogSettings(&logItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_LogSettings() to populate field Logs")
			}
			logList[logIndex] = log
		}
		setting.Logs = logList
	} else {
		setting.Logs = nil
	}

	// MarketplacePartnerReference
	if source.MarketplacePartnerReference != nil {
		marketplacePartnerReference := source.MarketplacePartnerReference.Copy()
		setting.MarketplacePartnerReference = &marketplacePartnerReference
	} else {
		setting.MarketplacePartnerReference = nil
	}

	// Metrics
	if source.Metrics != nil {
		metricList := make([]MetricSettings, len(source.Metrics))
		for metricIndex, metricItem := range source.Metrics {
			var metric MetricSettings
			err := metric.AssignProperties_From_MetricSettings(&metricItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_MetricSettings() to populate field Metrics")
			}
			metricList[metricIndex] = metric
		}
		setting.Metrics = metricList
	} else {
		setting.Metrics = nil
	}

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

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

	// ServiceBusRuleId
	setting.ServiceBusRuleId = genruntime.ClonePointerToString(source.ServiceBusRuleId)

	// StorageAccountReference
	if source.StorageAccountReference != nil {
		storageAccountReference := source.StorageAccountReference.Copy()
		setting.StorageAccountReference = &storageAccountReference
	} else {
		setting.StorageAccountReference = nil
	}

	// WorkspaceReference
	if source.WorkspaceReference != nil {
		workspaceReference := source.WorkspaceReference.Copy()
		setting.WorkspaceReference = &workspaceReference
	} else {
		setting.WorkspaceReference = nil
	}

	// No error
	return nil
}

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

	// AzureName
	destination.AzureName = setting.AzureName

	// EventHubAuthorizationRuleReference
	if setting.EventHubAuthorizationRuleReference != nil {
		eventHubAuthorizationRuleReference := setting.EventHubAuthorizationRuleReference.Copy()
		destination.EventHubAuthorizationRuleReference = &eventHubAuthorizationRuleReference
	} else {
		destination.EventHubAuthorizationRuleReference = nil
	}

	// EventHubName
	destination.EventHubName = genruntime.ClonePointerToString(setting.EventHubName)

	// LogAnalyticsDestinationType
	destination.LogAnalyticsDestinationType = genruntime.ClonePointerToString(setting.LogAnalyticsDestinationType)

	// Logs
	if setting.Logs != nil {
		logList := make([]storage.LogSettings, len(setting.Logs))
		for logIndex, logItem := range setting.Logs {
			var log storage.LogSettings
			err := logItem.AssignProperties_To_LogSettings(&log)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_LogSettings() to populate field Logs")
			}
			logList[logIndex] = log
		}
		destination.Logs = logList
	} else {
		destination.Logs = nil
	}

	// MarketplacePartnerReference
	if setting.MarketplacePartnerReference != nil {
		marketplacePartnerReference := setting.MarketplacePartnerReference.Copy()
		destination.MarketplacePartnerReference = &marketplacePartnerReference
	} else {
		destination.MarketplacePartnerReference = nil
	}

	// Metrics
	if setting.Metrics != nil {
		metricList := make([]storage.MetricSettings, len(setting.Metrics))
		for metricIndex, metricItem := range setting.Metrics {
			var metric storage.MetricSettings
			err := metricItem.AssignProperties_To_MetricSettings(&metric)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_MetricSettings() to populate field Metrics")
			}
			metricList[metricIndex] = metric
		}
		destination.Metrics = metricList
	} else {
		destination.Metrics = nil
	}

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

	// OriginalVersion
	destination.OriginalVersion = setting.OriginalVersion()

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

	// ServiceBusRuleId
	destination.ServiceBusRuleId = genruntime.ClonePointerToString(setting.ServiceBusRuleId)

	// StorageAccountReference
	if setting.StorageAccountReference != nil {
		storageAccountReference := setting.StorageAccountReference.Copy()
		destination.StorageAccountReference = &storageAccountReference
	} else {
		destination.StorageAccountReference = nil
	}

	// WorkspaceReference
	if setting.WorkspaceReference != nil {
		workspaceReference := setting.WorkspaceReference.Copy()
		destination.WorkspaceReference = &workspaceReference
	} else {
		destination.WorkspaceReference = nil
	}

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

	// No error
	return nil
}

// Initialize_From_DiagnosticSetting_STATUS populates our DiagnosticSetting_Spec from the provided source DiagnosticSetting_STATUS
func (setting *DiagnosticSetting_Spec) Initialize_From_DiagnosticSetting_STATUS(source *DiagnosticSetting_STATUS) error {

	// EventHubAuthorizationRuleReference
	if source.EventHubAuthorizationRuleId != nil {
		eventHubAuthorizationRuleReference := genruntime.CreateResourceReferenceFromARMID(*source.EventHubAuthorizationRuleId)
		setting.EventHubAuthorizationRuleReference = &eventHubAuthorizationRuleReference
	} else {
		setting.EventHubAuthorizationRuleReference = nil
	}

	// EventHubName
	setting.EventHubName = genruntime.ClonePointerToString(source.EventHubName)

	// LogAnalyticsDestinationType
	setting.LogAnalyticsDestinationType = genruntime.ClonePointerToString(source.LogAnalyticsDestinationType)

	// Logs
	if source.Logs != nil {
		logList := make([]LogSettings, len(source.Logs))
		for logIndex, logItem := range source.Logs {
			var log LogSettings
			err := log.Initialize_From_LogSettings_STATUS(&logItem)
			if err != nil {
				return eris.Wrap(err, "calling Initialize_From_LogSettings_STATUS() to populate field Logs")
			}
			logList[logIndex] = log
		}
		setting.Logs = logList
	} else {
		setting.Logs = nil
	}

	// MarketplacePartnerReference
	if source.MarketplacePartnerId != nil {
		marketplacePartnerReference := genruntime.CreateResourceReferenceFromARMID(*source.MarketplacePartnerId)
		setting.MarketplacePartnerReference = &marketplacePartnerReference
	} else {
		setting.MarketplacePartnerReference = nil
	}

	// Metrics
	if source.Metrics != nil {
		metricList := make([]MetricSettings, len(source.Metrics))
		for metricIndex, metricItem := range source.Metrics {
			var metric MetricSettings
			err := metric.Initialize_From_MetricSettings_STATUS(&metricItem)
			if err != nil {
				return eris.Wrap(err, "calling Initialize_From_MetricSettings_STATUS() to populate field Metrics")
			}
			metricList[metricIndex] = metric
		}
		setting.Metrics = metricList
	} else {
		setting.Metrics = nil
	}

	// ServiceBusRuleId
	setting.ServiceBusRuleId = genruntime.ClonePointerToString(source.ServiceBusRuleId)

	// StorageAccountReference
	if source.StorageAccountId != nil {
		storageAccountReference := genruntime.CreateResourceReferenceFromARMID(*source.StorageAccountId)
		setting.StorageAccountReference = &storageAccountReference
	} else {
		setting.StorageAccountReference = nil
	}

	// WorkspaceReference
	if source.WorkspaceId != nil {
		workspaceReference := genruntime.CreateResourceReferenceFromARMID(*source.WorkspaceId)
		setting.WorkspaceReference = &workspaceReference
	} else {
		setting.WorkspaceReference = nil
	}

	// No error
	return nil
}

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

// SetAzureName sets the Azure name of the resource
func (setting *DiagnosticSetting_Spec) SetAzureName(azureName string) { setting.AzureName = azureName }

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

	// EventHubAuthorizationRuleId: The resource Id for the event hub authorization rule.
	EventHubAuthorizationRuleId *string `json:"eventHubAuthorizationRuleId,omitempty"`

	// EventHubName: The name of the event hub. If none is specified, the default event hub will be selected.
	EventHubName *string `json:"eventHubName,omitempty"`

	// Id: Fully qualified resource ID for the resource. Ex -
	// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
	Id *string `json:"id,omitempty"`

	// LogAnalyticsDestinationType: A string indicating whether the export to Log Analytics should use the default destination
	// type, i.e. AzureDiagnostics, or use a destination type constructed as follows: <normalized service identity>_<normalized
	// category name>. Possible values are: Dedicated and null (null is default.)
	LogAnalyticsDestinationType *string `json:"logAnalyticsDestinationType,omitempty"`

	// Logs: The list of logs settings.
	Logs []LogSettings_STATUS `json:"logs,omitempty"`

	// MarketplacePartnerId: The full ARM resource ID of the Marketplace resource to which you would like to send Diagnostic
	// Logs.
	MarketplacePartnerId *string `json:"marketplacePartnerId,omitempty"`

	// Metrics: The list of metric settings.
	Metrics []MetricSettings_STATUS `json:"metrics,omitempty"`

	// Name: The name of the resource
	Name *string `json:"name,omitempty"`

	// ServiceBusRuleId: The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility.
	ServiceBusRuleId *string `json:"serviceBusRuleId,omitempty"`

	// StorageAccountId: The resource ID of the storage account to which you would like to send Diagnostic Logs.
	StorageAccountId *string `json:"storageAccountId,omitempty"`

	// SystemData: The system metadata related to this resource.
	SystemData *SystemData_STATUS `json:"systemData,omitempty"`

	// Type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
	Type *string `json:"type,omitempty"`

	// WorkspaceId: The full ARM resource ID of the Log Analytics workspace to which you would like to send Diagnostic Logs.
	// Example:
	// /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2
	WorkspaceId *string `json:"workspaceId,omitempty"`
}

var _ genruntime.ConvertibleStatus = &DiagnosticSetting_STATUS{}

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

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

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

	return nil
}

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

	// Convert to an intermediate form
	dst = &storage.DiagnosticSetting_STATUS{}
	err := setting.AssignProperties_To_DiagnosticSetting_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 = &DiagnosticSetting_STATUS{}

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

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

	// no assignment for property "Conditions"

	// Set property "EventHubAuthorizationRuleId":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.EventHubAuthorizationRuleId != nil {
			eventHubAuthorizationRuleId := *typedInput.Properties.EventHubAuthorizationRuleId
			setting.EventHubAuthorizationRuleId = &eventHubAuthorizationRuleId
		}
	}

	// Set property "EventHubName":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.EventHubName != nil {
			eventHubName := *typedInput.Properties.EventHubName
			setting.EventHubName = &eventHubName
		}
	}

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

	// Set property "LogAnalyticsDestinationType":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.LogAnalyticsDestinationType != nil {
			logAnalyticsDestinationType := *typedInput.Properties.LogAnalyticsDestinationType
			setting.LogAnalyticsDestinationType = &logAnalyticsDestinationType
		}
	}

	// Set property "Logs":
	// copying flattened property:
	if typedInput.Properties != nil {
		for _, item := range typedInput.Properties.Logs {
			var item1 LogSettings_STATUS
			err := item1.PopulateFromARM(owner, item)
			if err != nil {
				return err
			}
			setting.Logs = append(setting.Logs, item1)
		}
	}

	// Set property "MarketplacePartnerId":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.MarketplacePartnerId != nil {
			marketplacePartnerId := *typedInput.Properties.MarketplacePartnerId
			setting.MarketplacePartnerId = &marketplacePartnerId
		}
	}

	// Set property "Metrics":
	// copying flattened property:
	if typedInput.Properties != nil {
		for _, item := range typedInput.Properties.Metrics {
			var item1 MetricSettings_STATUS
			err := item1.PopulateFromARM(owner, item)
			if err != nil {
				return err
			}
			setting.Metrics = append(setting.Metrics, item1)
		}
	}

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

	// Set property "ServiceBusRuleId":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ServiceBusRuleId != nil {
			serviceBusRuleId := *typedInput.Properties.ServiceBusRuleId
			setting.ServiceBusRuleId = &serviceBusRuleId
		}
	}

	// Set property "StorageAccountId":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.StorageAccountId != nil {
			storageAccountId := *typedInput.Properties.StorageAccountId
			setting.StorageAccountId = &storageAccountId
		}
	}

	// Set property "SystemData":
	if typedInput.SystemData != nil {
		var systemData1 SystemData_STATUS
		err := systemData1.PopulateFromARM(owner, *typedInput.SystemData)
		if err != nil {
			return err
		}
		systemData := systemData1
		setting.SystemData = &systemData
	}

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

	// Set property "WorkspaceId":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.WorkspaceId != nil {
			workspaceId := *typedInput.Properties.WorkspaceId
			setting.WorkspaceId = &workspaceId
		}
	}

	// No error
	return nil
}

// AssignProperties_From_DiagnosticSetting_STATUS populates our DiagnosticSetting_STATUS from the provided source DiagnosticSetting_STATUS
func (setting *DiagnosticSetting_STATUS) AssignProperties_From_DiagnosticSetting_STATUS(source *storage.DiagnosticSetting_STATUS) error {

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

	// EventHubAuthorizationRuleId
	setting.EventHubAuthorizationRuleId = genruntime.ClonePointerToString(source.EventHubAuthorizationRuleId)

	// EventHubName
	setting.EventHubName = genruntime.ClonePointerToString(source.EventHubName)

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

	// LogAnalyticsDestinationType
	setting.LogAnalyticsDestinationType = genruntime.ClonePointerToString(source.LogAnalyticsDestinationType)

	// Logs
	if source.Logs != nil {
		logList := make([]LogSettings_STATUS, len(source.Logs))
		for logIndex, logItem := range source.Logs {
			var log LogSettings_STATUS
			err := log.AssignProperties_From_LogSettings_STATUS(&logItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_LogSettings_STATUS() to populate field Logs")
			}
			logList[logIndex] = log
		}
		setting.Logs = logList
	} else {
		setting.Logs = nil
	}

	// MarketplacePartnerId
	setting.MarketplacePartnerId = genruntime.ClonePointerToString(source.MarketplacePartnerId)

	// Metrics
	if source.Metrics != nil {
		metricList := make([]MetricSettings_STATUS, len(source.Metrics))
		for metricIndex, metricItem := range source.Metrics {
			var metric MetricSettings_STATUS
			err := metric.AssignProperties_From_MetricSettings_STATUS(&metricItem)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_From_MetricSettings_STATUS() to populate field Metrics")
			}
			metricList[metricIndex] = metric
		}
		setting.Metrics = metricList
	} else {
		setting.Metrics = nil
	}

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

	// ServiceBusRuleId
	setting.ServiceBusRuleId = genruntime.ClonePointerToString(source.ServiceBusRuleId)

	// StorageAccountId
	setting.StorageAccountId = genruntime.ClonePointerToString(source.StorageAccountId)

	// SystemData
	if source.SystemData != nil {
		var systemDatum SystemData_STATUS
		err := systemDatum.AssignProperties_From_SystemData_STATUS(source.SystemData)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_SystemData_STATUS() to populate field SystemData")
		}
		setting.SystemData = &systemDatum
	} else {
		setting.SystemData = nil
	}

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

	// WorkspaceId
	setting.WorkspaceId = genruntime.ClonePointerToString(source.WorkspaceId)

	// No error
	return nil
}

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

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

	// EventHubAuthorizationRuleId
	destination.EventHubAuthorizationRuleId = genruntime.ClonePointerToString(setting.EventHubAuthorizationRuleId)

	// EventHubName
	destination.EventHubName = genruntime.ClonePointerToString(setting.EventHubName)

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

	// LogAnalyticsDestinationType
	destination.LogAnalyticsDestinationType = genruntime.ClonePointerToString(setting.LogAnalyticsDestinationType)

	// Logs
	if setting.Logs != nil {
		logList := make([]storage.LogSettings_STATUS, len(setting.Logs))
		for logIndex, logItem := range setting.Logs {
			var log storage.LogSettings_STATUS
			err := logItem.AssignProperties_To_LogSettings_STATUS(&log)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_LogSettings_STATUS() to populate field Logs")
			}
			logList[logIndex] = log
		}
		destination.Logs = logList
	} else {
		destination.Logs = nil
	}

	// MarketplacePartnerId
	destination.MarketplacePartnerId = genruntime.ClonePointerToString(setting.MarketplacePartnerId)

	// Metrics
	if setting.Metrics != nil {
		metricList := make([]storage.MetricSettings_STATUS, len(setting.Metrics))
		for metricIndex, metricItem := range setting.Metrics {
			var metric storage.MetricSettings_STATUS
			err := metricItem.AssignProperties_To_MetricSettings_STATUS(&metric)
			if err != nil {
				return eris.Wrap(err, "calling AssignProperties_To_MetricSettings_STATUS() to populate field Metrics")
			}
			metricList[metricIndex] = metric
		}
		destination.Metrics = metricList
	} else {
		destination.Metrics = nil
	}

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

	// ServiceBusRuleId
	destination.ServiceBusRuleId = genruntime.ClonePointerToString(setting.ServiceBusRuleId)

	// StorageAccountId
	destination.StorageAccountId = genruntime.ClonePointerToString(setting.StorageAccountId)

	// SystemData
	if setting.SystemData != nil {
		var systemDatum storage.SystemData_STATUS
		err := setting.SystemData.AssignProperties_To_SystemData_STATUS(&systemDatum)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_SystemData_STATUS() to populate field SystemData")
		}
		destination.SystemData = &systemDatum
	} else {
		destination.SystemData = nil
	}

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

	// WorkspaceId
	destination.WorkspaceId = genruntime.ClonePointerToString(setting.WorkspaceId)

	// 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 DiagnosticSettingOperatorSpec 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_DiagnosticSettingOperatorSpec populates our DiagnosticSettingOperatorSpec from the provided source DiagnosticSettingOperatorSpec
func (operator *DiagnosticSettingOperatorSpec) AssignProperties_From_DiagnosticSettingOperatorSpec(source *storage.DiagnosticSettingOperatorSpec) 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_DiagnosticSettingOperatorSpec populates the provided destination DiagnosticSettingOperatorSpec from our DiagnosticSettingOperatorSpec
func (operator *DiagnosticSettingOperatorSpec) AssignProperties_To_DiagnosticSettingOperatorSpec(destination *storage.DiagnosticSettingOperatorSpec) 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
}

// Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log.
type LogSettings struct {
	// Category: Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of
	// Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation.
	Category *string `json:"category,omitempty"`

	// CategoryGroup: Name of a Diagnostic Log category group for a resource type this setting is applied to. To obtain the
	// list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation.
	CategoryGroup *string `json:"categoryGroup,omitempty"`

	// +kubebuilder:validation:Required
	// Enabled: a value indicating whether this log is enabled.
	Enabled *bool `json:"enabled,omitempty"`

	// RetentionPolicy: the retention policy for this log.
	RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"`
}

var _ genruntime.ARMTransformer = &LogSettings{}

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

	// Set property "Category":
	if settings.Category != nil {
		category := *settings.Category
		result.Category = &category
	}

	// Set property "CategoryGroup":
	if settings.CategoryGroup != nil {
		categoryGroup := *settings.CategoryGroup
		result.CategoryGroup = &categoryGroup
	}

	// Set property "Enabled":
	if settings.Enabled != nil {
		enabled := *settings.Enabled
		result.Enabled = &enabled
	}

	// Set property "RetentionPolicy":
	if settings.RetentionPolicy != nil {
		retentionPolicy_ARM, err := settings.RetentionPolicy.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		retentionPolicy := *retentionPolicy_ARM.(*arm.RetentionPolicy)
		result.RetentionPolicy = &retentionPolicy
	}
	return result, nil
}

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

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

	// Set property "Category":
	if typedInput.Category != nil {
		category := *typedInput.Category
		settings.Category = &category
	}

	// Set property "CategoryGroup":
	if typedInput.CategoryGroup != nil {
		categoryGroup := *typedInput.CategoryGroup
		settings.CategoryGroup = &categoryGroup
	}

	// Set property "Enabled":
	if typedInput.Enabled != nil {
		enabled := *typedInput.Enabled
		settings.Enabled = &enabled
	}

	// Set property "RetentionPolicy":
	if typedInput.RetentionPolicy != nil {
		var retentionPolicy1 RetentionPolicy
		err := retentionPolicy1.PopulateFromARM(owner, *typedInput.RetentionPolicy)
		if err != nil {
			return err
		}
		retentionPolicy := retentionPolicy1
		settings.RetentionPolicy = &retentionPolicy
	}

	// No error
	return nil
}

// AssignProperties_From_LogSettings populates our LogSettings from the provided source LogSettings
func (settings *LogSettings) AssignProperties_From_LogSettings(source *storage.LogSettings) error {

	// Category
	settings.Category = genruntime.ClonePointerToString(source.Category)

	// CategoryGroup
	settings.CategoryGroup = genruntime.ClonePointerToString(source.CategoryGroup)

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

	// RetentionPolicy
	if source.RetentionPolicy != nil {
		var retentionPolicy RetentionPolicy
		err := retentionPolicy.AssignProperties_From_RetentionPolicy(source.RetentionPolicy)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_RetentionPolicy() to populate field RetentionPolicy")
		}
		settings.RetentionPolicy = &retentionPolicy
	} else {
		settings.RetentionPolicy = nil
	}

	// No error
	return nil
}

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

	// Category
	destination.Category = genruntime.ClonePointerToString(settings.Category)

	// CategoryGroup
	destination.CategoryGroup = genruntime.ClonePointerToString(settings.CategoryGroup)

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

	// RetentionPolicy
	if settings.RetentionPolicy != nil {
		var retentionPolicy storage.RetentionPolicy
		err := settings.RetentionPolicy.AssignProperties_To_RetentionPolicy(&retentionPolicy)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_RetentionPolicy() to populate field RetentionPolicy")
		}
		destination.RetentionPolicy = &retentionPolicy
	} else {
		destination.RetentionPolicy = nil
	}

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

	// No error
	return nil
}

// Initialize_From_LogSettings_STATUS populates our LogSettings from the provided source LogSettings_STATUS
func (settings *LogSettings) Initialize_From_LogSettings_STATUS(source *LogSettings_STATUS) error {

	// Category
	settings.Category = genruntime.ClonePointerToString(source.Category)

	// CategoryGroup
	settings.CategoryGroup = genruntime.ClonePointerToString(source.CategoryGroup)

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

	// RetentionPolicy
	if source.RetentionPolicy != nil {
		var retentionPolicy RetentionPolicy
		err := retentionPolicy.Initialize_From_RetentionPolicy_STATUS(source.RetentionPolicy)
		if err != nil {
			return eris.Wrap(err, "calling Initialize_From_RetentionPolicy_STATUS() to populate field RetentionPolicy")
		}
		settings.RetentionPolicy = &retentionPolicy
	} else {
		settings.RetentionPolicy = nil
	}

	// No error
	return nil
}

// Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log.
type LogSettings_STATUS struct {
	// Category: Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of
	// Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation.
	Category *string `json:"category,omitempty"`

	// CategoryGroup: Name of a Diagnostic Log category group for a resource type this setting is applied to. To obtain the
	// list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation.
	CategoryGroup *string `json:"categoryGroup,omitempty"`

	// Enabled: a value indicating whether this log is enabled.
	Enabled *bool `json:"enabled,omitempty"`

	// RetentionPolicy: the retention policy for this log.
	RetentionPolicy *RetentionPolicy_STATUS `json:"retentionPolicy,omitempty"`
}

var _ genruntime.FromARMConverter = &LogSettings_STATUS{}

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

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

	// Set property "Category":
	if typedInput.Category != nil {
		category := *typedInput.Category
		settings.Category = &category
	}

	// Set property "CategoryGroup":
	if typedInput.CategoryGroup != nil {
		categoryGroup := *typedInput.CategoryGroup
		settings.CategoryGroup = &categoryGroup
	}

	// Set property "Enabled":
	if typedInput.Enabled != nil {
		enabled := *typedInput.Enabled
		settings.Enabled = &enabled
	}

	// Set property "RetentionPolicy":
	if typedInput.RetentionPolicy != nil {
		var retentionPolicy1 RetentionPolicy_STATUS
		err := retentionPolicy1.PopulateFromARM(owner, *typedInput.RetentionPolicy)
		if err != nil {
			return err
		}
		retentionPolicy := retentionPolicy1
		settings.RetentionPolicy = &retentionPolicy
	}

	// No error
	return nil
}

// AssignProperties_From_LogSettings_STATUS populates our LogSettings_STATUS from the provided source LogSettings_STATUS
func (settings *LogSettings_STATUS) AssignProperties_From_LogSettings_STATUS(source *storage.LogSettings_STATUS) error {

	// Category
	settings.Category = genruntime.ClonePointerToString(source.Category)

	// CategoryGroup
	settings.CategoryGroup = genruntime.ClonePointerToString(source.CategoryGroup)

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

	// RetentionPolicy
	if source.RetentionPolicy != nil {
		var retentionPolicy RetentionPolicy_STATUS
		err := retentionPolicy.AssignProperties_From_RetentionPolicy_STATUS(source.RetentionPolicy)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_RetentionPolicy_STATUS() to populate field RetentionPolicy")
		}
		settings.RetentionPolicy = &retentionPolicy
	} else {
		settings.RetentionPolicy = nil
	}

	// No error
	return nil
}

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

	// Category
	destination.Category = genruntime.ClonePointerToString(settings.Category)

	// CategoryGroup
	destination.CategoryGroup = genruntime.ClonePointerToString(settings.CategoryGroup)

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

	// RetentionPolicy
	if settings.RetentionPolicy != nil {
		var retentionPolicy storage.RetentionPolicy_STATUS
		err := settings.RetentionPolicy.AssignProperties_To_RetentionPolicy_STATUS(&retentionPolicy)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_RetentionPolicy_STATUS() to populate field RetentionPolicy")
		}
		destination.RetentionPolicy = &retentionPolicy
	} else {
		destination.RetentionPolicy = nil
	}

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

	// No error
	return nil
}

// Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric.
type MetricSettings struct {
	// Category: Name of a Diagnostic Metric category for a resource type this setting is applied to. To obtain the list of
	// Diagnostic metric categories for a resource, first perform a GET diagnostic settings operation.
	Category *string `json:"category,omitempty"`

	// +kubebuilder:validation:Required
	// Enabled: a value indicating whether this category is enabled.
	Enabled *bool `json:"enabled,omitempty"`

	// RetentionPolicy: the retention policy for this category.
	RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"`

	// TimeGrain: the timegrain of the metric in ISO8601 format.
	TimeGrain *string `json:"timeGrain,omitempty"`
}

var _ genruntime.ARMTransformer = &MetricSettings{}

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

	// Set property "Category":
	if settings.Category != nil {
		category := *settings.Category
		result.Category = &category
	}

	// Set property "Enabled":
	if settings.Enabled != nil {
		enabled := *settings.Enabled
		result.Enabled = &enabled
	}

	// Set property "RetentionPolicy":
	if settings.RetentionPolicy != nil {
		retentionPolicy_ARM, err := settings.RetentionPolicy.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		retentionPolicy := *retentionPolicy_ARM.(*arm.RetentionPolicy)
		result.RetentionPolicy = &retentionPolicy
	}

	// Set property "TimeGrain":
	if settings.TimeGrain != nil {
		timeGrain := *settings.TimeGrain
		result.TimeGrain = &timeGrain
	}
	return result, nil
}

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

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

	// Set property "Category":
	if typedInput.Category != nil {
		category := *typedInput.Category
		settings.Category = &category
	}

	// Set property "Enabled":
	if typedInput.Enabled != nil {
		enabled := *typedInput.Enabled
		settings.Enabled = &enabled
	}

	// Set property "RetentionPolicy":
	if typedInput.RetentionPolicy != nil {
		var retentionPolicy1 RetentionPolicy
		err := retentionPolicy1.PopulateFromARM(owner, *typedInput.RetentionPolicy)
		if err != nil {
			return err
		}
		retentionPolicy := retentionPolicy1
		settings.RetentionPolicy = &retentionPolicy
	}

	// Set property "TimeGrain":
	if typedInput.TimeGrain != nil {
		timeGrain := *typedInput.TimeGrain
		settings.TimeGrain = &timeGrain
	}

	// No error
	return nil
}

// AssignProperties_From_MetricSettings populates our MetricSettings from the provided source MetricSettings
func (settings *MetricSettings) AssignProperties_From_MetricSettings(source *storage.MetricSettings) error {

	// Category
	settings.Category = genruntime.ClonePointerToString(source.Category)

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

	// RetentionPolicy
	if source.RetentionPolicy != nil {
		var retentionPolicy RetentionPolicy
		err := retentionPolicy.AssignProperties_From_RetentionPolicy(source.RetentionPolicy)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_RetentionPolicy() to populate field RetentionPolicy")
		}
		settings.RetentionPolicy = &retentionPolicy
	} else {
		settings.RetentionPolicy = nil
	}

	// TimeGrain
	settings.TimeGrain = genruntime.ClonePointerToString(source.TimeGrain)

	// No error
	return nil
}

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

	// Category
	destination.Category = genruntime.ClonePointerToString(settings.Category)

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

	// RetentionPolicy
	if settings.RetentionPolicy != nil {
		var retentionPolicy storage.RetentionPolicy
		err := settings.RetentionPolicy.AssignProperties_To_RetentionPolicy(&retentionPolicy)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_RetentionPolicy() to populate field RetentionPolicy")
		}
		destination.RetentionPolicy = &retentionPolicy
	} else {
		destination.RetentionPolicy = nil
	}

	// TimeGrain
	destination.TimeGrain = genruntime.ClonePointerToString(settings.TimeGrain)

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

	// No error
	return nil
}

// Initialize_From_MetricSettings_STATUS populates our MetricSettings from the provided source MetricSettings_STATUS
func (settings *MetricSettings) Initialize_From_MetricSettings_STATUS(source *MetricSettings_STATUS) error {

	// Category
	settings.Category = genruntime.ClonePointerToString(source.Category)

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

	// RetentionPolicy
	if source.RetentionPolicy != nil {
		var retentionPolicy RetentionPolicy
		err := retentionPolicy.Initialize_From_RetentionPolicy_STATUS(source.RetentionPolicy)
		if err != nil {
			return eris.Wrap(err, "calling Initialize_From_RetentionPolicy_STATUS() to populate field RetentionPolicy")
		}
		settings.RetentionPolicy = &retentionPolicy
	} else {
		settings.RetentionPolicy = nil
	}

	// TimeGrain
	settings.TimeGrain = genruntime.ClonePointerToString(source.TimeGrain)

	// No error
	return nil
}

// Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric.
type MetricSettings_STATUS struct {
	// Category: Name of a Diagnostic Metric category for a resource type this setting is applied to. To obtain the list of
	// Diagnostic metric categories for a resource, first perform a GET diagnostic settings operation.
	Category *string `json:"category,omitempty"`

	// Enabled: a value indicating whether this category is enabled.
	Enabled *bool `json:"enabled,omitempty"`

	// RetentionPolicy: the retention policy for this category.
	RetentionPolicy *RetentionPolicy_STATUS `json:"retentionPolicy,omitempty"`

	// TimeGrain: the timegrain of the metric in ISO8601 format.
	TimeGrain *string `json:"timeGrain,omitempty"`
}

var _ genruntime.FromARMConverter = &MetricSettings_STATUS{}

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

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

	// Set property "Category":
	if typedInput.Category != nil {
		category := *typedInput.Category
		settings.Category = &category
	}

	// Set property "Enabled":
	if typedInput.Enabled != nil {
		enabled := *typedInput.Enabled
		settings.Enabled = &enabled
	}

	// Set property "RetentionPolicy":
	if typedInput.RetentionPolicy != nil {
		var retentionPolicy1 RetentionPolicy_STATUS
		err := retentionPolicy1.PopulateFromARM(owner, *typedInput.RetentionPolicy)
		if err != nil {
			return err
		}
		retentionPolicy := retentionPolicy1
		settings.RetentionPolicy = &retentionPolicy
	}

	// Set property "TimeGrain":
	if typedInput.TimeGrain != nil {
		timeGrain := *typedInput.TimeGrain
		settings.TimeGrain = &timeGrain
	}

	// No error
	return nil
}

// AssignProperties_From_MetricSettings_STATUS populates our MetricSettings_STATUS from the provided source MetricSettings_STATUS
func (settings *MetricSettings_STATUS) AssignProperties_From_MetricSettings_STATUS(source *storage.MetricSettings_STATUS) error {

	// Category
	settings.Category = genruntime.ClonePointerToString(source.Category)

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

	// RetentionPolicy
	if source.RetentionPolicy != nil {
		var retentionPolicy RetentionPolicy_STATUS
		err := retentionPolicy.AssignProperties_From_RetentionPolicy_STATUS(source.RetentionPolicy)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_RetentionPolicy_STATUS() to populate field RetentionPolicy")
		}
		settings.RetentionPolicy = &retentionPolicy
	} else {
		settings.RetentionPolicy = nil
	}

	// TimeGrain
	settings.TimeGrain = genruntime.ClonePointerToString(source.TimeGrain)

	// No error
	return nil
}

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

	// Category
	destination.Category = genruntime.ClonePointerToString(settings.Category)

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

	// RetentionPolicy
	if settings.RetentionPolicy != nil {
		var retentionPolicy storage.RetentionPolicy_STATUS
		err := settings.RetentionPolicy.AssignProperties_To_RetentionPolicy_STATUS(&retentionPolicy)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_RetentionPolicy_STATUS() to populate field RetentionPolicy")
		}
		destination.RetentionPolicy = &retentionPolicy
	} else {
		destination.RetentionPolicy = nil
	}

	// TimeGrain
	destination.TimeGrain = genruntime.ClonePointerToString(settings.TimeGrain)

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

	// No error
	return nil
}

// Metadata pertaining to creation and last modification of the resource.
type SystemData_STATUS struct {
	// CreatedAt: The timestamp of resource creation (UTC).
	CreatedAt *string `json:"createdAt,omitempty"`

	// CreatedBy: The identity that created the resource.
	CreatedBy *string `json:"createdBy,omitempty"`

	// CreatedByType: The type of identity that created the resource.
	CreatedByType *SystemData_CreatedByType_STATUS `json:"createdByType,omitempty"`

	// LastModifiedAt: The timestamp of resource last modification (UTC)
	LastModifiedAt *string `json:"lastModifiedAt,omitempty"`

	// LastModifiedBy: The identity that last modified the resource.
	LastModifiedBy *string `json:"lastModifiedBy,omitempty"`

	// LastModifiedByType: The type of identity that last modified the resource.
	LastModifiedByType *SystemData_LastModifiedByType_STATUS `json:"lastModifiedByType,omitempty"`
}

var _ genruntime.FromARMConverter = &SystemData_STATUS{}

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

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

	// Set property "CreatedAt":
	if typedInput.CreatedAt != nil {
		createdAt := *typedInput.CreatedAt
		data.CreatedAt = &createdAt
	}

	// Set property "CreatedBy":
	if typedInput.CreatedBy != nil {
		createdBy := *typedInput.CreatedBy
		data.CreatedBy = &createdBy
	}

	// Set property "CreatedByType":
	if typedInput.CreatedByType != nil {
		var temp string
		temp = string(*typedInput.CreatedByType)
		createdByType := SystemData_CreatedByType_STATUS(temp)
		data.CreatedByType = &createdByType
	}

	// Set property "LastModifiedAt":
	if typedInput.LastModifiedAt != nil {
		lastModifiedAt := *typedInput.LastModifiedAt
		data.LastModifiedAt = &lastModifiedAt
	}

	// Set property "LastModifiedBy":
	if typedInput.LastModifiedBy != nil {
		lastModifiedBy := *typedInput.LastModifiedBy
		data.LastModifiedBy = &lastModifiedBy
	}

	// Set property "LastModifiedByType":
	if typedInput.LastModifiedByType != nil {
		var temp string
		temp = string(*typedInput.LastModifiedByType)
		lastModifiedByType := SystemData_LastModifiedByType_STATUS(temp)
		data.LastModifiedByType = &lastModifiedByType
	}

	// No error
	return nil
}

// AssignProperties_From_SystemData_STATUS populates our SystemData_STATUS from the provided source SystemData_STATUS
func (data *SystemData_STATUS) AssignProperties_From_SystemData_STATUS(source *storage.SystemData_STATUS) error {

	// CreatedAt
	data.CreatedAt = genruntime.ClonePointerToString(source.CreatedAt)

	// CreatedBy
	data.CreatedBy = genruntime.ClonePointerToString(source.CreatedBy)

	// CreatedByType
	if source.CreatedByType != nil {
		createdByType := *source.CreatedByType
		createdByTypeTemp := genruntime.ToEnum(createdByType, systemData_CreatedByType_STATUS_Values)
		data.CreatedByType = &createdByTypeTemp
	} else {
		data.CreatedByType = nil
	}

	// LastModifiedAt
	data.LastModifiedAt = genruntime.ClonePointerToString(source.LastModifiedAt)

	// LastModifiedBy
	data.LastModifiedBy = genruntime.ClonePointerToString(source.LastModifiedBy)

	// LastModifiedByType
	if source.LastModifiedByType != nil {
		lastModifiedByType := *source.LastModifiedByType
		lastModifiedByTypeTemp := genruntime.ToEnum(lastModifiedByType, systemData_LastModifiedByType_STATUS_Values)
		data.LastModifiedByType = &lastModifiedByTypeTemp
	} else {
		data.LastModifiedByType = nil
	}

	// No error
	return nil
}

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

	// CreatedAt
	destination.CreatedAt = genruntime.ClonePointerToString(data.CreatedAt)

	// CreatedBy
	destination.CreatedBy = genruntime.ClonePointerToString(data.CreatedBy)

	// CreatedByType
	if data.CreatedByType != nil {
		createdByType := string(*data.CreatedByType)
		destination.CreatedByType = &createdByType
	} else {
		destination.CreatedByType = nil
	}

	// LastModifiedAt
	destination.LastModifiedAt = genruntime.ClonePointerToString(data.LastModifiedAt)

	// LastModifiedBy
	destination.LastModifiedBy = genruntime.ClonePointerToString(data.LastModifiedBy)

	// LastModifiedByType
	if data.LastModifiedByType != nil {
		lastModifiedByType := string(*data.LastModifiedByType)
		destination.LastModifiedByType = &lastModifiedByType
	} else {
		destination.LastModifiedByType = nil
	}

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

	// No error
	return nil
}

// Specifies the retention policy for the log.
type RetentionPolicy struct {
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:Minimum=0
	// Days: the number of days for the retention in days. A value of 0 will retain the events indefinitely.
	Days *int `json:"days,omitempty"`

	// +kubebuilder:validation:Required
	// Enabled: a value indicating whether the retention policy is enabled.
	Enabled *bool `json:"enabled,omitempty"`
}

var _ genruntime.ARMTransformer = &RetentionPolicy{}

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

	// Set property "Days":
	if policy.Days != nil {
		days := *policy.Days
		result.Days = &days
	}

	// Set property "Enabled":
	if policy.Enabled != nil {
		enabled := *policy.Enabled
		result.Enabled = &enabled
	}
	return result, nil
}

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

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

	// Set property "Days":
	if typedInput.Days != nil {
		days := *typedInput.Days
		policy.Days = &days
	}

	// Set property "Enabled":
	if typedInput.Enabled != nil {
		enabled := *typedInput.Enabled
		policy.Enabled = &enabled
	}

	// No error
	return nil
}

// AssignProperties_From_RetentionPolicy populates our RetentionPolicy from the provided source RetentionPolicy
func (policy *RetentionPolicy) AssignProperties_From_RetentionPolicy(source *storage.RetentionPolicy) error {

	// Days
	policy.Days = genruntime.ClonePointerToInt(source.Days)

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

	// No error
	return nil
}

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

	// Days
	destination.Days = genruntime.ClonePointerToInt(policy.Days)

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

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

	// No error
	return nil
}

// Initialize_From_RetentionPolicy_STATUS populates our RetentionPolicy from the provided source RetentionPolicy_STATUS
func (policy *RetentionPolicy) Initialize_From_RetentionPolicy_STATUS(source *RetentionPolicy_STATUS) error {

	// Days
	policy.Days = genruntime.ClonePointerToInt(source.Days)

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

	// No error
	return nil
}

// Specifies the retention policy for the log.
type RetentionPolicy_STATUS struct {
	// Days: the number of days for the retention in days. A value of 0 will retain the events indefinitely.
	Days *int `json:"days,omitempty"`

	// Enabled: a value indicating whether the retention policy is enabled.
	Enabled *bool `json:"enabled,omitempty"`
}

var _ genruntime.FromARMConverter = &RetentionPolicy_STATUS{}

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

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

	// Set property "Days":
	if typedInput.Days != nil {
		days := *typedInput.Days
		policy.Days = &days
	}

	// Set property "Enabled":
	if typedInput.Enabled != nil {
		enabled := *typedInput.Enabled
		policy.Enabled = &enabled
	}

	// No error
	return nil
}

// AssignProperties_From_RetentionPolicy_STATUS populates our RetentionPolicy_STATUS from the provided source RetentionPolicy_STATUS
func (policy *RetentionPolicy_STATUS) AssignProperties_From_RetentionPolicy_STATUS(source *storage.RetentionPolicy_STATUS) error {

	// Days
	policy.Days = genruntime.ClonePointerToInt(source.Days)

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

	// No error
	return nil
}

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

	// Days
	destination.Days = genruntime.ClonePointerToInt(policy.Days)

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

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

	// No error
	return nil
}

type SystemData_CreatedByType_STATUS string

const (
	SystemData_CreatedByType_STATUS_Application     = SystemData_CreatedByType_STATUS("Application")
	SystemData_CreatedByType_STATUS_Key             = SystemData_CreatedByType_STATUS("Key")
	SystemData_CreatedByType_STATUS_ManagedIdentity = SystemData_CreatedByType_STATUS("ManagedIdentity")
	SystemData_CreatedByType_STATUS_User            = SystemData_CreatedByType_STATUS("User")
)

// Mapping from string to SystemData_CreatedByType_STATUS
var systemData_CreatedByType_STATUS_Values = map[string]SystemData_CreatedByType_STATUS{
	"application":     SystemData_CreatedByType_STATUS_Application,
	"key":             SystemData_CreatedByType_STATUS_Key,
	"managedidentity": SystemData_CreatedByType_STATUS_ManagedIdentity,
	"user":            SystemData_CreatedByType_STATUS_User,
}

type SystemData_LastModifiedByType_STATUS string

const (
	SystemData_LastModifiedByType_STATUS_Application     = SystemData_LastModifiedByType_STATUS("Application")
	SystemData_LastModifiedByType_STATUS_Key             = SystemData_LastModifiedByType_STATUS("Key")
	SystemData_LastModifiedByType_STATUS_ManagedIdentity = SystemData_LastModifiedByType_STATUS("ManagedIdentity")
	SystemData_LastModifiedByType_STATUS_User            = SystemData_LastModifiedByType_STATUS("User")
)

// Mapping from string to SystemData_LastModifiedByType_STATUS
var systemData_LastModifiedByType_STATUS_Values = map[string]SystemData_LastModifiedByType_STATUS{
	"application":     SystemData_LastModifiedByType_STATUS_Application,
	"key":             SystemData_LastModifiedByType_STATUS_Key,
	"managedidentity": SystemData_LastModifiedByType_STATUS_ManagedIdentity,
	"user":            SystemData_LastModifiedByType_STATUS_User,
}

func init() {
	SchemeBuilder.Register(&DiagnosticSetting{}, &DiagnosticSettingList{})
}
