MCPcopy
hub / github.com/elastic/go-elasticsearch / Do

Method Do

esapi/api.indices.exists.go:76–201  ·  view source on GitHub ↗

Do executes the request and returns response or error.

(providedCtx context.Context, transport Transport)

Source from the content-addressed store, hash-verified

74
75// Do executes the request and returns response or error.
76func (r IndicesExistsRequest) Do(providedCtx context.Context, transport Transport) (*Response, error) {
77 var (
78 method string
79 path strings.Builder
80 params map[string]string
81 ctx context.Context
82 )
83
84 if instrument, ok := r.Instrument.(Instrumentation); ok {
85 ctx = instrument.Start(providedCtx, "indices.exists")
86 defer instrument.Close(ctx)
87 }
88 if ctx == nil {
89 ctx = providedCtx
90 }
91
92 method = "HEAD"
93
94 if len(r.Index) == 0 {
95 return nil, errors.New("index is required and cannot be nil or empty")
96 }
97
98 path.Grow(7 + 1 + len(strings.Join(r.Index, ",")))
99 path.WriteString("http://")
100 path.WriteString("/")
101 path.WriteString(strings.Join(r.Index, ","))
102 if instrument, ok := r.Instrument.(Instrumentation); ok {
103 instrument.RecordPathPart(ctx, "index", strings.Join(r.Index, ","))
104 }
105
106 params = make(map[string]string)
107
108 if r.AllowNoIndices != nil {
109 params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices)
110 }
111
112 if len(r.ExpandWildcards) > 0 {
113 params["expand_wildcards"] = strings.Join(r.ExpandWildcards, ",")
114 }
115
116 if r.FlatSettings != nil {
117 params["flat_settings"] = strconv.FormatBool(*r.FlatSettings)
118 }
119
120 if r.IgnoreUnavailable != nil {
121 params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable)
122 }
123
124 if r.IncludeDefaults != nil {
125 params["include_defaults"] = strconv.FormatBool(*r.IncludeDefaults)
126 }
127
128 if r.Local != nil {
129 params["local"] = strconv.FormatBool(*r.Local)
130 }
131
132 if r.Pretty {
133 params["pretty"] = "true"

Callers

nothing calls this directly

Calls 14

newRequestFunction · 0.85
JoinMethod · 0.80
CloseMethod · 0.65
AddMethod · 0.65
PerformMethod · 0.65
StartMethod · 0.45
RecordPathPartMethod · 0.45
StringMethod · 0.45
RecordErrorMethod · 0.45
QueryMethod · 0.45
SetMethod · 0.45
WithContextMethod · 0.45

Tested by

no test coverage detected