/*
Copyright The Kubernetes 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 v1alpha2

import (
	schedulingv1alpha2 "k8s.io/api/scheduling/v1alpha2"
)

// PodGroupTemplateApplyConfiguration represents a declarative configuration of the PodGroupTemplate type for use
// with apply.
//
// PodGroupTemplate represents a template for a set of pods with a scheduling policy.
type PodGroupTemplateApplyConfiguration struct {
	// Name is a unique identifier for the PodGroupTemplate within the Workload.
	// It must be a DNS label. This field is immutable.
	Name *string `json:"name,omitempty"`
	// SchedulingPolicy defines the scheduling policy for this PodGroupTemplate.
	SchedulingPolicy *PodGroupSchedulingPolicyApplyConfiguration `json:"schedulingPolicy,omitempty"`
	// SchedulingConstraints defines optional scheduling constraints (e.g. topology) for this PodGroupTemplate.
	// This field is only available when the TopologyAwareWorkloadScheduling feature gate is enabled.
	SchedulingConstraints *PodGroupSchedulingConstraintsApplyConfiguration `json:"schedulingConstraints,omitempty"`
	// ResourceClaims defines which ResourceClaims may be shared among Pods in
	// the group. Pods consume the devices allocated to a PodGroup's claim by
	// defining a claim in its own Spec.ResourceClaims that matches the
	// PodGroup's claim exactly. The claim must have the same name and refer to
	// the same ResourceClaim or ResourceClaimTemplate.
	//
	// This is an alpha-level field and requires that the
	// DRAWorkloadResourceClaims feature gate is enabled.
	//
	// This field is immutable.
	ResourceClaims []PodGroupResourceClaimApplyConfiguration `json:"resourceClaims,omitempty"`
	// DisruptionMode defines the mode in which a given PodGroup can be disrupted.
	// One of Pod, PodGroup.
	// This field is available only when the WorkloadAwarePreemption feature gate
	// is enabled.
	DisruptionMode *schedulingv1alpha2.DisruptionMode `json:"disruptionMode,omitempty"`
	// PriorityClassName indicates the priority that should be considered when scheduling
	// a pod group created from this template. If no priority class is specified, admission
	// control can set this to the global default priority class if it exists. Otherwise,
	// pod groups created from this template will have the priority set to zero.
	// This field is available only when the WorkloadAwarePreemption feature gate
	// is enabled.
	PriorityClassName *string `json:"priorityClassName,omitempty"`
	// Priority is the value of priority of pod groups created from this template. Various
	// system components use this field to find the priority of the pod group. When
	// Priority Admission Controller is enabled, it prevents users from setting this field.
	// The admission controller populates this field from PriorityClassName.
	// The higher the value, the higher the priority.
	// This field is available only when the WorkloadAwarePreemption feature gate
	// is enabled.
	Priority *int32 `json:"priority,omitempty"`
}

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

// 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 *PodGroupTemplateApplyConfiguration) WithName(value string) *PodGroupTemplateApplyConfiguration {
	b.Name = &value
	return b
}

// WithSchedulingPolicy sets the SchedulingPolicy 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 SchedulingPolicy field is set to the value of the last call.
func (b *PodGroupTemplateApplyConfiguration) WithSchedulingPolicy(value *PodGroupSchedulingPolicyApplyConfiguration) *PodGroupTemplateApplyConfiguration {
	b.SchedulingPolicy = value
	return b
}

// WithSchedulingConstraints sets the SchedulingConstraints 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 SchedulingConstraints field is set to the value of the last call.
func (b *PodGroupTemplateApplyConfiguration) WithSchedulingConstraints(value *PodGroupSchedulingConstraintsApplyConfiguration) *PodGroupTemplateApplyConfiguration {
	b.SchedulingConstraints = value
	return b
}

// WithResourceClaims adds the given value to the ResourceClaims 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 ResourceClaims field.
func (b *PodGroupTemplateApplyConfiguration) WithResourceClaims(values ...*PodGroupResourceClaimApplyConfiguration) *PodGroupTemplateApplyConfiguration {
	for i := range values {
		if values[i] == nil {
			panic("nil value passed to WithResourceClaims")
		}
		b.ResourceClaims = append(b.ResourceClaims, *values[i])
	}
	return b
}

// WithDisruptionMode sets the DisruptionMode 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 DisruptionMode field is set to the value of the last call.
func (b *PodGroupTemplateApplyConfiguration) WithDisruptionMode(value schedulingv1alpha2.DisruptionMode) *PodGroupTemplateApplyConfiguration {
	b.DisruptionMode = &value
	return b
}

// WithPriorityClassName sets the PriorityClassName 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 PriorityClassName field is set to the value of the last call.
func (b *PodGroupTemplateApplyConfiguration) WithPriorityClassName(value string) *PodGroupTemplateApplyConfiguration {
	b.PriorityClassName = &value
	return b
}

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