/*
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/apimachinery/pkg/apis/meta/v1"
	busv1alpha1 "volcano.sh/apis/pkg/apis/bus/v1alpha1"
)

// LifecyclePolicyApplyConfiguration represents a declarative configuration of the LifecyclePolicy type for use
// with apply.
//
// LifecyclePolicy specifies the lifecycle and error handling of task and job.
type LifecyclePolicyApplyConfiguration struct {
	// The action that will be taken to the PodGroup according to Event.
	// One of "Restart", "None".
	// Default to None.
	Action *busv1alpha1.Action `json:"action,omitempty"`
	// The Event recorded by scheduler; the controller takes actions
	// according to this Event.
	Event *busv1alpha1.Event `json:"event,omitempty"`
	// The Events recorded by scheduler; the controller takes actions
	// according to this Events.
	Events []busv1alpha1.Event `json:"events,omitempty"`
	// The exit code of the pod container, controller will take action
	// according to this code.
	// Note: only one of `Event` or `ExitCode` can be specified.
	ExitCode *int32 `json:"exitCode,omitempty"`
	// Timeout is the grace period for controller to take actions.
	// Default to nil (take action immediately).
	Timeout *v1.Duration `json:"timeout,omitempty"`
}

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

// WithAction sets the Action 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 Action field is set to the value of the last call.
func (b *LifecyclePolicyApplyConfiguration) WithAction(value busv1alpha1.Action) *LifecyclePolicyApplyConfiguration {
	b.Action = &value
	return b
}

// WithEvent sets the Event 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 Event field is set to the value of the last call.
func (b *LifecyclePolicyApplyConfiguration) WithEvent(value busv1alpha1.Event) *LifecyclePolicyApplyConfiguration {
	b.Event = &value
	return b
}

// WithEvents adds the given value to the Events 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 Events field.
func (b *LifecyclePolicyApplyConfiguration) WithEvents(values ...busv1alpha1.Event) *LifecyclePolicyApplyConfiguration {
	for i := range values {
		b.Events = append(b.Events, values[i])
	}
	return b
}

// WithExitCode sets the ExitCode 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 ExitCode field is set to the value of the last call.
func (b *LifecyclePolicyApplyConfiguration) WithExitCode(value int32) *LifecyclePolicyApplyConfiguration {
	b.ExitCode = &value
	return b
}

// WithTimeout sets the Timeout 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 Timeout field is set to the value of the last call.
func (b *LifecyclePolicyApplyConfiguration) WithTimeout(value v1.Duration) *LifecyclePolicyApplyConfiguration {
	b.Timeout = &value
	return b
}
