Skip to content

Commit 1e97151

Browse files
feat: Phani/deploy with GitHub url
1 parent 10d37a0 commit 1e97151

File tree

9 files changed

+175
-140
lines changed

9 files changed

+175
-140
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 57
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-6c765f1c4ce1c4dd4ceb371f56bf047aa79af36031ba43cbd68fa16a5fdb9bb3.yml
3-
openapi_spec_hash: e9086f69281360f4e0895c9274a59531
4-
config_hash: deadfc4d2b0a947673bcf559b5db6e1b
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-6eaa6f5654abc94549962d7db1e8c7936af1f815bb3abe2f8249959394da1278.yml
3+
openapi_spec_hash: 31ece7cd801e74228b80a8112a762e56
4+
config_hash: 3fc2057ce765bc5f27785a694ed0f553

README.md

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,29 +67,17 @@ import Kernel, { toFile } from '@onkernel/sdk';
6767
const client = new Kernel();
6868

6969
// If you have access to Node `fs` we recommend using `fs.createReadStream()`:
70-
await client.deployments.create({
71-
entrypoint_rel_path: 'src/app.py',
72-
file: fs.createReadStream('/path/to/file'),
73-
});
70+
await client.deployments.create({ file: fs.createReadStream('/path/to/file') });
7471

7572
// Or if you have the web `File` API you can pass a `File` instance:
76-
await client.deployments.create({ entrypoint_rel_path: 'src/app.py', file: new File(['my bytes'], 'file') });
73+
await client.deployments.create({ file: new File(['my bytes'], 'file') });
7774

7875
// You can also pass a `fetch` `Response`:
79-
await client.deployments.create({
80-
entrypoint_rel_path: 'src/app.py',
81-
file: await fetch('https://somesite/file'),
82-
});
76+
await client.deployments.create({ file: await fetch('https://somesite/file') });
8377

8478
// Finally, if none of the above are convenient, you can use our `toFile` helper:
85-
await client.deployments.create({
86-
entrypoint_rel_path: 'src/app.py',
87-
file: await toFile(Buffer.from('my bytes'), 'file'),
88-
});
89-
await client.deployments.create({
90-
entrypoint_rel_path: 'src/app.py',
91-
file: await toFile(new Uint8Array([0, 1, 2]), 'file'),
92-
});
79+
await client.deployments.create({ file: await toFile(Buffer.from('my bytes'), 'file') });
80+
await client.deployments.create({ file: await toFile(new Uint8Array([0, 1, 2]), 'file') });
9381
```
9482

9583
## Handling errors

api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,13 @@ Methods:
183183

184184
Types:
185185

186+
- <code><a href="./src/resources/extensions.ts">ExtensionCreateResponse</a></code>
186187
- <code><a href="./src/resources/extensions.ts">ExtensionListResponse</a></code>
187-
- <code><a href="./src/resources/extensions.ts">ExtensionUploadResponse</a></code>
188188

189189
Methods:
190190

191+
- <code title="post /extensions">client.extensions.<a href="./src/resources/extensions.ts">create</a>({ ...params }) -> ExtensionCreateResponse</code>
192+
- <code title="get /extensions/{id_or_name}">client.extensions.<a href="./src/resources/extensions.ts">retrieve</a>(idOrName) -> Response</code>
191193
- <code title="get /extensions">client.extensions.<a href="./src/resources/extensions.ts">list</a>() -> ExtensionListResponse</code>
192194
- <code title="delete /extensions/{id_or_name}">client.extensions.<a href="./src/resources/extensions.ts">delete</a>(idOrName) -> void</code>
193-
- <code title="get /extensions/{id_or_name}">client.extensions.<a href="./src/resources/extensions.ts">download</a>(idOrName) -> Response</code>
194195
- <code title="get /extensions/from_chrome_store">client.extensions.<a href="./src/resources/extensions.ts">downloadFromChromeStore</a>({ ...params }) -> Response</code>
195-
- <code title="post /extensions">client.extensions.<a href="./src/resources/extensions.ts">upload</a>({ ...params }) -> ExtensionUploadResponse</code>

src/client.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ import {
3333
} from './resources/deployments';
3434
import { KernelApp } from './core/app-framework';
3535
import {
36+
ExtensionCreateParams,
37+
ExtensionCreateResponse,
3638
ExtensionDownloadFromChromeStoreParams,
3739
ExtensionListResponse,
38-
ExtensionUploadParams,
39-
ExtensionUploadResponse,
4040
Extensions,
4141
} from './resources/extensions';
4242
import {
@@ -918,10 +918,10 @@ export declare namespace Kernel {
918918

919919
export {
920920
Extensions as Extensions,
921+
type ExtensionCreateResponse as ExtensionCreateResponse,
921922
type ExtensionListResponse as ExtensionListResponse,
922-
type ExtensionUploadResponse as ExtensionUploadResponse,
923+
type ExtensionCreateParams as ExtensionCreateParams,
923924
type ExtensionDownloadFromChromeStoreParams as ExtensionDownloadFromChromeStoreParams,
924-
type ExtensionUploadParams as ExtensionUploadParams,
925925
};
926926

927927
export type AppAction = API.AppAction;

src/resources/deployments.ts

Lines changed: 68 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ export class Deployments extends APIResource {
1919
* ```ts
2020
* const deployment = await client.deployments.create({
2121
* entrypoint_rel_path: 'src/app.py',
22+
* env_vars: { FOO: 'bar' },
2223
* file: fs.createReadStream('path/to/file'),
24+
* region: 'aws.us-east-1a',
25+
* version: '1.0.0',
2326
* });
2427
* ```
2528
*/
@@ -349,19 +352,19 @@ export interface DeploymentCreateParams {
349352
/**
350353
* Relative path to the entrypoint of the application
351354
*/
352-
entrypoint_rel_path: string;
353-
354-
/**
355-
* ZIP file containing the application source directory
356-
*/
357-
file: Uploadable;
355+
entrypoint_rel_path?: string;
358356

359357
/**
360358
* Map of environment variables to set for the deployed application. Each key-value
361359
* pair represents an environment variable.
362360
*/
363361
env_vars?: { [key: string]: string };
364362

363+
/**
364+
* ZIP file containing the application source directory
365+
*/
366+
file?: Uploadable;
367+
365368
/**
366369
* Allow overwriting an existing app version
367370
*/
@@ -372,12 +375,71 @@ export interface DeploymentCreateParams {
372375
*/
373376
region?: 'aws.us-east-1a';
374377

378+
/**
379+
* Source from which to fetch application code.
380+
*/
381+
source?: DeploymentCreateParams.Source;
382+
375383
/**
376384
* Version of the application. Can be any string.
377385
*/
378386
version?: string;
379387
}
380388

389+
export namespace DeploymentCreateParams {
390+
/**
391+
* Source from which to fetch application code.
392+
*/
393+
export interface Source {
394+
/**
395+
* Relative path to the application entrypoint within the selected path.
396+
*/
397+
entrypoint: string;
398+
399+
/**
400+
* Git ref (branch, tag, or commit SHA) to fetch.
401+
*/
402+
ref: string;
403+
404+
/**
405+
* Source type identifier.
406+
*/
407+
type: 'github';
408+
409+
/**
410+
* Base repository URL (without blob/tree suffixes).
411+
*/
412+
url: string;
413+
414+
/**
415+
* Authentication for private repositories.
416+
*/
417+
auth?: Source.Auth;
418+
419+
/**
420+
* Path within the repo to deploy (omit to use repo root).
421+
*/
422+
path?: string;
423+
}
424+
425+
export namespace Source {
426+
/**
427+
* Authentication for private repositories.
428+
*/
429+
export interface Auth {
430+
/**
431+
* GitHub PAT or installation access token
432+
*/
433+
token: string;
434+
435+
/**
436+
* Auth method
437+
*/
438+
method: 'github_token';
439+
}
440+
}
441+
}
442+
381443
export interface DeploymentListParams extends OffsetPaginationParams {
382444
/**
383445
* Filter results by application name.

src/resources/extensions.ts

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -10,50 +10,65 @@ import { path } from '../internal/utils/path';
1010

1111
export class Extensions extends APIResource {
1212
/**
13-
* List extensions owned by the caller's organization.
13+
* Upload a zip file containing an unpacked browser extension. Optionally provide a
14+
* unique name for later reference.
1415
*
1516
* @example
1617
* ```ts
17-
* const extensions = await client.extensions.list();
18+
* const extension = await client.extensions.create({
19+
* file: fs.createReadStream('path/to/file'),
20+
* });
1821
* ```
1922
*/
20-
list(options?: RequestOptions): APIPromise<ExtensionListResponse> {
21-
return this._client.get('/extensions', options);
23+
create(body: ExtensionCreateParams, options?: RequestOptions): APIPromise<ExtensionCreateResponse> {
24+
return this._client.post('/extensions', multipartFormRequestOptions({ body, ...options }, this._client));
2225
}
2326

2427
/**
25-
* Delete an extension by its ID or by its name.
28+
* Download the extension as a ZIP archive by ID or name.
2629
*
2730
* @example
2831
* ```ts
29-
* await client.extensions.delete('id_or_name');
32+
* const extension = await client.extensions.retrieve(
33+
* 'id_or_name',
34+
* );
35+
*
36+
* const content = await extension.blob();
37+
* console.log(content);
3038
* ```
3139
*/
32-
delete(idOrName: string, options?: RequestOptions): APIPromise<void> {
33-
return this._client.delete(path`/extensions/${idOrName}`, {
40+
retrieve(idOrName: string, options?: RequestOptions): APIPromise<Response> {
41+
return this._client.get(path`/extensions/${idOrName}`, {
3442
...options,
35-
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
43+
headers: buildHeaders([{ Accept: 'application/octet-stream' }, options?.headers]),
44+
__binaryResponse: true,
3645
});
3746
}
3847

3948
/**
40-
* Download the extension as a ZIP archive by ID or name.
49+
* List extensions owned by the caller's organization.
4150
*
4251
* @example
4352
* ```ts
44-
* const response = await client.extensions.download(
45-
* 'id_or_name',
46-
* );
53+
* const extensions = await client.extensions.list();
54+
* ```
55+
*/
56+
list(options?: RequestOptions): APIPromise<ExtensionListResponse> {
57+
return this._client.get('/extensions', options);
58+
}
59+
60+
/**
61+
* Delete an extension by its ID or by its name.
4762
*
48-
* const content = await response.blob();
49-
* console.log(content);
63+
* @example
64+
* ```ts
65+
* await client.extensions.delete('id_or_name');
5066
* ```
5167
*/
52-
download(idOrName: string, options?: RequestOptions): APIPromise<Response> {
53-
return this._client.get(path`/extensions/${idOrName}`, {
68+
delete(idOrName: string, options?: RequestOptions): APIPromise<void> {
69+
return this._client.delete(path`/extensions/${idOrName}`, {
5470
...options,
55-
headers: buildHeaders([{ Accept: 'application/octet-stream' }, options?.headers]),
56-
__binaryResponse: true,
71+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
5772
});
5873
}
5974

@@ -83,21 +98,37 @@ export class Extensions extends APIResource {
8398
__binaryResponse: true,
8499
});
85100
}
101+
}
86102

103+
/**
104+
* A browser extension uploaded to Kernel.
105+
*/
106+
export interface ExtensionCreateResponse {
87107
/**
88-
* Upload a zip file containing an unpacked browser extension. Optionally provide a
89-
* unique name for later reference.
90-
*
91-
* @example
92-
* ```ts
93-
* const response = await client.extensions.upload({
94-
* file: fs.createReadStream('path/to/file'),
95-
* });
96-
* ```
108+
* Unique identifier for the extension
97109
*/
98-
upload(body: ExtensionUploadParams, options?: RequestOptions): APIPromise<ExtensionUploadResponse> {
99-
return this._client.post('/extensions', multipartFormRequestOptions({ body, ...options }, this._client));
100-
}
110+
id: string;
111+
112+
/**
113+
* Timestamp when the extension was created
114+
*/
115+
created_at: string;
116+
117+
/**
118+
* Size of the extension archive in bytes
119+
*/
120+
size_bytes: number;
121+
122+
/**
123+
* Timestamp when the extension was last used
124+
*/
125+
last_used_at?: string | null;
126+
127+
/**
128+
* Optional, easier-to-reference name for the extension. Must be unique within the
129+
* organization.
130+
*/
131+
name?: string | null;
101132
}
102133

103134
export type ExtensionListResponse = Array<ExtensionListResponse.ExtensionListResponseItem>;
@@ -135,35 +166,16 @@ export namespace ExtensionListResponse {
135166
}
136167
}
137168

138-
/**
139-
* A browser extension uploaded to Kernel.
140-
*/
141-
export interface ExtensionUploadResponse {
142-
/**
143-
* Unique identifier for the extension
144-
*/
145-
id: string;
146-
169+
export interface ExtensionCreateParams {
147170
/**
148-
* Timestamp when the extension was created
149-
*/
150-
created_at: string;
151-
152-
/**
153-
* Size of the extension archive in bytes
154-
*/
155-
size_bytes: number;
156-
157-
/**
158-
* Timestamp when the extension was last used
171+
* ZIP file containing the browser extension.
159172
*/
160-
last_used_at?: string | null;
173+
file: Uploadable;
161174

162175
/**
163-
* Optional, easier-to-reference name for the extension. Must be unique within the
164-
* organization.
176+
* Optional unique name within the organization to reference this extension.
165177
*/
166-
name?: string | null;
178+
name?: string;
167179
}
168180

169181
export interface ExtensionDownloadFromChromeStoreParams {
@@ -178,23 +190,11 @@ export interface ExtensionDownloadFromChromeStoreParams {
178190
os?: 'win' | 'mac' | 'linux';
179191
}
180192

181-
export interface ExtensionUploadParams {
182-
/**
183-
* ZIP file containing the browser extension.
184-
*/
185-
file: Uploadable;
186-
187-
/**
188-
* Optional unique name within the organization to reference this extension.
189-
*/
190-
name?: string;
191-
}
192-
193193
export declare namespace Extensions {
194194
export {
195+
type ExtensionCreateResponse as ExtensionCreateResponse,
195196
type ExtensionListResponse as ExtensionListResponse,
196-
type ExtensionUploadResponse as ExtensionUploadResponse,
197+
type ExtensionCreateParams as ExtensionCreateParams,
197198
type ExtensionDownloadFromChromeStoreParams as ExtensionDownloadFromChromeStoreParams,
198-
type ExtensionUploadParams as ExtensionUploadParams,
199199
};
200200
}

0 commit comments

Comments
 (0)