Skip to content

Commit dd624bd

Browse files
POC
1 parent fdd335d commit dd624bd

File tree

7 files changed

+429
-29
lines changed

7 files changed

+429
-29
lines changed

openapi.json

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,54 @@
212212
"title": "VMCreateTagResponse",
213213
"type": "object"
214214
},
215+
"VMListRunningVMsResponse": {
216+
"allOf": [
217+
{
218+
"properties": {
219+
"errors": {
220+
"items": {
221+
"oneOf": [
222+
{ "type": "string" },
223+
{ "additionalProperties": true, "type": "object" }
224+
],
225+
"title": "Error"
226+
},
227+
"type": "array"
228+
},
229+
"success": { "type": "boolean" }
230+
},
231+
"title": "Response",
232+
"type": "object"
233+
},
234+
{
235+
"properties": {
236+
"data": {
237+
"properties": {
238+
"concurrent_vm_count": { "type": "integer" },
239+
"concurrent_vm_limit": { "type": "integer" },
240+
"vms": {
241+
"items": {
242+
"properties": { "id": { "type": "string" } },
243+
"type": "object"
244+
},
245+
"required": ["id"],
246+
"type": "array"
247+
}
248+
},
249+
"required": [
250+
"vms",
251+
"concurrent_vm_count",
252+
"concurrent_vm_limit"
253+
],
254+
"type": "object"
255+
}
256+
},
257+
"type": "object"
258+
}
259+
],
260+
"title": "VMListRunningVMsResponse",
261+
"type": "object"
262+
},
215263
"SandboxGetResponse": {
216264
"allOf": [
217265
{
@@ -1855,6 +1903,29 @@
18551903
"tags": ["vm"]
18561904
}
18571905
},
1906+
"/vm/running": {
1907+
"get": {
1908+
"callbacks": {},
1909+
"description": "List information about currently running VMs. This information is updated roughly every 30 seconds, so this data is not guaranteed to be perfectly up-to-date.\n",
1910+
"operationId": "vm/list_running_vms",
1911+
"parameters": [],
1912+
"responses": {
1913+
"200": {
1914+
"content": {
1915+
"application/json": {
1916+
"schema": {
1917+
"$ref": "#/components/schemas/VMListRunningVMsResponse"
1918+
}
1919+
}
1920+
},
1921+
"description": "VM List Running VMs Response"
1922+
}
1923+
},
1924+
"security": [{ "authorization": ["vm:manage"] }],
1925+
"summary": "List information about currently running VMs",
1926+
"tags": ["vm"]
1927+
}
1928+
},
18581929
"/vm/tag": {
18591930
"post": {
18601931
"callbacks": {},

package-lock.json

Lines changed: 67 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
"yargs": "^17.7.2"
114114
},
115115
"dependencies": {
116+
"@inkjs/ui": "^2.0.0",
116117
"@tanstack/react-query": "^5.76.1",
117118
"ink": "^5.2.1",
118119
"ora": "^8.2.0",

src/api-clients/client/sdk.gen.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

33
import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
4-
import type { MetaInfoData, MetaInfoResponse, WorkspaceCreateData, WorkspaceCreateResponse2, TokenCreateData, TokenCreateResponse2, TokenUpdateData, TokenUpdateResponse2, SandboxListData, SandboxListResponse2, SandboxCreateData, SandboxCreateResponse2, SandboxGetData, SandboxGetResponse2, SandboxForkData, SandboxForkResponse2, PreviewTokenRevokeAllData, PreviewTokenRevokeAllResponse2, PreviewTokenListData, PreviewTokenListResponse2, PreviewTokenCreateData, PreviewTokenCreateResponse2, PreviewTokenUpdateData, PreviewTokenUpdateResponse2, VmListClustersData, VmListClustersResponse2, VmCreateTagData, VmCreateTagResponse2, VmHibernateData, VmHibernateResponse2, VmUpdateHibernationTimeoutData, VmUpdateHibernationTimeoutResponse2, VmCreateSessionData, VmCreateSessionResponse2, VmShutdownData, VmShutdownResponse2, VmUpdateSpecsData, VmUpdateSpecsResponse2, VmStartData, VmStartResponse2, VmUpdateSpecs2Data, VmUpdateSpecs2Response, PreviewHostListData, PreviewHostListResponse2, PreviewHostCreateData, PreviewHostCreateResponse, PreviewHostUpdateData, PreviewHostUpdateResponse } from './types.gen';
4+
import type { MetaInfoData, MetaInfoResponse, WorkspaceCreateData, WorkspaceCreateResponse2, TokenCreateData, TokenCreateResponse2, TokenUpdateData, TokenUpdateResponse2, SandboxListData, SandboxListResponse2, SandboxCreateData, SandboxCreateResponse2, SandboxGetData, SandboxGetResponse2, SandboxForkData, SandboxForkResponse2, PreviewTokenRevokeAllData, PreviewTokenRevokeAllResponse2, PreviewTokenListData, PreviewTokenListResponse2, PreviewTokenCreateData, PreviewTokenCreateResponse2, PreviewTokenUpdateData, PreviewTokenUpdateResponse2, VmListClustersData, VmListClustersResponse2, VmListRunningVmsData, VmListRunningVmsResponse2, VmCreateTagData, VmCreateTagResponse2, VmHibernateData, VmHibernateResponse2, VmUpdateHibernationTimeoutData, VmUpdateHibernationTimeoutResponse2, VmCreateSessionData, VmCreateSessionResponse2, VmShutdownData, VmShutdownResponse2, VmUpdateSpecsData, VmUpdateSpecsResponse2, VmStartData, VmStartResponse2, VmUpdateSpecs2Data, VmUpdateSpecs2Response, PreviewHostListData, PreviewHostListResponse2, PreviewHostCreateData, PreviewHostCreateResponse, PreviewHostUpdateData, PreviewHostUpdateResponse } from './types.gen';
55
import { client as _heyApiClient } from './client.gen';
66

77
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
@@ -268,6 +268,24 @@ export const vmListClusters = <ThrowOnError extends boolean = false>(options?: O
268268
});
269269
};
270270

271+
/**
272+
* List information about currently running VMs
273+
* List information about currently running VMs. This information is updated roughly every 30 seconds, so this data is not guaranteed to be perfectly up-to-date.
274+
*
275+
*/
276+
export const vmListRunningVms = <ThrowOnError extends boolean = false>(options?: Options<VmListRunningVmsData, ThrowOnError>) => {
277+
return (options?.client ?? _heyApiClient).get<VmListRunningVmsResponse2, unknown, ThrowOnError>({
278+
security: [
279+
{
280+
scheme: 'bearer',
281+
type: 'http'
282+
}
283+
],
284+
url: '/vm/running',
285+
...options
286+
});
287+
};
288+
271289
/**
272290
* Create a new tag for a VM
273291
* Creates a new tag for a VM.

src/api-clients/client/types.gen.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,21 @@ export type VmCreateTagResponse = {
9595
};
9696
};
9797

98+
export type VmListRunningVmsResponse = {
99+
errors?: Array<string | {
100+
[key: string]: unknown;
101+
}>;
102+
success?: boolean;
103+
} & {
104+
data?: {
105+
concurrent_vm_count: number;
106+
concurrent_vm_limit: number;
107+
vms: Array<{
108+
id?: string;
109+
}>;
110+
};
111+
};
112+
98113
export type SandboxGetResponse = {
99114
errors?: Array<string | {
100115
[key: string]: unknown;
@@ -951,6 +966,22 @@ export type VmListClustersResponses = {
951966

952967
export type VmListClustersResponse2 = VmListClustersResponses[keyof VmListClustersResponses];
953968

969+
export type VmListRunningVmsData = {
970+
body?: never;
971+
path?: never;
972+
query?: never;
973+
url: '/vm/running';
974+
};
975+
976+
export type VmListRunningVmsResponses = {
977+
/**
978+
* VM List Running VMs Response
979+
*/
980+
200: VmListRunningVmsResponse;
981+
};
982+
983+
export type VmListRunningVmsResponse2 = VmListRunningVmsResponses[keyof VmListRunningVmsResponses];
984+
954985
export type VmCreateTagData = {
955986
/**
956987
* VM Create Tag Request

src/bin/main.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import { SDKProvider } from "./ui/sdkContext";
1313
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
1414

1515
if (process.argv.length === 2) {
16+
// Clear the screen before rendering the dashboard
17+
process.stdout.write('\x1Bc');
18+
1619
const sdk = new CodeSandbox();
1720
const queryClient = new QueryClient();
1821
render(

0 commit comments

Comments
 (0)