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

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

package v3

// HostEndpointSpecApplyConfiguration represents a declarative configuration of the HostEndpointSpec type for use
// with apply.
//
// HostEndpointSpec contains the specification for a HostEndpoint resource.
type HostEndpointSpecApplyConfiguration struct {
	// The node name identifying the Calico node instance.
	Node *string `json:"node,omitempty"`
	// Either "*", or the name of a specific Linux interface to apply policy to; or empty.  "*"
	// indicates that this HostEndpoint governs all traffic to, from or through the default
	// network namespace of the host named by the "Node" field; entering and leaving that
	// namespace via any interface, including those from/to non-host-networked local workloads.
	//
	// If InterfaceName is not "*", this HostEndpoint only governs traffic that enters or leaves
	// the host through the specific interface named by InterfaceName, or - when InterfaceName
	// is empty - through the specific interface that has one of the IPs in ExpectedIPs.
	// Therefore, when InterfaceName is empty, at least one expected IP must be specified.  Only
	// external interfaces (such as "eth0") are supported here; it isn't possible for a
	// HostEndpoint to protect traffic through a specific local workload interface.
	//
	// Note: Only some kinds of policy are implemented for "*" HostEndpoints; initially just
	// pre-DNAT policy.  Please check Calico documentation for the latest position.
	InterfaceName *string `json:"interfaceName,omitempty"`
	// The expected IP addresses (IPv4 and IPv6) of the endpoint.
	// If "InterfaceName" is not present, Calico will look for an interface matching any
	// of the IPs in the list and apply policy to that.
	// Note:
	// When using the selector match criteria in an ingress or egress security Policy
	// or Profile, Calico converts the selector into a set of IP addresses. For host
	// endpoints, the ExpectedIPs field is used for that purpose. (If only the interface
	// name is specified, Calico does not learn the IPs of the interface for use in match
	// criteria.)
	ExpectedIPs []string `json:"expectedIPs,omitempty"`
	// A list of identifiers of security Profile objects that apply to this endpoint. Each
	// profile is applied in the order that they appear in this list.  Profile rules are applied
	// after the selector-based security policy.
	Profiles []string `json:"profiles,omitempty"`
	// Ports contains the endpoint's named ports, which may be referenced in security policy rules.
	Ports []EndpointPortApplyConfiguration `json:"ports,omitempty"`
}

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

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

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

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

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

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