|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +import { APIResource } from '../resource'; |
| 4 | +import { isRequestOptions } from '../core'; |
| 5 | +import * as Core from '../core'; |
| 6 | +import * as ScenariosAPI from './scenarios/scenarios'; |
| 7 | +import { ScenarioRunViewsBenchmarkRunsCursorIDPage } from './scenarios/scenarios'; |
| 8 | +import { BenchmarkRunsCursorIDPage, type BenchmarkRunsCursorIDPageParams } from '../pagination'; |
| 9 | + |
| 10 | +export class BenchmarkRuns extends APIResource { |
| 11 | + /** |
| 12 | + * Get a BenchmarkRun given ID. |
| 13 | + */ |
| 14 | + retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise<BenchmarkRunView> { |
| 15 | + return this._client.get(`/v1/benchmark_runs/${id}`, options); |
| 16 | + } |
| 17 | + |
| 18 | + /** |
| 19 | + * List all BenchmarkRuns matching filter. |
| 20 | + */ |
| 21 | + list( |
| 22 | + query?: BenchmarkRunListParams, |
| 23 | + options?: Core.RequestOptions, |
| 24 | + ): Core.PagePromise<BenchmarkRunViewsBenchmarkRunsCursorIDPage, BenchmarkRunView>; |
| 25 | + list( |
| 26 | + options?: Core.RequestOptions, |
| 27 | + ): Core.PagePromise<BenchmarkRunViewsBenchmarkRunsCursorIDPage, BenchmarkRunView>; |
| 28 | + list( |
| 29 | + query: BenchmarkRunListParams | Core.RequestOptions = {}, |
| 30 | + options?: Core.RequestOptions, |
| 31 | + ): Core.PagePromise<BenchmarkRunViewsBenchmarkRunsCursorIDPage, BenchmarkRunView> { |
| 32 | + if (isRequestOptions(query)) { |
| 33 | + return this.list({}, query); |
| 34 | + } |
| 35 | + return this._client.getAPIList('/v1/benchmark_runs', BenchmarkRunViewsBenchmarkRunsCursorIDPage, { |
| 36 | + query, |
| 37 | + ...options, |
| 38 | + }); |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * Cancel a currently running Benchmark run. |
| 43 | + */ |
| 44 | + cancel(id: string, options?: Core.RequestOptions): Core.APIPromise<BenchmarkRunView> { |
| 45 | + return this._client.post(`/v1/benchmark_runs/${id}/cancel`, options); |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * Complete a currently running BenchmarkRun. |
| 50 | + */ |
| 51 | + complete(id: string, options?: Core.RequestOptions): Core.APIPromise<BenchmarkRunView> { |
| 52 | + return this._client.post(`/v1/benchmark_runs/${id}/complete`, options); |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * List started scenario runs for a benchmark run. |
| 57 | + */ |
| 58 | + listScenarioRuns( |
| 59 | + id: string, |
| 60 | + query?: BenchmarkRunListScenarioRunsParams, |
| 61 | + options?: Core.RequestOptions, |
| 62 | + ): Core.PagePromise<ScenarioRunViewsBenchmarkRunsCursorIDPage, ScenariosAPI.ScenarioRunView>; |
| 63 | + listScenarioRuns( |
| 64 | + id: string, |
| 65 | + options?: Core.RequestOptions, |
| 66 | + ): Core.PagePromise<ScenarioRunViewsBenchmarkRunsCursorIDPage, ScenariosAPI.ScenarioRunView>; |
| 67 | + listScenarioRuns( |
| 68 | + id: string, |
| 69 | + query: BenchmarkRunListScenarioRunsParams | Core.RequestOptions = {}, |
| 70 | + options?: Core.RequestOptions, |
| 71 | + ): Core.PagePromise<ScenarioRunViewsBenchmarkRunsCursorIDPage, ScenariosAPI.ScenarioRunView> { |
| 72 | + if (isRequestOptions(query)) { |
| 73 | + return this.listScenarioRuns(id, {}, query); |
| 74 | + } |
| 75 | + return this._client.getAPIList( |
| 76 | + `/v1/benchmark_runs/${id}/scenario_runs`, |
| 77 | + ScenarioRunViewsBenchmarkRunsCursorIDPage, |
| 78 | + { query, ...options }, |
| 79 | + ); |
| 80 | + } |
| 81 | +} |
| 82 | + |
| 83 | +export class BenchmarkRunViewsBenchmarkRunsCursorIDPage extends BenchmarkRunsCursorIDPage<BenchmarkRunView> {} |
| 84 | + |
| 85 | +export interface BenchmarkRunListView { |
| 86 | + has_more: boolean; |
| 87 | + |
| 88 | + remaining_count: number; |
| 89 | + |
| 90 | + /** |
| 91 | + * List of BenchmarkRuns matching filter. |
| 92 | + */ |
| 93 | + runs: Array<BenchmarkRunView>; |
| 94 | + |
| 95 | + total_count: number; |
| 96 | +} |
| 97 | + |
| 98 | +/** |
| 99 | + * A BenchmarkRunView represents a run of a complete set of Scenarios, organized |
| 100 | + * under a Benchmark or created by a BenchmarkJob. |
| 101 | + */ |
| 102 | +export interface BenchmarkRunView { |
| 103 | + /** |
| 104 | + * The ID of the BenchmarkRun. |
| 105 | + */ |
| 106 | + id: string; |
| 107 | + |
| 108 | + /** |
| 109 | + * User defined metadata to attach to the benchmark run for organization. |
| 110 | + */ |
| 111 | + metadata: { [key: string]: string }; |
| 112 | + |
| 113 | + /** |
| 114 | + * The time the benchmark run execution started (Unix timestamp milliseconds). |
| 115 | + */ |
| 116 | + start_time_ms: number; |
| 117 | + |
| 118 | + /** |
| 119 | + * The state of the BenchmarkRun. |
| 120 | + */ |
| 121 | + state: 'running' | 'canceled' | 'completed'; |
| 122 | + |
| 123 | + /** |
| 124 | + * The ID of the Benchmark definition. Present if run was created from a benchmark |
| 125 | + * definition. |
| 126 | + */ |
| 127 | + benchmark_id?: string | null; |
| 128 | + |
| 129 | + /** |
| 130 | + * The duration for the BenchmarkRun to complete. |
| 131 | + */ |
| 132 | + duration_ms?: number | null; |
| 133 | + |
| 134 | + /** |
| 135 | + * Environment variables used to run the benchmark. |
| 136 | + */ |
| 137 | + environment_variables?: { [key: string]: string } | null; |
| 138 | + |
| 139 | + /** |
| 140 | + * The name of the BenchmarkRun. |
| 141 | + */ |
| 142 | + name?: string | null; |
| 143 | + |
| 144 | + /** |
| 145 | + * Purpose of the run. |
| 146 | + */ |
| 147 | + purpose?: string | null; |
| 148 | + |
| 149 | + /** |
| 150 | + * The final score across the BenchmarkRun, present once completed. Calculated as |
| 151 | + * sum of scenario scores / number of scenario runs. |
| 152 | + */ |
| 153 | + score?: number | null; |
| 154 | + |
| 155 | + /** |
| 156 | + * User secrets used to run the benchmark. Example: {"DB_PASS": |
| 157 | + * "DATABASE_PASSWORD"} would set the environment variable 'DB_PASS' on all |
| 158 | + * scenario devboxes to the value of the secret 'DATABASE_PASSWORD'. |
| 159 | + */ |
| 160 | + secrets_provided?: { [key: string]: string } | null; |
| 161 | +} |
| 162 | + |
| 163 | +export interface ScenarioRunListView { |
| 164 | + has_more: boolean; |
| 165 | + |
| 166 | + remaining_count: number; |
| 167 | + |
| 168 | + /** |
| 169 | + * List of ScenarioRuns matching filter. |
| 170 | + */ |
| 171 | + runs: Array<ScenariosAPI.ScenarioRunView>; |
| 172 | + |
| 173 | + total_count: number; |
| 174 | +} |
| 175 | + |
| 176 | +export interface BenchmarkRunListParams extends BenchmarkRunsCursorIDPageParams { |
| 177 | + /** |
| 178 | + * The Benchmark ID to filter by. |
| 179 | + */ |
| 180 | + benchmark_id?: string; |
| 181 | + |
| 182 | + /** |
| 183 | + * Filter by name |
| 184 | + */ |
| 185 | + name?: string; |
| 186 | +} |
| 187 | + |
| 188 | +export interface BenchmarkRunListScenarioRunsParams extends BenchmarkRunsCursorIDPageParams { |
| 189 | + /** |
| 190 | + * Filter by Scenario Run state |
| 191 | + */ |
| 192 | + state?: 'running' | 'scoring' | 'scored' | 'completed' | 'canceled' | 'timeout' | 'failed'; |
| 193 | +} |
| 194 | + |
| 195 | +BenchmarkRuns.BenchmarkRunViewsBenchmarkRunsCursorIDPage = BenchmarkRunViewsBenchmarkRunsCursorIDPage; |
| 196 | + |
| 197 | +export declare namespace BenchmarkRuns { |
| 198 | + export { |
| 199 | + type BenchmarkRunListView as BenchmarkRunListView, |
| 200 | + type BenchmarkRunView as BenchmarkRunView, |
| 201 | + type ScenarioRunListView as ScenarioRunListView, |
| 202 | + BenchmarkRunViewsBenchmarkRunsCursorIDPage as BenchmarkRunViewsBenchmarkRunsCursorIDPage, |
| 203 | + type BenchmarkRunListParams as BenchmarkRunListParams, |
| 204 | + type BenchmarkRunListScenarioRunsParams as BenchmarkRunListScenarioRunsParams, |
| 205 | + }; |
| 206 | +} |
| 207 | + |
| 208 | +export { ScenarioRunViewsBenchmarkRunsCursorIDPage }; |
0 commit comments