| 1153 | } |
| 1154 | |
| 1155 | func (h *httpAPI) Query(ctx context.Context, query string, ts time.Time, opts ...Option) (model.Value, Warnings, error) { |
| 1156 | u := h.client.URL(epQuery, nil) |
| 1157 | q := addOptionalURLParams(u.Query(), opts) |
| 1158 | |
| 1159 | q.Set("query", query) |
| 1160 | if !ts.IsZero() { |
| 1161 | q.Set("time", formatTime(ts)) |
| 1162 | } |
| 1163 | |
| 1164 | _, body, warnings, err := h.client.DoGetFallback(ctx, u, q) |
| 1165 | if err != nil { |
| 1166 | return nil, warnings, err |
| 1167 | } |
| 1168 | |
| 1169 | var qres queryResult |
| 1170 | return qres.v, warnings, json.Unmarshal(body, &qres) |
| 1171 | } |
| 1172 | |
| 1173 | func (h *httpAPI) QueryRange(ctx context.Context, query string, r Range, opts ...Option) (model.Value, Warnings, error) { |
| 1174 | u := h.client.URL(epQueryRange, nil) |