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

// HTTPHeaderFilterApplyConfiguration represents a declarative configuration of the HTTPHeaderFilter type for use
// with apply.
//
// HTTPHeaderFilter defines a filter that modifies the headers of an HTTP
// request or response. Only one action for a given header name is
// permitted. Filters specifying multiple actions of the same or different
// type for any one header name are invalid. Configuration to set or add
// multiple values for a header must use RFC 7230 header value formatting,
// separating each value with a comma.
type HTTPHeaderFilterApplyConfiguration struct {
	// Set overwrites the request with the given header (name, value)
	// before the action.
	//
	// Input:
	// GET /foo HTTP/1.1
	// my-header: foo
	//
	// Config:
	// set:
	// - name: "my-header"
	// value: "bar"
	//
	// Output:
	// GET /foo HTTP/1.1
	// my-header: bar
	Set []HTTPHeaderApplyConfiguration `json:"set,omitempty"`
	// Add adds the given header(s) (name, value) to the request
	// before the action. It appends to any existing values associated
	// with the header name.
	//
	// Input:
	// GET /foo HTTP/1.1
	// my-header: foo
	//
	// Config:
	// add:
	// - name: "my-header"
	// value: "bar,baz"
	//
	// Output:
	// GET /foo HTTP/1.1
	// my-header: foo,bar,baz
	Add []HTTPHeaderApplyConfiguration `json:"add,omitempty"`
	// Remove the given header(s) from the HTTP request before the action. The
	// value of Remove is a list of HTTP header names. Note that the header
	// names are case-insensitive (see
	// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2).
	//
	// Input:
	// GET /foo HTTP/1.1
	// my-header1: foo
	// my-header2: bar
	// my-header3: baz
	//
	// Config:
	// remove: ["my-header1", "my-header3"]
	//
	// Output:
	// GET /foo HTTP/1.1
	// my-header2: bar
	Remove []string `json:"remove,omitempty"`
}

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

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

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

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