// Copyright (c) 2026 Tigera, Inc. All rights reserved.

// Code generated by applyconfiguration-gen. DO NOT EDIT.

package v3

// ProfileSpecApplyConfiguration represents a declarative configuration of the ProfileSpec type for use
// with apply.
//
// ProfileSpec contains the specification for a security Profile resource.
type ProfileSpecApplyConfiguration struct {
	// The ordered set of ingress rules.  Each rule contains a set of packet match criteria and
	// a corresponding action to apply.
	Ingress []RuleApplyConfiguration `json:"ingress,omitempty"`
	// The ordered set of egress rules.  Each rule contains a set of packet match criteria and
	// a corresponding action to apply.
	Egress []RuleApplyConfiguration `json:"egress,omitempty"`
	// An option set of labels to apply to each endpoint (in addition to their own labels)
	// referencing this profile.  If labels configured on the endpoint have keys matching those
	// labels inherited from the profile, the endpoint label values take precedence.
	LabelsToApply map[string]string `json:"labelsToApply,omitempty"`
}

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

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

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

// WithLabelsToApply puts the entries into the LabelsToApply field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, the entries provided by each call will be put on the LabelsToApply field,
// overwriting an existing map entries in LabelsToApply field with the same key.
func (b *ProfileSpecApplyConfiguration) WithLabelsToApply(entries map[string]string) *ProfileSpecApplyConfiguration {
	if b.LabelsToApply == nil && len(entries) > 0 {
		b.LabelsToApply = make(map[string]string, len(entries))
	}
	for k, v := range entries {
		b.LabelsToApply[k] = v
	}
	return b
}
