// 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"
	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// BGPConfigurationSpecApplyConfiguration represents a declarative configuration of the BGPConfigurationSpec type for use
// with apply.
//
// BGPConfigurationSpec contains the values of the BGP configuration.
type BGPConfigurationSpecApplyConfiguration struct {
	// LogSeverityScreen is the log severity above which logs are sent to the stdout. [Default: Info]
	LogSeverityScreen *string `json:"logSeverityScreen,omitempty"`
	// NodeToNodeMeshEnabled sets whether full node to node BGP mesh is enabled. [Default: true]
	NodeToNodeMeshEnabled *bool `json:"nodeToNodeMeshEnabled,omitempty"`
	// ASNumber is the default AS number used by a node. [Default: 64512]
	ASNumber *numorstring.ASNumber `json:"asNumber,omitempty"`
	// ServiceLoadBalancerIPs are the CIDR blocks for Kubernetes Service LoadBalancer IPs.
	// Kubernetes Service status.LoadBalancer.Ingress IPs will only be advertised if they are within one of these blocks.
	ServiceLoadBalancerIPs []ServiceLoadBalancerIPBlockApplyConfiguration `json:"serviceLoadBalancerIPs,omitempty"`
	// ServiceExternalIPs are the CIDR blocks for Kubernetes Service External IPs.
	// Kubernetes Service ExternalIPs will only be advertised if they are within one of these blocks.
	ServiceExternalIPs []ServiceExternalIPBlockApplyConfiguration `json:"serviceExternalIPs,omitempty"`
	// ServiceClusterIPs are the CIDR blocks from which service cluster IPs are allocated.
	// If specified, Calico will advertise these blocks, as well as any cluster IPs within them.
	ServiceClusterIPs []ServiceClusterIPBlockApplyConfiguration `json:"serviceClusterIPs,omitempty"`
	// ServiceLoadBalancerAggregation controls how LoadBalancer service IPs are advertised.
	// When set to "Disabled", individual /32 routes are advertised for each service instead of
	// the full CIDR range. This is useful for anycast failover mechanisms where failed service
	// routes need to be withdrawn. [Default: Enabled]
	ServiceLoadBalancerAggregation *projectcalicov3.ServiceLoadBalancerAggregation `json:"serviceLoadBalancerAggregation,omitempty"`
	// Communities is a list of BGP community values and their arbitrary names for tagging routes.
	Communities []CommunityApplyConfiguration `json:"communities,omitempty"`
	// PrefixAdvertisements contains per-prefix advertisement configuration.
	PrefixAdvertisements []PrefixAdvertisementApplyConfiguration `json:"prefixAdvertisements,omitempty"`
	// ListenPort is the port where BGP protocol should listen. Defaults to 179
	ListenPort *uint16 `json:"listenPort,omitempty"`
	// Optional BGP password for full node-to-mesh peerings.
	// This field can only be set on the default BGPConfiguration instance and requires that NodeMesh is enabled
	NodeMeshPassword *BGPPasswordApplyConfiguration `json:"nodeMeshPassword,omitempty"`
	// Time to allow for software restart for node-to-mesh peerings.  When specified, this is configured
	// as the graceful restart timeout.  When not specified, the BIRD default of 120s is used.
	// This field can only be set on the default BGPConfiguration instance and requires that NodeMesh is enabled
	NodeMeshMaxRestartTime *v1.Duration `json:"nodeMeshMaxRestartTime,omitempty"`
	// BindMode indicates whether to listen for BGP connections on all addresses (None)
	// or only on the node's canonical IP address Node.Spec.BGP.IPvXAddress (NodeIP).
	// Default behaviour is to listen for BGP connections on all addresses.
	BindMode *projectcalicov3.BindMode `json:"bindMode,omitempty"`
	// IgnoredInterfaces indicates the network interfaces that needs to be excluded when reading device routes.
	IgnoredInterfaces []string `json:"ignoredInterfaces,omitempty"`
	// The virtual IPv4 address of the node with which its local workload is expected to peer.
	// It is recommended to use a link-local address.
	LocalWorkloadPeeringIPV4 *string `json:"localWorkloadPeeringIPV4,omitempty"`
	// The virtual IPv6 address of the node with which its local workload is expected to peer.
	// It is recommended to use a link-local address.
	LocalWorkloadPeeringIPV6 *string `json:"localWorkloadPeeringIPV6,omitempty"`
	// ProgramClusterRoutes controls how a cluster node gets a route to a workload on another node,
	// when that workload's IP comes from an IP Pool with vxlanMode: Never. When ProgramClusterRoutes is Enabled,
	// confd and BIRD program that route. When ProgramClusterRoutes is Disabled, it is expected that Felix will program that route.
	// Felix always programs such routes for IP Pools with vxlanMode: Always or vxlanMode: CrossSubnet. [Default: Enabled]
	ProgramClusterRoutes *string `json:"programClusterRoutes,omitempty"`
	// IPv4NormalRoutePriority is the normal route priority (metric) that Felix uses for IPv4
	// workload routes. This must match the value configured in FelixConfiguration. BIRD uses
	// this to identify elevated-priority routes during live migration and to override local
	// workload routes with higher-priority BGP-learned routes. [Default: 1024]
	IPv4NormalRoutePriority *int `json:"ipv4NormalRoutePriority,omitempty"`
	// IPv6NormalRoutePriority is the normal route priority (metric) that Felix uses for IPv6
	// workload routes. This must match the value configured in FelixConfiguration. BIRD uses
	// this to identify elevated-priority routes during live migration and to override local
	// workload routes with higher-priority BGP-learned routes. [Default: 1024]
	IPv6NormalRoutePriority *int `json:"ipv6NormalRoutePriority,omitempty"`
}

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

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

// WithNodeToNodeMeshEnabled sets the NodeToNodeMeshEnabled 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 NodeToNodeMeshEnabled field is set to the value of the last call.
func (b *BGPConfigurationSpecApplyConfiguration) WithNodeToNodeMeshEnabled(value bool) *BGPConfigurationSpecApplyConfiguration {
	b.NodeToNodeMeshEnabled = &value
	return b
}

// WithASNumber sets the ASNumber 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 ASNumber field is set to the value of the last call.
func (b *BGPConfigurationSpecApplyConfiguration) WithASNumber(value numorstring.ASNumber) *BGPConfigurationSpecApplyConfiguration {
	b.ASNumber = &value
	return b
}

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

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

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

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

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

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

// WithListenPort sets the ListenPort 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 ListenPort field is set to the value of the last call.
func (b *BGPConfigurationSpecApplyConfiguration) WithListenPort(value uint16) *BGPConfigurationSpecApplyConfiguration {
	b.ListenPort = &value
	return b
}

// WithNodeMeshPassword sets the NodeMeshPassword 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 NodeMeshPassword field is set to the value of the last call.
func (b *BGPConfigurationSpecApplyConfiguration) WithNodeMeshPassword(value *BGPPasswordApplyConfiguration) *BGPConfigurationSpecApplyConfiguration {
	b.NodeMeshPassword = value
	return b
}

// WithNodeMeshMaxRestartTime sets the NodeMeshMaxRestartTime 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 NodeMeshMaxRestartTime field is set to the value of the last call.
func (b *BGPConfigurationSpecApplyConfiguration) WithNodeMeshMaxRestartTime(value v1.Duration) *BGPConfigurationSpecApplyConfiguration {
	b.NodeMeshMaxRestartTime = &value
	return b
}

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

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

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

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

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

// WithIPv4NormalRoutePriority sets the IPv4NormalRoutePriority 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 IPv4NormalRoutePriority field is set to the value of the last call.
func (b *BGPConfigurationSpecApplyConfiguration) WithIPv4NormalRoutePriority(value int) *BGPConfigurationSpecApplyConfiguration {
	b.IPv4NormalRoutePriority = &value
	return b
}

// WithIPv6NormalRoutePriority sets the IPv6NormalRoutePriority 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 IPv6NormalRoutePriority field is set to the value of the last call.
func (b *BGPConfigurationSpecApplyConfiguration) WithIPv6NormalRoutePriority(value int) *BGPConfigurationSpecApplyConfiguration {
	b.IPv6NormalRoutePriority = &value
	return b
}
