/*
The MIT License (MIT)

Copyright (c) 2016-2020 Containous SAS; 2020-2026 Traefik Labs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

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

package v1alpha1

// BufferingApplyConfiguration represents a declarative configuration of the Buffering type for use
// with apply.
//
// Buffering holds the buffering middleware configuration.
// This middleware retries or limits the size of requests that can be forwarded to backends.
// More info: https://doc.traefik.io/traefik/v3.7/middlewares/http/buffering/#maxrequestbodybytes
type BufferingApplyConfiguration struct {
	// MaxRequestBodyBytes defines the maximum allowed body size for the request (in bytes).
	// If the request exceeds the allowed size, it is not forwarded to the service, and the client gets a 413 (Request Entity Too Large) response.
	// Default: 0 (no maximum).
	MaxRequestBodyBytes *int64 `json:"maxRequestBodyBytes,omitempty"`
	// MemRequestBodyBytes defines the threshold (in bytes) from which the request will be buffered on disk instead of in memory.
	// Default: 1048576 (1Mi).
	MemRequestBodyBytes *int64 `json:"memRequestBodyBytes,omitempty"`
	// MaxResponseBodyBytes defines the maximum allowed response size from the service (in bytes).
	// If the response exceeds the allowed size, it is not forwarded to the client. The client gets a 500 (Internal Server Error) response instead.
	// Default: 0 (no maximum).
	MaxResponseBodyBytes *int64 `json:"maxResponseBodyBytes,omitempty"`
	// MemResponseBodyBytes defines the threshold (in bytes) from which the response will be buffered on disk instead of in memory.
	// Default: 1048576 (1Mi).
	MemResponseBodyBytes *int64 `json:"memResponseBodyBytes,omitempty"`
	// RetryExpression defines the retry conditions.
	// It is a logical combination of functions with operators AND (&&) and OR (||).
	// More info: https://doc.traefik.io/traefik/v3.7/middlewares/http/buffering/#retryexpression
	RetryExpression *string `json:"retryExpression,omitempty"`
}

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

// WithMaxRequestBodyBytes sets the MaxRequestBodyBytes 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 MaxRequestBodyBytes field is set to the value of the last call.
func (b *BufferingApplyConfiguration) WithMaxRequestBodyBytes(value int64) *BufferingApplyConfiguration {
	b.MaxRequestBodyBytes = &value
	return b
}

// WithMemRequestBodyBytes sets the MemRequestBodyBytes 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 MemRequestBodyBytes field is set to the value of the last call.
func (b *BufferingApplyConfiguration) WithMemRequestBodyBytes(value int64) *BufferingApplyConfiguration {
	b.MemRequestBodyBytes = &value
	return b
}

// WithMaxResponseBodyBytes sets the MaxResponseBodyBytes 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 MaxResponseBodyBytes field is set to the value of the last call.
func (b *BufferingApplyConfiguration) WithMaxResponseBodyBytes(value int64) *BufferingApplyConfiguration {
	b.MaxResponseBodyBytes = &value
	return b
}

// WithMemResponseBodyBytes sets the MemResponseBodyBytes 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 MemResponseBodyBytes field is set to the value of the last call.
func (b *BufferingApplyConfiguration) WithMemResponseBodyBytes(value int64) *BufferingApplyConfiguration {
	b.MemResponseBodyBytes = &value
	return b
}

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