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

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

package v3

import (
	projectcalicov3 "github.com/projectcalico/api/pkg/apis/projectcalico/v3"
)

// StagedNetworkPolicySpecApplyConfiguration represents a declarative configuration of the StagedNetworkPolicySpec type for use
// with apply.
type StagedNetworkPolicySpecApplyConfiguration struct {
	// The staged action. If this is omitted, the default is Set.
	StagedAction *projectcalicov3.StagedAction `json:"stagedAction,omitempty"`
	// The name of the tier that this policy belongs to.  If this is omitted, the default
	// tier (name is "default") is assumed.  The specified tier must exist in order to create
	// security policies within the tier, the "default" tier is created automatically if it
	// does not exist, this means for deployments requiring only a single Tier, the tier name
	// may be omitted on all policy management requests.
	Tier *string `json:"tier,omitempty"`
	// Order is an optional field that specifies the order in which the policy is applied.
	// Policies with higher "order" are applied after those with lower
	// order within the same tier.  If the order is omitted, it may be considered to be "infinite" - i.e. the
	// policy will be applied last.  Policies with identical order will be applied in
	// alphanumerical order based on the Policy "Name" within the tier.
	Order *float64 `json:"order,omitempty"`
	// 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"`
	// The selector is an expression used to pick pick out the endpoints that the policy should
	// be applied to.
	//
	// Selector expressions follow this syntax:
	//
	// label == "string_literal"  ->  comparison, e.g. my_label == "foo bar"
	// label != "string_literal"   ->  not equal; also matches if label is not present
	// label in { "a", "b", "c", ... }  ->  true if the value of label X is one of "a", "b", "c"
	// label not in { "a", "b", "c", ... }  ->  true if the value of label X is not one of "a", "b", "c"
	// has(label_name)  -> True if that label is present
	// ! expr -> negation of expr
	// expr && expr  -> Short-circuit and
	// expr || expr  -> Short-circuit or
	// ( expr ) -> parens for grouping
	// all() or the empty selector -> matches all endpoints.
	//
	// Label names are allowed to contain alphanumerics, -, _ and /. String literals are more permissive
	// but they do not support escape characters.
	//
	// Examples (with made-up labels):
	//
	// type == "webserver" && deployment == "prod"
	// type in {"frontend", "backend"}
	// deployment != "dev"
	// ! has(label_name)
	Selector *string `json:"selector,omitempty"`
	// Types indicates whether this policy applies to ingress, or to egress, or to both.  When
	// not explicitly specified (and so the value on creation is empty or nil), Calico defaults
	// Types according to what Ingress and Egress are present in the policy.  The
	// default is:
	//
	// - [ PolicyTypeIngress ], if there are no Egress rules (including the case where there are
	// also no Ingress rules)
	//
	// - [ PolicyTypeEgress ], if there are Egress rules but no Ingress rules
	//
	// - [ PolicyTypeIngress, PolicyTypeEgress ], if there are both Ingress and Egress rules.
	//
	// When the policy is read back again, Types will always be one of these values, never empty
	// or nil.
	Types []projectcalicov3.PolicyType `json:"types,omitempty"`
	// ServiceAccountSelector is an optional field for an expression used to select a pod based on service accounts.
	ServiceAccountSelector *string `json:"serviceAccountSelector,omitempty"`
	// PerformanceHints contains a list of hints to Calico's policy engine to
	// help process the policy more efficiently.  Hints never change the
	// enforcement behaviour of the policy.
	//
	// Currently, the only available hint is "AssumeNeededOnEveryNode".  When
	// that hint is set on a policy, Felix will act as if the policy matches
	// a local endpoint even if it does not. This is useful for "preloading"
	// any large static policies that are known to be used on every node.
	// If the policy is _not_ used on a particular node then the work
	// done to preload the policy (and to maintain it) is wasted.
	PerformanceHints []projectcalicov3.PolicyPerformanceHint `json:"performanceHints,omitempty"`
}

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

// WithStagedAction sets the StagedAction 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 StagedAction field is set to the value of the last call.
func (b *StagedNetworkPolicySpecApplyConfiguration) WithStagedAction(value projectcalicov3.StagedAction) *StagedNetworkPolicySpecApplyConfiguration {
	b.StagedAction = &value
	return b
}

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

// WithOrder sets the Order 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 Order field is set to the value of the last call.
func (b *StagedNetworkPolicySpecApplyConfiguration) WithOrder(value float64) *StagedNetworkPolicySpecApplyConfiguration {
	b.Order = &value
	return b
}

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

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

// WithTypes adds the given value to the Types 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 Types field.
func (b *StagedNetworkPolicySpecApplyConfiguration) WithTypes(values ...projectcalicov3.PolicyType) *StagedNetworkPolicySpecApplyConfiguration {
	for i := range values {
		b.Types = append(b.Types, values[i])
	}
	return b
}

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

// WithPerformanceHints adds the given value to the PerformanceHints 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 PerformanceHints field.
func (b *StagedNetworkPolicySpecApplyConfiguration) WithPerformanceHints(values ...projectcalicov3.PolicyPerformanceHint) *StagedNetworkPolicySpecApplyConfiguration {
	for i := range values {
		b.PerformanceHints = append(b.PerformanceHints, values[i])
	}
	return b
}
