All Projects → tonobo → hcloud-ruby

tonobo / hcloud-ruby

Licence: MIT license
Native ruby client for HetznerCloud

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to hcloud-ruby

hcloud-rust
Unofficial Rust crate for accessing the Hetzner Cloud API
Stars: ✭ 22 (-24.14%)
Mutual labels:  hetzner, hetzner-cloud, hcloud
hetzner.hcloud
A collection containing modules to manage resources on the Hetzner Cloud.
Stars: ✭ 58 (+100%)
Mutual labels:  hetzner, hetzner-cloud, hcloud
wireguard-setup
WireGuard and Unbound setup with Packer and Terraform.
Stars: ✭ 55 (+89.66%)
Mutual labels:  hetzner, hetzner-cloud, hcloud
hcloud-pricing-exporter
A prometheus exporter for the current pricing and costs of your HCloud account
Stars: ✭ 19 (-34.48%)
Mutual labels:  hetzner, hetzner-cloud, hcloud
ui-driver-hetzner
Rancher UI driver for the Hetzner Cloud docker driver.
Stars: ✭ 238 (+720.69%)
Mutual labels:  hetzner, hetzner-cloud, hcloud
hcloud-ip-floater
k8s controller for Hetzner Cloud floating IPs
Stars: ✭ 43 (+48.28%)
Mutual labels:  hetzner, hcloud
cluster-api-provider-hcloud
Cluster API infrastructure provider for Hetzner's Hcloud
Stars: ✭ 26 (-10.34%)
Mutual labels:  hetzner, hcloud
hetzner-k3s
A Ruby gem (and Docker image) to install and manage Kubernetes clusters in Hetzner Cloud using the lightweight distribution k3s by Rancher.
Stars: ✭ 201 (+593.1%)
Mutual labels:  hetzner, hetzner-cloud
packer-builder-hcloud
Packer builder plugin for Hetzner Cloud - https://hetzner.cloud
Stars: ✭ 24 (-17.24%)
Mutual labels:  hetzner, hetzner-cloud
docker-volume-hetzner
Docker Volume Plugin for accessing Hetzner Cloud Volumes
Stars: ✭ 81 (+179.31%)
Mutual labels:  hetzner, hetzner-cloud
kube-hetzner
Optimized and Maintenance-free Kubernetes on Hetzner Cloud in one command!
Stars: ✭ 937 (+3131.03%)
Mutual labels:  hetzner-cloud, hcloud
minectl
minectl 🗺 is a cli for creating Minecraft server on different cloud provider.
Stars: ✭ 85 (+193.1%)
Mutual labels:  hetzner, hetzner-cloud
molecule-hetznercloud
Molecule Hetzner Cloud driver 💀
Stars: ✭ 21 (-27.59%)
Mutual labels:  hetzner, hetzner-cloud
hetzner-rescaler
Lightweight CLI tool to programmatically rescale your Hetzner virtual server daily to optimize your budget spending
Stars: ✭ 44 (+51.72%)
Mutual labels:  hetzner, hetzner-cloud
hetzner exporter
Prometheus exporter for Hetzner
Stars: ✭ 16 (-44.83%)
Mutual labels:  hetzner
Guide
Kubernetes clusters for the hobbyist.
Stars: ✭ 5,150 (+17658.62%)
Mutual labels:  hetzner-cloud
disk-encryption-hetzner
Encrypt a hetzner server from the "serverbörse" and unlock it remote via ssh
Stars: ✭ 122 (+320.69%)
Mutual labels:  hetzner
community-content
Hetzner Online Community Project
Stars: ✭ 149 (+413.79%)
Mutual labels:  hetzner
terraform-provider-hetznerdns
Terraform provider for Hetzner DNS
Stars: ✭ 78 (+168.97%)
Mutual labels:  hetzner
prometheus-hetzner-sd
Prometheus Service Discovery for Hetzner
Stars: ✭ 15 (-48.28%)
Mutual labels:  hetzner

Hcloud

Build Status codecov Gem Version Maintainability

This is an unoffical ruby client for HetznerCloud Api service.

Its currently in development and lacking a lot of feature. The bindings are also not considered stable.

Installation

Add this line to your application's Gemfile:

gem 'hcloud'

And then execute:

$ bundle

Or install it yourself as:

$ gem install hcloud

Usage

Client

  • Create a client instance.
c = Hcloud::Client.new(token: "<your project token>")
  • Create a client instance which fully handles concurrent pagination
c = Hcloud::Client.new(
  token: "<your project token>", 
  auto_pagination: true,
  concurrency: 50 # default 20
)
  • Expose client connection to class level
Hcloud::Client.connection = Hcloud::Client.new(...)

Client concurrency

Each action could be handled concurrently. The actual downsides are located at the exception handling. Means one request could break the whole bunch of requests, you currently have to deal with that.

servers = []
client.concurrent do
  10.times do 
    servers << client.servers.create(...)
  end
end 

servers.each do |(action, server, root_password)|
  # do something with your servers ...
end

Server Resource

  • List servers (basic client)
# default page(1)
# default per_page(50)
c.servers.page(2).per_page(40).each do |server|
  server.datacenter.location.id #=> 1
end
  • List servers (auto pagination client)
# default nolimit
c.servers.limit(80).each do |server|
  server.datacenter.location.id #=> 1
end
  • List with registered class level client
Server.limit(10).each do |server|
  # do something with the server
end
  • Create a server

Nonblocking:

c.servers.create(name: "moo5", server_type: "cx11", image: "ubuntu-16.04")
#=> [#<Hcloud::Action>, <#Hcloud::Server>, "root_password"]

Wating for finish:

action,server = c.servers.create(name: "moo5", server_type: "cx11", image: "ubuntu-16.04")

while action.status == "running"
  puts "Waiting for Action #{action.id} to complete ..."
  action = c.actions.find(action.id)
  server = c.servers.find(server.id)
  puts "Action Status: #{action.status}"
  puts "Server Status: #{server.status}"
  puts "Server IP Config: #{server.public_net["ipv4"]}"
  sleep 5
end
  • Update servers' name
c.servers.count
#=> 2
c.servers.first.update(name: "moo")
#=> #<Hcloud::Server>
c.servers.each{|x| x.update(name: "moo") }
Hcloud::Error::UniquenessError: server name is already used
  • Delete a server
c.servers.first.destroy
#=> #<Hcloud::Action>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].