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

import (
	apisxv1alpha1 "sigs.k8s.io/gateway-api/apisx/v1alpha1"
)

// BackendSpecApplyConfiguration represents a declarative configuration of the BackendSpec type for use
// with apply.
//
// BackendSpec defines the desired state of a Backend.
type BackendSpecApplyConfiguration struct {
	// Type defines the backend type.
	Type *apisxv1alpha1.BackendType `json:"type,omitempty"`
	// Port defines the port that the implementation should use when connecting
	// to this backend.
	Port *BackendPortApplyConfiguration `json:"port,omitempty"`
	// ExternalHostname specifies the configuration for an ExternalHostname
	// backend. This field must be set when type is ExternalHostname and must
	// be unset otherwise.
	//
	// Support: Extended
	ExternalHostname *ExternalHostnameBackendApplyConfiguration `json:"externalHostname,omitempty"`
	// Protocol defines the protocol for backend communication.
	//
	// In the common case, the underlying transport protocol for the
	// proxied traffic will already have been determined and processed
	// by the dataplane at the routing step. Where this field is useful
	// is either for higher level protocols or asymmetrical protocol
	// configurations (e.g. version upgrades or h2c).
	//
	// When set, the implementation uses the specified protocol when connecting
	// to this backend. When not set, the implementation will use the protocol
	// determined by the route or listener configuration.
	//
	// Support: Core - HTTP, HTTP2, H2C, and HTTP11
	//
	// Support: Extended - GRPC, MCP, TCP
	//
	// <gateway:util:excludeFromCRD>
	// Notes for implementers:
	//
	// In cases where the protocol is negotiated on the wire (e.g. HTTP/1.1
	// Upgrade or ALPN), implementations MUST include the protocol set here
	// in the negotiation options presented to the backend.
	// </gateway:util:excludeFromCRD>
	Protocol *apisxv1alpha1.BackendProtocol `json:"protocol,omitempty"`
	// TLS defines the TLS configuration that the implementation should use
	// when connecting to the backend.
	//
	// ExternalHostname backends SHOULD have TLS configured; the lack of TLS
	// for external hostnames should be considered insecure and a security risk.
	//
	// Support: Extended
	TLS *BackendTLSApplyConfiguration `json:"tls,omitempty"`
}

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

// WithType sets the Type 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 Type field is set to the value of the last call.
func (b *BackendSpecApplyConfiguration) WithType(value apisxv1alpha1.BackendType) *BackendSpecApplyConfiguration {
	b.Type = &value
	return b
}

// WithPort sets the Port 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 Port field is set to the value of the last call.
func (b *BackendSpecApplyConfiguration) WithPort(value *BackendPortApplyConfiguration) *BackendSpecApplyConfiguration {
	b.Port = value
	return b
}

// WithExternalHostname sets the ExternalHostname 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 ExternalHostname field is set to the value of the last call.
func (b *BackendSpecApplyConfiguration) WithExternalHostname(value *ExternalHostnameBackendApplyConfiguration) *BackendSpecApplyConfiguration {
	b.ExternalHostname = value
	return b
}

// WithProtocol sets the Protocol 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 Protocol field is set to the value of the last call.
func (b *BackendSpecApplyConfiguration) WithProtocol(value apisxv1alpha1.BackendProtocol) *BackendSpecApplyConfiguration {
	b.Protocol = &value
	return b
}

// WithTLS sets the TLS 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 TLS field is set to the value of the last call.
func (b *BackendSpecApplyConfiguration) WithTLS(value *BackendTLSApplyConfiguration) *BackendSpecApplyConfiguration {
	b.TLS = value
	return b
}
