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

// AdminNetworkPolicySpecApplyConfiguration represents a declarative configuration of the AdminNetworkPolicySpec type for use
// with apply.
//
// AdminNetworkPolicySpec defines the desired state of AdminNetworkPolicy.
type AdminNetworkPolicySpecApplyConfiguration struct {
	// Priority is a value from 0 to 1000. Policies with lower priority values have
	// higher precedence, and are checked before policies with higher priority values.
	// All AdminNetworkPolicy rules have higher precedence than NetworkPolicy or
	// BaselineAdminNetworkPolicy rules.
	// If two (or more) policies with the same priority could both match a connection,
	// then the implementation can apply any of the matching policies to the
	// connection, and there is no way for the user to reliably determine which one it
	// will choose. Administrators must be careful about assigning the priorities for
	// policies with rules that will match many connections, and ensure that policies
	// have unique priority values in cases where ambiguity would be unacceptable.
	Priority *int32 `json:"priority,omitempty"`
	// Subject defines the pods to which this AdminNetworkPolicy applies.
	// Note that host-networked pods are not included in subject selection.
	Subject *AdminNetworkPolicySubjectApplyConfiguration `json:"subject,omitempty"`
	// Ingress is the list of Ingress rules to be applied to the selected pods.
	// A total of 100 rules will be allowed in each ANP instance.
	// The relative precedence of ingress rules within a single ANP object (all of
	// which share the priority) will be determined by the order in which the rule
	// is written. Thus, a rule that appears at the top of the ingress rules
	// would take the highest precedence.
	// ANPs with no ingress rules do not affect ingress traffic.
	Ingress []AdminNetworkPolicyIngressRuleApplyConfiguration `json:"ingress,omitempty"`
	// Egress is the list of Egress rules to be applied to the selected pods.
	// A total of 100 rules will be allowed in each ANP instance.
	// The relative precedence of egress rules within a single ANP object (all of
	// which share the priority) will be determined by the order in which the rule
	// is written. Thus, a rule that appears at the top of the egress rules
	// would take the highest precedence.
	// ANPs with no egress rules do not affect egress traffic.
	Egress []AdminNetworkPolicyEgressRuleApplyConfiguration `json:"egress,omitempty"`
}

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

// 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 *AdminNetworkPolicySpecApplyConfiguration) WithPriority(value int32) *AdminNetworkPolicySpecApplyConfiguration {
	b.Priority = &value
	return b
}

// WithSubject sets the Subject 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 Subject field is set to the value of the last call.
func (b *AdminNetworkPolicySpecApplyConfiguration) WithSubject(value *AdminNetworkPolicySubjectApplyConfiguration) *AdminNetworkPolicySpecApplyConfiguration {
	b.Subject = 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 *AdminNetworkPolicySpecApplyConfiguration) WithIngress(values ...*AdminNetworkPolicyIngressRuleApplyConfiguration) *AdminNetworkPolicySpecApplyConfiguration {
	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 *AdminNetworkPolicySpecApplyConfiguration) WithEgress(values ...*AdminNetworkPolicyEgressRuleApplyConfiguration) *AdminNetworkPolicySpecApplyConfiguration {
	for i := range values {
		if values[i] == nil {
			panic("nil value passed to WithEgress")
		}
		b.Egress = append(b.Egress, *values[i])
	}
	return b
}
