UNPKG

@codesandbox/sdk

Version:
219 lines (218 loc) 13.1 kB
import type { Client, Options as Options2, TDataShape } from './client'; import type { MetaInfoData, MetaInfoResponses, PreviewHostCreateData, PreviewHostCreateResponses, PreviewHostListData, PreviewHostListResponses, PreviewHostUpdateData, PreviewHostUpdateResponses, PreviewTokenCreateData, PreviewTokenCreateResponses, PreviewTokenListData, PreviewTokenListResponses, PreviewTokenRevokeAllData, PreviewTokenRevokeAllResponses, PreviewTokenUpdateData, PreviewTokenUpdateResponses, SandboxCreateData, SandboxCreateResponses, SandboxForkData, SandboxForkResponses, SandboxGetData, SandboxGetResponses, SandboxListData, SandboxListResponses, TemplatesCreateData, TemplatesCreateResponses, TokenCreateData, TokenCreateResponses, TokenUpdateData, TokenUpdateResponses, VmAssignTagAliasData, VmAssignTagAliasResponses, VmCreateSessionData, VmCreateSessionResponses, VmCreateTagData, VmCreateTagResponses, VmDeleteData, VmDeleteResponses, VmHibernateData, VmHibernateResponses, VmListClustersData, VmListClustersResponses, VmListRunningVmsData, VmListRunningVmsResponses, VmShutdownData, VmShutdownResponses, VmStartData, VmStartResponses, VmUpdateHibernationTimeoutData, VmUpdateHibernationTimeoutResponses, VmUpdateSpecs2Data, VmUpdateSpecs2Responses, VmUpdateSpecsData, VmUpdateSpecsResponses, WorkspaceCreateData, WorkspaceCreateResponses } from './types.gen'; export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a * custom client. */ client?: Client; /** * You can pass arbitrary values through the `meta` object. This can be * used to access values that aren't defined as part of the SDK function. */ meta?: Record<string, unknown>; }; /** * Metadata about the API */ export declare const metaInfo: <ThrowOnError extends boolean = false>(options?: Options<MetaInfoData, ThrowOnError>) => import("./client").RequestResult<MetaInfoResponses, unknown, ThrowOnError, "fields">; /** * Create a Workspace * Create a new, empty, workspace in the current organization * */ export declare const workspaceCreate: <ThrowOnError extends boolean = false>(options?: Options<WorkspaceCreateData, ThrowOnError>) => import("./client").RequestResult<WorkspaceCreateResponses, unknown, ThrowOnError, "fields">; /** * Create an API Token * Create a new API token for a workspace that is part of the current organization. * */ export declare const tokenCreate: <ThrowOnError extends boolean = false>(options: Options<TokenCreateData, ThrowOnError>) => import("./client").RequestResult<TokenCreateResponses, unknown, ThrowOnError, "fields">; /** * Update an API Token * Update an API token for a workspace that is part of the current organization. * */ export declare const tokenUpdate: <ThrowOnError extends boolean = false>(options: Options<TokenUpdateData, ThrowOnError>) => import("./client").RequestResult<TokenUpdateResponses, unknown, ThrowOnError, "fields">; /** * List Sandboxes * List sandboxes from the current workspace with optional filters. * Results are limited to a maximum of 50 sandboxes per request. * */ export declare const sandboxList: <ThrowOnError extends boolean = false>(options?: Options<SandboxListData, ThrowOnError>) => import("./client").RequestResult<SandboxListResponses, unknown, ThrowOnError, "fields">; /** * Create a Sandbox * Create a new sandbox in the current workspace with file contents * */ export declare const sandboxCreate: <ThrowOnError extends boolean = false>(options?: Options<SandboxCreateData, ThrowOnError>) => import("./client").RequestResult<SandboxCreateResponses, unknown, ThrowOnError, "fields">; /** * Get a Sandbox * Retrieve a sandbox by its ID * */ export declare const sandboxGet: <ThrowOnError extends boolean = false>(options: Options<SandboxGetData, ThrowOnError>) => import("./client").RequestResult<SandboxGetResponses, unknown, ThrowOnError, "fields">; /** * Fork a Sandbox * Fork an existing sandbox to the current workspace * */ export declare const sandboxFork: <ThrowOnError extends boolean = false>(options: Options<SandboxForkData, ThrowOnError>) => import("./client").RequestResult<SandboxForkResponses, unknown, ThrowOnError, "fields">; /** * Revoke preview tokens * Immediately expires all active preview tokens associated with this sandbox * */ export declare const previewTokenRevokeAll: <ThrowOnError extends boolean = false>(options: Options<PreviewTokenRevokeAllData, ThrowOnError>) => import("./client").RequestResult<PreviewTokenRevokeAllResponses, unknown, ThrowOnError, "fields">; /** * List Preview Tokens * List information about the preview tokens associated with the current sandbox * */ export declare const previewTokenList: <ThrowOnError extends boolean = false>(options: Options<PreviewTokenListData, ThrowOnError>) => import("./client").RequestResult<PreviewTokenListResponses, unknown, ThrowOnError, "fields">; /** * Create a Preview Token * Create a new Preview token that allow access to a private sandbox * */ export declare const previewTokenCreate: <ThrowOnError extends boolean = false>(options: Options<PreviewTokenCreateData, ThrowOnError>) => import("./client").RequestResult<PreviewTokenCreateResponses, unknown, ThrowOnError, "fields">; /** * Update a Preview Token * Update a Preview token that allow access to a private sandbox * */ export declare const previewTokenUpdate: <ThrowOnError extends boolean = false>(options: Options<PreviewTokenUpdateData, ThrowOnError>) => import("./client").RequestResult<PreviewTokenUpdateResponses, unknown, ThrowOnError, "fields">; /** * Create a template * Create a new template in the current workspace (creates 3 sandboxes and tags them) * */ export declare const templatesCreate: <ThrowOnError extends boolean = false>(options?: Options<TemplatesCreateData, ThrowOnError>) => import("./client").RequestResult<TemplatesCreateResponses, unknown, ThrowOnError, "fields">; /** * Assign a tag alias to a VM tag * Assign a tag alias to a VM tag. * */ export declare const vmAssignTagAlias: <ThrowOnError extends boolean = false>(options: Options<VmAssignTagAliasData, ThrowOnError>) => import("./client").RequestResult<VmAssignTagAliasResponses, unknown, ThrowOnError, "fields">; /** * List all available clusters * List all available clusters. * */ export declare const vmListClusters: <ThrowOnError extends boolean = false>(options?: Options<VmListClustersData, ThrowOnError>) => import("./client").RequestResult<VmListClustersResponses, unknown, ThrowOnError, "fields">; /** * List information about currently running VMs * 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. * */ export declare const vmListRunningVms: <ThrowOnError extends boolean = false>(options?: Options<VmListRunningVmsData, ThrowOnError>) => import("./client").RequestResult<VmListRunningVmsResponses, unknown, ThrowOnError, "fields">; /** * Create a new tag for a VM * Creates a new tag for a VM. * */ export declare const vmCreateTag: <ThrowOnError extends boolean = false>(options?: Options<VmCreateTagData, ThrowOnError>) => import("./client").RequestResult<VmCreateTagResponses, unknown, ThrowOnError, "fields">; /** * Delete a VM * Deletes a VM, permanently removing it from the system. * * This endpoint can only be used on VMs that belong to your team's workspace. * Deleting a VM is irreversible and will permanently delete all data associated with it. * */ export declare const vmDelete: <ThrowOnError extends boolean = false>(options: Options<VmDeleteData, ThrowOnError>) => import("./client").RequestResult<VmDeleteResponses, unknown, ThrowOnError, "fields">; /** * Hibernate a VM * Suspends a running VM, saving a snapshot of its memory and running processes * * This endpoint may take an extended amount of time to return (30 seconds). If the VM is not * currently running, it will return an error (404). * * Unless later shut down by request or due to inactivity, a hibernated VM can be resumed with * minimal latency. * */ export declare const vmHibernate: <ThrowOnError extends boolean = false>(options: Options<VmHibernateData, ThrowOnError>) => import("./client").RequestResult<VmHibernateResponses, unknown, ThrowOnError, "fields">; /** * Update VM Hibernation Timeout * Updates the hibernation timeout of a running VM. * * This endpoint can only be used on VMs that belong to your team's workspace. * The new timeout must be greater than 0 and less than or equal to 86400 seconds (24 hours). * */ export declare const vmUpdateHibernationTimeout: <ThrowOnError extends boolean = false>(options: Options<VmUpdateHibernationTimeoutData, ThrowOnError>) => import("./client").RequestResult<VmUpdateHibernationTimeoutResponses, unknown, ThrowOnError, "fields">; /** * Create a new session on a VM * Creates a new session on a running VM. A session represents an isolated Linux user, with their own container. * A session has a single use token that the user can use to connect to the VM. This token has specific permissions (currently, read or write). * The session is identified by a unique session ID, and the Linux username is based on the session ID. * * The Git user name and email can be configured via parameters. * * This endpoint requires the VM to be running. If the VM is not running, it will return a 404 error. * */ export declare const vmCreateSession: <ThrowOnError extends boolean = false>(options: Options<VmCreateSessionData, ThrowOnError>) => import("./client").RequestResult<VmCreateSessionResponses, unknown, ThrowOnError, "fields">; /** * Shutdown a VM * Stops a running VM, ending all currently running processes * * This endpoint may take an extended amount of time to return (30 seconds). If the VM is not * currently running, it will return an error (404). * * Shutdown VMs require additional time to start up. * */ export declare const vmShutdown: <ThrowOnError extends boolean = false>(options: Options<VmShutdownData, ThrowOnError>) => import("./client").RequestResult<VmShutdownResponses, unknown, ThrowOnError, "fields">; /** * Update VM Specs * Updates the specifications (CPU, memory, storage) of a running VM. * * This endpoint can only be used on VMs that belong to your team's workspace. * The new tier must not exceed your team's maximum allowed tier. * */ export declare const vmUpdateSpecs: <ThrowOnError extends boolean = false>(options: Options<VmUpdateSpecsData, ThrowOnError>) => import("./client").RequestResult<VmUpdateSpecsResponses, unknown, ThrowOnError, "fields">; /** * Start a VM * Start a virtual machine for the sandbox (devbox) with the given ID * * While the `sandbox:read` scope is required for this endpoint, the resulting VM will have * permissions according to the `sandbox:edit_code` scope. If present, the returned token will * have write permissions to the contents of the VM. Otherwise, the returned token will grant * only read-only permissions. * * This endpoint is subject to special rate limits related to concurrent VM usage. * */ export declare const vmStart: <ThrowOnError extends boolean = false>(options: Options<VmStartData, ThrowOnError>) => import("./client").RequestResult<VmStartResponses, unknown, ThrowOnError, "fields">; /** * Update VM Specs * Updates the specifications (CPU, memory, storage) of a running VM. * * This endpoint can only be used on VMs that belong to your team's workspace. * The new tier must not exceed your team's maximum allowed tier. * */ export declare const vmUpdateSpecs2: <ThrowOnError extends boolean = false>(options: Options<VmUpdateSpecs2Data, ThrowOnError>) => import("./client").RequestResult<VmUpdateSpecs2Responses, unknown, ThrowOnError, "fields">; /** * List Preview Hosts * List all trusted preview hosts for the current team * */ export declare const previewHostList: <ThrowOnError extends boolean = false>(options?: Options<PreviewHostListData, ThrowOnError>) => import("./client").RequestResult<PreviewHostListResponses, unknown, ThrowOnError, "fields">; /** * Create Preview Hosts * Add one or more trusted domains that are allowed to access sandbox previews for this workspace. * */ export declare const previewHostCreate: <ThrowOnError extends boolean = false>(options?: Options<PreviewHostCreateData, ThrowOnError>) => import("./client").RequestResult<PreviewHostCreateResponses, unknown, ThrowOnError, "fields">; /** * Update Preview Hosts * Replace the list of trusted domains that are allowed to access sandbox previews for this workspace. * */ export declare const previewHostUpdate: <ThrowOnError extends boolean = false>(options?: Options<PreviewHostUpdateData, ThrowOnError>) => import("./client").RequestResult<PreviewHostUpdateResponses, unknown, ThrowOnError, "fields">;