// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../core/resource'; import * as SandboxesAPI from './sandboxes'; import { APIPromise } from '../../../core/api-promise'; import { buildHeaders } from '../../../internal/headers'; import { RequestOptions } from '../../../internal/request-options'; import { path } from '../../../internal/utils/path'; /** * Run heavy work in Village-managed compute sandboxes. */ export class Files extends APIResource { /** * List sandbox files */ list(sandboxID: string, query: FileListParams, options?: RequestOptions): APIPromise { return this._client.get(path`/compute/sandboxes/${sandboxID}/files`, { query, ...options }); } /** * Create a sandbox directory */ mkdir(sandboxID: string, body: FileMkdirParams, options?: RequestOptions): APIPromise { return this._client.post(path`/compute/sandboxes/${sandboxID}/files/mkdir`, { body, ...options, headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), }); } /** * Read a sandbox file */ read(sandboxID: string, body: FileReadParams, options?: RequestOptions): APIPromise { return this._client.post(path`/compute/sandboxes/${sandboxID}/files/read`, { body, ...options }); } /** * Remove a sandbox file or directory */ remove(sandboxID: string, body: FileRemoveParams, options?: RequestOptions): APIPromise { return this._client.post(path`/compute/sandboxes/${sandboxID}/files/remove`, { body, ...options, headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), }); } /** * Write a sandbox file */ write(sandboxID: string, body: FileWriteParams, options?: RequestOptions): APIPromise { return this._client.post(path`/compute/sandboxes/${sandboxID}/files/write`, { body, ...options, headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), }); } } export type FileListResponse = Array; export interface FileReadResponse { /** * Base64-encoded binary content. */ data_base64?: string | null; /** * UTF-8 text content. */ text?: string | null; } export interface FileListParams { /** * Directory path inside the sandbox. */ path: string; } export interface FileMkdirParams { /** * Absolute path inside the sandbox. */ path: string; /** * Create missing parent directories. */ parents?: boolean; } export interface FileReadParams { /** * Absolute path inside the sandbox. */ path: string; /** * Return text or base64-encoded bytes. */ encoding?: 'utf-8' | 'base64'; } export interface FileRemoveParams { /** * Absolute path inside the sandbox. */ path: string; /** * Remove directories recursively. */ recursive?: boolean; } export interface FileWriteParams { /** * Absolute path inside the sandbox. */ path: string; /** * Base64-encoded bytes to write. */ data_base64?: string | null; /** * UTF-8 text to write. */ text?: string | null; } export declare namespace Files { export { type FileListResponse as FileListResponse, type FileReadResponse as FileReadResponse, type FileListParams as FileListParams, type FileMkdirParams as FileMkdirParams, type FileReadParams as FileReadParams, type FileRemoveParams as FileRemoveParams, type FileWriteParams as FileWriteParams, }; }