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

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,web}
// +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 v1api20220301.SitesSourcecontrol
// Generator information:
// - Generated from: /web/resource-manager/Microsoft.Web/stable/2022-03-01/WebApps.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/sourcecontrols/web
type SitesSourcecontrol struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              SitesSourcecontrol_Spec   `json:"spec,omitempty"`
	Status            SitesSourcecontrol_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &SitesSourcecontrol{}

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

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

var _ configmaps.Exporter = &SitesSourcecontrol{}

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

var _ secrets.Exporter = &SitesSourcecontrol{}

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

var _ genruntime.KubernetesResource = &SitesSourcecontrol{}

// AzureName returns the Azure name of the resource (always "web")
func (sourcecontrol *SitesSourcecontrol) AzureName() string {
	return "web"
}

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

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.Web/sites/sourcecontrols"
func (sourcecontrol *SitesSourcecontrol) GetType() string {
	return "Microsoft.Web/sites/sourcecontrols"
}

// NewEmptyStatus returns a new empty (blank) status
func (sourcecontrol *SitesSourcecontrol) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &SitesSourcecontrol_STATUS{}
}

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

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

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

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

	sourcecontrol.Status = st
	return nil
}

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

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

// +kubebuilder:object:root=true
// Storage version of v1api20220301.SitesSourcecontrol
// Generator information:
// - Generated from: /web/resource-manager/Microsoft.Web/stable/2022-03-01/WebApps.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/sourcecontrols/web
type SitesSourcecontrolList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []SitesSourcecontrol `json:"items"`
}

// Storage version of v1api20220301.SitesSourcecontrol_Spec
type SitesSourcecontrol_Spec struct {
	Branch                    *string                         `json:"branch,omitempty"`
	DeploymentRollbackEnabled *bool                           `json:"deploymentRollbackEnabled,omitempty"`
	GitHubActionConfiguration *GitHubActionConfiguration      `json:"gitHubActionConfiguration,omitempty"`
	IsGitHubAction            *bool                           `json:"isGitHubAction,omitempty"`
	IsManualIntegration       *bool                           `json:"isManualIntegration,omitempty"`
	IsMercurial               *bool                           `json:"isMercurial,omitempty"`
	Kind                      *string                         `json:"kind,omitempty"`
	OperatorSpec              *SitesSourcecontrolOperatorSpec `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 web.azure.com/Site resource
	Owner       *genruntime.KnownResourceReference `group:"web.azure.com" json:"owner,omitempty" kind:"Site"`
	PropertyBag genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
	RepoUrl     *string                            `json:"repoUrl,omitempty"`
}

var _ genruntime.ConvertibleSpec = &SitesSourcecontrol_Spec{}

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

	return source.ConvertSpecTo(sourcecontrol)
}

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

	return destination.ConvertSpecFrom(sourcecontrol)
}

// Storage version of v1api20220301.SitesSourcecontrol_STATUS
type SitesSourcecontrol_STATUS struct {
	Branch                    *string                           `json:"branch,omitempty"`
	Conditions                []conditions.Condition            `json:"conditions,omitempty"`
	DeploymentRollbackEnabled *bool                             `json:"deploymentRollbackEnabled,omitempty"`
	GitHubActionConfiguration *GitHubActionConfiguration_STATUS `json:"gitHubActionConfiguration,omitempty"`
	Id                        *string                           `json:"id,omitempty"`
	IsGitHubAction            *bool                             `json:"isGitHubAction,omitempty"`
	IsManualIntegration       *bool                             `json:"isManualIntegration,omitempty"`
	IsMercurial               *bool                             `json:"isMercurial,omitempty"`
	Kind                      *string                           `json:"kind,omitempty"`
	Name                      *string                           `json:"name,omitempty"`
	PropertyBag               genruntime.PropertyBag            `json:"$propertyBag,omitempty"`
	RepoUrl                   *string                           `json:"repoUrl,omitempty"`
	Type                      *string                           `json:"type,omitempty"`
}

var _ genruntime.ConvertibleStatus = &SitesSourcecontrol_STATUS{}

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

	return source.ConvertStatusTo(sourcecontrol)
}

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

	return destination.ConvertStatusFrom(sourcecontrol)
}

// Storage version of v1api20220301.GitHubActionConfiguration
// The GitHub action configuration.
type GitHubActionConfiguration struct {
	CodeConfiguration      *GitHubActionCodeConfiguration      `json:"codeConfiguration,omitempty"`
	ContainerConfiguration *GitHubActionContainerConfiguration `json:"containerConfiguration,omitempty"`
	GenerateWorkflowFile   *bool                               `json:"generateWorkflowFile,omitempty"`
	IsLinux                *bool                               `json:"isLinux,omitempty"`
	PropertyBag            genruntime.PropertyBag              `json:"$propertyBag,omitempty"`
}

// Storage version of v1api20220301.GitHubActionConfiguration_STATUS
// The GitHub action configuration.
type GitHubActionConfiguration_STATUS struct {
	CodeConfiguration      *GitHubActionCodeConfiguration_STATUS      `json:"codeConfiguration,omitempty"`
	ContainerConfiguration *GitHubActionContainerConfiguration_STATUS `json:"containerConfiguration,omitempty"`
	GenerateWorkflowFile   *bool                                      `json:"generateWorkflowFile,omitempty"`
	IsLinux                *bool                                      `json:"isLinux,omitempty"`
	PropertyBag            genruntime.PropertyBag                     `json:"$propertyBag,omitempty"`
}

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

// Storage version of v1api20220301.GitHubActionCodeConfiguration
// The GitHub action code configuration.
type GitHubActionCodeConfiguration struct {
	PropertyBag    genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	RuntimeStack   *string                `json:"runtimeStack,omitempty"`
	RuntimeVersion *string                `json:"runtimeVersion,omitempty"`
}

// Storage version of v1api20220301.GitHubActionCodeConfiguration_STATUS
// The GitHub action code configuration.
type GitHubActionCodeConfiguration_STATUS struct {
	PropertyBag    genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	RuntimeStack   *string                `json:"runtimeStack,omitempty"`
	RuntimeVersion *string                `json:"runtimeVersion,omitempty"`
}

// Storage version of v1api20220301.GitHubActionContainerConfiguration
// The GitHub action container configuration.
type GitHubActionContainerConfiguration struct {
	ImageName   *string                     `json:"imageName,omitempty"`
	Password    *genruntime.SecretReference `json:"password,omitempty"`
	PropertyBag genruntime.PropertyBag      `json:"$propertyBag,omitempty"`
	ServerUrl   *string                     `json:"serverUrl,omitempty"`
	Username    *string                     `json:"username,omitempty"`
}

// Storage version of v1api20220301.GitHubActionContainerConfiguration_STATUS
// The GitHub action container configuration.
type GitHubActionContainerConfiguration_STATUS struct {
	ImageName   *string                `json:"imageName,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ServerUrl   *string                `json:"serverUrl,omitempty"`
	Username    *string                `json:"username,omitempty"`
}

func init() {
	SchemeBuilder.Register(&SitesSourcecontrol{}, &SitesSourcecontrolList{})
}
