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

import (
	apixv1alpha2 "sigs.k8s.io/gateway-api-inference-extension/apix/v1alpha2"
)

// ExtensionApplyConfiguration represents a declarative configuration of the Extension type for use
// with apply.
//
// Extension specifies how to configure an extension that runs the endpoint picker.
type ExtensionApplyConfiguration struct {
	// Group is the group of the referent.
	// The default value is "", representing the Core API group.
	Group *apixv1alpha2.Group `json:"group,omitempty"`
	// Kind is the Kubernetes resource kind of the referent.
	//
	// Defaults to "Service" when not specified.
	//
	// ExternalName services can refer to CNAME DNS records that may live
	// outside of the cluster and as such are difficult to reason about in
	// terms of conformance. They also may not be safe to forward to (see
	// CVE-2021-25740 for more information). Implementations MUST NOT
	// support ExternalName Services.
	Kind *apixv1alpha2.Kind `json:"kind,omitempty"`
	// Name is the name of the referent.
	Name *apixv1alpha2.ObjectName `json:"name,omitempty"`
	// The port number on the service running the extension. When unspecified,
	// implementations SHOULD infer a default value of 9002 when the Kind is
	// Service.
	PortNumber *apixv1alpha2.PortNumber `json:"portNumber,omitempty"`
	// Configures how the gateway handles the case when the extension is not responsive.
	// Defaults to failClose.
	FailureMode *apixv1alpha2.ExtensionFailureMode `json:"failureMode,omitempty"`
}

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

// WithGroup sets the Group 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 Group field is set to the value of the last call.
func (b *ExtensionApplyConfiguration) WithGroup(value apixv1alpha2.Group) *ExtensionApplyConfiguration {
	b.Group = &value
	return b
}

// WithKind sets the Kind 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 Kind field is set to the value of the last call.
func (b *ExtensionApplyConfiguration) WithKind(value apixv1alpha2.Kind) *ExtensionApplyConfiguration {
	b.Kind = &value
	return b
}

// WithName sets the Name 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 Name field is set to the value of the last call.
func (b *ExtensionApplyConfiguration) WithName(value apixv1alpha2.ObjectName) *ExtensionApplyConfiguration {
	b.Name = &value
	return b
}

// WithPortNumber sets the PortNumber 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 PortNumber field is set to the value of the last call.
func (b *ExtensionApplyConfiguration) WithPortNumber(value apixv1alpha2.PortNumber) *ExtensionApplyConfiguration {
	b.PortNumber = &value
	return b
}

// WithFailureMode sets the FailureMode 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 FailureMode field is set to the value of the last call.
func (b *ExtensionApplyConfiguration) WithFailureMode(value apixv1alpha2.ExtensionFailureMode) *ExtensionApplyConfiguration {
	b.FailureMode = &value
	return b
}
