// 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"
	"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime/schema"
)

// +kubebuilder:rbac:groups=app.azure.com,resources=jobs,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=app.azure.com,resources={jobs/status,jobs/finalizers},verbs=get;update;patch

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,app}
// +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 v1api20250101.Job
// Generator information:
// - Generated from: /app/resource-manager/Microsoft.App/ContainerApps/stable/2025-01-01/Jobs.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/jobs/{jobName}
type Job struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              Job_Spec   `json:"spec,omitempty"`
	Status            Job_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &Job{}

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

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

var _ configmaps.Exporter = &Job{}

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

var _ secrets.Exporter = &Job{}

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

var _ genruntime.KubernetesResource = &Job{}

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

// GetAPIVersion returns the ARM API version of the resource. This is always "2025-01-01"
func (job Job) GetAPIVersion() string {
	return "2025-01-01"
}

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

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

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

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

// GetType returns the ARM Type of the resource. This is always "Microsoft.App/jobs"
func (job *Job) GetType() string {
	return "Microsoft.App/jobs"
}

// NewEmptyStatus returns a new empty (blank) status
func (job *Job) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &Job_STATUS{}
}

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

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

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

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

	job.Status = st
	return nil
}

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

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

// +kubebuilder:object:root=true
// Storage version of v1api20250101.Job
// Generator information:
// - Generated from: /app/resource-manager/Microsoft.App/ContainerApps/stable/2025-01-01/Jobs.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/jobs/{jobName}
type JobList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []Job `json:"items"`
}

// Storage version of v1api20250101.Job_Spec
type Job_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"`
	Configuration *JobConfiguration `json:"configuration,omitempty"`

	// EnvironmentReference: Resource ID of environment.
	EnvironmentReference *genruntime.ResourceReference `armReference:"EnvironmentId" json:"environmentReference,omitempty"`
	Identity             *ManagedServiceIdentity       `json:"identity,omitempty"`
	Location             *string                       `json:"location,omitempty"`
	OperatorSpec         *JobOperatorSpec              `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"`
	PropertyBag         genruntime.PropertyBag             `json:"$propertyBag,omitempty"`
	Tags                map[string]string                  `json:"tags,omitempty"`
	Template            *JobTemplate                       `json:"template,omitempty"`
	WorkloadProfileName *string                            `json:"workloadProfileName,omitempty"`
}

var _ genruntime.ConvertibleSpec = &Job_Spec{}

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

	return source.ConvertSpecTo(job)
}

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

	return destination.ConvertSpecFrom(job)
}

// Storage version of v1api20250101.Job_STATUS
// Container App Job
type Job_STATUS struct {
	Conditions          []conditions.Condition         `json:"conditions,omitempty"`
	Configuration       *JobConfiguration_STATUS       `json:"configuration,omitempty"`
	EnvironmentId       *string                        `json:"environmentId,omitempty"`
	EventStreamEndpoint *string                        `json:"eventStreamEndpoint,omitempty"`
	Id                  *string                        `json:"id,omitempty"`
	Identity            *ManagedServiceIdentity_STATUS `json:"identity,omitempty"`
	Location            *string                        `json:"location,omitempty"`
	Name                *string                        `json:"name,omitempty"`
	OutboundIpAddresses []string                       `json:"outboundIpAddresses,omitempty"`
	PropertyBag         genruntime.PropertyBag         `json:"$propertyBag,omitempty"`
	ProvisioningState   *string                        `json:"provisioningState,omitempty"`
	SystemData          *SystemData_STATUS             `json:"systemData,omitempty"`
	Tags                map[string]string              `json:"tags,omitempty"`
	Template            *JobTemplate_STATUS            `json:"template,omitempty"`
	Type                *string                        `json:"type,omitempty"`
	WorkloadProfileName *string                        `json:"workloadProfileName,omitempty"`
}

var _ genruntime.ConvertibleStatus = &Job_STATUS{}

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

	return source.ConvertStatusTo(job)
}

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

	return destination.ConvertStatusFrom(job)
}

// Storage version of v1api20250101.JobConfiguration
// Non versioned Container Apps Job configuration properties
type JobConfiguration struct {
	EventTriggerConfig    *JobConfiguration_EventTriggerConfig    `json:"eventTriggerConfig,omitempty"`
	IdentitySettings      []IdentitySettings                      `json:"identitySettings,omitempty"`
	ManualTriggerConfig   *JobConfiguration_ManualTriggerConfig   `json:"manualTriggerConfig,omitempty"`
	PropertyBag           genruntime.PropertyBag                  `json:"$propertyBag,omitempty"`
	Registries            []RegistryCredentials                   `json:"registries,omitempty"`
	ReplicaRetryLimit     *int                                    `json:"replicaRetryLimit,omitempty"`
	ReplicaTimeout        *int                                    `json:"replicaTimeout,omitempty"`
	ScheduleTriggerConfig *JobConfiguration_ScheduleTriggerConfig `json:"scheduleTriggerConfig,omitempty"`
	Secrets               []Secret                                `json:"secrets,omitempty"`
	TriggerType           *string                                 `json:"triggerType,omitempty"`
}

// Storage version of v1api20250101.JobConfiguration_STATUS
// Non versioned Container Apps Job configuration properties
type JobConfiguration_STATUS struct {
	EventTriggerConfig    *JobConfiguration_EventTriggerConfig_STATUS    `json:"eventTriggerConfig,omitempty"`
	IdentitySettings      []IdentitySettings_STATUS                      `json:"identitySettings,omitempty"`
	ManualTriggerConfig   *JobConfiguration_ManualTriggerConfig_STATUS   `json:"manualTriggerConfig,omitempty"`
	PropertyBag           genruntime.PropertyBag                         `json:"$propertyBag,omitempty"`
	Registries            []RegistryCredentials_STATUS                   `json:"registries,omitempty"`
	ReplicaRetryLimit     *int                                           `json:"replicaRetryLimit,omitempty"`
	ReplicaTimeout        *int                                           `json:"replicaTimeout,omitempty"`
	ScheduleTriggerConfig *JobConfiguration_ScheduleTriggerConfig_STATUS `json:"scheduleTriggerConfig,omitempty"`
	Secrets               []Secret_STATUS                                `json:"secrets,omitempty"`
	TriggerType           *string                                        `json:"triggerType,omitempty"`
}

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

// Storage version of v1api20250101.JobTemplate
// Container Apps Job versioned application definition. Defines the desired state of an immutable revision. Any changes to
// this section Will result in a new revision being created
type JobTemplate struct {
	Containers     []Container            `json:"containers,omitempty"`
	InitContainers []BaseContainer        `json:"initContainers,omitempty"`
	PropertyBag    genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Volumes        []Volume               `json:"volumes,omitempty"`
}

// Storage version of v1api20250101.JobTemplate_STATUS
// Container Apps Job versioned application definition. Defines the desired state of an immutable revision. Any changes to
// this section Will result in a new revision being created
type JobTemplate_STATUS struct {
	Containers     []Container_STATUS     `json:"containers,omitempty"`
	InitContainers []BaseContainer_STATUS `json:"initContainers,omitempty"`
	PropertyBag    genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Volumes        []Volume_STATUS        `json:"volumes,omitempty"`
}

// Storage version of v1api20250101.JobConfiguration_EventTriggerConfig
type JobConfiguration_EventTriggerConfig struct {
	Parallelism            *int                   `json:"parallelism,omitempty"`
	PropertyBag            genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ReplicaCompletionCount *int                   `json:"replicaCompletionCount,omitempty"`
	Scale                  *JobScale              `json:"scale,omitempty"`
}

// Storage version of v1api20250101.JobConfiguration_EventTriggerConfig_STATUS
type JobConfiguration_EventTriggerConfig_STATUS struct {
	Parallelism            *int                   `json:"parallelism,omitempty"`
	PropertyBag            genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ReplicaCompletionCount *int                   `json:"replicaCompletionCount,omitempty"`
	Scale                  *JobScale_STATUS       `json:"scale,omitempty"`
}

// Storage version of v1api20250101.JobConfiguration_ManualTriggerConfig
type JobConfiguration_ManualTriggerConfig struct {
	Parallelism            *int                   `json:"parallelism,omitempty"`
	PropertyBag            genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ReplicaCompletionCount *int                   `json:"replicaCompletionCount,omitempty"`
}

// Storage version of v1api20250101.JobConfiguration_ManualTriggerConfig_STATUS
type JobConfiguration_ManualTriggerConfig_STATUS struct {
	Parallelism            *int                   `json:"parallelism,omitempty"`
	PropertyBag            genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ReplicaCompletionCount *int                   `json:"replicaCompletionCount,omitempty"`
}

// Storage version of v1api20250101.JobConfiguration_ScheduleTriggerConfig
type JobConfiguration_ScheduleTriggerConfig struct {
	CronExpression         *string                `json:"cronExpression,omitempty"`
	Parallelism            *int                   `json:"parallelism,omitempty"`
	PropertyBag            genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ReplicaCompletionCount *int                   `json:"replicaCompletionCount,omitempty"`
}

// Storage version of v1api20250101.JobConfiguration_ScheduleTriggerConfig_STATUS
type JobConfiguration_ScheduleTriggerConfig_STATUS struct {
	CronExpression         *string                `json:"cronExpression,omitempty"`
	Parallelism            *int                   `json:"parallelism,omitempty"`
	PropertyBag            genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	ReplicaCompletionCount *int                   `json:"replicaCompletionCount,omitempty"`
}

// Storage version of v1api20250101.JobScale
// Scaling configurations for event driven jobs.
type JobScale struct {
	MaxExecutions   *int                   `json:"maxExecutions,omitempty"`
	MinExecutions   *int                   `json:"minExecutions,omitempty"`
	PollingInterval *int                   `json:"pollingInterval,omitempty"`
	PropertyBag     genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Rules           []JobScaleRule         `json:"rules,omitempty"`
}

// Storage version of v1api20250101.JobScale_STATUS
// Scaling configurations for event driven jobs.
type JobScale_STATUS struct {
	MaxExecutions   *int                   `json:"maxExecutions,omitempty"`
	MinExecutions   *int                   `json:"minExecutions,omitempty"`
	PollingInterval *int                   `json:"pollingInterval,omitempty"`
	PropertyBag     genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Rules           []JobScaleRule_STATUS  `json:"rules,omitempty"`
}

// Storage version of v1api20250101.JobScaleRule
// Scaling rule.
type JobScaleRule struct {
	Auth []ScaleRuleAuth `json:"auth,omitempty"`

	// IdentityReference: The resource ID of a user-assigned managed identity that is assigned to the Container App, or
	// 'system' for system-assigned identity.
	IdentityReference *genruntime.WellKnownResourceReference `armReference:"Identity" json:"identityReference,omitempty"`
	Metadata          map[string]v1.JSON                     `json:"metadata,omitempty"`
	Name              *string                                `json:"name,omitempty"`
	PropertyBag       genruntime.PropertyBag                 `json:"$propertyBag,omitempty"`
	Type              *string                                `json:"type,omitempty"`
}

// Storage version of v1api20250101.JobScaleRule_STATUS
// Scaling rule.
type JobScaleRule_STATUS struct {
	Auth        []ScaleRuleAuth_STATUS `json:"auth,omitempty"`
	Identity    *string                `json:"identity,omitempty"`
	Metadata    map[string]v1.JSON     `json:"metadata,omitempty"`
	Name        *string                `json:"name,omitempty"`
	PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"`
	Type        *string                `json:"type,omitempty"`
}

func init() {
	SchemeBuilder.Register(&Job{}, &JobList{})
}
