RSDO - DigitalOcean Rust Client
Pronunciation:
/ˈrɪz.doʊ/(rizz-do)
- because every crate needs a catchy name.
A comprehensive, type-safe Rust client for the DigitalOcean API, automatically generated from the official OpenAPI specification using progenitor.
Features
- 🚀 Complete API Coverage - All 500+ DigitalOcean API endpoints
- 🔒 Type Safety - Fully typed request/response models
- ⚡ Async/Await - Built on tokio and reqwest
- 📚 Auto-Generated - Always up-to-date with the latest API
- 🛡️ Error Handling - Comprehensive error types
- 📖 Rich Documentation - Extensive examples and guides
- 🔄 Pagination Support - Built-in pagination helpers
- 🏷️ Resource Tagging - Full support for DigitalOcean tags
Supported Services
| Service | Description | Documentation |
|---|---|---|
| Droplets | Virtual machines and compute resources | 📖 Guide |
| Kubernetes | Managed Kubernetes clusters (DOKS) | 📖 Guide |
| Databases | Managed databases (PostgreSQL, MySQL, Redis/Valkey, MongoDB) | 📖 Guide |
| VPC | Virtual Private Cloud networking | 📖 Guide |
| Spaces | S3-compatible object storage with CDN | 📖 Guide |
| Load Balancers | Application and network load balancing | API Reference |
| Firewalls | Cloud firewall rules and policies | API Reference |
| Volumes | Block storage volumes | API Reference |
| Snapshots | Backup and restore functionality | API Reference |
| Images | Custom images and distributions | API Reference |
| SSH Keys | SSH key management | API Reference |
| Domains | DNS management | API Reference |
| Certificates | SSL/TLS certificate management | API Reference |
| Monitoring | Metrics and alerting | API Reference |
| Projects | Resource organization | API Reference |
Quick Start
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
= { = "0.12", = ["json"] }
= { = "1.0", = ["full"] }
Authentication
Get your API token from the DigitalOcean Control Panel:
use ;
use ;
async
Environment Variable Setup
For convenience, set your API token as an environment variable:
Then use it in your code:
let token = var?;
headers.insert;
Examples
Create a Droplet
use *;
let droplet_spec = DropletsCreateBody ;
let response = client.droplets_create.await?;
let droplet = response.into_inner.droplet;
println!;
Create a Kubernetes Cluster
let cluster_spec = KubernetesCreateClusterBody ;
let response = client.kubernetes_create_cluster.await?;
let cluster = response.into_inner.kubernetes_cluster;
println!;
Create a Database
let db_spec = DatabasesCreateClusterBody ;
let response = client.databases_create_cluster.await?;
let database = response.into_inner.database;
println!;
Upload to Spaces (S3-Compatible)
use ;
// Setup S3 client for Spaces
let credentials = new;
let config = new
.credentials_provider
.region
.endpoint_url
.build;
let s3_client = from_conf;
// Upload file
s3_client
.put_object
.bucket
.key
.body
.acl
.send
.await?;
println!;
Error Handling
The client provides comprehensive error handling:
use Error;
match client.droplets_get.await
Pagination
Many API endpoints support pagination:
let mut page = 1;
let per_page = 50;
loop
Configuration
Using Environment Variables
You can configure the client using environment variables:
# Required
# Optional
# Custom API endpoint
# Request timeout in seconds
Custom HTTP Client
use Duration;
let http_client = builder
.timeout
.user_agent
.default_headers
.build?;
let client = new_with_client;
Complete Examples
Check out the comprehensive guides for complete, production-ready examples:
- Web Server Deployment - Full droplet lifecycle with nginx, firewall, and monitoring
- Kubernetes Cluster Setup - End-to-end cluster creation with node pools and configuration
- Multi-tier Database - PostgreSQL + Redis setup with replicas and connection pooling
- Static Website Hosting - Spaces + CDN setup for static sites
- VPC Infrastructure - Private networking setup with proper resource organization
Development
Building from Source
Running Tests
# Unit tests
# Integration tests (requires API token)
DIGITALOCEAN_TOKEN="your-token"
Code Generation
This client is auto-generated from the DigitalOcean OpenAPI specification. To regenerate:
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Reporting Issues
- API Issues: If you find issues with the generated client, please check if it's an upstream OpenAPI spec issue
- Documentation: Help improve our examples and documentation
- Features: Suggest new features or improvements
Minimum Supported Rust Version (MSRV)
Current MSRV: 1.70.0
MSRV Policy
This crate follows an aggressive MSRV policy to take advantage of the latest Rust language features, performance improvements, and safety enhancements:
- ✅ MSRV can be raised at any time for new features, safety improvements, or maintainability
- ✅ MSRV increases will result in a semver minor release (not patch)
- ✅ We will always document MSRV changes in release notes and changelog
- ✅ No advance warning period - we adopt new language features as soon as they're beneficial
For Users
- If you need to support older Rust versions, pin to a specific version range in your
Cargo.toml:[] = ">=1.0.0, <1.2.0" # Example: avoid MSRV bumps in 1.2.0+ - Check the
rust-versionfield in ourCargo.tomlfor the current MSRV - Our CI automatically tests against the declared MSRV to ensure compatibility
This policy allows us to provide the safest, most performant, and maintainable DigitalOcean client possible by leveraging the latest Rust ecosystem improvements.
API Reference
Full API documentation is available at docs.rs/rsdo.
For DigitalOcean API documentation, see: https://docs.digitalocean.com/reference/api/
Rate Limiting
DigitalOcean API has rate limits:
- 5,000 requests per hour per API token
- 250 requests per minute per API token
The client doesn't automatically handle rate limiting, but you can implement retry logic:
use ;
async
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Acknowledgments
- Built with progenitor for type-safe API client generation
- Powered by reqwest for HTTP client functionality
- Uses tokio for async runtime
🚀 Ready to build amazing things with DigitalOcean and Rust!
For questions, issues, or contributions, please visit our GitHub repository.