// 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=compute.azure.com,resources=availabilitysets,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=compute.azure.com,resources={availabilitysets/status,availabilitysets/finalizers},verbs=get;update;patch

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,compute}
// +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 v1api20241101.AvailabilitySet
// Generator information:
// - Generated from: /compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-11-01/ComputeRP.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}
type AvailabilitySet struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              AvailabilitySet_Spec   `json:"spec,omitempty"`
	Status            AvailabilitySet_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &AvailabilitySet{}

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

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

var _ configmaps.Exporter = &AvailabilitySet{}

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

var _ secrets.Exporter = &AvailabilitySet{}

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

var _ genruntime.KubernetesResource = &AvailabilitySet{}

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

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

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Compute/availabilitySets"
func (availabilitySet *AvailabilitySet) GetType() string {
	return "Microsoft.Compute/availabilitySets"
}

// NewEmptyStatus returns a new empty (blank) status
func (availabilitySet *AvailabilitySet) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &AvailabilitySet_STATUS{}
}

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

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

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

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

	availabilitySet.Status = st
	return nil
}

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

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

// +kubebuilder:object:root=true
// Storage version of v1api20241101.AvailabilitySet
// Generator information:
// - Generated from: /compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-11-01/ComputeRP.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}
type AvailabilitySetList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []AvailabilitySet `json:"items"`
}

// Storage version of v1api20241101.APIVersion
// +kubebuilder:validation:Enum={"2024-11-01"}
type APIVersion string

const APIVersion_Value = APIVersion("2024-11-01")

// Storage version of v1api20241101.AvailabilitySet_Spec
type AvailabilitySet_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"`
	Location        *string                      `json:"location,omitempty"`
	OperatorSpec    *AvailabilitySetOperatorSpec `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 resources.azure.com/ResourceGroup resource
	Owner                     *genruntime.KnownResourceReference `group:"resources.azure.com" json:"owner,omitempty" kind:"ResourceGroup"`
	PlatformFaultDomainCount  *int                               `json:"platformFaultDomainCount,omitempty"`
	PlatformUpdateDomainCount *int                               `json:"platformUpdateDomainCount,omitempty"`
	PropertyBag               genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
	ProximityPlacementGroup   *SubResource                       `json:"proximityPlacementGroup,omitempty"`
	ScheduledEventsPolicy     *ScheduledEventsPolicy             `json:"scheduledEventsPolicy,omitempty"`
	Sku                       *Sku                               `json:"sku,omitempty"`
	Tags                      map[string]string                  `json:"tags,omitempty"`
}

var _ genruntime.ConvertibleSpec = &AvailabilitySet_Spec{}

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

	return source.ConvertSpecTo(availabilitySet)
}

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

	return destination.ConvertSpecFrom(availabilitySet)
}

// Storage version of v1api20241101.AvailabilitySet_STATUS
// Specifies information about the availability set that the virtual machine should be assigned to. Virtual machines
// specified in the same availability set are allocated to different nodes to maximize availability. For more information
// about availability sets, see [Availability sets
// overview](https://docs.microsoft.com/azure/virtual-machines/availability-set-overview). For more information on Azure
// planned maintenance, see [Maintenance and updates for Virtual Machines in
// Azure](https://docs.microsoft.com/azure/virtual-machines/maintenance-and-updates). Currently, a VM can only be added to
// an availability set at creation time. An existing VM cannot be added to an availability set.
type AvailabilitySet_STATUS struct {
	Conditions                          []conditions.Condition                      `json:"conditions,omitempty"`
	Id                                  *string                                     `json:"id,omitempty"`
	Location                            *string                                     `json:"location,omitempty"`
	Name                                *string                                     `json:"name,omitempty"`
	PlatformFaultDomainCount            *int                                        `json:"platformFaultDomainCount,omitempty"`
	PlatformUpdateDomainCount           *int                                        `json:"platformUpdateDomainCount,omitempty"`
	PropertyBag                         genruntime.PropertyBag                      `json:"$propertyBag,omitempty"`
	ProximityPlacementGroup             *SubResource_STATUS                         `json:"proximityPlacementGroup,omitempty"`
	ScheduledEventsPolicy               *ScheduledEventsPolicy_STATUS               `json:"scheduledEventsPolicy,omitempty"`
	Sku                                 *Sku_STATUS                                 `json:"sku,omitempty"`
	Statuses                            []InstanceViewStatus_STATUS                 `json:"statuses,omitempty"`
	SystemData                          *SystemData_STATUS                          `json:"systemData,omitempty"`
	Tags                                map[string]string                           `json:"tags,omitempty"`
	Type                                *string                                     `json:"type,omitempty"`
	VirtualMachineScaleSetMigrationInfo *VirtualMachineScaleSetMigrationInfo_STATUS `json:"virtualMachineScaleSetMigrationInfo,omitempty"`
	VirtualMachines                     []SubResource_STATUS                        `json:"virtualMachines,omitempty"`
}

var _ genruntime.ConvertibleStatus = &AvailabilitySet_STATUS{}

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

	return source.ConvertStatusTo(availabilitySet)
}

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

	return destination.ConvertStatusFrom(availabilitySet)
}

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

// Storage version of v1api20241101.InstanceViewStatus_STATUS
// Instance view status.
type InstanceViewStatus_STATUS struct {
	Code          *string                `json:"code,omitempty"`
	DisplayStatus *string                `json:"displayStatus,omitempty"`
	Level         *string                `json:"level,omitempty"`
	Message       *string                `json:"message,omitempty"`
	PropertyBag   genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Time          *string                `json:"time,omitempty"`
}

// Storage version of v1api20241101.ScheduledEventsPolicy
// Specifies Redeploy, Reboot and ScheduledEventsAdditionalPublishingTargets Scheduled Event related configurations.
type ScheduledEventsPolicy struct {
	PropertyBag                                genruntime.PropertyBag                      `json:"$propertyBag,omitempty"`
	ScheduledEventsAdditionalPublishingTargets *ScheduledEventsAdditionalPublishingTargets `json:"scheduledEventsAdditionalPublishingTargets,omitempty"`
	UserInitiatedReboot                        *UserInitiatedReboot                        `json:"userInitiatedReboot,omitempty"`
	UserInitiatedRedeploy                      *UserInitiatedRedeploy                      `json:"userInitiatedRedeploy,omitempty"`
}

// Storage version of v1api20241101.ScheduledEventsPolicy_STATUS
// Specifies Redeploy, Reboot and ScheduledEventsAdditionalPublishingTargets Scheduled Event related configurations.
type ScheduledEventsPolicy_STATUS struct {
	PropertyBag                                genruntime.PropertyBag                             `json:"$propertyBag,omitempty"`
	ScheduledEventsAdditionalPublishingTargets *ScheduledEventsAdditionalPublishingTargets_STATUS `json:"scheduledEventsAdditionalPublishingTargets,omitempty"`
	UserInitiatedReboot                        *UserInitiatedReboot_STATUS                        `json:"userInitiatedReboot,omitempty"`
	UserInitiatedRedeploy                      *UserInitiatedRedeploy_STATUS                      `json:"userInitiatedRedeploy,omitempty"`
}

// Storage version of v1api20241101.Sku
// Describes a virtual machine scale set sku. NOTE: If the new VM SKU is not supported on the hardware the scale set is
// currently on, you need to deallocate the VMs in the scale set before you modify the SKU name.
type Sku struct {
	Capacity    *int                   `json:"capacity,omitempty"`
	Name        *string                `json:"name,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Tier        *string                `json:"tier,omitempty"`
}

// Storage version of v1api20241101.Sku_STATUS
// Describes a virtual machine scale set sku. NOTE: If the new VM SKU is not supported on the hardware the scale set is
// currently on, you need to deallocate the VMs in the scale set before you modify the SKU name.
type Sku_STATUS struct {
	Capacity    *int                   `json:"capacity,omitempty"`
	Name        *string                `json:"name,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Tier        *string                `json:"tier,omitempty"`
}

// Storage version of v1api20241101.SubResource
type SubResource struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`

	// Reference: Resource Id
	Reference *genruntime.ResourceReference `armReference:"Id" json:"reference,omitempty"`
}

// Storage version of v1api20241101.SubResource_STATUS
type SubResource_STATUS struct {
	Id          *string                `json:"id,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20241101.SystemData_STATUS
// Metadata pertaining to creation and last modification of the resource.
type SystemData_STATUS struct {
	CreatedAt          *string                `json:"createdAt,omitempty"`
	CreatedBy          *string                `json:"createdBy,omitempty"`
	CreatedByType      *string                `json:"createdByType,omitempty"`
	LastModifiedAt     *string                `json:"lastModifiedAt,omitempty"`
	LastModifiedBy     *string                `json:"lastModifiedBy,omitempty"`
	LastModifiedByType *string                `json:"lastModifiedByType,omitempty"`
	PropertyBag        genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20241101.VirtualMachineScaleSetMigrationInfo_STATUS
// Describes the Availability Set properties related to migration to Flexible Virtual Machine Scale Set.
type VirtualMachineScaleSetMigrationInfo_STATUS struct {
	DefaultVirtualMachineScaleSetInfo *DefaultVirtualMachineScaleSetInfo_STATUS `json:"defaultVirtualMachineScaleSetInfo,omitempty"`
	MigrateToVirtualMachineScaleSet   *SubResource_STATUS                       `json:"migrateToVirtualMachineScaleSet,omitempty"`
	PropertyBag                       genruntime.PropertyBag                    `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20241101.DefaultVirtualMachineScaleSetInfo_STATUS
// Indicates the target Virtual Machine ScaleSet properties upon triggering a seamless migration without downtime of the
// VMs via the ConvertToVirtualMachineScaleSet API.
type DefaultVirtualMachineScaleSetInfo_STATUS struct {
	ConstrainedMaximumCapacity    *bool                  `json:"constrainedMaximumCapacity,omitempty"`
	DefaultVirtualMachineScaleSet *SubResource_STATUS    `json:"defaultVirtualMachineScaleSet,omitempty"`
	PropertyBag                   genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20241101.ScheduledEventsAdditionalPublishingTargets
type ScheduledEventsAdditionalPublishingTargets struct {
	EventGridAndResourceGraph *EventGridAndResourceGraph `json:"eventGridAndResourceGraph,omitempty"`
	PropertyBag               genruntime.PropertyBag     `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20241101.ScheduledEventsAdditionalPublishingTargets_STATUS
type ScheduledEventsAdditionalPublishingTargets_STATUS struct {
	EventGridAndResourceGraph *EventGridAndResourceGraph_STATUS `json:"eventGridAndResourceGraph,omitempty"`
	PropertyBag               genruntime.PropertyBag            `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20241101.UserInitiatedReboot
// Specifies Reboot related Scheduled Event related configurations.
type UserInitiatedReboot struct {
	AutomaticallyApprove *bool                  `json:"automaticallyApprove,omitempty"`
	PropertyBag          genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20241101.UserInitiatedReboot_STATUS
// Specifies Reboot related Scheduled Event related configurations.
type UserInitiatedReboot_STATUS struct {
	AutomaticallyApprove *bool                  `json:"automaticallyApprove,omitempty"`
	PropertyBag          genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20241101.UserInitiatedRedeploy
// Specifies Redeploy related Scheduled Event related configurations.
type UserInitiatedRedeploy struct {
	AutomaticallyApprove *bool                  `json:"automaticallyApprove,omitempty"`
	PropertyBag          genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20241101.UserInitiatedRedeploy_STATUS
// Specifies Redeploy related Scheduled Event related configurations.
type UserInitiatedRedeploy_STATUS struct {
	AutomaticallyApprove *bool                  `json:"automaticallyApprove,omitempty"`
	PropertyBag          genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20241101.EventGridAndResourceGraph
// Specifies eventGridAndResourceGraph related Scheduled Event related configurations.
type EventGridAndResourceGraph struct {
	Enable      *bool                  `json:"enable,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20241101.EventGridAndResourceGraph_STATUS
// Specifies eventGridAndResourceGraph related Scheduled Event related configurations.
type EventGridAndResourceGraph_STATUS struct {
	Enable      *bool                  `json:"enable,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

func init() {
	SchemeBuilder.Register(&AvailabilitySet{}, &AvailabilitySetList{})
}
