/*
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 v1beta1

import (
	v1 "k8s.io/client-go/applyconfigurations/meta/v1"
)

// SubGroupPolicySpecApplyConfiguration represents a declarative configuration of the SubGroupPolicySpec type for use
// with apply.
type SubGroupPolicySpecApplyConfiguration struct {
	// Name specifies the name of SubGroupPolicy
	Name *string `json:"name,omitempty"`
	// NetworkTopology defines the NetworkTopology config, this field works in conjunction with network topology feature and hyperNode CRD.
	NetworkTopology *NetworkTopologySpecApplyConfiguration `json:"networkTopology,omitempty"`
	// SubGroupSize defines the number of pods in each sub-affinity group.
	// Only when a subGroup of pods, with a size of "subGroupSize", can satisfy the network topology constraint then will the subGroup be scheduled.
	SubGroupSize *int32 `json:"subGroupSize,omitempty"`
	// MinSubGroups: Minimum number of subgroups required to trigger scheduling. Scheduling is initiated only if cluster resources meet the requirements of at least this number of subgroups.
	// Subgroup-level Gang Scheduling
	MinSubGroups *int32 `json:"minSubGroups,omitempty"`
	// LabelSelector is used to find matching pods.
	// Pods that match this label selector are counted to determine the number of pods
	// in their corresponding topology domain.
	LabelSelector *v1.LabelSelectorApplyConfiguration `json:"labelSelector,omitempty"`
	// MatchLabelKeys: A label-based grouping configuration field for Pods, defining filtering rules for grouping label keys
	// Core function: Refine grouping of Pods that meet LabelSelector criteria by label attributes, with the following rules and constraints:
	// 1. Scope: Only applies to Pods matching the predefined LabelSelector
	// 2. Grouping rule: Specify one or more label keys; Pods containing the target label keys with exactly the same corresponding label values are grouped together
	// 3. Policy constraint: Pods in the same group follow a unified NetworkTopology policy to achieve group-level network behavior governance
	MatchLabelKeys []string `json:"matchLabelKeys,omitempty"`
}

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

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

// WithNetworkTopology sets the NetworkTopology 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 NetworkTopology field is set to the value of the last call.
func (b *SubGroupPolicySpecApplyConfiguration) WithNetworkTopology(value *NetworkTopologySpecApplyConfiguration) *SubGroupPolicySpecApplyConfiguration {
	b.NetworkTopology = value
	return b
}

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

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

// WithLabelSelector sets the LabelSelector 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 LabelSelector field is set to the value of the last call.
func (b *SubGroupPolicySpecApplyConfiguration) WithLabelSelector(value *v1.LabelSelectorApplyConfiguration) *SubGroupPolicySpecApplyConfiguration {
	b.LabelSelector = value
	return b
}

// WithMatchLabelKeys adds the given value to the MatchLabelKeys 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 MatchLabelKeys field.
func (b *SubGroupPolicySpecApplyConfiguration) WithMatchLabelKeys(values ...string) *SubGroupPolicySpecApplyConfiguration {
	for i := range values {
		b.MatchLabelKeys = append(b.MatchLabelKeys, values[i])
	}
	return b
}
