export type GetApiApiMetricsTaskTaskNameArgs = {taskName: string, start: string, end: string, step: string}; export type GetApiApiMetricsTaskTaskNameOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Returns prometheus task metrics * * GET /api/metrics/task/{taskName} */ export const getApiApiMetricsTaskTaskName = async (args: GetApiApiMetricsTaskTaskNameArgs, options?: GetApiApiMetricsTaskTaskNameOptions) => { const {baseUrl = "https://developer.orkescloud.com", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.start != null) query.append("start", String(args.start)) if (args.end != null) query.append("end", String(args.end)) if (args.step != null) query.append("step", String(args.step)) if (apiKey !== undefined) headers.set("X-Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/metrics/task/${encodeURIComponent(String(args.taskName))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };