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

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,network}
// +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 v1api20240301.VirtualNetworksSubnet
// Generator information:
// - Generated from: /network/resource-manager/Microsoft.Network/stable/2024-03-01/virtualNetwork.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}
type VirtualNetworksSubnet struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              VirtualNetworksSubnet_Spec   `json:"spec,omitempty"`
	Status            VirtualNetworksSubnet_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &VirtualNetworksSubnet{}

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

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

var _ configmaps.Exporter = &VirtualNetworksSubnet{}

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

var _ secrets.Exporter = &VirtualNetworksSubnet{}

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

var _ genruntime.KubernetesResource = &VirtualNetworksSubnet{}

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

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

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Network/virtualNetworks/subnets"
func (subnet *VirtualNetworksSubnet) GetType() string {
	return "Microsoft.Network/virtualNetworks/subnets"
}

// NewEmptyStatus returns a new empty (blank) status
func (subnet *VirtualNetworksSubnet) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &VirtualNetworksSubnet_STATUS{}
}

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

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

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

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

	subnet.Status = st
	return nil
}

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

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

// +kubebuilder:object:root=true
// Storage version of v1api20240301.VirtualNetworksSubnet
// Generator information:
// - Generated from: /network/resource-manager/Microsoft.Network/stable/2024-03-01/virtualNetwork.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}
type VirtualNetworksSubnetList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []VirtualNetworksSubnet `json:"items"`
}

// Storage version of v1api20240301.VirtualNetworksSubnet_Spec
type VirtualNetworksSubnet_Spec struct {
	AddressPrefix                      *string                                                                        `json:"addressPrefix,omitempty"`
	AddressPrefixes                    []string                                                                       `json:"addressPrefixes,omitempty"`
	ApplicationGatewayIPConfigurations []ApplicationGatewayIPConfiguration_VirtualNetworks_Subnet_SubResourceEmbedded `json:"applicationGatewayIPConfigurations,omitempty"`

	// 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"`
	DefaultOutboundAccess *bool                                                                `json:"defaultOutboundAccess,omitempty"`
	Delegations           []Delegation                                                         `json:"delegations,omitempty"`
	IpAllocations         []SubResource                                                        `json:"ipAllocations,omitempty"`
	NatGateway            *SubResource                                                         `json:"natGateway,omitempty"`
	NetworkSecurityGroup  *NetworkSecurityGroupSpec_VirtualNetworks_Subnet_SubResourceEmbedded `json:"networkSecurityGroup,omitempty"`
	OperatorSpec          *VirtualNetworksSubnetOperatorSpec                                   `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 network.azure.com/VirtualNetwork resource
	Owner                             *genruntime.KnownResourceReference                                     `group:"network.azure.com" json:"owner,omitempty" kind:"VirtualNetwork"`
	PrivateEndpointNetworkPolicies    *string                                                                `json:"privateEndpointNetworkPolicies,omitempty"`
	PrivateLinkServiceNetworkPolicies *string                                                                `json:"privateLinkServiceNetworkPolicies,omitempty"`
	PropertyBag                       genruntime.PropertyBag                                                 `json:"$propertyBag,omitempty"`
	RouteTable                        *RouteTableSpec_VirtualNetworks_Subnet_SubResourceEmbedded             `json:"routeTable,omitempty"`
	ServiceEndpointPolicies           []ServiceEndpointPolicySpec_VirtualNetworks_Subnet_SubResourceEmbedded `json:"serviceEndpointPolicies,omitempty"`
	ServiceEndpoints                  []ServiceEndpointPropertiesFormat                                      `json:"serviceEndpoints,omitempty"`
	SharingScope                      *string                                                                `json:"sharingScope,omitempty"`
}

var _ genruntime.ConvertibleSpec = &VirtualNetworksSubnet_Spec{}

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

	return source.ConvertSpecTo(subnet)
}

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

	return destination.ConvertSpecFrom(subnet)
}

// Storage version of v1api20240301.VirtualNetworksSubnet_STATUS
type VirtualNetworksSubnet_STATUS struct {
	AddressPrefix                      *string                                                                               `json:"addressPrefix,omitempty"`
	AddressPrefixes                    []string                                                                              `json:"addressPrefixes,omitempty"`
	ApplicationGatewayIPConfigurations []ApplicationGatewayIPConfiguration_STATUS_VirtualNetworks_Subnet_SubResourceEmbedded `json:"applicationGatewayIPConfigurations,omitempty"`
	Conditions                         []conditions.Condition                                                                `json:"conditions,omitempty"`
	DefaultOutboundAccess              *bool                                                                                 `json:"defaultOutboundAccess,omitempty"`
	Delegations                        []Delegation_STATUS                                                                   `json:"delegations,omitempty"`
	Etag                               *string                                                                               `json:"etag,omitempty"`
	Id                                 *string                                                                               `json:"id,omitempty"`
	IpAllocations                      []SubResource_STATUS                                                                  `json:"ipAllocations,omitempty"`
	IpConfigurationProfiles            []IPConfigurationProfile_STATUS                                                       `json:"ipConfigurationProfiles,omitempty"`
	IpConfigurations                   []IPConfiguration_STATUS_VirtualNetworks_Subnet_SubResourceEmbedded                   `json:"ipConfigurations,omitempty"`
	Name                               *string                                                                               `json:"name,omitempty"`
	NatGateway                         *SubResource_STATUS                                                                   `json:"natGateway,omitempty"`
	NetworkSecurityGroup               *NetworkSecurityGroup_STATUS_VirtualNetworks_Subnet_SubResourceEmbedded               `json:"networkSecurityGroup,omitempty"`
	PrivateEndpointNetworkPolicies     *string                                                                               `json:"privateEndpointNetworkPolicies,omitempty"`
	PrivateEndpoints                   []PrivateEndpoint_STATUS_VirtualNetworks_Subnet_SubResourceEmbedded                   `json:"privateEndpoints,omitempty"`
	PrivateLinkServiceNetworkPolicies  *string                                                                               `json:"privateLinkServiceNetworkPolicies,omitempty"`
	PropertyBag                        genruntime.PropertyBag                                                                `json:"$propertyBag,omitempty"`
	ProvisioningState                  *string                                                                               `json:"provisioningState,omitempty"`
	Purpose                            *string                                                                               `json:"purpose,omitempty"`
	ResourceNavigationLinks            []ResourceNavigationLink_STATUS                                                       `json:"resourceNavigationLinks,omitempty"`
	RouteTable                         *RouteTable_STATUS_SubResourceEmbedded                                                `json:"routeTable,omitempty"`
	ServiceAssociationLinks            []ServiceAssociationLink_STATUS                                                       `json:"serviceAssociationLinks,omitempty"`
	ServiceEndpointPolicies            []ServiceEndpointPolicy_STATUS_VirtualNetworks_Subnet_SubResourceEmbedded             `json:"serviceEndpointPolicies,omitempty"`
	ServiceEndpoints                   []ServiceEndpointPropertiesFormat_STATUS                                              `json:"serviceEndpoints,omitempty"`
	SharingScope                       *string                                                                               `json:"sharingScope,omitempty"`
	Type                               *string                                                                               `json:"type,omitempty"`
}

var _ genruntime.ConvertibleStatus = &VirtualNetworksSubnet_STATUS{}

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

	return source.ConvertStatusTo(subnet)
}

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

	return destination.ConvertStatusFrom(subnet)
}

// Storage version of v1api20240301.ApplicationGatewayIPConfiguration_STATUS_VirtualNetworks_Subnet_SubResourceEmbedded
// IP configuration of an application gateway. Currently 1 public and 1 private IP configuration is allowed.
type ApplicationGatewayIPConfiguration_STATUS_VirtualNetworks_Subnet_SubResourceEmbedded struct {
	Id          *string                `json:"id,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20240301.ApplicationGatewayIPConfiguration_VirtualNetworks_Subnet_SubResourceEmbedded
// IP configuration of an application gateway. Currently 1 public and 1 private IP configuration is allowed.
type ApplicationGatewayIPConfiguration_VirtualNetworks_Subnet_SubResourceEmbedded struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`

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

// Storage version of v1api20240301.Delegation
// Details the service to which the subnet is delegated.
type Delegation struct {
	Name        *string                `json:"name,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ServiceName *string                `json:"serviceName,omitempty"`
}

// Storage version of v1api20240301.Delegation_STATUS
// Details the service to which the subnet is delegated.
type Delegation_STATUS struct {
	Actions           []string               `json:"actions,omitempty"`
	Etag              *string                `json:"etag,omitempty"`
	Id                *string                `json:"id,omitempty"`
	Name              *string                `json:"name,omitempty"`
	PropertyBag       genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ProvisioningState *string                `json:"provisioningState,omitempty"`
	ServiceName       *string                `json:"serviceName,omitempty"`
	Type              *string                `json:"type,omitempty"`
}

// Storage version of v1api20240301.IPConfiguration_STATUS_VirtualNetworks_Subnet_SubResourceEmbedded
// IP configuration.
type IPConfiguration_STATUS_VirtualNetworks_Subnet_SubResourceEmbedded struct {
	Id          *string                `json:"id,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20240301.IPConfigurationProfile_STATUS
// IP configuration profile child resource.
type IPConfigurationProfile_STATUS struct {
	Id          *string                `json:"id,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20240301.NetworkSecurityGroup_STATUS_VirtualNetworks_Subnet_SubResourceEmbedded
// NetworkSecurityGroup resource.
type NetworkSecurityGroup_STATUS_VirtualNetworks_Subnet_SubResourceEmbedded struct {
	Id          *string                `json:"id,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20240301.NetworkSecurityGroupSpec_VirtualNetworks_Subnet_SubResourceEmbedded
// NetworkSecurityGroup resource.
type NetworkSecurityGroupSpec_VirtualNetworks_Subnet_SubResourceEmbedded struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`

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

// Storage version of v1api20240301.PrivateEndpoint_STATUS_VirtualNetworks_Subnet_SubResourceEmbedded
// Private endpoint resource.
type PrivateEndpoint_STATUS_VirtualNetworks_Subnet_SubResourceEmbedded struct {
	Id          *string                `json:"id,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20240301.ResourceNavigationLink_STATUS
// ResourceNavigationLink resource.
type ResourceNavigationLink_STATUS struct {
	Id          *string                `json:"id,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20240301.RouteTable_STATUS_SubResourceEmbedded
// Route table resource.
type RouteTable_STATUS_SubResourceEmbedded struct {
	Id          *string                `json:"id,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20240301.RouteTableSpec_VirtualNetworks_Subnet_SubResourceEmbedded
// Route table resource.
type RouteTableSpec_VirtualNetworks_Subnet_SubResourceEmbedded struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`

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

// Storage version of v1api20240301.ServiceAssociationLink_STATUS
// ServiceAssociationLink resource.
type ServiceAssociationLink_STATUS struct {
	Id          *string                `json:"id,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20240301.ServiceEndpointPolicy_STATUS_VirtualNetworks_Subnet_SubResourceEmbedded
// Service End point policy resource.
type ServiceEndpointPolicy_STATUS_VirtualNetworks_Subnet_SubResourceEmbedded struct {
	Id          *string                `json:"id,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20240301.ServiceEndpointPolicySpec_VirtualNetworks_Subnet_SubResourceEmbedded
// Service End point policy resource.
type ServiceEndpointPolicySpec_VirtualNetworks_Subnet_SubResourceEmbedded struct {
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`

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

// Storage version of v1api20240301.ServiceEndpointPropertiesFormat
// The service endpoint properties.
type ServiceEndpointPropertiesFormat struct {
	Locations         []string               `json:"locations,omitempty"`
	NetworkIdentifier *SubResource           `json:"networkIdentifier,omitempty"`
	PropertyBag       genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Service           *string                `json:"service,omitempty"`
}

// Storage version of v1api20240301.ServiceEndpointPropertiesFormat_STATUS
// The service endpoint properties.
type ServiceEndpointPropertiesFormat_STATUS struct {
	Locations         []string               `json:"locations,omitempty"`
	NetworkIdentifier *SubResource_STATUS    `json:"networkIdentifier,omitempty"`
	PropertyBag       genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ProvisioningState *string                `json:"provisioningState,omitempty"`
	Service           *string                `json:"service,omitempty"`
}

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

func init() {
	SchemeBuilder.Register(&VirtualNetworksSubnet{}, &VirtualNetworksSubnetList{})
}
