Files
pikasTech-HWLAB/web/hwlab-cloud-web/src/api/caserun.ts
T

16 lines
1.1 KiB
TypeScript

import { fetchJson } from "./client";
import type { ApiResult, CaseRunAggregateResponse, CaseRunCasesResponse, CaseRunEventsResponse, CaseRunRunResponse } from "@/types";
export const caserunAPI = {
cases: (): Promise<ApiResult<CaseRunCasesResponse>> => fetchJson("/v1/caserun/cases", { timeoutMs: 12000, timeoutName: "CaseRun cases" }),
startRun: (caseId: string): Promise<ApiResult<CaseRunRunResponse>> => fetchJson("/v1/caserun/runs", {
method: "POST",
body: JSON.stringify({ caseId }),
timeoutMs: 12000,
timeoutName: "CaseRun start"
}),
run: (runId: string): Promise<ApiResult<CaseRunRunResponse>> => fetchJson(`/v1/caserun/runs/${encodeURIComponent(runId)}`, { timeoutMs: 12000, timeoutName: "CaseRun run" }),
events: (runId: string): Promise<ApiResult<CaseRunEventsResponse>> => fetchJson(`/v1/caserun/runs/${encodeURIComponent(runId)}/events`, { timeoutMs: 12000, timeoutName: "CaseRun events" }),
aggregate: (runId: string): Promise<ApiResult<CaseRunAggregateResponse>> => fetchJson(`/v1/caserun/runs/${encodeURIComponent(runId)}/aggregate`, { timeoutMs: 12000, timeoutName: "CaseRun aggregate" })
};