|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +import { APIResource } from '../core/resource'; |
| 4 | +import { APIPromise } from '../core/api-promise'; |
| 5 | +import { buildHeaders } from '../internal/headers'; |
| 6 | +import { RequestOptions } from '../internal/request-options'; |
| 7 | +import { path } from '../internal/utils/path'; |
| 8 | + |
| 9 | +export class Builders extends APIResource { |
| 10 | + /** |
| 11 | + * Creates a builder and its cache disk. One build at a time runs per builder. |
| 12 | + * |
| 13 | + * @example |
| 14 | + * ```ts |
| 15 | + * const builder = await client.builders.create(); |
| 16 | + * ``` |
| 17 | + */ |
| 18 | + create(body: BuilderCreateParams, options?: RequestOptions): APIPromise<Builder> { |
| 19 | + return this._client.post('/builders', { body, ...options }); |
| 20 | + } |
| 21 | + |
| 22 | + /** |
| 23 | + * List builders |
| 24 | + * |
| 25 | + * @example |
| 26 | + * ```ts |
| 27 | + * const builders = await client.builders.list(); |
| 28 | + * ``` |
| 29 | + */ |
| 30 | + list( |
| 31 | + query: BuilderListParams | null | undefined = {}, |
| 32 | + options?: RequestOptions, |
| 33 | + ): APIPromise<BuilderListResponse> { |
| 34 | + return this._client.get('/builders', { query, ...options }); |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * Permanently deletes a builder and its cache disk. |
| 39 | + * |
| 40 | + * @example |
| 41 | + * ```ts |
| 42 | + * await client.builders.delete('id'); |
| 43 | + * ``` |
| 44 | + */ |
| 45 | + delete(id: string, options?: RequestOptions): APIPromise<void> { |
| 46 | + return this._client.delete(path`/builders/${id}`, { |
| 47 | + ...options, |
| 48 | + headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), |
| 49 | + }); |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * Get builder details |
| 54 | + * |
| 55 | + * @example |
| 56 | + * ```ts |
| 57 | + * const builder = await client.builders.get('id'); |
| 58 | + * ``` |
| 59 | + */ |
| 60 | + get(id: string, options?: RequestOptions): APIPromise<Builder> { |
| 61 | + return this._client.get(path`/builders/${id}`, options); |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | + * Resets the builder's cache disk. The builder transitions to pruning, then ready. |
| 66 | + * Builder identity is preserved. |
| 67 | + * |
| 68 | + * @example |
| 69 | + * ```ts |
| 70 | + * const builder = await client.builders.prune('id'); |
| 71 | + * ``` |
| 72 | + */ |
| 73 | + prune(id: string, options?: RequestOptions): APIPromise<Builder> { |
| 74 | + return this._client.post(path`/builders/${id}/prune`, options); |
| 75 | + } |
| 76 | +} |
| 77 | + |
| 78 | +export interface Builder { |
| 79 | + /** |
| 80 | + * Builder identifier |
| 81 | + */ |
| 82 | + id: string; |
| 83 | + |
| 84 | + /** |
| 85 | + * Creation timestamp (RFC3339) |
| 86 | + */ |
| 87 | + created_at: string; |
| 88 | + |
| 89 | + /** |
| 90 | + * Persistent builder cache disk size in gigabytes. Cannot be changed after |
| 91 | + * creation. |
| 92 | + */ |
| 93 | + disk_size_gb: number; |
| 94 | + |
| 95 | + /** |
| 96 | + * Maximum concurrent builds on this builder. Currently fixed at 1. |
| 97 | + */ |
| 98 | + max_concurrency: number; |
| 99 | + |
| 100 | + /** |
| 101 | + * Point-in-time IDs of queued builds waiting for this builder, oldest first |
| 102 | + */ |
| 103 | + queued_builds: Array<string>; |
| 104 | + |
| 105 | + /** |
| 106 | + * Builder lifecycle status |
| 107 | + */ |
| 108 | + status: BuilderStatus; |
| 109 | + |
| 110 | + /** |
| 111 | + * Point-in-time ID of the build currently running on this builder |
| 112 | + */ |
| 113 | + active_build_id?: string | null; |
| 114 | + |
| 115 | + /** |
| 116 | + * When a build last ran on this builder |
| 117 | + */ |
| 118 | + last_used_at?: string | null; |
| 119 | + |
| 120 | + /** |
| 121 | + * Optional non-unique display name |
| 122 | + */ |
| 123 | + name?: string; |
| 124 | + |
| 125 | + /** |
| 126 | + * User-defined key-value tags. |
| 127 | + */ |
| 128 | + tags?: { [key: string]: string }; |
| 129 | +} |
| 130 | + |
| 131 | +/** |
| 132 | + * Builder lifecycle status |
| 133 | + */ |
| 134 | +export type BuilderStatus = 'ready' | 'pruning' | 'deleting' | 'error'; |
| 135 | + |
| 136 | +export type BuilderListResponse = Array<Builder>; |
| 137 | + |
| 138 | +export interface BuilderCreateParams { |
| 139 | + /** |
| 140 | + * Optional caller-supplied identifier, auto-generated if not provided |
| 141 | + */ |
| 142 | + id?: string; |
| 143 | + |
| 144 | + /** |
| 145 | + * Cache disk size in gigabytes. Omit to use the server default. |
| 146 | + */ |
| 147 | + disk_size_gb?: number; |
| 148 | + |
| 149 | + /** |
| 150 | + * Optional non-unique display name |
| 151 | + */ |
| 152 | + name?: string; |
| 153 | + |
| 154 | + /** |
| 155 | + * User-defined key-value tags. |
| 156 | + */ |
| 157 | + tags?: { [key: string]: string }; |
| 158 | +} |
| 159 | + |
| 160 | +export interface BuilderListParams { |
| 161 | + /** |
| 162 | + * Filter builders by tag key-value pairs. |
| 163 | + */ |
| 164 | + tags?: { [key: string]: string }; |
| 165 | +} |
| 166 | + |
| 167 | +export declare namespace Builders { |
| 168 | + export { |
| 169 | + type Builder as Builder, |
| 170 | + type BuilderStatus as BuilderStatus, |
| 171 | + type BuilderListResponse as BuilderListResponse, |
| 172 | + type BuilderCreateParams as BuilderCreateParams, |
| 173 | + type BuilderListParams as BuilderListParams, |
| 174 | + }; |
| 175 | +} |
0 commit comments