// Code generated by azure-service-operator-codegen. DO NOT EDIT.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package arm

import (
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
	"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
)

type Job_Spec struct {
	// Identity: Managed identities needed by a container app job to interact with other Azure services to not maintain any
	// secrets or credentials in code.
	Identity *ManagedServiceIdentity `json:"identity,omitempty"`

	// Location: The geo-location where the resource lives
	Location *string `json:"location,omitempty"`
	Name     string  `json:"name,omitempty"`

	// Properties: Container Apps Job resource specific properties.
	Properties *Job_Properties_Spec `json:"properties,omitempty"`

	// Tags: Resource tags.
	Tags map[string]string `json:"tags,omitempty"`
}

var _ genruntime.ARMResourceSpec = &Job_Spec{}

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

// GetName returns the Name of the resource
func (job *Job_Spec) GetName() string {
	return job.Name
}

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

type Job_Properties_Spec struct {
	// Configuration: Container Apps Job configuration properties.
	Configuration *JobConfiguration `json:"configuration,omitempty"`

	// EnvironmentId: Resource ID of environment.
	EnvironmentId *string `json:"environmentId,omitempty"`

	// Template: Container Apps job definition.
	Template *JobTemplate `json:"template,omitempty"`

	// WorkloadProfileName: Workload profile name to pin for container apps job execution.
	WorkloadProfileName *string `json:"workloadProfileName,omitempty"`
}

// Non versioned Container Apps Job configuration properties
type JobConfiguration struct {
	// EventTriggerConfig: Trigger configuration of an event driven job.
	EventTriggerConfig *JobConfiguration_EventTriggerConfig `json:"eventTriggerConfig,omitempty"`

	// ManualTriggerConfig: Manual trigger configuration for a single execution job. Properties replicaCompletionCount and
	// parallelism would be set to 1 by default
	ManualTriggerConfig *JobConfiguration_ManualTriggerConfig `json:"manualTriggerConfig,omitempty"`

	// Registries: Collection of private container registry credentials used by a Container apps job
	Registries []RegistryCredentials `json:"registries,omitempty"`

	// ReplicaRetryLimit: Maximum number of retries before failing the job.
	ReplicaRetryLimit *int `json:"replicaRetryLimit,omitempty"`

	// ReplicaTimeout: Maximum number of seconds a replica is allowed to run.
	ReplicaTimeout *int `json:"replicaTimeout,omitempty"`

	// ScheduleTriggerConfig: Cron formatted repeating trigger schedule ("* * * * *") for cronjobs. Properties completions and
	// parallelism would be set to 1 by default
	ScheduleTriggerConfig *JobConfiguration_ScheduleTriggerConfig `json:"scheduleTriggerConfig,omitempty"`

	// Secrets: Collection of secrets used by a Container Apps Job
	Secrets []Secret `json:"secrets,omitempty"`

	// TriggerType: Trigger type of the job
	TriggerType *JobConfiguration_TriggerType `json:"triggerType,omitempty"`
}

// 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: List of container definitions for the Container App.
	Containers []Container `json:"containers,omitempty"`

	// InitContainers: List of specialized containers that run before app containers.
	InitContainers []BaseContainer `json:"initContainers,omitempty"`

	// Volumes: List of volume definitions for the Container App.
	Volumes []Volume `json:"volumes,omitempty"`
}

type JobConfiguration_EventTriggerConfig struct {
	Parallelism            *int `json:"parallelism,omitempty"`
	ReplicaCompletionCount *int `json:"replicaCompletionCount,omitempty"`

	// Scale: Scaling configurations for event driven jobs.
	Scale *JobScale `json:"scale,omitempty"`
}

type JobConfiguration_ManualTriggerConfig struct {
	Parallelism            *int `json:"parallelism,omitempty"`
	ReplicaCompletionCount *int `json:"replicaCompletionCount,omitempty"`
}

type JobConfiguration_ScheduleTriggerConfig struct {
	// CronExpression: Cron formatted repeating schedule ("* * * * *") of a Cron Job.
	CronExpression         *string `json:"cronExpression,omitempty"`
	Parallelism            *int    `json:"parallelism,omitempty"`
	ReplicaCompletionCount *int    `json:"replicaCompletionCount,omitempty"`
}

// +kubebuilder:validation:Enum={"Event","Manual","Schedule"}
type JobConfiguration_TriggerType string

const (
	JobConfiguration_TriggerType_Event    = JobConfiguration_TriggerType("Event")
	JobConfiguration_TriggerType_Manual   = JobConfiguration_TriggerType("Manual")
	JobConfiguration_TriggerType_Schedule = JobConfiguration_TriggerType("Schedule")
)

// Mapping from string to JobConfiguration_TriggerType
var jobConfiguration_TriggerType_Values = map[string]JobConfiguration_TriggerType{
	"event":    JobConfiguration_TriggerType_Event,
	"manual":   JobConfiguration_TriggerType_Manual,
	"schedule": JobConfiguration_TriggerType_Schedule,
}

// Scaling configurations for event driven jobs.
type JobScale struct {
	// MaxExecutions: Maximum number of job executions that are created for a trigger, default 100.
	MaxExecutions *int `json:"maxExecutions,omitempty"`

	// MinExecutions: Minimum number of job executions that are created for a trigger, default 0
	MinExecutions   *int `json:"minExecutions,omitempty"`
	PollingInterval *int `json:"pollingInterval,omitempty"`

	// Rules: Scaling rules.
	Rules []JobScaleRule `json:"rules,omitempty"`
}

// Scaling rule.
type JobScaleRule struct {
	// Auth: Authentication secrets for the scale rule.
	Auth []ScaleRuleAuth `json:"auth,omitempty"`

	// Metadata: Metadata properties to describe the scale rule.
	Metadata map[string]v1.JSON `json:"metadata,omitempty"`

	// Name: Scale Rule Name
	Name *string `json:"name,omitempty"`

	// Type: Type of the scale rule
	// eg: azure-servicebus, redis etc.
	Type *string `json:"type,omitempty"`
}
