Module clients.sandbox.filesystem.client
Classes
FilesystemClient
class FilesystemClient(connection_config: h2o_engine_manager.clients.connection_config.ConnectionConfig, verify_ssl: bool = True, ssl_ca_cert: Optional[str] = None)
FilesystemClient manages filesystem operations within a SandboxEngine.
Args
connection_config- AIEM connection configuration object.
verify_ssl- Set to False to disable SSL certificate verification.
ssl_ca_cert- Path to a CA cert bundle with certificates of trusted CAs.
Methods
list_directory
def list_directory(self, name: str, path: str) ‑> List[h2o_engine_manager.clients.sandbox.filesystem.file_info.FileInfo]
List files and directories in a given directory.
Args
name:str- SandboxEngine resource name. Format: "workspaces//sandboxEngines/"
path:str- The absolute path to the directory to list. Must start with a forward slash (e.g., "/workspace"). Lists only direct children of the directory (non-recursive).
Returns
List[FileInfo]- List of file and directory information.
make_directory
def make_directory(self, name: str, path: str, create_parent_directories: bool = False) ‑> h2o_engine_manager.clients.sandbox.filesystem.file_info.FileInfo
Create a directory (similar to Unix mkdir).
Args
name:str- SandboxEngine resource name. Format: "workspaces//sandboxEngines/"
path:str- The absolute path where the directory should be created. Must start with a forward slash (e.g., "/workspace/data"). The directory will be created with 0755 permissions (rwxr-xr-x).
create_parent_directories:bool- If True, creates parent directories if they don't exist. If False, the operation will fail if parent directories don't exist. Defaults to False.
Returns
FileInfo- Metadata about the created directory.
move
def move(self, name: str, source_path: str, destination_path: str, overwrite: Optional[bool] = None, create_parent_directories: bool = False) ‑> h2o_engine_manager.clients.sandbox.filesystem.file_info.FileInfo
Move or rename a file, directory, or symbolic link.
Args
name:str- SandboxEngine resource name. Format: "workspaces//sandboxEngines/"
source_path:str- The absolute path of the source. Must start with a forward slash (e.g., "/workspace/old.js"). If the source is a symbolic link, the link itself is moved, not its target.
destination_path:str- The absolute path of the destination. Must start with a forward slash (e.g., "/workspace/new.js").
overwrite:Optional[bool]- If True, overwrites the destination if it exists. If False or None, the operation will fail if the destination exists. Defaults to None.
create_parent_directories:bool- If True, creates parent directories of the destination path if they don't exist. Defaults to False.
Returns
FileInfo- Metadata about the moved entry at its new location.
read_file
def read_file(self, name: str, path: str) ‑> h2o_engine_manager.clients.sandbox.filesystem.read_file_response.ReadFileResponse
Read a file from the sandbox engine filesystem.
Args
name:str- SandboxEngine resource name. Format: "workspaces//sandboxEngines/"
path:str- The absolute path to the file to read. Must start with a forward slash (e.g., "/workspace/app.js"). If the path is a symbolic link, it will be resolved to the target file.
Returns
ReadFileResponse- Response containing file content and metadata.
remove
def remove(self, name: str, path: str, recursive: bool = False) ‑> None
Remove (delete) a file or directory.
Args
name:str- SandboxEngine resource name. Format: "workspaces//sandboxEngines/"
path:str- The absolute path to the file or directory to delete. Must start with a forward slash (e.g., "/workspace/app.js"). If the path is a symbolic link, the link itself is removed, not its target.
recursive:bool- If True, removes directories and their contents recursively (similar to
rm -rf). If False, non-empty directories will cause an error. Defaults to False.
stat_file
def stat_file(self, name: str, path: str) ‑> h2o_engine_manager.clients.sandbox.filesystem.file_info.FileInfo
Get metadata about a file or directory (similar to Unix stat).
Args
name:str- SandboxEngine resource name. Format: "workspaces//sandboxEngines/"
path:str- The absolute path to the file or directory. Must start with a forward slash (e.g., "/workspace/app.js"). If the path is a symbolic link, metadata about the target file is returned (symlink is followed).
Returns
FileInfo- Metadata about the file or directory.
write_file
def write_file(self, name: str, path: str, content: bytes, create_parent_directories: bool = False, overwrite: Optional[bool] = None) ‑> h2o_engine_manager.clients.sandbox.filesystem.write_file_response.WriteFileResponse
Write content to a file in the sandbox engine filesystem.
Args
name:str- SandboxEngine resource name. Format: "workspaces//sandboxEngines/"
path:str- The absolute path where the file should be written. Must start with a forward slash (e.g., "/workspace/app.js").
content:bytes- The raw content to write to the file as bytes. For text files, provide UTF-8 encoded text.
create_parent_directories:bool- If True, creates parent directories if they don't exist. Defaults to False.
overwrite:Optional[bool]- Controls overwrite behavior. If True or None, overwrites the file if it exists. If False, the operation will fail if the file already exists.
Returns
WriteFileResponse- Response containing metadata about the written file.
Feedback
- Submit and view feedback for this page
- Send feedback about AI Engine Manager to cloud-feedback@h2o.ai