// Code generated by mdatagen. DO NOT EDIT.

package confighttp

import (
	"time"

	"go.opentelemetry.io/collector/config/configauth"
	"go.opentelemetry.io/collector/config/configcompression"
	"go.opentelemetry.io/collector/config/configmiddleware"
	"go.opentelemetry.io/collector/config/confignet"
	"go.opentelemetry.io/collector/config/configopaque"
	"go.opentelemetry.io/collector/config/configoptional"
	"go.opentelemetry.io/collector/config/configtls"
)

type AuthConfig struct {
	// Config defines the auth settings for the receiver.
	Config configauth.Config `mapstructure:",squash"`

	// RequestParameters is a list of parameters that should be extracted from the request and added to the context.
	// When a parameter is found in both the query string and the header, the value from the query string will be used.
	RequestParameters []string `mapstructure:"request_params,omitempty"`

	// prevent unkeyed literal initialization
	_ struct{}
}

// ClientConfig defines settings for creating an HTTP client.
type ClientConfig struct {
	// DialerMiddleware dialer middleware is a handler customizing how the client will dial connections over TCP.
	DialerMiddleware configoptional.Optional[configmiddleware.Config] `mapstructure:"dialer_middleware,omitempty"`

	// Endpoint is the target URL to send data to (e.g.: http://some.url:9411/v1/traces).
	Endpoint string `mapstructure:"endpoint,omitempty"`

	// ProxyURL is the proxy setting for the collector.
	ProxyURL string `mapstructure:"proxy_url,omitempty"`

	// TLS exposes TLS client configuration.
	TLS configtls.ClientConfig `mapstructure:"tls,omitempty"`

	// ReadBufferSize is the read buffer size for the HTTP client. See http.Transport.ReadBufferSize.
	// Default is 0.
	ReadBufferSize int `mapstructure:"read_buffer_size,omitempty"`

	// WriteBufferSize is the write buffer size for the HTTP client. See http.Transport.WriteBufferSize.
	// Default is 0.
	WriteBufferSize int `mapstructure:"write_buffer_size,omitempty"`

	// Timeout is a parameter that configures `http.Client.Timeout`.
	// Default is 0 (unlimited).
	Timeout time.Duration `mapstructure:"timeout,omitempty"`

	// Headers defines additional headers attached to each HTTP request sent by the client.
	// Existing header values are overwritten if collision happens.
	// Header values are opaque since they may be sensitive.
	Headers configopaque.MapList `mapstructure:"headers,omitempty"`

	// Auth is authentication configuration for outgoing HTTP calls.
	Auth configoptional.Optional[configauth.Config] `mapstructure:"auth,omitempty"`

	// Compression is the key for the supported compression types within the collector.
	Compression configcompression.Type `mapstructure:"compression,omitempty"`

	// CompressionParams provides advanced configuration options for the configured compression type.
	CompressionParams configcompression.CompressionParams `mapstructure:"compression_params,omitempty"`

	// MaxConnsPerHost limits the total number of connections per host, including connections in the dialing,
	// active, and idle states. Default is 0 (unlimited).
	MaxConnsPerHost int `mapstructure:"max_conns_per_host,omitempty"`

	// HTTP2ReadIdleTimeout is the duration after which, if the connection has been idle, a ping frame is sent for a health check.
	// 0s means no health check will be performed.
	// This is needed in case you run into
	// https://github.com/golang/go/issues/59690
	// https://github.com/golang/go/issues/36026
	HTTP2ReadIdleTimeout time.Duration `mapstructure:"http2_read_idle_timeout,omitempty"`

	// HTTP2PingTimeout is the duration to wait for a response to a health check ping before the connection is closed.
	// If not set or set to 0, it defaults to 15s.
	HTTP2PingTimeout time.Duration `mapstructure:"http2_ping_timeout,omitempty"`

	// Cookies configures the cookie management of the HTTP client.
	Cookies configoptional.Optional[CookiesConfig] `mapstructure:"cookies,omitempty"`

	// ForceAttemptHTTP2 controls whether the HTTP transport is forced to use the HTTP/2 protocol.
	// By default, this is set to true.
	// NOTE: HTTP/2 does not support settings such as max_conns_per_host, max_idle_conns_per_host and max_idle_conns.
	ForceAttemptHTTP2 bool `mapstructure:"force_attempt_http2,omitempty"`

	// Middlewares are used to add custom functionality to the HTTP client.
	// Middleware handlers are called in the order they appear in this list,
	// with the first middleware becoming the outermost handler.
	Middlewares []configmiddleware.Config `mapstructure:"middlewares,omitempty"`

	// Keepalive controls HTTP client keep-alives. Unmarshal folds this section into the deprecated
	// fields below, which remain the source of truth during their deprecation
	// window, and always resets it to None. A value visible to ToClient was
	// therefore set programmatically after unmarshaling (or the config was
	// never unmarshaled) and takes precedence over the deprecated fields.
	Keepalive configoptional.Optional[KeepaliveClientConfig] `mapstructure:"keepalive,omitempty"`

	// placeholder for the private fields
	privateClientConfigFields

	// prevent unkeyed literal initialization
	_ struct{}
}

// CORSConfig configures a receiver for HTTP cross-origin resource sharing (CORS).
// See the underlying https://github.com/rs/cors package for details.
type CORSConfig struct {
	// AllowedOrigins sets the allowed values of the Origin header for
	// HTTP/JSON requests to an OTLP receiver. An origin may contain a
	// wildcard (*) to replace 0 or more characters (e.g.,
	// "http://*.domain.com", or "*" to allow any origin).
	AllowedOrigins []string `mapstructure:"allowed_origins,omitempty"`

	// AllowedHeaders sets what headers will be allowed in CORS requests.
	// The Accept, Accept-Language, Content-Type, and Content-Language
	// headers are implicitly allowed. If no headers are listed,
	// X-Requested-With will also be accepted by default. Include "*" to
	// allow any request header.
	AllowedHeaders []string `mapstructure:"allowed_headers,omitempty"`

	// ExposedHeaders sets the value of the Access-Control-Expose-Headers response header,
	// indicating which headers are safe to expose to the API of a CORS response.
	ExposedHeaders []string `mapstructure:"exposed_headers,omitempty"`

	// MaxAge sets the value of the Access-Control-Max-Age response header.
	// Set it to the number of seconds that browsers should cache a CORS
	// preflight response for.
	MaxAge int `mapstructure:"max_age,omitempty"`

	// prevent unkeyed literal initialization
	_ struct{}
}

// NewDefaultCORSConfig returns a new CORSConfig with its default values applied.
// Prefer this over an empty struct literal so default changes stay in sync automatically.
func NewDefaultCORSConfig() CORSConfig {
	return CORSConfig{}
}

// KeepaliveClientConfig describes the keepalive configuration.
type KeepaliveClientConfig struct {
	// IdleConnTimeout is the maximum amount of time an idle (keep-alive) connection will remain open before closing itself.
	// By default, it is set to 90 seconds.
	IdleConnTimeout time.Duration `mapstructure:"idle_conn_timeout"`

	// MaxIdleConns is used to set a limit to the maximum idle HTTP connections the client can keep open.
	// By default, it is set to 100. Zero means no limit.
	MaxIdleConns int `mapstructure:"max_idle_conns"`

	// MaxIdleConnsPerHost is used to set a limit to the maximum idle HTTP connections the host can keep open.
	// If zero, [net/http.DefaultMaxIdleConnsPerHost] is used.
	MaxIdleConnsPerHost int `mapstructure:"max_idle_conns_per_host,omitempty"`

	// prevent unkeyed literal initialization
	_ struct{}
}

type KeepaliveServerConfig struct {
	// IdleTimeout is the maximum amount of time to wait for the
	// next request when keep-alives are enabled. If IdleTimeout
	// is zero, the value of ReadTimeout is used. If both are
	// zero, there is no timeout.
	IdleTimeout time.Duration `mapstructure:"idle_timeout"`

	// prevent unkeyed literal initialization
	_ struct{}
}

// NewDefaultKeepaliveServerConfig returns a new KeepaliveServerConfig with its default values applied.
// Prefer this over an empty struct literal so default changes stay in sync automatically.
func NewDefaultKeepaliveServerConfig() KeepaliveServerConfig {
	return KeepaliveServerConfig{
		IdleTimeout: 1 * time.Minute,
	}
}

// ServerConfig defines settings for creating an HTTP server.
type ServerConfig struct {
	// NetAddr holds configuration for the network listener.
	// Transport defaults to "tcp" if unspecified, and only
	// "tcp", "tcp4", "tcp6", and "unix" are valid options.
	NetAddr confignet.AddrConfig `mapstructure:",squash"`

	// TLS exposes TLS server configuration.
	TLS configoptional.Optional[configtls.ServerConfig] `mapstructure:"tls,omitempty"`

	// CORS configures the server for HTTP cross-origin resource sharing (CORS).
	CORS configoptional.Optional[CORSConfig] `mapstructure:"cors,omitempty"`

	// Auth is the authentication configuration for this receiver.
	Auth configoptional.Optional[AuthConfig] `mapstructure:"auth,omitempty"`

	// MaxRequestBodySize sets the maximum request body size in bytes. Default: 20MiB.
	// The limit is enforced on the bytes received and, when the request has a
	// supported Content-Encoding (for example gzip), again on the decompressed
	// body. Set it to the maximum expected decompressed payload size.
	MaxRequestBodySize int64 `mapstructure:"max_request_body_size,omitempty"`

	// IncludeMetadata propagates the client metadata from the incoming requests to the downstream consumers.
	IncludeMetadata bool `mapstructure:"include_metadata,omitempty"`

	// ResponseHeaders defines additional headers attached to each HTTP response sent to the client.
	// Header values are opaque since they may be sensitive.
	ResponseHeaders configopaque.MapList `mapstructure:"response_headers,omitempty"`

	// CompressionAlgorithms configures the list of compression algorithms the server can accept.
	// Default: ["", "gzip", "zstd", "zlib", "snappy", "deflate"]
	CompressionAlgorithms []string `mapstructure:"compression_algorithms,omitempty"`

	// ReadTimeout is the maximum duration for reading the entire
	// request, including the body. A zero or negative value means
	// there will be no timeout.
	//
	// Because ReadTimeout does not let Handlers make per-request
	// decisions on each request body's acceptable deadline or
	// upload rate, most users will prefer to use
	// ReadHeaderTimeout. It is valid to use them both.
	ReadTimeout time.Duration `mapstructure:"read_timeout,omitempty"`

	// ReadHeaderTimeout is the amount of time allowed to read
	// request headers. The connection's read deadline is reset
	// after reading the headers and the Handler can decide what
	// is considered too slow for the body. If ReadHeaderTimeout
	// is zero, the value of ReadTimeout is used. If both are
	// zero, there is no timeout.
	ReadHeaderTimeout time.Duration `mapstructure:"read_header_timeout"`

	// WriteTimeout is the maximum duration before timing out
	// writes of the response. It is reset whenever a new
	// request's header is read. Like ReadTimeout, it does not
	// let Handlers make decisions on a per-request basis.
	// A zero or negative value means there will be no timeout.
	WriteTimeout time.Duration `mapstructure:"write_timeout"`

	// Middlewares are used to add custom functionality to the HTTP server.
	// Middleware handlers are called in the order they appear in this list,
	// with the first middleware becoming the outermost handler.
	Middlewares []configmiddleware.Config `mapstructure:"middlewares,omitempty"`

	// Keepalive controls HTTP keep-alives.
	// By default, keep-alives are always enabled. Only very resource-constrained environments should disable them.
	// Unmarshal folds this section into the deprecated fields below, which
	// remain the source of truth during their deprecation window, and always
	// resets it to None. A value visible to ToServer was therefore set
	// programmatically after unmarshaling (or the config was never unmarshaled)
	// and takes precedence over the deprecated fields.
	Keepalive configoptional.Optional[KeepaliveServerConfig] `mapstructure:"keepalive,omitempty"`

	// placeholder for the private fields
	privateServerConfigFields

	// prevent unkeyed literal initialization
	_ struct{}
}
