TypeScript SDK
Official TypeScript SDK for interacting with the Valyent Cloud platform.
Installation
Quick Start
Core Concepts
Client
The Client
class is the main entry point for interacting with the Valyent Cloud API. It provides access to all available resources through dedicated sub-clients.
Fleets
Fleets are logical groupings of machines. They help organize your resources and manage them collectively.
Machines
Machines are the compute instances running your workloads. Each machine runs in a microVM with its own resources and configuration.
Machine Configuration
Gateways
Gateways provide network access to your machines. They can be used to expose services running in your machines.
Filesystem Operations
The SDK provides access to the machine’s filesystem through the fs
property on machine instances.
Logs and Events
You can access machine logs and events for monitoring and debugging:
Machine States
Machines can be in the following states:
created
: Initial state after creation -preparing
: Machine is being prepared -starting
: Machine is starting up -running
: Machine is runningstopping
: Machine is being stopped -stopped
: Machine has stopped -destroying
: Machine is being destroyed -destroyed
: Machine has been destroyed
You can wait for a specific machine state:
Error Handling
The SDK throws FetchErrorWithPayload
for API errors, which includes both the error message and the response payload:
Best Practices
-
Resource Cleanup: Always clean up resources when they’re no longer needed:
-
Error Handling: Implement proper error handling for API calls to handle network issues and API errors gracefully.
-
Configuration Management: Keep machine configurations in version control and use environment variables for dynamic values.
-
Monitoring: Use the logs and events APIs to monitor your machines’ health and troubleshoot issues.
TypeScript Support
The SDK is written in TypeScript and provides full type definitions for all APIs. You can import types directly: