Do executes the request and returns response or error.
(providedCtx context.Context, transport Transport)
| 74 | |
| 75 | // Do executes the request and returns response or error. |
| 76 | func (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" |
nothing calls this directly
no test coverage detected