Do executes the request and returns response or error.
(providedCtx context.Context, transport Transport)
| 69 | |
| 70 | // Do executes the request and returns response or error. |
| 71 | func (r MLGetDatafeedsRequest) Do(providedCtx context.Context, transport Transport) (*Response, error) { |
| 72 | var ( |
| 73 | method string |
| 74 | path strings.Builder |
| 75 | params map[string]string |
| 76 | ctx context.Context |
| 77 | ) |
| 78 | |
| 79 | if instrument, ok := r.Instrument.(Instrumentation); ok { |
| 80 | ctx = instrument.Start(providedCtx, "ml.get_datafeeds") |
| 81 | defer instrument.Close(ctx) |
| 82 | } |
| 83 | if ctx == nil { |
| 84 | ctx = providedCtx |
| 85 | } |
| 86 | |
| 87 | method = "GET" |
| 88 | |
| 89 | path.Grow(7 + 1 + len("_ml") + 1 + len("datafeeds") + 1 + len(strings.Join(r.DatafeedID, ","))) |
| 90 | path.WriteString("http://") |
| 91 | path.WriteString("/") |
| 92 | path.WriteString("_ml") |
| 93 | path.WriteString("/") |
| 94 | path.WriteString("datafeeds") |
| 95 | if len(r.DatafeedID) > 0 { |
| 96 | path.WriteString("/") |
| 97 | path.WriteString(strings.Join(r.DatafeedID, ",")) |
| 98 | if instrument, ok := r.Instrument.(Instrumentation); ok { |
| 99 | instrument.RecordPathPart(ctx, "datafeed_id", strings.Join(r.DatafeedID, ",")) |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | params = make(map[string]string) |
| 104 | |
| 105 | if r.AllowNoMatch != nil { |
| 106 | params["allow_no_match"] = strconv.FormatBool(*r.AllowNoMatch) |
| 107 | } |
| 108 | |
| 109 | if r.ExcludeGenerated != nil { |
| 110 | params["exclude_generated"] = strconv.FormatBool(*r.ExcludeGenerated) |
| 111 | } |
| 112 | |
| 113 | if r.Pretty { |
| 114 | params["pretty"] = "true" |
| 115 | } |
| 116 | |
| 117 | if r.Human { |
| 118 | params["human"] = "true" |
| 119 | } |
| 120 | |
| 121 | if r.ErrorTrace { |
| 122 | params["error_trace"] = "true" |
| 123 | } |
| 124 | |
| 125 | if len(r.FilterPath) > 0 { |
| 126 | params["filter_path"] = strings.Join(r.FilterPath, ",") |
| 127 | } |
| 128 |
nothing calls this directly
no test coverage detected