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

import (
	"fmt"
	v20220901s "github.com/Azure/azure-service-operator/v2/api/storage/v1api20220901storage"
	"github.com/Azure/azure-service-operator/v2/internal/reflecthelpers"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime/conditions"
	"github.com/pkg/errors"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime"
	"k8s.io/apimachinery/pkg/runtime/schema"
	"sigs.k8s.io/controller-runtime/pkg/conversion"
	"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// +kubebuilder:object:root=true
// +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: /storage/resource-manager/Microsoft.Storage/stable/2022-09-01/file.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default
type StorageAccountsFileService struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              StorageAccounts_FileService_Spec   `json:"spec,omitempty"`
	Status            StorageAccounts_FileService_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &StorageAccountsFileService{}

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

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

var _ conversion.Convertible = &StorageAccountsFileService{}

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

	return service.AssignProperties_From_StorageAccountsFileService(source)
}

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

	return service.AssignProperties_To_StorageAccountsFileService(destination)
}

// +kubebuilder:webhook:path=/mutate-storage-azure-com-v1api20220901-storageaccountsfileservice,mutating=true,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=storage.azure.com,resources=storageaccountsfileservices,verbs=create;update,versions=v1api20220901,name=default.v1api20220901.storageaccountsfileservices.storage.azure.com,admissionReviewVersions=v1

var _ admission.Defaulter = &StorageAccountsFileService{}

// Default applies defaults to the StorageAccountsFileService resource
func (service *StorageAccountsFileService) Default() {
	service.defaultImpl()
	var temp any = service
	if runtimeDefaulter, ok := temp.(genruntime.Defaulter); ok {
		runtimeDefaulter.CustomDefault()
	}
}

// defaultImpl applies the code generated defaults to the StorageAccountsFileService resource
func (service *StorageAccountsFileService) defaultImpl() {}

var _ genruntime.ImportableResource = &StorageAccountsFileService{}

// InitializeSpec initializes the spec for this resource from the given status
func (service *StorageAccountsFileService) InitializeSpec(status genruntime.ConvertibleStatus) error {
	if s, ok := status.(*StorageAccounts_FileService_STATUS); ok {
		return service.Spec.Initialize_From_StorageAccounts_FileService_STATUS(s)
	}

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

var _ genruntime.KubernetesResource = &StorageAccountsFileService{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2022-09-01"
func (service StorageAccountsFileService) GetAPIVersion() string {
	return string(APIVersion_Value)
}

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Storage/storageAccounts/fileServices"
func (service *StorageAccountsFileService) GetType() string {
	return "Microsoft.Storage/storageAccounts/fileServices"
}

// NewEmptyStatus returns a new empty (blank) status
func (service *StorageAccountsFileService) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &StorageAccounts_FileService_STATUS{}
}

// Owner returns the ResourceReference of the owner
func (service *StorageAccountsFileService) Owner() *genruntime.ResourceReference {
	group, kind := genruntime.LookupOwnerGroupKind(service.Spec)
	return service.Spec.Owner.AsResourceReference(group, kind)
}

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

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

	service.Status = st
	return nil
}

// +kubebuilder:webhook:path=/validate-storage-azure-com-v1api20220901-storageaccountsfileservice,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=storage.azure.com,resources=storageaccountsfileservices,verbs=create;update,versions=v1api20220901,name=validate.v1api20220901.storageaccountsfileservices.storage.azure.com,admissionReviewVersions=v1

var _ admission.Validator = &StorageAccountsFileService{}

// ValidateCreate validates the creation of the resource
func (service *StorageAccountsFileService) ValidateCreate() (admission.Warnings, error) {
	validations := service.createValidations()
	var temp any = service
	if runtimeValidator, ok := temp.(genruntime.Validator); ok {
		validations = append(validations, runtimeValidator.CreateValidations()...)
	}
	return genruntime.ValidateCreate(validations)
}

// ValidateDelete validates the deletion of the resource
func (service *StorageAccountsFileService) ValidateDelete() (admission.Warnings, error) {
	validations := service.deleteValidations()
	var temp any = service
	if runtimeValidator, ok := temp.(genruntime.Validator); ok {
		validations = append(validations, runtimeValidator.DeleteValidations()...)
	}
	return genruntime.ValidateDelete(validations)
}

// ValidateUpdate validates an update of the resource
func (service *StorageAccountsFileService) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
	validations := service.updateValidations()
	var temp any = service
	if runtimeValidator, ok := temp.(genruntime.Validator); ok {
		validations = append(validations, runtimeValidator.UpdateValidations()...)
	}
	return genruntime.ValidateUpdate(old, validations)
}

// createValidations validates the creation of the resource
func (service *StorageAccountsFileService) createValidations() []func() (admission.Warnings, error) {
	return []func() (admission.Warnings, error){service.validateResourceReferences, service.validateOwnerReference}
}

// deleteValidations validates the deletion of the resource
func (service *StorageAccountsFileService) deleteValidations() []func() (admission.Warnings, error) {
	return nil
}

// updateValidations validates the update of the resource
func (service *StorageAccountsFileService) updateValidations() []func(old runtime.Object) (admission.Warnings, error) {
	return []func(old runtime.Object) (admission.Warnings, error){
		func(old runtime.Object) (admission.Warnings, error) {
			return service.validateResourceReferences()
		},
		service.validateWriteOnceProperties,
		func(old runtime.Object) (admission.Warnings, error) {
			return service.validateOwnerReference()
		},
	}
}

// validateOwnerReference validates the owner field
func (service *StorageAccountsFileService) validateOwnerReference() (admission.Warnings, error) {
	return genruntime.ValidateOwner(service)
}

// validateResourceReferences validates all resource references
func (service *StorageAccountsFileService) validateResourceReferences() (admission.Warnings, error) {
	refs, err := reflecthelpers.FindResourceReferences(&service.Spec)
	if err != nil {
		return nil, err
	}
	return genruntime.ValidateResourceReferences(refs)
}

// validateWriteOnceProperties validates all WriteOnce properties
func (service *StorageAccountsFileService) validateWriteOnceProperties(old runtime.Object) (admission.Warnings, error) {
	oldObj, ok := old.(*StorageAccountsFileService)
	if !ok {
		return nil, nil
	}

	return genruntime.ValidateWriteOnceProperties(oldObj, service)
}

// AssignProperties_From_StorageAccountsFileService populates our StorageAccountsFileService from the provided source StorageAccountsFileService
func (service *StorageAccountsFileService) AssignProperties_From_StorageAccountsFileService(source *v20220901s.StorageAccountsFileService) error {

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

	// Spec
	var spec StorageAccounts_FileService_Spec
	err := spec.AssignProperties_From_StorageAccounts_FileService_Spec(&source.Spec)
	if err != nil {
		return errors.Wrap(err, "calling AssignProperties_From_StorageAccounts_FileService_Spec() to populate field Spec")
	}
	service.Spec = spec

	// Status
	var status StorageAccounts_FileService_STATUS
	err = status.AssignProperties_From_StorageAccounts_FileService_STATUS(&source.Status)
	if err != nil {
		return errors.Wrap(err, "calling AssignProperties_From_StorageAccounts_FileService_STATUS() to populate field Status")
	}
	service.Status = status

	// No error
	return nil
}

// AssignProperties_To_StorageAccountsFileService populates the provided destination StorageAccountsFileService from our StorageAccountsFileService
func (service *StorageAccountsFileService) AssignProperties_To_StorageAccountsFileService(destination *v20220901s.StorageAccountsFileService) error {

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

	// Spec
	var spec v20220901s.StorageAccounts_FileService_Spec
	err := service.Spec.AssignProperties_To_StorageAccounts_FileService_Spec(&spec)
	if err != nil {
		return errors.Wrap(err, "calling AssignProperties_To_StorageAccounts_FileService_Spec() to populate field Spec")
	}
	destination.Spec = spec

	// Status
	var status v20220901s.StorageAccounts_FileService_STATUS
	err = service.Status.AssignProperties_To_StorageAccounts_FileService_STATUS(&status)
	if err != nil {
		return errors.Wrap(err, "calling AssignProperties_To_StorageAccounts_FileService_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 (service *StorageAccountsFileService) OriginalGVK() *schema.GroupVersionKind {
	return &schema.GroupVersionKind{
		Group:   GroupVersion.Group,
		Version: service.Spec.OriginalVersion(),
		Kind:    "StorageAccountsFileService",
	}
}

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /storage/resource-manager/Microsoft.Storage/stable/2022-09-01/file.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default
type StorageAccountsFileServiceList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []StorageAccountsFileService `json:"items"`
}

type StorageAccounts_FileService_Spec struct {
	// Cors: Specifies CORS rules for the File service. You can include up to five CorsRule elements in the request. If no
	// CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the
	// File service.
	Cors *CorsRules `json:"cors,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 storage.azure.com/StorageAccount resource
	Owner *genruntime.KnownResourceReference `group:"storage.azure.com" json:"owner,omitempty" kind:"StorageAccount"`

	// ProtocolSettings: Protocol settings for file service
	ProtocolSettings *ProtocolSettings `json:"protocolSettings,omitempty"`

	// ShareDeleteRetentionPolicy: The file service properties for share soft delete.
	ShareDeleteRetentionPolicy *DeleteRetentionPolicy `json:"shareDeleteRetentionPolicy,omitempty"`
}

var _ genruntime.ARMTransformer = &StorageAccounts_FileService_Spec{}

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

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

	// Set property "Properties":
	if service.Cors != nil ||
		service.ProtocolSettings != nil ||
		service.ShareDeleteRetentionPolicy != nil {
		result.Properties = &StorageAccounts_FileService_Properties_Spec_ARM{}
	}
	if service.Cors != nil {
		cors_ARM, err := (*service.Cors).ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		cors := *cors_ARM.(*CorsRules_ARM)
		result.Properties.Cors = &cors
	}
	if service.ProtocolSettings != nil {
		protocolSettings_ARM, err := (*service.ProtocolSettings).ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		protocolSettings := *protocolSettings_ARM.(*ProtocolSettings_ARM)
		result.Properties.ProtocolSettings = &protocolSettings
	}
	if service.ShareDeleteRetentionPolicy != nil {
		shareDeleteRetentionPolicy_ARM, err := (*service.ShareDeleteRetentionPolicy).ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		shareDeleteRetentionPolicy := *shareDeleteRetentionPolicy_ARM.(*DeleteRetentionPolicy_ARM)
		result.Properties.ShareDeleteRetentionPolicy = &shareDeleteRetentionPolicy
	}
	return result, nil
}

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (service *StorageAccounts_FileService_Spec) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &StorageAccounts_FileService_Spec_ARM{}
}

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

	// Set property "Cors":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Cors != nil {
			var cors1 CorsRules
			err := cors1.PopulateFromARM(owner, *typedInput.Properties.Cors)
			if err != nil {
				return err
			}
			cors := cors1
			service.Cors = &cors
		}
	}

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

	// Set property "ProtocolSettings":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ProtocolSettings != nil {
			var protocolSettings1 ProtocolSettings
			err := protocolSettings1.PopulateFromARM(owner, *typedInput.Properties.ProtocolSettings)
			if err != nil {
				return err
			}
			protocolSettings := protocolSettings1
			service.ProtocolSettings = &protocolSettings
		}
	}

	// Set property "ShareDeleteRetentionPolicy":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ShareDeleteRetentionPolicy != nil {
			var shareDeleteRetentionPolicy1 DeleteRetentionPolicy
			err := shareDeleteRetentionPolicy1.PopulateFromARM(owner, *typedInput.Properties.ShareDeleteRetentionPolicy)
			if err != nil {
				return err
			}
			shareDeleteRetentionPolicy := shareDeleteRetentionPolicy1
			service.ShareDeleteRetentionPolicy = &shareDeleteRetentionPolicy
		}
	}

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &StorageAccounts_FileService_Spec{}

// ConvertSpecFrom populates our StorageAccounts_FileService_Spec from the provided source
func (service *StorageAccounts_FileService_Spec) ConvertSpecFrom(source genruntime.ConvertibleSpec) error {
	src, ok := source.(*v20220901s.StorageAccounts_FileService_Spec)
	if ok {
		// Populate our instance from source
		return service.AssignProperties_From_StorageAccounts_FileService_Spec(src)
	}

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

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

	return nil
}

// ConvertSpecTo populates the provided destination from our StorageAccounts_FileService_Spec
func (service *StorageAccounts_FileService_Spec) ConvertSpecTo(destination genruntime.ConvertibleSpec) error {
	dst, ok := destination.(*v20220901s.StorageAccounts_FileService_Spec)
	if ok {
		// Populate destination from our instance
		return service.AssignProperties_To_StorageAccounts_FileService_Spec(dst)
	}

	// Convert to an intermediate form
	dst = &v20220901s.StorageAccounts_FileService_Spec{}
	err := service.AssignProperties_To_StorageAccounts_FileService_Spec(dst)
	if err != nil {
		return errors.Wrap(err, "initial step of conversion in ConvertSpecTo()")
	}

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

	return nil
}

// AssignProperties_From_StorageAccounts_FileService_Spec populates our StorageAccounts_FileService_Spec from the provided source StorageAccounts_FileService_Spec
func (service *StorageAccounts_FileService_Spec) AssignProperties_From_StorageAccounts_FileService_Spec(source *v20220901s.StorageAccounts_FileService_Spec) error {

	// Cors
	if source.Cors != nil {
		var cor CorsRules
		err := cor.AssignProperties_From_CorsRules(source.Cors)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_From_CorsRules() to populate field Cors")
		}
		service.Cors = &cor
	} else {
		service.Cors = nil
	}

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

	// ProtocolSettings
	if source.ProtocolSettings != nil {
		var protocolSetting ProtocolSettings
		err := protocolSetting.AssignProperties_From_ProtocolSettings(source.ProtocolSettings)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_From_ProtocolSettings() to populate field ProtocolSettings")
		}
		service.ProtocolSettings = &protocolSetting
	} else {
		service.ProtocolSettings = nil
	}

	// ShareDeleteRetentionPolicy
	if source.ShareDeleteRetentionPolicy != nil {
		var shareDeleteRetentionPolicy DeleteRetentionPolicy
		err := shareDeleteRetentionPolicy.AssignProperties_From_DeleteRetentionPolicy(source.ShareDeleteRetentionPolicy)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_From_DeleteRetentionPolicy() to populate field ShareDeleteRetentionPolicy")
		}
		service.ShareDeleteRetentionPolicy = &shareDeleteRetentionPolicy
	} else {
		service.ShareDeleteRetentionPolicy = nil
	}

	// No error
	return nil
}

// AssignProperties_To_StorageAccounts_FileService_Spec populates the provided destination StorageAccounts_FileService_Spec from our StorageAccounts_FileService_Spec
func (service *StorageAccounts_FileService_Spec) AssignProperties_To_StorageAccounts_FileService_Spec(destination *v20220901s.StorageAccounts_FileService_Spec) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// Cors
	if service.Cors != nil {
		var cor v20220901s.CorsRules
		err := service.Cors.AssignProperties_To_CorsRules(&cor)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_To_CorsRules() to populate field Cors")
		}
		destination.Cors = &cor
	} else {
		destination.Cors = nil
	}

	// OriginalVersion
	destination.OriginalVersion = service.OriginalVersion()

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

	// ProtocolSettings
	if service.ProtocolSettings != nil {
		var protocolSetting v20220901s.ProtocolSettings
		err := service.ProtocolSettings.AssignProperties_To_ProtocolSettings(&protocolSetting)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_To_ProtocolSettings() to populate field ProtocolSettings")
		}
		destination.ProtocolSettings = &protocolSetting
	} else {
		destination.ProtocolSettings = nil
	}

	// ShareDeleteRetentionPolicy
	if service.ShareDeleteRetentionPolicy != nil {
		var shareDeleteRetentionPolicy v20220901s.DeleteRetentionPolicy
		err := service.ShareDeleteRetentionPolicy.AssignProperties_To_DeleteRetentionPolicy(&shareDeleteRetentionPolicy)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_To_DeleteRetentionPolicy() to populate field ShareDeleteRetentionPolicy")
		}
		destination.ShareDeleteRetentionPolicy = &shareDeleteRetentionPolicy
	} else {
		destination.ShareDeleteRetentionPolicy = nil
	}

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

	// No error
	return nil
}

// Initialize_From_StorageAccounts_FileService_STATUS populates our StorageAccounts_FileService_Spec from the provided source StorageAccounts_FileService_STATUS
func (service *StorageAccounts_FileService_Spec) Initialize_From_StorageAccounts_FileService_STATUS(source *StorageAccounts_FileService_STATUS) error {

	// Cors
	if source.Cors != nil {
		var cor CorsRules
		err := cor.Initialize_From_CorsRules_STATUS(source.Cors)
		if err != nil {
			return errors.Wrap(err, "calling Initialize_From_CorsRules_STATUS() to populate field Cors")
		}
		service.Cors = &cor
	} else {
		service.Cors = nil
	}

	// ProtocolSettings
	if source.ProtocolSettings != nil {
		var protocolSetting ProtocolSettings
		err := protocolSetting.Initialize_From_ProtocolSettings_STATUS(source.ProtocolSettings)
		if err != nil {
			return errors.Wrap(err, "calling Initialize_From_ProtocolSettings_STATUS() to populate field ProtocolSettings")
		}
		service.ProtocolSettings = &protocolSetting
	} else {
		service.ProtocolSettings = nil
	}

	// ShareDeleteRetentionPolicy
	if source.ShareDeleteRetentionPolicy != nil {
		var shareDeleteRetentionPolicy DeleteRetentionPolicy
		err := shareDeleteRetentionPolicy.Initialize_From_DeleteRetentionPolicy_STATUS(source.ShareDeleteRetentionPolicy)
		if err != nil {
			return errors.Wrap(err, "calling Initialize_From_DeleteRetentionPolicy_STATUS() to populate field ShareDeleteRetentionPolicy")
		}
		service.ShareDeleteRetentionPolicy = &shareDeleteRetentionPolicy
	} else {
		service.ShareDeleteRetentionPolicy = nil
	}

	// No error
	return nil
}

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

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

	// Cors: Specifies CORS rules for the File service. You can include up to five CorsRule elements in the request. If no
	// CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the
	// File service.
	Cors *CorsRules_STATUS `json:"cors,omitempty"`

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

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

	// ProtocolSettings: Protocol settings for file service
	ProtocolSettings *ProtocolSettings_STATUS `json:"protocolSettings,omitempty"`

	// ShareDeleteRetentionPolicy: The file service properties for share soft delete.
	ShareDeleteRetentionPolicy *DeleteRetentionPolicy_STATUS `json:"shareDeleteRetentionPolicy,omitempty"`

	// Sku: Sku name and tier.
	Sku *Sku_STATUS `json:"sku,omitempty"`

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

var _ genruntime.ConvertibleStatus = &StorageAccounts_FileService_STATUS{}

// ConvertStatusFrom populates our StorageAccounts_FileService_STATUS from the provided source
func (service *StorageAccounts_FileService_STATUS) ConvertStatusFrom(source genruntime.ConvertibleStatus) error {
	src, ok := source.(*v20220901s.StorageAccounts_FileService_STATUS)
	if ok {
		// Populate our instance from source
		return service.AssignProperties_From_StorageAccounts_FileService_STATUS(src)
	}

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

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

	return nil
}

// ConvertStatusTo populates the provided destination from our StorageAccounts_FileService_STATUS
func (service *StorageAccounts_FileService_STATUS) ConvertStatusTo(destination genruntime.ConvertibleStatus) error {
	dst, ok := destination.(*v20220901s.StorageAccounts_FileService_STATUS)
	if ok {
		// Populate destination from our instance
		return service.AssignProperties_To_StorageAccounts_FileService_STATUS(dst)
	}

	// Convert to an intermediate form
	dst = &v20220901s.StorageAccounts_FileService_STATUS{}
	err := service.AssignProperties_To_StorageAccounts_FileService_STATUS(dst)
	if err != nil {
		return errors.Wrap(err, "initial step of conversion in ConvertStatusTo()")
	}

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

	return nil
}

var _ genruntime.FromARMConverter = &StorageAccounts_FileService_STATUS{}

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (service *StorageAccounts_FileService_STATUS) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &StorageAccounts_FileService_STATUS_ARM{}
}

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

	// no assignment for property "Conditions"

	// Set property "Cors":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Cors != nil {
			var cors1 CorsRules_STATUS
			err := cors1.PopulateFromARM(owner, *typedInput.Properties.Cors)
			if err != nil {
				return err
			}
			cors := cors1
			service.Cors = &cors
		}
	}

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

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

	// Set property "ProtocolSettings":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ProtocolSettings != nil {
			var protocolSettings1 ProtocolSettings_STATUS
			err := protocolSettings1.PopulateFromARM(owner, *typedInput.Properties.ProtocolSettings)
			if err != nil {
				return err
			}
			protocolSettings := protocolSettings1
			service.ProtocolSettings = &protocolSettings
		}
	}

	// Set property "ShareDeleteRetentionPolicy":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ShareDeleteRetentionPolicy != nil {
			var shareDeleteRetentionPolicy1 DeleteRetentionPolicy_STATUS
			err := shareDeleteRetentionPolicy1.PopulateFromARM(owner, *typedInput.Properties.ShareDeleteRetentionPolicy)
			if err != nil {
				return err
			}
			shareDeleteRetentionPolicy := shareDeleteRetentionPolicy1
			service.ShareDeleteRetentionPolicy = &shareDeleteRetentionPolicy
		}
	}

	// Set property "Sku":
	if typedInput.Sku != nil {
		var sku1 Sku_STATUS
		err := sku1.PopulateFromARM(owner, *typedInput.Sku)
		if err != nil {
			return err
		}
		sku := sku1
		service.Sku = &sku
	}

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

	// No error
	return nil
}

// AssignProperties_From_StorageAccounts_FileService_STATUS populates our StorageAccounts_FileService_STATUS from the provided source StorageAccounts_FileService_STATUS
func (service *StorageAccounts_FileService_STATUS) AssignProperties_From_StorageAccounts_FileService_STATUS(source *v20220901s.StorageAccounts_FileService_STATUS) error {

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

	// Cors
	if source.Cors != nil {
		var cor CorsRules_STATUS
		err := cor.AssignProperties_From_CorsRules_STATUS(source.Cors)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_From_CorsRules_STATUS() to populate field Cors")
		}
		service.Cors = &cor
	} else {
		service.Cors = nil
	}

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

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

	// ProtocolSettings
	if source.ProtocolSettings != nil {
		var protocolSetting ProtocolSettings_STATUS
		err := protocolSetting.AssignProperties_From_ProtocolSettings_STATUS(source.ProtocolSettings)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_From_ProtocolSettings_STATUS() to populate field ProtocolSettings")
		}
		service.ProtocolSettings = &protocolSetting
	} else {
		service.ProtocolSettings = nil
	}

	// ShareDeleteRetentionPolicy
	if source.ShareDeleteRetentionPolicy != nil {
		var shareDeleteRetentionPolicy DeleteRetentionPolicy_STATUS
		err := shareDeleteRetentionPolicy.AssignProperties_From_DeleteRetentionPolicy_STATUS(source.ShareDeleteRetentionPolicy)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_From_DeleteRetentionPolicy_STATUS() to populate field ShareDeleteRetentionPolicy")
		}
		service.ShareDeleteRetentionPolicy = &shareDeleteRetentionPolicy
	} else {
		service.ShareDeleteRetentionPolicy = nil
	}

	// Sku
	if source.Sku != nil {
		var sku Sku_STATUS
		err := sku.AssignProperties_From_Sku_STATUS(source.Sku)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_From_Sku_STATUS() to populate field Sku")
		}
		service.Sku = &sku
	} else {
		service.Sku = nil
	}

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

	// No error
	return nil
}

// AssignProperties_To_StorageAccounts_FileService_STATUS populates the provided destination StorageAccounts_FileService_STATUS from our StorageAccounts_FileService_STATUS
func (service *StorageAccounts_FileService_STATUS) AssignProperties_To_StorageAccounts_FileService_STATUS(destination *v20220901s.StorageAccounts_FileService_STATUS) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

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

	// Cors
	if service.Cors != nil {
		var cor v20220901s.CorsRules_STATUS
		err := service.Cors.AssignProperties_To_CorsRules_STATUS(&cor)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_To_CorsRules_STATUS() to populate field Cors")
		}
		destination.Cors = &cor
	} else {
		destination.Cors = nil
	}

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

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

	// ProtocolSettings
	if service.ProtocolSettings != nil {
		var protocolSetting v20220901s.ProtocolSettings_STATUS
		err := service.ProtocolSettings.AssignProperties_To_ProtocolSettings_STATUS(&protocolSetting)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_To_ProtocolSettings_STATUS() to populate field ProtocolSettings")
		}
		destination.ProtocolSettings = &protocolSetting
	} else {
		destination.ProtocolSettings = nil
	}

	// ShareDeleteRetentionPolicy
	if service.ShareDeleteRetentionPolicy != nil {
		var shareDeleteRetentionPolicy v20220901s.DeleteRetentionPolicy_STATUS
		err := service.ShareDeleteRetentionPolicy.AssignProperties_To_DeleteRetentionPolicy_STATUS(&shareDeleteRetentionPolicy)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_To_DeleteRetentionPolicy_STATUS() to populate field ShareDeleteRetentionPolicy")
		}
		destination.ShareDeleteRetentionPolicy = &shareDeleteRetentionPolicy
	} else {
		destination.ShareDeleteRetentionPolicy = nil
	}

	// Sku
	if service.Sku != nil {
		var sku v20220901s.Sku_STATUS
		err := service.Sku.AssignProperties_To_Sku_STATUS(&sku)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_To_Sku_STATUS() to populate field Sku")
		}
		destination.Sku = &sku
	} else {
		destination.Sku = nil
	}

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

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

	// No error
	return nil
}

// Protocol settings for file service
type ProtocolSettings struct {
	// Smb: Setting for SMB protocol
	Smb *SmbSetting `json:"smb,omitempty"`
}

var _ genruntime.ARMTransformer = &ProtocolSettings{}

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

	// Set property "Smb":
	if settings.Smb != nil {
		smb_ARM, err := (*settings.Smb).ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		smb := *smb_ARM.(*SmbSetting_ARM)
		result.Smb = &smb
	}
	return result, nil
}

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

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

	// Set property "Smb":
	if typedInput.Smb != nil {
		var smb1 SmbSetting
		err := smb1.PopulateFromARM(owner, *typedInput.Smb)
		if err != nil {
			return err
		}
		smb := smb1
		settings.Smb = &smb
	}

	// No error
	return nil
}

// AssignProperties_From_ProtocolSettings populates our ProtocolSettings from the provided source ProtocolSettings
func (settings *ProtocolSettings) AssignProperties_From_ProtocolSettings(source *v20220901s.ProtocolSettings) error {

	// Smb
	if source.Smb != nil {
		var smb SmbSetting
		err := smb.AssignProperties_From_SmbSetting(source.Smb)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_From_SmbSetting() to populate field Smb")
		}
		settings.Smb = &smb
	} else {
		settings.Smb = nil
	}

	// No error
	return nil
}

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

	// Smb
	if settings.Smb != nil {
		var smb v20220901s.SmbSetting
		err := settings.Smb.AssignProperties_To_SmbSetting(&smb)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_To_SmbSetting() to populate field Smb")
		}
		destination.Smb = &smb
	} else {
		destination.Smb = nil
	}

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

	// No error
	return nil
}

// Initialize_From_ProtocolSettings_STATUS populates our ProtocolSettings from the provided source ProtocolSettings_STATUS
func (settings *ProtocolSettings) Initialize_From_ProtocolSettings_STATUS(source *ProtocolSettings_STATUS) error {

	// Smb
	if source.Smb != nil {
		var smb SmbSetting
		err := smb.Initialize_From_SmbSetting_STATUS(source.Smb)
		if err != nil {
			return errors.Wrap(err, "calling Initialize_From_SmbSetting_STATUS() to populate field Smb")
		}
		settings.Smb = &smb
	} else {
		settings.Smb = nil
	}

	// No error
	return nil
}

// Protocol settings for file service
type ProtocolSettings_STATUS struct {
	// Smb: Setting for SMB protocol
	Smb *SmbSetting_STATUS `json:"smb,omitempty"`
}

var _ genruntime.FromARMConverter = &ProtocolSettings_STATUS{}

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

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

	// Set property "Smb":
	if typedInput.Smb != nil {
		var smb1 SmbSetting_STATUS
		err := smb1.PopulateFromARM(owner, *typedInput.Smb)
		if err != nil {
			return err
		}
		smb := smb1
		settings.Smb = &smb
	}

	// No error
	return nil
}

// AssignProperties_From_ProtocolSettings_STATUS populates our ProtocolSettings_STATUS from the provided source ProtocolSettings_STATUS
func (settings *ProtocolSettings_STATUS) AssignProperties_From_ProtocolSettings_STATUS(source *v20220901s.ProtocolSettings_STATUS) error {

	// Smb
	if source.Smb != nil {
		var smb SmbSetting_STATUS
		err := smb.AssignProperties_From_SmbSetting_STATUS(source.Smb)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_From_SmbSetting_STATUS() to populate field Smb")
		}
		settings.Smb = &smb
	} else {
		settings.Smb = nil
	}

	// No error
	return nil
}

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

	// Smb
	if settings.Smb != nil {
		var smb v20220901s.SmbSetting_STATUS
		err := settings.Smb.AssignProperties_To_SmbSetting_STATUS(&smb)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_To_SmbSetting_STATUS() to populate field Smb")
		}
		destination.Smb = &smb
	} else {
		destination.Smb = nil
	}

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

	// No error
	return nil
}

// Setting for SMB protocol
type SmbSetting struct {
	// AuthenticationMethods: SMB authentication methods supported by server. Valid values are NTLMv2, Kerberos. Should be
	// passed as a string with delimiter ';'.
	AuthenticationMethods *string `json:"authenticationMethods,omitempty"`

	// ChannelEncryption: SMB channel encryption supported by server. Valid values are AES-128-CCM, AES-128-GCM, AES-256-GCM.
	// Should be passed as a string with delimiter ';'.
	ChannelEncryption *string `json:"channelEncryption,omitempty"`

	// KerberosTicketEncryption: Kerberos ticket encryption supported by server. Valid values are RC4-HMAC, AES-256. Should be
	// passed as a string with delimiter ';'
	KerberosTicketEncryption *string `json:"kerberosTicketEncryption,omitempty"`

	// Multichannel: Multichannel setting. Applies to Premium FileStorage only.
	Multichannel *Multichannel `json:"multichannel,omitempty"`

	// Versions: SMB protocol versions supported by server. Valid values are SMB2.1, SMB3.0, SMB3.1.1. Should be passed as a
	// string with delimiter ';'.
	Versions *string `json:"versions,omitempty"`
}

var _ genruntime.ARMTransformer = &SmbSetting{}

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

	// Set property "AuthenticationMethods":
	if setting.AuthenticationMethods != nil {
		authenticationMethods := *setting.AuthenticationMethods
		result.AuthenticationMethods = &authenticationMethods
	}

	// Set property "ChannelEncryption":
	if setting.ChannelEncryption != nil {
		channelEncryption := *setting.ChannelEncryption
		result.ChannelEncryption = &channelEncryption
	}

	// Set property "KerberosTicketEncryption":
	if setting.KerberosTicketEncryption != nil {
		kerberosTicketEncryption := *setting.KerberosTicketEncryption
		result.KerberosTicketEncryption = &kerberosTicketEncryption
	}

	// Set property "Multichannel":
	if setting.Multichannel != nil {
		multichannel_ARM, err := (*setting.Multichannel).ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		multichannel := *multichannel_ARM.(*Multichannel_ARM)
		result.Multichannel = &multichannel
	}

	// Set property "Versions":
	if setting.Versions != nil {
		versions := *setting.Versions
		result.Versions = &versions
	}
	return result, nil
}

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

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

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

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

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

	// Set property "Multichannel":
	if typedInput.Multichannel != nil {
		var multichannel1 Multichannel
		err := multichannel1.PopulateFromARM(owner, *typedInput.Multichannel)
		if err != nil {
			return err
		}
		multichannel := multichannel1
		setting.Multichannel = &multichannel
	}

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

	// No error
	return nil
}

// AssignProperties_From_SmbSetting populates our SmbSetting from the provided source SmbSetting
func (setting *SmbSetting) AssignProperties_From_SmbSetting(source *v20220901s.SmbSetting) error {

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

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

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

	// Multichannel
	if source.Multichannel != nil {
		var multichannel Multichannel
		err := multichannel.AssignProperties_From_Multichannel(source.Multichannel)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_From_Multichannel() to populate field Multichannel")
		}
		setting.Multichannel = &multichannel
	} else {
		setting.Multichannel = nil
	}

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

	// No error
	return nil
}

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

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

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

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

	// Multichannel
	if setting.Multichannel != nil {
		var multichannel v20220901s.Multichannel
		err := setting.Multichannel.AssignProperties_To_Multichannel(&multichannel)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_To_Multichannel() to populate field Multichannel")
		}
		destination.Multichannel = &multichannel
	} else {
		destination.Multichannel = nil
	}

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

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

	// No error
	return nil
}

// Initialize_From_SmbSetting_STATUS populates our SmbSetting from the provided source SmbSetting_STATUS
func (setting *SmbSetting) Initialize_From_SmbSetting_STATUS(source *SmbSetting_STATUS) error {

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

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

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

	// Multichannel
	if source.Multichannel != nil {
		var multichannel Multichannel
		err := multichannel.Initialize_From_Multichannel_STATUS(source.Multichannel)
		if err != nil {
			return errors.Wrap(err, "calling Initialize_From_Multichannel_STATUS() to populate field Multichannel")
		}
		setting.Multichannel = &multichannel
	} else {
		setting.Multichannel = nil
	}

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

	// No error
	return nil
}

// Setting for SMB protocol
type SmbSetting_STATUS struct {
	// AuthenticationMethods: SMB authentication methods supported by server. Valid values are NTLMv2, Kerberos. Should be
	// passed as a string with delimiter ';'.
	AuthenticationMethods *string `json:"authenticationMethods,omitempty"`

	// ChannelEncryption: SMB channel encryption supported by server. Valid values are AES-128-CCM, AES-128-GCM, AES-256-GCM.
	// Should be passed as a string with delimiter ';'.
	ChannelEncryption *string `json:"channelEncryption,omitempty"`

	// KerberosTicketEncryption: Kerberos ticket encryption supported by server. Valid values are RC4-HMAC, AES-256. Should be
	// passed as a string with delimiter ';'
	KerberosTicketEncryption *string `json:"kerberosTicketEncryption,omitempty"`

	// Multichannel: Multichannel setting. Applies to Premium FileStorage only.
	Multichannel *Multichannel_STATUS `json:"multichannel,omitempty"`

	// Versions: SMB protocol versions supported by server. Valid values are SMB2.1, SMB3.0, SMB3.1.1. Should be passed as a
	// string with delimiter ';'.
	Versions *string `json:"versions,omitempty"`
}

var _ genruntime.FromARMConverter = &SmbSetting_STATUS{}

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

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

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

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

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

	// Set property "Multichannel":
	if typedInput.Multichannel != nil {
		var multichannel1 Multichannel_STATUS
		err := multichannel1.PopulateFromARM(owner, *typedInput.Multichannel)
		if err != nil {
			return err
		}
		multichannel := multichannel1
		setting.Multichannel = &multichannel
	}

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

	// No error
	return nil
}

// AssignProperties_From_SmbSetting_STATUS populates our SmbSetting_STATUS from the provided source SmbSetting_STATUS
func (setting *SmbSetting_STATUS) AssignProperties_From_SmbSetting_STATUS(source *v20220901s.SmbSetting_STATUS) error {

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

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

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

	// Multichannel
	if source.Multichannel != nil {
		var multichannel Multichannel_STATUS
		err := multichannel.AssignProperties_From_Multichannel_STATUS(source.Multichannel)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_From_Multichannel_STATUS() to populate field Multichannel")
		}
		setting.Multichannel = &multichannel
	} else {
		setting.Multichannel = nil
	}

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

	// No error
	return nil
}

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

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

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

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

	// Multichannel
	if setting.Multichannel != nil {
		var multichannel v20220901s.Multichannel_STATUS
		err := setting.Multichannel.AssignProperties_To_Multichannel_STATUS(&multichannel)
		if err != nil {
			return errors.Wrap(err, "calling AssignProperties_To_Multichannel_STATUS() to populate field Multichannel")
		}
		destination.Multichannel = &multichannel
	} else {
		destination.Multichannel = nil
	}

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

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

	// No error
	return nil
}

// Multichannel setting. Applies to Premium FileStorage only.
type Multichannel struct {
	// Enabled: Indicates whether multichannel is enabled
	Enabled *bool `json:"enabled,omitempty"`
}

var _ genruntime.ARMTransformer = &Multichannel{}

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

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

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (multichannel *Multichannel) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &Multichannel_ARM{}
}

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

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

	// No error
	return nil
}

// AssignProperties_From_Multichannel populates our Multichannel from the provided source Multichannel
func (multichannel *Multichannel) AssignProperties_From_Multichannel(source *v20220901s.Multichannel) error {

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

	// No error
	return nil
}

// AssignProperties_To_Multichannel populates the provided destination Multichannel from our Multichannel
func (multichannel *Multichannel) AssignProperties_To_Multichannel(destination *v20220901s.Multichannel) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// Enabled
	if multichannel.Enabled != nil {
		enabled := *multichannel.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_Multichannel_STATUS populates our Multichannel from the provided source Multichannel_STATUS
func (multichannel *Multichannel) Initialize_From_Multichannel_STATUS(source *Multichannel_STATUS) error {

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

	// No error
	return nil
}

// Multichannel setting. Applies to Premium FileStorage only.
type Multichannel_STATUS struct {
	// Enabled: Indicates whether multichannel is enabled
	Enabled *bool `json:"enabled,omitempty"`
}

var _ genruntime.FromARMConverter = &Multichannel_STATUS{}

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (multichannel *Multichannel_STATUS) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &Multichannel_STATUS_ARM{}
}

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

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

	// No error
	return nil
}

// AssignProperties_From_Multichannel_STATUS populates our Multichannel_STATUS from the provided source Multichannel_STATUS
func (multichannel *Multichannel_STATUS) AssignProperties_From_Multichannel_STATUS(source *v20220901s.Multichannel_STATUS) error {

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

	// No error
	return nil
}

// AssignProperties_To_Multichannel_STATUS populates the provided destination Multichannel_STATUS from our Multichannel_STATUS
func (multichannel *Multichannel_STATUS) AssignProperties_To_Multichannel_STATUS(destination *v20220901s.Multichannel_STATUS) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// Enabled
	if multichannel.Enabled != nil {
		enabled := *multichannel.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
}

func init() {
	SchemeBuilder.Register(&StorageAccountsFileService{}, &StorageAccountsFileServiceList{})
}
