-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuilds.ts
More file actions
525 lines (409 loc) · 11.7 KB
/
builds.ts
File metadata and controls
525 lines (409 loc) · 11.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../core/resource';
import * as BuildsAPI from './builds';
import * as Shared from '../shared';
import * as DiagnosticsAPI from './diagnostics';
import {
BuildDiagnostic,
BuildDiagnosticMore,
BuildDiagnosticsPage,
DiagnosticListParams,
Diagnostics,
} from './diagnostics';
import * as TargetOutputsAPI from './target-outputs';
import { TargetOutputRetrieveParams, TargetOutputRetrieveResponse, TargetOutputs } from './target-outputs';
import { APIPromise } from '../../core/api-promise';
import { Page, type PageParams, PagePromise } from '../../core/pagination';
import { RequestOptions } from '../../internal/request-options';
import { path } from '../../internal/utils/path';
export class Builds extends APIResource {
diagnostics: DiagnosticsAPI.Diagnostics = new DiagnosticsAPI.Diagnostics(this._client);
targetOutputs: TargetOutputsAPI.TargetOutputs = new TargetOutputsAPI.TargetOutputs(this._client);
/**
* Create a build, on top of a project branch, against a given input revision.
*
* The project branch will be modified so that its latest set of config files
* points to the one specified by the input revision.
*/
create(params: BuildCreateParams, options?: RequestOptions): APIPromise<Build> {
const { project = this._client.project, ...body } = params;
return this._client.post('/v0/builds', { body: { project, ...body }, ...options });
}
/**
* Retrieve a build by its ID.
*/
retrieve(buildID: string, options?: RequestOptions): APIPromise<Build> {
return this._client.get(path`/v0/builds/${buildID}`, options);
}
/**
* List user-triggered builds for a given project.
*
* An optional revision can be specified to filter by config commit SHA, or hashes
* of file contents.
*/
list(
params: BuildListParams | null | undefined = {},
options?: RequestOptions,
): PagePromise<BuildsPage, Build> {
const { project = this._client.project, ...query } = params ?? {};
return this._client.getAPIList('/v0/builds', Page<Build>, { query: { project, ...query }, ...options });
}
/**
* Create two builds whose outputs can be directly compared with each other.
*
* Created builds _modify_ their project branches so that their latest sets of
* config files point to the ones specified by the input revision.
*
* This endpoint is useful because a build has more inputs than the set of config
* files it uses, so comparing two builds directly may return spurious differences.
* Builds made via this endpoint are guaranteed to have differences arising from
* the set of config files, and any custom code.
*/
compare(params: BuildCompareParams, options?: RequestOptions): APIPromise<BuildCompareResponse> {
const { project = this._client.project, ...body } = params;
return this._client.post('/v0/builds/compare', { body: { project, ...body }, ...options });
}
}
export type BuildsPage = Page<Build>;
export interface Build {
/**
* Build ID
*/
id: string;
config_commit: string;
created_at: string;
documented_spec: Build.UnionMember0 | Build.UnionMember1 | null;
object: 'build';
org: string;
project: string;
targets: Build.Targets;
updated_at: string;
}
export namespace Build {
export interface UnionMember0 {
content: string;
type: 'content';
}
export interface UnionMember1 {
expires: string;
type: 'url';
url: string;
}
export interface Targets {
cli?: BuildsAPI.BuildTarget;
csharp?: BuildsAPI.BuildTarget;
go?: BuildsAPI.BuildTarget;
java?: BuildsAPI.BuildTarget;
kotlin?: BuildsAPI.BuildTarget;
node?: BuildsAPI.BuildTarget;
openapi?: BuildsAPI.BuildTarget;
php?: BuildsAPI.BuildTarget;
python?: BuildsAPI.BuildTarget;
ruby?: BuildsAPI.BuildTarget;
sql?: BuildsAPI.BuildTarget;
terraform?: BuildsAPI.BuildTarget;
typescript?: BuildsAPI.BuildTarget;
}
}
export interface BuildTarget {
commit: BuildTarget.NotStarted | BuildTarget.Queued | BuildTarget.InProgress | BuildTarget.Completed;
install_url: string | null;
object: 'build_target';
status: 'not_started' | 'codegen' | 'postgen' | 'completed';
build?: CheckStep;
lint?: CheckStep;
test?: CheckStep;
}
export namespace BuildTarget {
export interface NotStarted {
status: 'not_started';
}
export interface Queued {
status: 'queued';
}
export interface InProgress {
status: 'in_progress';
}
export interface Completed {
commit: Shared.Commit | null;
/**
* deprecated
*/
completed: Completed.Completed;
completed_at: string;
conclusion:
| 'error'
| 'warning'
| 'note'
| 'success'
| 'merge_conflict'
| 'upstream_merge_conflict'
| 'fatal'
| 'payment_required'
| 'cancelled'
| 'timed_out'
| 'noop'
| 'version_bump';
merge_conflict_pr: Completed.MergeConflictPr | null;
status: 'completed';
}
export namespace Completed {
/**
* deprecated
*/
export interface Completed {
commit: Shared.Commit | null;
completed_at: string;
conclusion:
| 'error'
| 'warning'
| 'note'
| 'success'
| 'merge_conflict'
| 'upstream_merge_conflict'
| 'fatal'
| 'payment_required'
| 'cancelled'
| 'timed_out'
| 'noop'
| 'version_bump';
merge_conflict_pr: Completed.MergeConflictPr | null;
}
export namespace Completed {
export interface MergeConflictPr {
number: number;
repo: MergeConflictPr.Repo;
}
export namespace MergeConflictPr {
export interface Repo {
name: string;
owner: string;
}
}
}
export interface MergeConflictPr {
number: number;
repo: MergeConflictPr.Repo;
}
export namespace MergeConflictPr {
export interface Repo {
name: string;
owner: string;
}
}
}
}
export type CheckStep = CheckStep.NotStarted | CheckStep.Queued | CheckStep.InProgress | CheckStep.Completed;
export namespace CheckStep {
export interface NotStarted {
status: 'not_started';
}
export interface Queued {
status: 'queued';
url: string | null;
}
export interface InProgress {
status: 'in_progress';
url: string | null;
}
export interface Completed {
/**
* deprecated
*/
completed: Completed.Completed;
conclusion: 'success' | 'failure' | 'skipped' | 'cancelled' | 'action_required' | 'neutral' | 'timed_out';
status: 'completed';
url: string | null;
}
export namespace Completed {
/**
* deprecated
*/
export interface Completed {
conclusion:
| 'success'
| 'failure'
| 'skipped'
| 'cancelled'
| 'action_required'
| 'neutral'
| 'timed_out';
url: string | null;
}
}
}
export interface BuildCompareResponse {
base: Build;
head: Build;
}
export interface BuildCreateParams {
/**
* Project name
*/
project?: string;
/**
* Specifies what to build: a branch name, commit SHA, merge command
* ("base..head"), or file contents.
*/
revision: string | { [key: string]: Shared.FileInput };
/**
* Whether to allow empty commits (no changes). Defaults to false.
*/
allow_empty?: boolean;
/**
* The project branch to use for the build. If not specified, the branch is
* inferred from the `revision`, and will 400 when that is not possible.
*/
branch?: string;
/**
* Optional commit message to use when creating a new commit.
*/
commit_message?: string;
/**
* Whether to generate AI-powered commit messages for the build. Cannot be combined
* with `commit_message` or `target_commit_messages`.
*/
enable_ai_commit_message?: boolean;
/**
* Optional commit messages to use for each SDK when making a new commit. SDKs not
* represented in this object will fallback to the optional `commit_message`
* parameter, or will fallback further to the default commit message.
*/
target_commit_messages?: BuildCreateParams.TargetCommitMessages;
/**
* Optional list of SDK targets to build. If not specified, all configured targets
* will be built.
*/
targets?: Array<Shared.Target>;
}
export namespace BuildCreateParams {
/**
* Optional commit messages to use for each SDK when making a new commit. SDKs not
* represented in this object will fallback to the optional `commit_message`
* parameter, or will fallback further to the default commit message.
*/
export interface TargetCommitMessages {
cli?: string;
csharp?: string;
go?: string;
java?: string;
kotlin?: string;
node?: string;
openapi?: string;
php?: string;
python?: string;
ruby?: string;
sql?: string;
terraform?: string;
typescript?: string;
}
}
export interface BuildListParams extends PageParams {
/**
* Project name
*/
project?: string;
/**
* Branch name
*/
branch?: string;
/**
* Maximum number of builds to return, defaults to 10 (maximum: 100).
*/
limit?: number;
/**
* A config commit SHA used for the build
*/
revision?: string | { [key: string]: BuildListParams.unnamed_schema_with_map_parent_0 };
}
export namespace BuildListParams {
export interface unnamed_schema_with_map_parent_0 {
/**
* File content hash
*/
hash: string;
}
}
export interface BuildCompareParams {
/**
* Parameters for the base build
*/
base: BuildCompareParams.Base;
/**
* Parameters for the head build
*/
head: BuildCompareParams.Head;
/**
* Project name
*/
project?: string;
/**
* Optional list of SDK targets to build. If not specified, all configured targets
* will be built.
*/
targets?: Array<Shared.Target>;
}
export namespace BuildCompareParams {
/**
* Parameters for the base build
*/
export interface Base {
/**
* Branch to use. When using a branch name as revision, this must match or be
* omitted.
*/
branch: string;
/**
* Specifies what to build: a branch name, a commit SHA, or file contents.
*/
revision: string | { [key: string]: Shared.FileInput };
/**
* Optional commit message to use when creating a new commit.
*/
commit_message?: string;
}
/**
* Parameters for the head build
*/
export interface Head {
/**
* Branch to use. When using a branch name as revision, this must match or be
* omitted.
*/
branch: string;
/**
* Specifies what to build: a branch name, a commit SHA, or file contents.
*/
revision: string | { [key: string]: Shared.FileInput };
/**
* Optional commit message to use when creating a new commit.
*/
commit_message?: string;
}
}
Builds.Diagnostics = Diagnostics;
Builds.TargetOutputs = TargetOutputs;
export declare namespace Builds {
export {
type Build as Build,
type BuildTarget as BuildTarget,
type CheckStep as CheckStep,
type BuildCompareResponse as BuildCompareResponse,
type BuildsPage as BuildsPage,
type BuildCreateParams as BuildCreateParams,
type BuildListParams as BuildListParams,
type BuildCompareParams as BuildCompareParams,
};
export {
Diagnostics as Diagnostics,
type BuildDiagnostic as BuildDiagnostic,
type BuildDiagnosticMore as BuildDiagnosticMore,
type BuildDiagnosticsPage as BuildDiagnosticsPage,
type DiagnosticListParams as DiagnosticListParams,
};
export {
TargetOutputs as TargetOutputs,
type TargetOutputRetrieveResponse as TargetOutputRetrieveResponse,
type TargetOutputRetrieveParams as TargetOutputRetrieveParams,
};
}