Skip to content

Commit 9d7d6f6

Browse files
committed
cp dines
1 parent 73f7aa5 commit 9d7d6f6

8 files changed

Lines changed: 278 additions & 217 deletions

File tree

src/sdk.ts

Lines changed: 120 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ type ContentType = ObjectCreateParams['content_type'];
104104
*
105105
* @example
106106
* ```typescript
107-
* const sdk = new RunloopSDK(); // export RUNLOOP_API_KEY will automatically be used.
108-
* const devbox = await sdk.devbox.create({ name: 'my-devbox' });
107+
* const runloop = new RunloopSDK(); // export RUNLOOP_API_KEY will automatically be used.
108+
* const devbox = await runloop.devbox.create({ name: 'my-devbox' });
109109
* const result = await devbox.cmd.exec({ command: 'echo "Hello, World!"' });
110110
* console.log(result.exitCode);
111111
* ```
@@ -117,6 +117,10 @@ export class RunloopSDK {
117117
public readonly snapshot: RunloopSDK.SnapshotInterface;
118118
public readonly storageObject: RunloopSDK.StorageObjectInterface;
119119

120+
/**
121+
* Creates a new RunloopSDK instance.
122+
* @param {ClientOptions} [options] - Optional client configuration options.
123+
*/
120124
constructor(options?: ClientOptions) {
121125
this.api = new Runloop(options);
122126
this.devbox = new RunloopSDK.DevboxInterface(this.api);
@@ -128,7 +132,7 @@ export class RunloopSDK {
128132

129133
export namespace RunloopSDK {
130134
/**
131-
* Devbox management interface
135+
* Devbox SDK interface for managing devboxes.
132136
*
133137
* ## Overview
134138
*
@@ -144,8 +148,8 @@ export namespace RunloopSDK {
144148
*
145149
* @example
146150
* ```typescript
147-
* const sdk = new RunloopSDK();
148-
* const devbox = await sdk.devbox.create({ name: 'my-devbox' });
151+
* const runloop = new RunloopSDK();
152+
* const devbox = await runloop.devbox.create({ name: 'my-devbox' });
149153
* const result = await devbox.cmd.exec({ command: 'echo "Hello, World!"' });
150154
* ```
151155
*/
@@ -155,13 +159,26 @@ export namespace RunloopSDK {
155159
*/
156160
constructor(private client: Runloop) {}
157161

162+
/**
163+
* Create a new devbox.
164+
* @param {DevboxCreateParams} [params] - Parameters for creating the devbox.
165+
* @param {Core.RequestOptions & { polling?: Partial<PollingOptions<DevboxView>> }} [options] - Request options including polling configuration.
166+
* @returns {Promise<Devbox>} A {@link Devbox} instance.
167+
*/
158168
async create(
159169
params?: DevboxCreateParams,
160170
options?: Core.RequestOptions & { polling?: Partial<PollingOptions<DevboxView>> },
161171
): Promise<Devbox> {
162172
return Devbox.create(this.client, params, options);
163173
}
164174

175+
/**
176+
* Create a new devbox from a blueprint ID.
177+
* @param {string} blueprintId - The ID of the blueprint to use.
178+
* @param {Omit<DevboxCreateParams, 'blueprint_id' | 'snapshot_id' | 'blueprint_name'>} [params] - Additional parameters for creating the devbox (excluding blueprint_id, snapshot_id, and blueprint_name).
179+
* @param {Core.RequestOptions & { polling?: Partial<PollingOptions<DevboxView>> }} [options] - Request options including polling configuration.
180+
* @returns {Promise<Devbox>} A {@link Devbox} instance.
181+
*/
165182
async createFromBlueprintId(
166183
blueprintId: string,
167184
params?: Omit<DevboxCreateParams, 'blueprint_id' | 'snapshot_id' | 'blueprint_name'>,
@@ -170,6 +187,13 @@ export namespace RunloopSDK {
170187
return Devbox.createFromBlueprintId(this.client, blueprintId, params, options);
171188
}
172189

190+
/**
191+
* Create a new devbox from a blueprint name.
192+
* @param {string} blueprintName - The name of the blueprint to use.
193+
* @param {Omit<DevboxCreateParams, 'blueprint_id' | 'snapshot_id' | 'blueprint_name'>} [params] - Additional parameters for creating the devbox (excluding blueprint_id, snapshot_id, and blueprint_name).
194+
* @param {Core.RequestOptions & { polling?: Partial<PollingOptions<DevboxView>> }} [options] - Request options including polling configuration.
195+
* @returns {Promise<Devbox>} A {@link Devbox} instance.
196+
*/
173197
async createFromBlueprintName(
174198
blueprintName: string,
175199
params?: Omit<DevboxCreateParams, 'blueprint_id' | 'snapshot_id' | 'blueprint_name'>,
@@ -178,6 +202,13 @@ export namespace RunloopSDK {
178202
return Devbox.createFromBlueprintName(this.client, blueprintName, params, options);
179203
}
180204

205+
/**
206+
* Create a new devbox from a snapshot.
207+
* @param {string} snapshotId - The ID of the snapshot to use.
208+
* @param {Omit<DevboxCreateParams, 'snapshot_id' | 'blueprint_id' | 'blueprint_name'>} [params] - Additional parameters for creating the devbox (excluding snapshot_id, blueprint_id, and blueprint_name).
209+
* @param {Core.RequestOptions & { polling?: Partial<PollingOptions<DevboxView>> }} [options] - Request options including polling configuration.
210+
* @returns {Promise<Devbox>} A {@link Devbox} instance.
211+
*/
181212
async createFromSnapshot(
182213
snapshotId: string,
183214
params?: Omit<DevboxCreateParams, 'snapshot_id' | 'blueprint_id' | 'blueprint_name'>,
@@ -186,10 +217,21 @@ export namespace RunloopSDK {
186217
return Devbox.createFromSnapshot(this.client, snapshotId, params, options);
187218
}
188219

220+
/**
221+
* Get a devbox object by its ID.
222+
* @param {string} id - The ID of the devbox.
223+
* @returns {Devbox} A {@link Devbox} instance.
224+
*/
189225
fromId(id: string): Devbox {
190226
return Devbox.fromId(this.client, id);
191227
}
192228

229+
/**
230+
* List all devboxes with optional filters.
231+
* @param {DevboxListParams} [params] - Optional filter parameters.
232+
* @param {Core.RequestOptions} [options] - Request options.
233+
* @returns {Promise<Devbox[]>} An array of {@link Devbox} instances.
234+
*/
193235
async list(params?: DevboxListParams, options?: Core.RequestOptions): Promise<Devbox[]> {
194236
const result = await this.client.devboxes.list(params, options);
195237
const devboxes: Devbox[] = [];
@@ -203,7 +245,7 @@ export namespace RunloopSDK {
203245
}
204246

205247
/**
206-
* Blueprint management interface
248+
* Blueprint SDK interface for managing blueprints.
207249
*
208250
* ## Overview
209251
*
@@ -233,17 +275,34 @@ export namespace RunloopSDK {
233275
*/
234276
constructor(private client: Runloop) {}
235277

278+
/**
279+
* Create a new blueprint.
280+
* @param {BlueprintCreateParams} params - Parameters for creating the blueprint.
281+
* @param {Core.RequestOptions & { polling?: Partial<PollingOptions<Runloop.Blueprints.BlueprintView>> }} [options] - Request options including polling configuration.
282+
* @returns {Promise<Blueprint>} A {@link Blueprint} instance.
283+
*/
236284
async create(
237285
params: BlueprintCreateParams,
238286
options?: Core.RequestOptions & { polling?: Partial<PollingOptions<Runloop.Blueprints.BlueprintView>> },
239287
): Promise<Blueprint> {
240288
return Blueprint.create(this.client, params, options);
241289
}
242290

291+
/**
292+
* Get a blueprint object by its ID.
293+
* @param {string} id - The ID of the blueprint.
294+
* @returns {Blueprint} A {@link Blueprint} instance.
295+
*/
243296
fromId(id: string): Blueprint {
244297
return Blueprint.fromId(this.client, id);
245298
}
246299

300+
/**
301+
* List all blueprints with optional filters.
302+
* @param {BlueprintListParams} [params] - Optional filter parameters.
303+
* @param {Core.RequestOptions} [options] - Request options.
304+
* @returns {Promise<Blueprint[]>} An array of {@link Blueprint} instances.
305+
*/
247306
async list(params?: BlueprintListParams, options?: Core.RequestOptions): Promise<Blueprint[]> {
248307
const result = await this.client.blueprints.list(params, options);
249308
const blueprints: Blueprint[] = [];
@@ -257,7 +316,7 @@ export namespace RunloopSDK {
257316
}
258317

259318
/**
260-
* Snapshot management interface
319+
* Snapshot SDK interface for managing disk snapshots.
261320
*
262321
* ## Overview
263322
*
@@ -273,7 +332,9 @@ export namespace RunloopSDK {
273332
* @example
274333
* ```typescript
275334
* const sdk = new RunloopSDK();
276-
* const snapshots = await sdk.snapshot.list(...);
335+
* const snapshot = await devbox.snapshotDisk({ name: 'backup' });
336+
* ...
337+
* const devbox = await snapshot.createDevbox();
277338
* ```
278339
*/
279340
export class SnapshotInterface {
@@ -282,10 +343,21 @@ export namespace RunloopSDK {
282343
*/
283344
constructor(private client: Runloop) {}
284345

346+
/**
347+
* Get a snapshot object by its ID.
348+
* @param {string} id - The ID of the snapshot.
349+
* @returns {Snapshot} A {@link Snapshot} instance.
350+
*/
285351
fromId(id: string): Snapshot {
286352
return Snapshot.fromId(this.client, id);
287353
}
288354

355+
/**
356+
* List all snapshots.
357+
* @param {DevboxListDiskSnapshotsParams} [params] - Optional filter parameters.
358+
* @param {Core.RequestOptions} [options] - Request options.
359+
* @returns {Promise<Snapshot[]>} An array of {@link Snapshot} instances.
360+
*/
289361
async list(params?: DevboxListDiskSnapshotsParams, options?: Core.RequestOptions): Promise<Snapshot[]> {
290362
return Snapshot.list(this.client, params, options);
291363
}
@@ -318,17 +390,44 @@ export namespace RunloopSDK {
318390
*/
319391
constructor(private client: Runloop) {}
320392

393+
/**
394+
* Create a new storage object. This is for advanced users and for basic operations you should use the {@link StorageObjectInterface.uploadFromFile uploadFromFile()}, {@link StorageObjectInterface.uploadFromText uploadFromText()}, or {@link StorageObjectInterface.uploadFromBuffer uploadFromBuffer()} methods instead.
395+
*
396+
* @example
397+
* ```typescript
398+
* const storageObject = await runloop.storageObject.create({
399+
* name: 'my-file.txt',
400+
* content_type: 'text',
401+
* metadata: { project: 'demo' },
402+
* });
403+
* console.log(storageObject.id);
404+
* ```
405+
* @param {ObjectCreateParams} params - Parameters for creating the object.
406+
* @param {Core.RequestOptions & { polling?: Partial<PollingOptions<Runloop.Objects.ObjectView>> }} [options] - Request options.
407+
* @returns {Promise<StorageObject>} A {@link StorageObject} instance.
408+
*/
321409
async create(
322410
params: ObjectCreateParams,
323411
options?: Core.RequestOptions & { polling?: Partial<PollingOptions<Runloop.Objects.ObjectView>> },
324412
): Promise<StorageObject> {
325413
return StorageObject.create(this.client, params, options);
326414
}
327415

416+
/**
417+
* Get a storage object by its ID.
418+
* @param {string} id - The ID of the storage object.
419+
* @returns {StorageObject} A {@link StorageObject} instance.
420+
*/
328421
fromId(id: string): StorageObject {
329422
return StorageObject.fromId(this.client, id);
330423
}
331424

425+
/**
426+
* List all storage objects with optional filters.
427+
* @param {ObjectListParams} [params] - Optional filter parameters.
428+
* @param {Core.RequestOptions} [options] - Request options.
429+
* @returns {Promise<StorageObject[]>} An array of {@link StorageObject} instances.
430+
*/
332431
async list(params?: ObjectListParams, options?: Core.RequestOptions): Promise<StorageObject[]> {
333432
const result = await this.client.objects.list(params, options);
334433
const storageObjects: StorageObject[] = [];
@@ -341,6 +440,10 @@ export namespace RunloopSDK {
341440
/**
342441
* Upload a file directly from the filesystem (Node.js only).
343442
* This method handles the complete three-step upload process.
443+
* @param {string} filePath - The path to the file to upload.
444+
* @param {string} name - The name to use for the storage object.
445+
* @param {Core.RequestOptions & { contentType?: ContentType; metadata?: Record<string, string> }} [options] - Request options including content type and metadata.
446+
* @returns {Promise<StorageObject>} A {@link StorageObject} instance.
344447
*/
345448
async uploadFromFile(
346449
filePath: string,
@@ -356,6 +459,10 @@ export namespace RunloopSDK {
356459
/**
357460
* Upload text content directly.
358461
* This method handles the complete three-step upload process.
462+
* @param {string} text - The text content to upload.
463+
* @param {string} name - The name to use for the storage object.
464+
* @param {Core.RequestOptions & { metadata?: Record<string, string> }} [options] - Request options including metadata.
465+
* @returns {Promise<StorageObject>} A {@link StorageObject} instance.
359466
*/
360467
async uploadFromText(
361468
text: string,
@@ -370,6 +477,11 @@ export namespace RunloopSDK {
370477
/**
371478
* Upload content from a Buffer (Node.js only).
372479
* This method handles the complete three-step upload process.
480+
* @param {Buffer} buffer - The buffer containing the content to upload.
481+
* @param {string} name - The name to use for the storage object.
482+
* @param {ContentType} contentType - The content type of the buffer.
483+
* @param {Core.RequestOptions & { metadata?: Record<string, string> }} [options] - Request options including metadata.
484+
* @returns {Promise<StorageObject>} A {@link StorageObject} instance.
373485
*/
374486
async uploadFromBuffer(
375487
buffer: Buffer,

0 commit comments

Comments
 (0)