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

import (
	"fmt"
	v20230201s "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20230201/storage"
	v20231001s "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20231001/storage"
	v20240901s "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20240901/storage"
	v20250301s "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20250301/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,containerservice}
// +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"
// Storage version of v1api20230315preview.FleetsMember
// Generator information:
// - Generated from: /containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2023-03-15-preview/fleets.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}/members/{fleetMemberName}
type FleetsMember struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              FleetsMember_Spec   `json:"spec,omitempty"`
	Status            FleetsMember_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &FleetsMember{}

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

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

var _ conversion.Convertible = &FleetsMember{}

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

	return member.AssignProperties_From_FleetsMember(source)
}

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

	return member.AssignProperties_To_FleetsMember(destination)
}

var _ configmaps.Exporter = &FleetsMember{}

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

var _ secrets.Exporter = &FleetsMember{}

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

var _ genruntime.KubernetesResource = &FleetsMember{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2023-03-15-preview"
func (member FleetsMember) GetAPIVersion() string {
	return "2023-03-15-preview"
}

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.ContainerService/fleets/members"
func (member *FleetsMember) GetType() string {
	return "Microsoft.ContainerService/fleets/members"
}

// NewEmptyStatus returns a new empty (blank) status
func (member *FleetsMember) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &FleetsMember_STATUS{}
}

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

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

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

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

	member.Status = st
	return nil
}

// AssignProperties_From_FleetsMember populates our FleetsMember from the provided source FleetsMember
func (member *FleetsMember) AssignProperties_From_FleetsMember(source *v20250301s.FleetsMember) error {

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

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

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

	// Invoke the augmentConversionForFleetsMember interface (if implemented) to customize the conversion
	var memberAsAny any = member
	if augmentedMember, ok := memberAsAny.(augmentConversionForFleetsMember); ok {
		err := augmentedMember.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// No error
	return nil
}

// AssignProperties_To_FleetsMember populates the provided destination FleetsMember from our FleetsMember
func (member *FleetsMember) AssignProperties_To_FleetsMember(destination *v20250301s.FleetsMember) error {

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

	// Spec
	var spec v20250301s.FleetsMember_Spec
	err := member.Spec.AssignProperties_To_FleetsMember_Spec(&spec)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_To_FleetsMember_Spec() to populate field Spec")
	}
	destination.Spec = spec

	// Status
	var status v20250301s.FleetsMember_STATUS
	err = member.Status.AssignProperties_To_FleetsMember_STATUS(&status)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_To_FleetsMember_STATUS() to populate field Status")
	}
	destination.Status = status

	// Invoke the augmentConversionForFleetsMember interface (if implemented) to customize the conversion
	var memberAsAny any = member
	if augmentedMember, ok := memberAsAny.(augmentConversionForFleetsMember); ok {
		err := augmentedMember.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

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

// +kubebuilder:object:root=true
// Storage version of v1api20230315preview.FleetsMember
// Generator information:
// - Generated from: /containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2023-03-15-preview/fleets.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/fleets/{fleetName}/members/{fleetMemberName}
type FleetsMemberList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []FleetsMember `json:"items"`
}

type augmentConversionForFleetsMember interface {
	AssignPropertiesFrom(src *v20250301s.FleetsMember) error
	AssignPropertiesTo(dst *v20250301s.FleetsMember) error
}

// Storage version of v1api20230315preview.FleetsMember_Spec
type FleetsMember_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"`

	// +kubebuilder:validation:Required
	// ClusterResourceReference: The ARM resource id of the cluster that joins the Fleet. Must be a valid Azure resource id.
	// e.g.:
	// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedClusters/{clusterName}'.
	ClusterResourceReference *genruntime.ResourceReference `armReference:"ClusterResourceId" json:"clusterResourceReference,omitempty"`
	Group                    *string                       `json:"group,omitempty"`
	OperatorSpec             *FleetsMemberOperatorSpec     `json:"operatorSpec,omitempty"`
	OriginalVersion          string                        `json:"originalVersion,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 containerservice.azure.com/Fleet resource
	Owner       *genruntime.KnownResourceReference `group:"containerservice.azure.com" json:"owner,omitempty" kind:"Fleet"`
	PropertyBag genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
}

var _ genruntime.ConvertibleSpec = &FleetsMember_Spec{}

// ConvertSpecFrom populates our FleetsMember_Spec from the provided source
func (member *FleetsMember_Spec) ConvertSpecFrom(source genruntime.ConvertibleSpec) error {
	src, ok := source.(*v20250301s.FleetsMember_Spec)
	if ok {
		// Populate our instance from source
		return member.AssignProperties_From_FleetsMember_Spec(src)
	}

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

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

	return nil
}

// ConvertSpecTo populates the provided destination from our FleetsMember_Spec
func (member *FleetsMember_Spec) ConvertSpecTo(destination genruntime.ConvertibleSpec) error {
	dst, ok := destination.(*v20250301s.FleetsMember_Spec)
	if ok {
		// Populate destination from our instance
		return member.AssignProperties_To_FleetsMember_Spec(dst)
	}

	// Convert to an intermediate form
	dst = &v20250301s.FleetsMember_Spec{}
	err := member.AssignProperties_To_FleetsMember_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_FleetsMember_Spec populates our FleetsMember_Spec from the provided source FleetsMember_Spec
func (member *FleetsMember_Spec) AssignProperties_From_FleetsMember_Spec(source *v20250301s.FleetsMember_Spec) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

	// AzureName
	member.AzureName = source.AzureName

	// ClusterResourceReference
	if source.ClusterResourceReference != nil {
		clusterResourceReference := source.ClusterResourceReference.Copy()
		member.ClusterResourceReference = &clusterResourceReference
	} else {
		member.ClusterResourceReference = nil
	}

	// Group
	member.Group = genruntime.ClonePointerToString(source.Group)

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

	// OriginalVersion
	member.OriginalVersion = source.OriginalVersion

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

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

	// Invoke the augmentConversionForFleetsMember_Spec interface (if implemented) to customize the conversion
	var memberAsAny any = member
	if augmentedMember, ok := memberAsAny.(augmentConversionForFleetsMember_Spec); ok {
		err := augmentedMember.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// No error
	return nil
}

// AssignProperties_To_FleetsMember_Spec populates the provided destination FleetsMember_Spec from our FleetsMember_Spec
func (member *FleetsMember_Spec) AssignProperties_To_FleetsMember_Spec(destination *v20250301s.FleetsMember_Spec) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(member.PropertyBag)

	// AzureName
	destination.AzureName = member.AzureName

	// ClusterResourceReference
	if member.ClusterResourceReference != nil {
		clusterResourceReference := member.ClusterResourceReference.Copy()
		destination.ClusterResourceReference = &clusterResourceReference
	} else {
		destination.ClusterResourceReference = nil
	}

	// Group
	destination.Group = genruntime.ClonePointerToString(member.Group)

	// OperatorSpec
	if member.OperatorSpec != nil {
		var operatorSpec v20250301s.FleetsMemberOperatorSpec
		err := member.OperatorSpec.AssignProperties_To_FleetsMemberOperatorSpec(&operatorSpec)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_FleetsMemberOperatorSpec() to populate field OperatorSpec")
		}
		destination.OperatorSpec = &operatorSpec
	} else {
		destination.OperatorSpec = nil
	}

	// OriginalVersion
	destination.OriginalVersion = member.OriginalVersion

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

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

	// Invoke the augmentConversionForFleetsMember_Spec interface (if implemented) to customize the conversion
	var memberAsAny any = member
	if augmentedMember, ok := memberAsAny.(augmentConversionForFleetsMember_Spec); ok {
		err := augmentedMember.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

// Storage version of v1api20230315preview.FleetsMember_STATUS
type FleetsMember_STATUS struct {
	ClusterResourceId *string                `json:"clusterResourceId,omitempty"`
	Conditions        []conditions.Condition `json:"conditions,omitempty"`
	ETag              *string                `json:"eTag,omitempty"`
	Group             *string                `json:"group,omitempty"`
	Id                *string                `json:"id,omitempty"`
	Name              *string                `json:"name,omitempty"`
	PropertyBag       genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ProvisioningState *string                `json:"provisioningState,omitempty"`
	SystemData        *SystemData_STATUS     `json:"systemData,omitempty"`
	Type              *string                `json:"type,omitempty"`
}

var _ genruntime.ConvertibleStatus = &FleetsMember_STATUS{}

// ConvertStatusFrom populates our FleetsMember_STATUS from the provided source
func (member *FleetsMember_STATUS) ConvertStatusFrom(source genruntime.ConvertibleStatus) error {
	src, ok := source.(*v20250301s.FleetsMember_STATUS)
	if ok {
		// Populate our instance from source
		return member.AssignProperties_From_FleetsMember_STATUS(src)
	}

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

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

	return nil
}

// ConvertStatusTo populates the provided destination from our FleetsMember_STATUS
func (member *FleetsMember_STATUS) ConvertStatusTo(destination genruntime.ConvertibleStatus) error {
	dst, ok := destination.(*v20250301s.FleetsMember_STATUS)
	if ok {
		// Populate destination from our instance
		return member.AssignProperties_To_FleetsMember_STATUS(dst)
	}

	// Convert to an intermediate form
	dst = &v20250301s.FleetsMember_STATUS{}
	err := member.AssignProperties_To_FleetsMember_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
}

// AssignProperties_From_FleetsMember_STATUS populates our FleetsMember_STATUS from the provided source FleetsMember_STATUS
func (member *FleetsMember_STATUS) AssignProperties_From_FleetsMember_STATUS(source *v20250301s.FleetsMember_STATUS) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

	// ClusterResourceId
	member.ClusterResourceId = genruntime.ClonePointerToString(source.ClusterResourceId)

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

	// ETag
	member.ETag = genruntime.ClonePointerToString(source.ETag)

	// Group
	member.Group = genruntime.ClonePointerToString(source.Group)

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

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

	// ProvisioningState
	member.ProvisioningState = genruntime.ClonePointerToString(source.ProvisioningState)

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

	// SystemData
	if source.SystemData != nil {
		var systemDataSTATUSStash v20240901s.SystemData_STATUS
		err := systemDataSTATUSStash.AssignProperties_From_SystemData_STATUS(source.SystemData)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_SystemData_STATUS() to populate field SystemData_STATUSStash from SystemData")
		}
		var systemDataSTATUSStashLocal v20231001s.SystemData_STATUS
		err = systemDataSTATUSStashLocal.AssignProperties_From_SystemData_STATUS(&systemDataSTATUSStash)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_SystemData_STATUS() to populate field SystemData_STATUSStash")
		}
		var systemDataSTATUSStashCopy v20230201s.SystemData_STATUS
		err = systemDataSTATUSStashCopy.AssignProperties_From_SystemData_STATUS(&systemDataSTATUSStashLocal)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_SystemData_STATUS() to populate field SystemData_STATUSStash")
		}
		var systemDatum SystemData_STATUS
		err = systemDatum.AssignProperties_From_SystemData_STATUS(&systemDataSTATUSStashCopy)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_SystemData_STATUS() to populate field SystemData from SystemData_STATUSStash")
		}
		member.SystemData = &systemDatum
	} else {
		member.SystemData = nil
	}

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

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

	// Invoke the augmentConversionForFleetsMember_STATUS interface (if implemented) to customize the conversion
	var memberAsAny any = member
	if augmentedMember, ok := memberAsAny.(augmentConversionForFleetsMember_STATUS); ok {
		err := augmentedMember.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// No error
	return nil
}

// AssignProperties_To_FleetsMember_STATUS populates the provided destination FleetsMember_STATUS from our FleetsMember_STATUS
func (member *FleetsMember_STATUS) AssignProperties_To_FleetsMember_STATUS(destination *v20250301s.FleetsMember_STATUS) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(member.PropertyBag)

	// ClusterResourceId
	destination.ClusterResourceId = genruntime.ClonePointerToString(member.ClusterResourceId)

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

	// ETag
	destination.ETag = genruntime.ClonePointerToString(member.ETag)

	// Group
	destination.Group = genruntime.ClonePointerToString(member.Group)

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

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

	// ProvisioningState
	destination.ProvisioningState = genruntime.ClonePointerToString(member.ProvisioningState)

	// Status
	if propertyBag.Contains("Status") {
		var status v20250301s.FleetMemberStatus_STATUS
		err := propertyBag.Pull("Status", &status)
		if err != nil {
			return eris.Wrap(err, "pulling 'Status' from propertyBag")
		}

		destination.Status = &status
	} else {
		destination.Status = nil
	}

	// SystemData
	if member.SystemData != nil {
		var systemDataSTATUSStash v20230201s.SystemData_STATUS
		err := member.SystemData.AssignProperties_To_SystemData_STATUS(&systemDataSTATUSStash)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_SystemData_STATUS() to populate field SystemData_STATUSStash from SystemData")
		}
		var systemDataSTATUSStashLocal v20231001s.SystemData_STATUS
		err = systemDataSTATUSStash.AssignProperties_To_SystemData_STATUS(&systemDataSTATUSStashLocal)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_SystemData_STATUS() to populate field SystemData_STATUSStash")
		}
		var systemDataSTATUSStashCopy v20240901s.SystemData_STATUS
		err = systemDataSTATUSStashLocal.AssignProperties_To_SystemData_STATUS(&systemDataSTATUSStashCopy)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_SystemData_STATUS() to populate field SystemData_STATUSStash")
		}
		var systemDatum v20250301s.SystemData_STATUS
		err = systemDataSTATUSStashCopy.AssignProperties_To_SystemData_STATUS(&systemDatum)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_SystemData_STATUS() to populate field SystemData from SystemData_STATUSStash")
		}
		destination.SystemData = &systemDatum
	} else {
		destination.SystemData = nil
	}

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

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

	// Invoke the augmentConversionForFleetsMember_STATUS interface (if implemented) to customize the conversion
	var memberAsAny any = member
	if augmentedMember, ok := memberAsAny.(augmentConversionForFleetsMember_STATUS); ok {
		err := augmentedMember.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

type augmentConversionForFleetsMember_Spec interface {
	AssignPropertiesFrom(src *v20250301s.FleetsMember_Spec) error
	AssignPropertiesTo(dst *v20250301s.FleetsMember_Spec) error
}

type augmentConversionForFleetsMember_STATUS interface {
	AssignPropertiesFrom(src *v20250301s.FleetsMember_STATUS) error
	AssignPropertiesTo(dst *v20250301s.FleetsMember_STATUS) error
}

// Storage version of v1api20230315preview.FleetsMemberOperatorSpec
// Details for configuring operator behavior. Fields in this struct are interpreted by the operator directly rather than being passed to Azure
type FleetsMemberOperatorSpec struct {
	ConfigMapExpressions []*core.DestinationExpression `json:"configMapExpressions,omitempty"`
	PropertyBag          genruntime.PropertyBag        `json:"$propertyBag,omitempty"`
	SecretExpressions    []*core.DestinationExpression `json:"secretExpressions,omitempty"`
}

// AssignProperties_From_FleetsMemberOperatorSpec populates our FleetsMemberOperatorSpec from the provided source FleetsMemberOperatorSpec
func (operator *FleetsMemberOperatorSpec) AssignProperties_From_FleetsMemberOperatorSpec(source *v20250301s.FleetsMemberOperatorSpec) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(source.PropertyBag)

	// 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
	}

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

	// Invoke the augmentConversionForFleetsMemberOperatorSpec interface (if implemented) to customize the conversion
	var operatorAsAny any = operator
	if augmentedOperator, ok := operatorAsAny.(augmentConversionForFleetsMemberOperatorSpec); ok {
		err := augmentedOperator.AssignPropertiesFrom(source)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesFrom() for conversion")
		}
	}

	// No error
	return nil
}

// AssignProperties_To_FleetsMemberOperatorSpec populates the provided destination FleetsMemberOperatorSpec from our FleetsMemberOperatorSpec
func (operator *FleetsMemberOperatorSpec) AssignProperties_To_FleetsMemberOperatorSpec(destination *v20250301s.FleetsMemberOperatorSpec) error {
	// Clone the existing property bag
	propertyBag := genruntime.NewPropertyBag(operator.PropertyBag)

	// 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
	}

	// Invoke the augmentConversionForFleetsMemberOperatorSpec interface (if implemented) to customize the conversion
	var operatorAsAny any = operator
	if augmentedOperator, ok := operatorAsAny.(augmentConversionForFleetsMemberOperatorSpec); ok {
		err := augmentedOperator.AssignPropertiesTo(destination)
		if err != nil {
			return eris.Wrap(err, "calling augmented AssignPropertiesTo() for conversion")
		}
	}

	// No error
	return nil
}

type augmentConversionForFleetsMemberOperatorSpec interface {
	AssignPropertiesFrom(src *v20250301s.FleetsMemberOperatorSpec) error
	AssignPropertiesTo(dst *v20250301s.FleetsMemberOperatorSpec) error
}

func init() {
	SchemeBuilder.Register(&FleetsMember{}, &FleetsMemberList{})
}
