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

import (
	"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"
)

// +kubebuilder:rbac:groups=containerservice.azure.com,resources=fleetsmembers,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=containerservice.azure.com,resources={fleetsmembers/status,fleetsmembers/finalizers},verbs=get;update;patch

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,containerservice}
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +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 v1api20250301.FleetsMember
// Generator information:
// - Generated from: /containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2025-03-01/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 _ 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 "2025-03-01"
func (member FleetsMember) GetAPIVersion() string {
	return "2025-03-01"
}

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

// Hub marks that this FleetsMember is the hub type for conversion
func (member *FleetsMember) Hub() {}

// 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 v1api20250301.FleetsMember
// Generator information:
// - Generated from: /containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2025-03-01/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"`
}

// Storage version of v1api20250301.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 {
	if source == member {
		return eris.New("attempted conversion between unrelated implementations of github.com/Azure/azure-service-operator/v2/pkg/genruntime/ConvertibleSpec")
	}

	return source.ConvertSpecTo(member)
}

// ConvertSpecTo populates the provided destination from our FleetsMember_Spec
func (member *FleetsMember_Spec) ConvertSpecTo(destination genruntime.ConvertibleSpec) error {
	if destination == member {
		return eris.New("attempted conversion between unrelated implementations of github.com/Azure/azure-service-operator/v2/pkg/genruntime/ConvertibleSpec")
	}

	return destination.ConvertSpecFrom(member)
}

// Storage version of v1api20250301.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"`
	Status            *FleetMemberStatus_STATUS `json:"status,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 {
	if source == member {
		return eris.New("attempted conversion between unrelated implementations of github.com/Azure/azure-service-operator/v2/pkg/genruntime/ConvertibleStatus")
	}

	return source.ConvertStatusTo(member)
}

// ConvertStatusTo populates the provided destination from our FleetsMember_STATUS
func (member *FleetsMember_STATUS) ConvertStatusTo(destination genruntime.ConvertibleStatus) error {
	if destination == member {
		return eris.New("attempted conversion between unrelated implementations of github.com/Azure/azure-service-operator/v2/pkg/genruntime/ConvertibleStatus")
	}

	return destination.ConvertStatusFrom(member)
}

// Storage version of v1api20250301.FleetMemberStatus_STATUS
// Status information for the fleet member
type FleetMemberStatus_STATUS struct {
	LastOperationError *ErrorDetail_STATUS    `json:"lastOperationError,omitempty"`
	LastOperationId    *string                `json:"lastOperationId,omitempty"`
	PropertyBag        genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20250301.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"`
}

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