Skip to content

hdresearch/csharp-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vers C# API Library

This library provides convenient access to the Vers REST API from C# / .NET.

It is generated with Sterling.

Installation

dotnet add package vers-sdk

Usage

using VersSdk;

var client = new VersSdkClient(
    apiKey: "your-api-key"  // or set VERS_API_KEY env var
);

// List all VMs
var response = await client.ListVmsAsync();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);

client.Dispose();

Configuration

var client = new VersSdkClient(
    baseUrl: "https://api.vers.sh",     // or set VERS_BASE_URL env var
    apiKey: "your-api-key",             // or set VERS_API_KEY env var
    maxRetries: 2,
    timeout: TimeSpan.FromSeconds(30),
    httpClient: customHttpClient,       // optional pre-configured HttpClient
    logger: loggerInstance              // optional ILogger
);

Error handling

using VersSdk;

try
{
    await client.DeleteVmAsync("nonexistent-id");
}
catch (NotFoundException e)
{
    Console.WriteLine($"Not found: {e.StatusCode} {e.Message}");
}
catch (ApiException e)
{
    Console.WriteLine($"API error: {e.StatusCode}");
}

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

Idempotency keys are automatically generated for POST, PUT, PATCH, and DELETE requests.

Requirements

  • .NET 8.0+
  • System.Text.Json (included in .NET)
  • Microsoft.Extensions.Logging.Abstractions

License

MIT

About

Vers SDK — generated from the Vers OpenAPI spec

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages