// 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=virtualnetworksvirtualnetworkpeerings,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=network.azure.com,resources={virtualnetworksvirtualnetworkpeerings/status,virtualnetworksvirtualnetworkpeerings/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.VirtualNetworksVirtualNetworkPeering
// 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}/virtualNetworkPeerings/{virtualNetworkPeeringName}
type VirtualNetworksVirtualNetworkPeering struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              VirtualNetworksVirtualNetworkPeering_Spec   `json:"spec,omitempty"`
	Status            VirtualNetworksVirtualNetworkPeering_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &VirtualNetworksVirtualNetworkPeering{}

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

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

var _ configmaps.Exporter = &VirtualNetworksVirtualNetworkPeering{}

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

var _ secrets.Exporter = &VirtualNetworksVirtualNetworkPeering{}

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

var _ genruntime.KubernetesResource = &VirtualNetworksVirtualNetworkPeering{}

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

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

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

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

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

// GetSupportedOperations returns the operations supported by the resource
func (peering *VirtualNetworksVirtualNetworkPeering) 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/virtualNetworkPeerings"
func (peering *VirtualNetworksVirtualNetworkPeering) GetType() string {
	return "Microsoft.Network/virtualNetworks/virtualNetworkPeerings"
}

// NewEmptyStatus returns a new empty (blank) status
func (peering *VirtualNetworksVirtualNetworkPeering) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &VirtualNetworksVirtualNetworkPeering_STATUS{}
}

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

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

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

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

	peering.Status = st
	return nil
}

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

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

// +kubebuilder:object:root=true
// Storage version of v1api20240301.VirtualNetworksVirtualNetworkPeering
// 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}/virtualNetworkPeerings/{virtualNetworkPeeringName}
type VirtualNetworksVirtualNetworkPeeringList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []VirtualNetworksVirtualNetworkPeering `json:"items"`
}

// Storage version of v1api20240301.VirtualNetworksVirtualNetworkPeering_Spec
type VirtualNetworksVirtualNetworkPeering_Spec struct {
	AllowForwardedTraffic     *bool `json:"allowForwardedTraffic,omitempty"`
	AllowGatewayTransit       *bool `json:"allowGatewayTransit,omitempty"`
	AllowVirtualNetworkAccess *bool `json:"allowVirtualNetworkAccess,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"`
	DoNotVerifyRemoteGateways       *bool                                             `json:"doNotVerifyRemoteGateways,omitempty"`
	EnableOnlyIPv6Peering           *bool                                             `json:"enableOnlyIPv6Peering,omitempty"`
	LocalAddressSpace               *AddressSpace                                     `json:"localAddressSpace,omitempty"`
	LocalSubnetNames                []string                                          `json:"localSubnetNames,omitempty"`
	LocalVirtualNetworkAddressSpace *AddressSpace                                     `json:"localVirtualNetworkAddressSpace,omitempty"`
	OperatorSpec                    *VirtualNetworksVirtualNetworkPeeringOperatorSpec `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"`
	PeerCompleteVnets                *bool                              `json:"peerCompleteVnets,omitempty"`
	PeeringState                     *string                            `json:"peeringState,omitempty"`
	PeeringSyncLevel                 *string                            `json:"peeringSyncLevel,omitempty"`
	PropertyBag                      genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
	RemoteAddressSpace               *AddressSpace                      `json:"remoteAddressSpace,omitempty"`
	RemoteBgpCommunities             *VirtualNetworkBgpCommunities      `json:"remoteBgpCommunities,omitempty"`
	RemoteSubnetNames                []string                           `json:"remoteSubnetNames,omitempty"`
	RemoteVirtualNetwork             *SubResource                       `json:"remoteVirtualNetwork,omitempty"`
	RemoteVirtualNetworkAddressSpace *AddressSpace                      `json:"remoteVirtualNetworkAddressSpace,omitempty"`
	UseRemoteGateways                *bool                              `json:"useRemoteGateways,omitempty"`
}

var _ genruntime.ConvertibleSpec = &VirtualNetworksVirtualNetworkPeering_Spec{}

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

	return source.ConvertSpecTo(peering)
}

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

	return destination.ConvertSpecFrom(peering)
}

// Storage version of v1api20240301.VirtualNetworksVirtualNetworkPeering_STATUS
type VirtualNetworksVirtualNetworkPeering_STATUS struct {
	AllowForwardedTraffic            *bool                                `json:"allowForwardedTraffic,omitempty"`
	AllowGatewayTransit              *bool                                `json:"allowGatewayTransit,omitempty"`
	AllowVirtualNetworkAccess        *bool                                `json:"allowVirtualNetworkAccess,omitempty"`
	Conditions                       []conditions.Condition               `json:"conditions,omitempty"`
	DoNotVerifyRemoteGateways        *bool                                `json:"doNotVerifyRemoteGateways,omitempty"`
	EnableOnlyIPv6Peering            *bool                                `json:"enableOnlyIPv6Peering,omitempty"`
	Etag                             *string                              `json:"etag,omitempty"`
	Id                               *string                              `json:"id,omitempty"`
	LocalAddressSpace                *AddressSpace_STATUS                 `json:"localAddressSpace,omitempty"`
	LocalSubnetNames                 []string                             `json:"localSubnetNames,omitempty"`
	LocalVirtualNetworkAddressSpace  *AddressSpace_STATUS                 `json:"localVirtualNetworkAddressSpace,omitempty"`
	Name                             *string                              `json:"name,omitempty"`
	PeerCompleteVnets                *bool                                `json:"peerCompleteVnets,omitempty"`
	PeeringState                     *string                              `json:"peeringState,omitempty"`
	PeeringSyncLevel                 *string                              `json:"peeringSyncLevel,omitempty"`
	PropertyBag                      genruntime.PropertyBag               `json:"$propertyBag,omitempty"`
	ProvisioningState                *string                              `json:"provisioningState,omitempty"`
	RemoteAddressSpace               *AddressSpace_STATUS                 `json:"remoteAddressSpace,omitempty"`
	RemoteBgpCommunities             *VirtualNetworkBgpCommunities_STATUS `json:"remoteBgpCommunities,omitempty"`
	RemoteSubnetNames                []string                             `json:"remoteSubnetNames,omitempty"`
	RemoteVirtualNetwork             *SubResource_STATUS                  `json:"remoteVirtualNetwork,omitempty"`
	RemoteVirtualNetworkAddressSpace *AddressSpace_STATUS                 `json:"remoteVirtualNetworkAddressSpace,omitempty"`
	RemoteVirtualNetworkEncryption   *VirtualNetworkEncryption_STATUS     `json:"remoteVirtualNetworkEncryption,omitempty"`
	ResourceGuid                     *string                              `json:"resourceGuid,omitempty"`
	Type                             *string                              `json:"type,omitempty"`
	UseRemoteGateways                *bool                                `json:"useRemoteGateways,omitempty"`
}

var _ genruntime.ConvertibleStatus = &VirtualNetworksVirtualNetworkPeering_STATUS{}

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

	return source.ConvertStatusTo(peering)
}

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

	return destination.ConvertStatusFrom(peering)
}

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

func init() {
	SchemeBuilder.Register(&VirtualNetworksVirtualNetworkPeering{}, &VirtualNetworksVirtualNetworkPeeringList{})
}
