func (f Reindex) WithOpaqueID(s string) func(*ReindexRequest) {
	return func(r *ReindexRequest) {
		if r.Header == nil {
			r.Header = make(http.Header)
		}
		r.Header.Set("X-Opaque-Id", s)
	}
}
WithOpaqueID adds the X-Opaque-Id header to the HTTP request.
package opensearchapi
import (
	"context"
	"fmt"
	"io"
	"net/http"
	"strconv"
	"strings"
	"time"
)
func newReindexFunc(t Transport) Reindex {
	return func(body io.Reader, o ...func(*ReindexRequest)) (*Response, error) {
		var r = ReindexRequest{Body: body}
		for _, f := range o {
			f(&r)
		}
		return r.Do(r.ctx, t)
	}
}
type Reindex func(body io.Reader, o ...func(*ReindexRequest)) (*Response, error)
type ReindexRequest struct {
	Body io.Reader
	MaxDocs             *int
	Refresh             *bool
	RequestsPerSecond   *int
	Scroll              time.Duration
	Slices              interface{}
	Timeout             time.Duration
	WaitForActiveShards string
	WaitForCompletion   *bool
	Pretty     bool
	Human      bool
	ErrorTrace bool
	FilterPath []string
	Header http.Header
	ctx context.Context
}
func (r ReindexRequest) Do(ctx context.Context, transport Transport) (*Response, error) {
	var (
		method string
		path   strings.Builder
		params map[string]string
	)
	method = "POST"
	path.Grow(len("/_reindex"))
	path.WriteString("/_reindex")
	params = make(map[string]string)
	if r.MaxDocs != nil {
		params["max_docs"] = strconv.FormatInt(int64(*r.MaxDocs), 10)
	}
	if r.Refresh != nil {
		params["refresh"] = strconv.FormatBool(*r.Refresh)
	}
	if r.RequestsPerSecond != nil {
		params["requests_per_second"] = strconv.FormatInt(int64(*r.RequestsPerSecond), 10)
	}
	if r.Scroll != 0 {
		params["scroll"] = formatDuration(r.Scroll)
	}
	if r.Slices != nil {
		params["slices"] = fmt.Sprintf("%v", r.Slices)
	}
	if r.Timeout != 0 {
		params["timeout"] = formatDuration(r.Timeout)
	}
	if r.WaitForActiveShards != "" {
		params["wait_for_active_shards"] = r.WaitForActiveShards
	}
	if r.WaitForCompletion != nil {
		params["wait_for_completion"] = strconv.FormatBool(*r.WaitForCompletion)
	}
	if r.Pretty {
		params["pretty"] = "true"
	}
	if r.Human {
		params["human"] = "true"
	}
	if r.ErrorTrace {
		params["error_trace"] = "true"
	}
	if len(r.FilterPath) > 0 {
		params["filter_path"] = strings.Join(r.FilterPath, ",")
	}
	req, err := newRequest(method, path.String(), r.Body)
	if err != nil {
		return nil, err
	}
	if len(params) > 0 {
		q := req.URL.Query()
		for k, v := range params {
			q.Set(k, v)
		}
		req.URL.RawQuery = q.Encode()
	}
	if r.Body != nil {
		req.Header[headerContentType] = headerContentTypeJSON
	}
	if len(r.Header) > 0 {
		if len(req.Header) == 0 {
			req.Header = r.Header
		} else {
			for k, vv := range r.Header {
				for _, v := range vv {
					req.Header.Add(k, v)
				}
			}
		}
	}
	if ctx != nil {
		req = req.WithContext(ctx)
	}
	res, err := transport.Perform(req)
	if err != nil {
		return nil, err
	}
	response := Response{
		StatusCode: res.StatusCode,
		Body:       res.Body,
		Header:     res.Header,
	}
	return &response, nil
}
func (f Reindex) WithContext(v context.Context) func(*ReindexRequest) {
	return func(r *ReindexRequest) {
		r.ctx = v
	}
}
func (f Reindex) WithMaxDocs(v int) func(*ReindexRequest) {
	return func(r *ReindexRequest) {
		r.MaxDocs = &v
	}
}
func (f Reindex) WithRefresh(v bool) func(*ReindexRequest) {
	return func(r *ReindexRequest) {
		r.Refresh = &v
	}
}
func (f Reindex) WithRequestsPerSecond(v int) func(*ReindexRequest) {
	return func(r *ReindexRequest) {
		r.RequestsPerSecond = &v
	}
}
func (f Reindex) WithScroll(v time.Duration) func(*ReindexRequest) {
	return func(r *ReindexRequest) {
		r.Scroll = v
	}
}
func (f Reindex) WithSlices(v interface{}) func(*ReindexRequest) {
	return func(r *ReindexRequest) {
		r.Slices = v
	}
}
func (f Reindex) WithTimeout(v time.Duration) func(*ReindexRequest) {
	return func(r *ReindexRequest) {
		r.Timeout = v
	}
}
func (f Reindex) WithWaitForActiveShards(v string) func(*ReindexRequest) {
	return func(r *ReindexRequest) {
		r.WaitForActiveShards = v
	}
}
func (f Reindex) WithWaitForCompletion(v bool) func(*ReindexRequest) {
	return func(r *ReindexRequest) {
		r.WaitForCompletion = &v
	}
}
func (f Reindex) WithPretty() func(*ReindexRequest) {
	return func(r *ReindexRequest) {
		r.Pretty = true
	}
}
func (f Reindex) WithHuman() func(*ReindexRequest) {
	return func(r *ReindexRequest) {
		r.Human = true
	}
}
func (f Reindex) WithErrorTrace() func(*ReindexRequest) {
	return func(r *ReindexRequest) {
		r.ErrorTrace = true
	}
}
func (f Reindex) WithFilterPath(v ...string) func(*ReindexRequest) {
	return func(r *ReindexRequest) {
		r.FilterPath = v
	}
}
func (f Reindex) WithHeader(h map[string]string) func(*ReindexRequest) {
	return func(r *ReindexRequest) {
		if r.Header == nil {
			r.Header = make(http.Header)
		}
		for k, v := range h {
			r.Header.Add(k, v)
		}
	}
}