Skip to content

Latest commit

 

History

History
86 lines (61 loc) · 1.56 KB

File metadata and controls

86 lines (61 loc) · 1.56 KB

Vers Ruby API Library

This library provides convenient access to the Vers REST API from Ruby.

It is generated with Sterling.

Installation

Add to your Gemfile:

gem "vers-sdk"

Or install directly:

gem install vers-sdk

Usage

require "vers_sdk"

client = VersSdk::VersSdkClient.new(
  api_key: "your-api-key"  # or set VERS_API_KEY env var
)

# List all VMs
response = client.list_vms
puts JSON.parse(response.body)

# Create a new root VM
response = client.create_new_root_vm(body: { "vm_config" => {} })
puts JSON.parse(response.body)

Configuration

client = VersSdk::VersSdkClient.new(
  api_key: "your-api-key",           # or set VERS_API_KEY env var
  base_url: "https://api.vers.sh",   # or set VERS_BASE_URL env var
  max_retries: 2,
  timeout: 30
)

Error handling

require "vers_sdk"

begin
  client.delete_vm("nonexistent-id")
rescue VersSdk::NotFoundError => e
  puts "Not found: #{e.status} #{e.message}"
rescue VersSdk::APIError => e
  puts "API error: #{e.status}"
end

Retries

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).

Per-request options

options = VersSdk::RequestOptions.new(
  headers: { "X-Custom" => "value" },
  timeout: 60
)
client.list_vms(options: options)

Requirements

  • Ruby >= 3.0
  • No external gem dependencies (uses net/http from stdlib)

License

MIT