This library provides convenient access to the Vers REST API from Java.
It is generated with Sterling.
<dependency>
<groupId>com.vers</groupId>
<artifactId>vers-sdk</artifactId>
<version>0.1.8</version>
</dependency>implementation 'com.vers:vers-sdk:0.1.8'import com.vers.sdk.VersClient;
public class Example {
public static void main(String[] args) throws Exception {
VersClient client = new VersClient(
"https://api.vers.sh", // or set VERS_BASE_URL env var
"your-api-key" // or set VERS_API_KEY env var
);
// List all VMs
var response = client.listVms(null, null);
System.out.println(response.body());
// Create a new root VM
var vm = client.createNewRootVm(java.util.Map.of("vm_config", java.util.Map.of()), null);
System.out.println(vm.body());
client.close();
}
}import com.vers.sdk.VersClient;
import java.time.Duration;
VersClient client = new VersClient(
"https://api.vers.sh", // base URL
"your-api-key", // API key
2, // max retries
Duration.ofSeconds(30), // timeout
null // optional custom HttpClient
);import com.vers.sdk.Errors.*;
try {
client.deleteVm("nonexistent-id", null);
} catch (NotFoundError e) {
System.out.println("Not found: " + e.getStatus() + " " + e.getMessage());
} catch (APIError e) {
System.out.println("API error: " + e.getStatus());
}Requests are automatically retried up to 2 times on 5xx errors and connection failures,
with exponential backoff and jitter. The client respects Retry-After headers (capped at 60s).
import com.vers.sdk.RequestOptions;
import java.time.Duration;
RequestOptions options = new RequestOptions()
.addHeader("X-Custom-Header", "value")
.setTimeout(Duration.ofSeconds(60));
client.listVms(null, options);- Java 11+
- Jackson Databind
MIT