Class: HCloud::Metadata

Inherits:
Resource show all
Defined in:
lib/hcloud/resources/metadata.rb

Overview

Server metadata.

This resource allows a Hetzner server to retrieve metadata about itself. It cannot be used outside of Hetzner servers.

Find metadata

HCloud::Metadata.find
# => #<HCloud::Metadata ...>

Constant Summary collapse

ENDPOINT =
"https://169.254.169.254/hetzner/v1/metadata"

Class Method Summary collapse

Methods inherited from Resource

#==, attribute, client, #initialize, #inspect, resource_name, #to_h

Constructor Details

This class inherits a constructor from HCloud::Resource

Class Method Details

.findObject



26
27
28
29
30
31
# File 'lib/hcloud/resources/metadata.rb', line 26

def self.find
  new(::HTTP
    .get(ENDPOINT)
    .parse(:yaml)
    .deep_transform_keys { |key| key.underscore.to_sym })
end