// 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=workbooks,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=insights.azure.com,resources={workbooks/status,workbooks/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 v1api20230601.Workbook
// Generator information:
// - Generated from: /applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/workbooks_API.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}
type Workbook struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              Workbook_Spec   `json:"spec,omitempty"`
	Status            Workbook_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &Workbook{}

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

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

var _ configmaps.Exporter = &Workbook{}

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

var _ secrets.Exporter = &Workbook{}

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

var _ genruntime.KubernetesResource = &Workbook{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2023-06-01"
func (workbook Workbook) GetAPIVersion() string {
	return "2023-06-01"
}

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Insights/workbooks"
func (workbook *Workbook) GetType() string {
	return "Microsoft.Insights/workbooks"
}

// NewEmptyStatus returns a new empty (blank) status
func (workbook *Workbook) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &Workbook_STATUS{}
}

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

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

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

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

	workbook.Status = st
	return nil
}

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

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

// +kubebuilder:object:root=true
// Storage version of v1api20230601.Workbook
// Generator information:
// - Generated from: /applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/workbooks_API.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}
type WorkbookList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []Workbook `json:"items"`
}

// Storage version of v1api20230601.APIVersion
// +kubebuilder:validation:Enum={"2023-06-01"}
type APIVersion string

const APIVersion_Value = APIVersion("2023-06-01")

// Storage version of v1api20230601.Workbook_Spec
type Workbook_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"`
	Category        *string                 `json:"category,omitempty"`
	Description     *string                 `json:"description,omitempty"`
	DisplayName     *string                 `json:"displayName,omitempty"`
	Identity        *ManagedServiceIdentity `json:"identity,omitempty"`
	Kind            *string                 `json:"kind,omitempty"`
	Location        *string                 `json:"location,omitempty"`
	OperatorSpec    *WorkbookOperatorSpec   `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"`
	PropertiesTags []string                           `json:"properties_tags,omitempty"`
	PropertyBag    genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
	SerializedData *string                            `json:"serializedData,omitempty"`

	// SourceReference: ResourceId for a source resource.
	SourceReference *genruntime.ResourceReference `armReference:"SourceId" json:"sourceReference,omitempty"`

	// StorageUriReference: The resourceId to the storage account when bring your own storage is used
	StorageUriReference *genruntime.ResourceReference `armReference:"StorageUri" json:"storageUriReference,omitempty"`
	Tags                map[string]string             `json:"tags,omitempty"`
	Version             *string                       `json:"version,omitempty"`
}

var _ genruntime.ConvertibleSpec = &Workbook_Spec{}

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

	return source.ConvertSpecTo(workbook)
}

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

	return destination.ConvertSpecFrom(workbook)
}

// Storage version of v1api20230601.Workbook_STATUS
// A workbook definition.
type Workbook_STATUS struct {
	Category       *string                        `json:"category,omitempty"`
	Conditions     []conditions.Condition         `json:"conditions,omitempty"`
	Description    *string                        `json:"description,omitempty"`
	DisplayName    *string                        `json:"displayName,omitempty"`
	Etag           *string                        `json:"etag,omitempty"`
	Id             *string                        `json:"id,omitempty"`
	Identity       *ManagedServiceIdentity_STATUS `json:"identity,omitempty"`
	Kind           *string                        `json:"kind,omitempty"`
	Location       *string                        `json:"location,omitempty"`
	Name           *string                        `json:"name,omitempty"`
	PropertiesTags []string                       `json:"properties_tags,omitempty"`
	PropertyBag    genruntime.PropertyBag         `json:"$propertyBag,omitempty"`
	Revision       *string                        `json:"revision,omitempty"`
	SerializedData *string                        `json:"serializedData,omitempty"`
	SourceId       *string                        `json:"sourceId,omitempty"`
	StorageUri     *string                        `json:"storageUri,omitempty"`
	SystemData     *SystemData_STATUS             `json:"systemData,omitempty"`
	Tags           map[string]string              `json:"tags,omitempty"`
	TimeModified   *string                        `json:"timeModified,omitempty"`
	Type           *string                        `json:"type,omitempty"`
	UserId         *string                        `json:"userId,omitempty"`
	Version        *string                        `json:"version,omitempty"`
}

var _ genruntime.ConvertibleStatus = &Workbook_STATUS{}

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

	return source.ConvertStatusTo(workbook)
}

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

	return destination.ConvertStatusFrom(workbook)
}

// Storage version of v1api20230601.ManagedServiceIdentity
// Managed service identity (system assigned and/or user assigned identities)
type ManagedServiceIdentity struct {
	PropertyBag            genruntime.PropertyBag        `json:"$propertyBag,omitempty"`
	Type                   *string                       `json:"type,omitempty"`
	UserAssignedIdentities []UserAssignedIdentityDetails `json:"userAssignedIdentities,omitempty"`
}

// Storage version of v1api20230601.ManagedServiceIdentity_STATUS
// Managed service identity (system assigned and/or user assigned identities)
type ManagedServiceIdentity_STATUS struct {
	PrincipalId            *string                                `json:"principalId,omitempty"`
	PropertyBag            genruntime.PropertyBag                 `json:"$propertyBag,omitempty"`
	TenantId               *string                                `json:"tenantId,omitempty"`
	Type                   *string                                `json:"type,omitempty"`
	UserAssignedIdentities map[string]UserAssignedIdentity_STATUS `json:"userAssignedIdentities,omitempty"`
}

// Storage version of v1api20230601.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 v1api20230601.WorkbookOperatorSpec
// Details for configuring operator behavior. Fields in this struct are interpreted by the operator directly rather than being passed to Azure
type WorkbookOperatorSpec struct {
	ConfigMapExpressions []*core.DestinationExpression `json:"configMapExpressions,omitempty"`
	PropertyBag          genruntime.PropertyBag        `json:"$propertyBag,omitempty"`
	SecretExpressions    []*core.DestinationExpression `json:"secretExpressions,omitempty"`
}

// Storage version of v1api20230601.UserAssignedIdentity_STATUS
// User assigned identity properties
type UserAssignedIdentity_STATUS struct {
	ClientId    *string                `json:"clientId,omitempty"`
	PrincipalId *string                `json:"principalId,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20230601.UserAssignedIdentityDetails
// Information about the user assigned identity for the resource
type UserAssignedIdentityDetails struct {
	PropertyBag genruntime.PropertyBag       `json:"$propertyBag,omitempty"`
	Reference   genruntime.ResourceReference `armReference:"Reference" json:"reference,omitempty"`
}

func init() {
	SchemeBuilder.Register(&Workbook{}, &WorkbookList{})
}
