/*
Copyright The Volcano Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by applyconfiguration-gen. DO NOT EDIT.

package v1alpha1

import (
	v1 "k8s.io/client-go/applyconfigurations/core/v1"
	batchv1alpha1 "volcano.sh/apis/pkg/apis/batch/v1alpha1"
)

// TaskSpecApplyConfiguration represents a declarative configuration of the TaskSpec type for use
// with apply.
//
// TaskSpec specifies the task specification of Job.
type TaskSpecApplyConfiguration struct {
	// Name specifies the name of tasks
	Name *string `json:"name,omitempty"`
	// Replicas specifies the replicas of this TaskSpec in Job
	Replicas *int32 `json:"replicas,omitempty"`
	// The minimal available pods to run for this Task
	// Defaults to the task replicas
	MinAvailable *int32 `json:"minAvailable,omitempty"`
	// Specifies the pod that will be created for this TaskSpec
	// when executing a Job
	Template *v1.PodTemplateSpecApplyConfiguration `json:"template,omitempty"`
	// Specifies the lifecycle of task
	Policies []LifecyclePolicyApplyConfiguration `json:"policies,omitempty"`
	// Specifies the topology policy of task
	TopologyPolicy *batchv1alpha1.NumaPolicy `json:"topologyPolicy,omitempty"`
	// Specifies the maximum number of retries before marking this Task failed.
	// Defaults to 3.
	MaxRetry *int32 `json:"maxRetry,omitempty"`
	// Specifies the tasks that this task depends on.
	DependsOn *DependsOnApplyConfiguration `json:"dependsOn,omitempty"`
	// PartitionPolicy defines the partition policy of a task.
	PartitionPolicy *PartitionPolicySpecApplyConfiguration `json:"partitionPolicy,omitempty"`
}

// TaskSpecApplyConfiguration constructs a declarative configuration of the TaskSpec type for use with
// apply.
func TaskSpec() *TaskSpecApplyConfiguration {
	return &TaskSpecApplyConfiguration{}
}

// WithName sets the Name field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Name field is set to the value of the last call.
func (b *TaskSpecApplyConfiguration) WithName(value string) *TaskSpecApplyConfiguration {
	b.Name = &value
	return b
}

// WithReplicas sets the Replicas field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Replicas field is set to the value of the last call.
func (b *TaskSpecApplyConfiguration) WithReplicas(value int32) *TaskSpecApplyConfiguration {
	b.Replicas = &value
	return b
}

// WithMinAvailable sets the MinAvailable field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the MinAvailable field is set to the value of the last call.
func (b *TaskSpecApplyConfiguration) WithMinAvailable(value int32) *TaskSpecApplyConfiguration {
	b.MinAvailable = &value
	return b
}

// WithTemplate sets the Template field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Template field is set to the value of the last call.
func (b *TaskSpecApplyConfiguration) WithTemplate(value *v1.PodTemplateSpecApplyConfiguration) *TaskSpecApplyConfiguration {
	b.Template = value
	return b
}

// WithPolicies adds the given value to the Policies field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the Policies field.
func (b *TaskSpecApplyConfiguration) WithPolicies(values ...*LifecyclePolicyApplyConfiguration) *TaskSpecApplyConfiguration {
	for i := range values {
		if values[i] == nil {
			panic("nil value passed to WithPolicies")
		}
		b.Policies = append(b.Policies, *values[i])
	}
	return b
}

// WithTopologyPolicy sets the TopologyPolicy field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the TopologyPolicy field is set to the value of the last call.
func (b *TaskSpecApplyConfiguration) WithTopologyPolicy(value batchv1alpha1.NumaPolicy) *TaskSpecApplyConfiguration {
	b.TopologyPolicy = &value
	return b
}

// WithMaxRetry sets the MaxRetry field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the MaxRetry field is set to the value of the last call.
func (b *TaskSpecApplyConfiguration) WithMaxRetry(value int32) *TaskSpecApplyConfiguration {
	b.MaxRetry = &value
	return b
}

// WithDependsOn sets the DependsOn field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the DependsOn field is set to the value of the last call.
func (b *TaskSpecApplyConfiguration) WithDependsOn(value *DependsOnApplyConfiguration) *TaskSpecApplyConfiguration {
	b.DependsOn = value
	return b
}

// WithPartitionPolicy sets the PartitionPolicy field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the PartitionPolicy field is set to the value of the last call.
func (b *TaskSpecApplyConfiguration) WithPartitionPolicy(value *PartitionPolicySpecApplyConfiguration) *TaskSpecApplyConfiguration {
	b.PartitionPolicy = value
	return b
}
