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

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,insights}
// +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 v1api20171001.PricingPlan
// Generator information:
// - Generated from: /applicationinsights/resource-manager/Microsoft.Insights/preview/2017-10-01/componentFeaturesAndPricing_API.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/pricingPlans/current
type PricingPlan struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              PricingPlan_Spec   `json:"spec,omitempty"`
	Status            PricingPlan_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &PricingPlan{}

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

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

var _ configmaps.Exporter = &PricingPlan{}

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

var _ secrets.Exporter = &PricingPlan{}

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

var _ genruntime.KubernetesResource = &PricingPlan{}

// AzureName returns the Azure name of the resource (always "current")
func (plan *PricingPlan) AzureName() string {
	return "current"
}

// GetAPIVersion returns the ARM API version of the resource. This is always "2017-10-01"
func (plan PricingPlan) GetAPIVersion() string {
	return "2017-10-01"
}

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "microsoft.insights/components/pricingPlans"
func (plan *PricingPlan) GetType() string {
	return "microsoft.insights/components/pricingPlans"
}

// NewEmptyStatus returns a new empty (blank) status
func (plan *PricingPlan) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &PricingPlan_STATUS{}
}

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

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

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

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

	plan.Status = st
	return nil
}

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

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

// +kubebuilder:object:root=true
// Storage version of v1api20171001.PricingPlan
// Generator information:
// - Generated from: /applicationinsights/resource-manager/Microsoft.Insights/preview/2017-10-01/componentFeaturesAndPricing_API.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/pricingPlans/current
type PricingPlanList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []PricingPlan `json:"items"`
}

// Storage version of v1api20171001.APIVersion
// +kubebuilder:validation:Enum={"2017-10-01"}
type APIVersion string

const APIVersion_Value = APIVersion("2017-10-01")

// Storage version of v1api20171001.PricingPlan_Spec
type PricingPlan_Spec struct {
	Cap             *float64                 `json:"cap,omitempty"`
	OperatorSpec    *PricingPlanOperatorSpec `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 insights.azure.com/Component resource
	Owner                                *genruntime.KnownResourceReference `group:"insights.azure.com" json:"owner,omitempty" kind:"Component"`
	PlanType                             *string                            `json:"planType,omitempty"`
	PropertyBag                          genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
	StopSendNotificationWhenHitCap       *bool                              `json:"stopSendNotificationWhenHitCap,omitempty"`
	StopSendNotificationWhenHitThreshold *bool                              `json:"stopSendNotificationWhenHitThreshold,omitempty"`
	WarningThreshold                     *int                               `json:"warningThreshold,omitempty"`
}

var _ genruntime.ConvertibleSpec = &PricingPlan_Spec{}

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

	return source.ConvertSpecTo(plan)
}

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

	return destination.ConvertSpecFrom(plan)
}

// Storage version of v1api20171001.PricingPlan_STATUS
type PricingPlan_STATUS struct {
	Cap                                  *float64               `json:"cap,omitempty"`
	Conditions                           []conditions.Condition `json:"conditions,omitempty"`
	Id                                   *string                `json:"id,omitempty"`
	MaxHistoryCap                        *float64               `json:"maxHistoryCap,omitempty"`
	Name                                 *string                `json:"name,omitempty"`
	PlanType                             *string                `json:"planType,omitempty"`
	PropertyBag                          genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ResetHour                            *int                   `json:"resetHour,omitempty"`
	StopSendNotificationWhenHitCap       *bool                  `json:"stopSendNotificationWhenHitCap,omitempty"`
	StopSendNotificationWhenHitThreshold *bool                  `json:"stopSendNotificationWhenHitThreshold,omitempty"`
	Type                                 *string                `json:"type,omitempty"`
	WarningThreshold                     *int                   `json:"warningThreshold,omitempty"`
}

var _ genruntime.ConvertibleStatus = &PricingPlan_STATUS{}

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

	return source.ConvertStatusTo(plan)
}

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

	return destination.ConvertStatusFrom(plan)
}

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

func init() {
	SchemeBuilder.Register(&PricingPlan{}, &PricingPlanList{})
}
