// 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"
	numorstring "github.com/projectcalico/api/pkg/lib/numorstring"
)

// BGPFilterRuleV6ApplyConfiguration represents a declarative configuration of the BGPFilterRuleV6 type for use
// with apply.
//
// BGPFilterRuleV6 defines a BGP filter rule consisting of match criteria, a terminal action,
// and optional operations to apply to matching routes.
type BGPFilterRuleV6ApplyConfiguration struct {
	// If non-empty, this filter rule will only apply when the route being exported or imported
	// "matches" the given CIDR - where the definition of "matches" is according to
	// MatchOperator and PrefixLength.  CIDR should be in conventional CIDR notation,
	// <prefix>/<length>.
	CIDR *string `json:"cidr,omitempty"`
	// PrefixLength further constrains the CIDR match by restricting the range of allowed
	// prefix lengths.  For example, CIDR "fd00::/8" with MatchOperator "In" and
	// PrefixLength {min: 48, max: 64} matches any route within fd00::/8 whose prefix
	// length is between /48 and /64.  Requires CIDR to be set; if CIDR is omitted,
	// PrefixLength is ignored.  If PrefixLength is nil and CIDR is set, the CIDR's own
	// prefix length is used as the minimum and /128 (for V6) as the maximum.
	PrefixLength *BGPFilterPrefixLengthV6ApplyConfiguration `json:"prefixLength,omitempty"`
	// If set to "RemotePeers": for export rules, this filter rule will only apply to routes
	// learned from BGP peers (i.e. re-advertised routes), not locally originated routes.
	// For import rules, this field is redundant because imported routes are by definition
	// from BGP peers.
	Source *projectcalicov3.BGPFilterMatchSource `json:"source,omitempty"`
	// If non-empty, this filter rule will only apply to routes with an outgoing interface that
	// matches Interface.
	Interface *string `json:"interface,omitempty"`
	// MatchOperator defines how the route's prefix is compared against CIDR.  "Equal" requires
	// an exact prefix match, "In" requires the route to be contained within the CIDR (or equal),
	// "NotEqual" and "NotIn" are their negations.  Only meaningful when CIDR is also specified.
	// Required when CIDR is set.
	MatchOperator *projectcalicov3.BGPFilterMatchOperator `json:"matchOperator,omitempty"`
	// If non-empty, this filter rule will only apply to routes being imported from or exported
	// to a BGP peer of the specified type.  If empty, the rule applies to all peers.
	PeerType *projectcalicov3.BGPFilterPeerType `json:"peerType,omitempty"`
	// If set, this filter rule will only apply to routes that carry the specified BGP
	// community.  On import, this matches communities set by the remote peer.  On export,
	// this matches communities already present on the route, whether received from a BGP
	// peer (e.g. on a route reflector re-advertising to an eBGP peer) or added locally
	// by an import filter or an earlier export rule's AddCommunity operation.
	Communities *BGPFilterCommunityMatchApplyConfiguration `json:"communities,omitempty"`
	// If non-empty, this filter rule will only apply to routes whose AS path begins with the
	// specified sequence of AS numbers.
	ASPathPrefix []numorstring.ASNumber `json:"asPathPrefix,omitempty"`
	// If set, this filter rule will only apply to routes with the given priority, in the
	// same units as the ...RoutePriority fields in FelixConfiguration.
	Priority *int                             `json:"priority,omitempty"`
	Action   *projectcalicov3.BGPFilterAction `json:"action,omitempty"`
	// Operations is an ordered list of route modifications to apply to matching routes before
	// accepting them.  Only valid when Action is "Accept"; specifying operations with "Reject"
	// is rejected by validation.  Each entry must set exactly one operation field.
	Operations []BGPFilterOperationApplyConfiguration `json:"operations,omitempty"`
}

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

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

// WithPrefixLength sets the PrefixLength 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 PrefixLength field is set to the value of the last call.
func (b *BGPFilterRuleV6ApplyConfiguration) WithPrefixLength(value *BGPFilterPrefixLengthV6ApplyConfiguration) *BGPFilterRuleV6ApplyConfiguration {
	b.PrefixLength = value
	return b
}

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

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

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

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

// WithCommunities sets the Communities 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 Communities field is set to the value of the last call.
func (b *BGPFilterRuleV6ApplyConfiguration) WithCommunities(value *BGPFilterCommunityMatchApplyConfiguration) *BGPFilterRuleV6ApplyConfiguration {
	b.Communities = value
	return b
}

// WithASPathPrefix adds the given value to the ASPathPrefix 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 ASPathPrefix field.
func (b *BGPFilterRuleV6ApplyConfiguration) WithASPathPrefix(values ...numorstring.ASNumber) *BGPFilterRuleV6ApplyConfiguration {
	for i := range values {
		b.ASPathPrefix = append(b.ASPathPrefix, values[i])
	}
	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 *BGPFilterRuleV6ApplyConfiguration) WithPriority(value int) *BGPFilterRuleV6ApplyConfiguration {
	b.Priority = &value
	return b
}

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

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