Class: Hetzner::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/hetzner/client.rb,
lib/hetzner/commands/ips.rb,
lib/hetzner/commands/ssh.rb,
lib/hetzner/commands/isos.rb,
lib/hetzner/commands/images.rb,
lib/hetzner/commands/actions.rb,
lib/hetzner/commands/pricing.rb,
lib/hetzner/commands/servers.rb,
lib/hetzner/commands/volumes.rb,
lib/hetzner/commands/networks.rb,
lib/hetzner/commands/firewalls.rb,
lib/hetzner/commands/locations.rb,
lib/hetzner/commands/datacenters.rb,
lib/hetzner/commands/certificates.rb,
lib/hetzner/commands/load_balancers.rb,
lib/hetzner/commands/placement_groups.rb

Constant Summary collapse

API_ENDPOINT =
"https://api.hetzner.cloud".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_token = nil) ⇒ Client

Returns a new instance of Client.



12
13
14
# File 'lib/hetzner/client.rb', line 12

def initialize(api_token = nil)
  @api_token = api_token
end

Instance Attribute Details

#api_tokenObject (readonly)

Returns the value of attribute api_token.



10
11
12
# File 'lib/hetzner/client.rb', line 10

def api_token
  @api_token
end

Instance Method Details

#action(id) ⇒ Object



7
8
9
# File 'lib/hetzner/commands/actions.rb', line 7

def action(id)
  get("/v1/actions/#{id}")
end

#actionsObject



3
4
5
# File 'lib/hetzner/commands/actions.rb', line 3

def actions
  get("/v1/actions")
end

#certificate(id) ⇒ Object



7
8
9
# File 'lib/hetzner/commands/certificates.rb', line 7

def certificate(id)
  get("/v1/certificates/#{id}")
end

#certificate_action(id, action) ⇒ Object



15
16
17
# File 'lib/hetzner/commands/certificates.rb', line 15

def certificate_action(id, action)
  get("/v1/certificates/#{id}/actions/#{action}")
end

#certificate_actions(id) ⇒ Object



11
12
13
# File 'lib/hetzner/commands/certificates.rb', line 11

def certificate_actions(id)
  get("/v1/certificates/#{id}/actions")
end

#certificatesObject



3
4
5
# File 'lib/hetzner/commands/certificates.rb', line 3

def certificates
  get("/v1/certificates")
end

#create_server(name, server_type, image) ⇒ Object



27
28
29
# File 'lib/hetzner/commands/servers.rb', line 27

def create_server(name, server_type, image)
  post("/v1/servers", { name: name, server_type: server_type, image: image })
end

#datacenter(id) ⇒ Object



7
8
9
# File 'lib/hetzner/commands/datacenters.rb', line 7

def datacenter(id)
  get("/v1/datacenters/#{id}")
end

#datacentersObject



3
4
5
# File 'lib/hetzner/commands/datacenters.rb', line 3

def datacenters
  get("/v1/datacenters")
end

#firewall(id) ⇒ Object



7
8
9
# File 'lib/hetzner/commands/firewalls.rb', line 7

def firewall(id)
  get("/v1/firewalls/#{id}")
end

#firewall_action(id, action) ⇒ Object



15
16
17
# File 'lib/hetzner/commands/firewalls.rb', line 15

def firewall_action(id, action)
  get("/v1/firewalls/#{id}/actions/#{action}")
end

#firewall_actions(id) ⇒ Object



11
12
13
# File 'lib/hetzner/commands/firewalls.rb', line 11

def firewall_actions(id)
  get("/v1/firewalls/#{id}/actions")
end

#firewallsObject



3
4
5
# File 'lib/hetzner/commands/firewalls.rb', line 3

def firewalls
  get("/v1/firewalls")
end

#floating_ip(id) ⇒ Object



7
8
9
# File 'lib/hetzner/commands/ips.rb', line 7

def floating_ip(id)
  get("/v1/floating_ips/#{id}")
end

#floating_ip_action(id, action) ⇒ Object



15
16
17
# File 'lib/hetzner/commands/ips.rb', line 15

def floating_ip_action(id, action)
  get("/v1/floating_ips/#{id}/actions/#{action}")
end

#floating_ip_actions(id) ⇒ Object



11
12
13
# File 'lib/hetzner/commands/ips.rb', line 11

def floating_ip_actions(id)
  get("/v1/floating_ips/#{id}/actions")
end

#floating_ipsObject



3
4
5
# File 'lib/hetzner/commands/ips.rb', line 3

def floating_ips
  get("/v1/floating_ips")
end

#image(id) ⇒ Object



7
8
9
# File 'lib/hetzner/commands/images.rb', line 7

def image(id)
  get("/v1/images/#{id}")
end

#image_action(id, action) ⇒ Object



15
16
17
# File 'lib/hetzner/commands/images.rb', line 15

def image_action(id, action)
  get("/v1/images/#{id}/actions/#{action}")
end

#image_actions(id) ⇒ Object



11
12
13
# File 'lib/hetzner/commands/images.rb', line 11

def image_actions(id)
  get("/v1/images/#{id}/actions")
end

#imagesObject



3
4
5
# File 'lib/hetzner/commands/images.rb', line 3

def images
  get("/v1/images")
end

#iso(id) ⇒ Object



7
8
9
# File 'lib/hetzner/commands/isos.rb', line 7

def iso(id)
  get("/v1/isos/#{id}")
end

#isosObject



3
4
5
# File 'lib/hetzner/commands/isos.rb', line 3

def isos
  get("/v1/isos")
end

#load_balancer(id) ⇒ Object



7
8
9
# File 'lib/hetzner/commands/load_balancers.rb', line 7

def load_balancer(id)
  get("/v1/load_balancers/#{id}")
end

#load_balancer_action(id, action) ⇒ Object



19
20
21
# File 'lib/hetzner/commands/load_balancers.rb', line 19

def load_balancer_action(id, action)
  get("/v1/load_balancers/#{id}/actions/#{action}")
end

#load_balancer_actions(id) ⇒ Object



15
16
17
# File 'lib/hetzner/commands/load_balancers.rb', line 15

def load_balancer_actions(id)
  get("/v1/load_balancers/#{id}/actions")
end

#load_balancer_metrics(id) ⇒ Object



11
12
13
# File 'lib/hetzner/commands/load_balancers.rb', line 11

def load_balancer_metrics(id)
  get("/v1/load_balancer/#{id}/metrics")
end

#load_balancer_type(id) ⇒ Object



27
28
29
# File 'lib/hetzner/commands/load_balancers.rb', line 27

def load_balancer_type(id)
  get("/v1/load_balancer_types/#{id}")
end

#load_balancer_typesObject



23
24
25
# File 'lib/hetzner/commands/load_balancers.rb', line 23

def load_balancer_types
  get("/v1/load_balancer_types")
end

#load_balancersObject



3
4
5
# File 'lib/hetzner/commands/load_balancers.rb', line 3

def load_balancers
  get("/v1/load_balancers")
end

#location(id) ⇒ Object



7
8
9
# File 'lib/hetzner/commands/locations.rb', line 7

def location(id)
  get("/v1/locations/#{id}")
end

#locationsObject



3
4
5
# File 'lib/hetzner/commands/locations.rb', line 3

def locations
  get("/v1/locations")
end

#network(id) ⇒ Object



7
8
9
# File 'lib/hetzner/commands/networks.rb', line 7

def network(id)
  get("/v1/networks/#{id}")
end

#network_action(id, action) ⇒ Object



15
16
17
# File 'lib/hetzner/commands/networks.rb', line 15

def network_action(id, action)
  get("/v1/networks/#{id}/actions/#{action}")
end

#network_actions(id) ⇒ Object



11
12
13
# File 'lib/hetzner/commands/networks.rb', line 11

def network_actions(id)
  get("/v1/networks/#{id}/actions")
end

#networksObject



3
4
5
# File 'lib/hetzner/commands/networks.rb', line 3

def networks
  get("/v1/networks")
end

#placement_group(id) ⇒ Object



7
8
9
# File 'lib/hetzner/commands/placement_groups.rb', line 7

def placement_group(id)
  get("/v1/placement_groups/#{id}")
end

#placement_groupsObject



3
4
5
# File 'lib/hetzner/commands/placement_groups.rb', line 3

def placement_groups
  get("/v1/placement_groups")
end

#pricingObject



3
4
5
# File 'lib/hetzner/commands/pricing.rb', line 3

def pricing
  get("/v1/pricing")
end

#server(id) ⇒ Object



7
8
9
# File 'lib/hetzner/commands/servers.rb', line 7

def server(id)
get("/v1/servers/#{id}")
end

#server_action(id, action) ⇒ Object



15
16
17
# File 'lib/hetzner/commands/servers.rb', line 15

def server_action(id, action)
  get("/v1/servers/#{id}/actions/#{action}")
end

#server_actions(id) ⇒ Object



11
12
13
# File 'lib/hetzner/commands/servers.rb', line 11

def server_actions(id)
  get("/v1/servers/#{id}/actions")
end

#server_type(id) ⇒ Object



23
24
25
# File 'lib/hetzner/commands/servers.rb', line 23

def server_type(id)
  get("/v1/server_types/#{id}")
end

#server_typesObject



19
20
21
# File 'lib/hetzner/commands/servers.rb', line 19

def server_types
  get("/v1/server_types")
end

#serversObject



3
4
5
# File 'lib/hetzner/commands/servers.rb', line 3

def servers
  get("/v1/servers")
end

#ssh_key(id) ⇒ Object



7
8
9
# File 'lib/hetzner/commands/ssh.rb', line 7

def ssh_key(id)
  get("/v1/ssh_keys/#{id}")
end

#ssh_keysObject



3
4
5
# File 'lib/hetzner/commands/ssh.rb', line 3

def ssh_keys
  get("/v1/ssh_keys")
end

#volume(id) ⇒ Object



7
8
9
# File 'lib/hetzner/commands/volumes.rb', line 7

def volume(id)
  get("/v1/volumes/#{id}")
end

#volume_action(id, action) ⇒ Object



15
16
17
# File 'lib/hetzner/commands/volumes.rb', line 15

def volume_action(id, action)
  get("/v1/volumes/#{id}/actions/#{action}")
end

#volume_actions(id) ⇒ Object



11
12
13
# File 'lib/hetzner/commands/volumes.rb', line 11

def volume_actions(id)
  get("/v1/volumes/#{id}/actions")
end

#volumesObject



3
4
5
# File 'lib/hetzner/commands/volumes.rb', line 3

def volumes
  get("/v1/volumes")
end