{"id":13702526,"url":"https://github.com/tonobo/hcloud-ruby","last_synced_at":"2025-05-05T04:31:05.385Z","repository":{"id":28736762,"uuid":"119202594","full_name":"tonobo/hcloud-ruby","owner":"tonobo","description":"Native ruby client for HetznerCloud","archived":false,"fork":false,"pushed_at":"2024-05-16T19:40:07.000Z","size":353,"stargazers_count":35,"open_issues_count":13,"forks_count":10,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-02T22:05:09.382Z","etag":null,"topics":["hcloud","hetzner","hetzner-cloud"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tonobo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-27T21:06:34.000Z","updated_at":"2025-02-23T04:43:50.000Z","dependencies_parsed_at":"2024-11-13T09:41:33.844Z","dependency_job_id":null,"html_url":"https://github.com/tonobo/hcloud-ruby","commit_stats":{"total_commits":216,"total_committers":9,"mean_commits":24.0,"dds":"0.43518518518518523","last_synced_commit":"aff46089045351c0dabe9074f8052e611e899072"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonobo%2Fhcloud-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonobo%2Fhcloud-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonobo%2Fhcloud-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonobo%2Fhcloud-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tonobo","download_url":"https://codeload.github.com/tonobo/hcloud-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252439528,"owners_count":21748024,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hcloud","hetzner","hetzner-cloud"],"created_at":"2024-08-02T21:00:37.246Z","updated_at":"2025-05-05T04:31:04.943Z","avatar_url":"https://github.com/tonobo.png","language":"Ruby","funding_links":[],"categories":["Libraries"],"sub_categories":["Ruby"],"readme":"# Hcloud\n\n[![Build Status](https://github.com/tonobo/hcloud-ruby/actions/workflows/ruby.yml/badge.svg)](https://github.com/tonobo/hcloud-ruby/actions/workflows/ruby.yml)\n[![codecov](https://codecov.io/gh/tonobo/hcloud-ruby/branch/master/graph/badge.svg)](https://codecov.io/gh/tonobo/hcloud-ruby)\n[![Gem Version](https://badge.fury.io/rb/hcloud.svg)](https://badge.fury.io/rb/hcloud)\n[![Maintainability](https://api.codeclimate.com/v1/badges/aa67f9d590d86845822f/maintainability)](https://codeclimate.com/github/tonobo/hcloud-ruby/maintainability)\n\nThis is an unoffical ruby client for HetznerCloud Api service.\n\n**Its currently in development and lacking a lot of feature. \nThe bindings are also not considered stable.**\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'hcloud'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install hcloud\n\n## Usage\n\n### Client\n\n* Create a client instance.\n\n```ruby\nc = Hcloud::Client.new(token: \"\u003cyour project token\u003e\")\n```\n\n* Create a client instance which fully handles concurrent pagination\n\n```ruby\nc = Hcloud::Client.new(\n  token: \"\u003cyour project token\u003e\", \n  auto_pagination: true,\n  concurrency: 50 # default 20\n)\n```\n\n* Expose client connection to class level\n\n```ruby\nHcloud::Client.connection = Hcloud::Client.new(...)\n```\n\n### Client concurrency\n\nEach action could be handled concurrently. The actual downsides are located \nat the exception handling. Means one request could break the whole bunch of requests,\nyou currently have to deal with that.\n\n```ruby\nservers = []\nclient.concurrent do\n  10.times do \n    servers \u003c\u003c client.servers.create(...)\n  end\nend \n\nservers.each do |(action, server, root_password)|\n  # do something with your servers ...\nend\n```\n\n### Server Resource\n\n* List servers (basic client)\n\n```ruby\n# default page(1)\n# default per_page(50)\nc.servers.page(2).per_page(40).each do |server|\n  server.datacenter.location.id #=\u003e 1\nend\n```\n\n* List servers (auto pagination client)\n\n```ruby\n# default nolimit\nc.servers.limit(80).each do |server|\n  server.datacenter.location.id #=\u003e 1\nend\n```\n\n* List with registered class level client\n\n```ruby\nServer.limit(10).each do |server|\n  # do something with the server\nend\n```\n\n* Create a server\n\nNonblocking:\n\n```ruby\nc.servers.create(name: \"moo5\", server_type: \"cx11\", image: \"ubuntu-16.04\")\n#=\u003e [#\u003cHcloud::Action\u003e, \u003c#Hcloud::Server\u003e, \"root_password\"]\n```\n\nWating for finish:\n\n```ruby\naction,server = c.servers.create(name: \"moo5\", server_type: \"cx11\", image: \"ubuntu-16.04\")\n\nwhile action.status == \"running\"\n  puts \"Waiting for Action #{action.id} to complete ...\"\n  action = c.actions.find(action.id)\n  server = c.servers.find(server.id)\n  puts \"Action Status: #{action.status}\"\n  puts \"Server Status: #{server.status}\"\n  puts \"Server IP Config: #{server.public_net[\"ipv4\"]}\"\n  sleep 5\nend\n```\n\n* Update servers' name\n\n```ruby\nc.servers.count\n#=\u003e 2\nc.servers.first.update(name: \"moo\")\n#=\u003e #\u003cHcloud::Server\u003e\nc.servers.each{|x| x.update(name: \"moo\") }\nHcloud::Error::UniquenessError: server name is already used\n```\n\n* Delete a server\n\n```ruby\nc.servers.first.destroy\n#=\u003e #\u003cHcloud::Action\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftonobo%2Fhcloud-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftonobo%2Fhcloud-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftonobo%2Fhcloud-ruby/lists"}