// Copyright (c) 2026 Tigera, Inc. All rights reserved.

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

package v3

// HTTPMatchApplyConfiguration represents a declarative configuration of the HTTPMatch type for use
// with apply.
//
// HTTPMatch is an optional field that apply only to HTTP requests
// The Methods and Path fields are joined with AND
type HTTPMatchApplyConfiguration struct {
	// Methods is an optional field that restricts the rule to apply only to HTTP requests that use one of the listed
	// HTTP Methods (e.g. GET, PUT, etc.)
	// Multiple methods are OR'd together.
	Methods []string `json:"methods,omitempty"`
	// Paths is an optional field that restricts the rule to apply to HTTP requests that use one of the listed
	// HTTP Paths.
	// Multiple paths are OR'd together.
	// e.g:
	// - exact: /foo
	// - prefix: /bar
	// NOTE: Each entry may ONLY specify either a `exact` or a `prefix` match. The validator will check for it.
	Paths []HTTPPathApplyConfiguration `json:"paths,omitempty"`
}

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

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

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