Class: Hcloud::Server

Inherits:
Object
  • Object
show all
Includes:
EntryLoader
Defined in:
lib/hcloud/server.rb

Instance Attribute Summary

Attributes included from EntryLoader

#response

Instance Method Summary collapse

Methods included from EntryLoader

#_attributes, #_load, #_run_callbacks, #_update_attribute, #client, #initialize, #inspect, #method_missing, #prepare_request, #resource_path, #resource_url, #respond_to_missing?, #rollback, #save, #update

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Hcloud::EntryLoader

Instance Method Details

#attach_iso(iso:) ⇒ Object



50
51
52
# File 'lib/hcloud/server.rb', line 50

def attach_iso(iso:)
  prepare_request('actions/attach_iso', j: { iso: iso })
end

#attach_to_network(network:, ip: nil, alias_ips: nil) ⇒ Object



54
55
56
# File 'lib/hcloud/server.rb', line 54

def attach_to_network(network:, ip: nil, alias_ips: nil)
  prepare_request('actions/attach_to_network', j: COLLECT_ARGS.call(__method__, binding))
end

#change_type(server_type:, upgrade_disk: nil) ⇒ Object



40
41
42
# File 'lib/hcloud/server.rb', line 40

def change_type(server_type:, upgrade_disk: nil)
  prepare_request('actions/change_type', j: COLLECT_ARGS.call(__method__, binding))
end

#create_image(description: nil, type: nil) ⇒ Object



31
32
33
34
# File 'lib/hcloud/server.rb', line 31

def create_image(description: nil, type: nil)
  query = COLLECT_ARGS.call(__method__, binding)
  prepare_request('actions/create_image', j: query) { |j| Image.new(client, j[:image]) }
end

#detach_from_network(network:) ⇒ Object



58
59
60
# File 'lib/hcloud/server.rb', line 58

def detach_from_network(network:)
  prepare_request('actions/detach_from_network', j: { network: network })
end

#enable_backup(**_kwargs) ⇒ Object

Specifying a backup window is not supported anymore. We keep this method to ensure backwards compatibility, but ignore the argument if provided.



46
47
48
# File 'lib/hcloud/server.rb', line 46

def enable_backup(**_kwargs)
  prepare_request('actions/enable_backup', method: :post)
end

#enable_rescue(type: 'linux64', ssh_keys: []) ⇒ Object



22
23
24
25
# File 'lib/hcloud/server.rb', line 22

def enable_rescue(type: 'linux64', ssh_keys: [])
  query = COLLECT_ARGS.call(__method__, binding)
  prepare_request('actions/enable_rescue', j: query) { |j| j[:root_password] }
end

#rebuild(image:) ⇒ Object



36
37
38
# File 'lib/hcloud/server.rb', line 36

def rebuild(image:)
  prepare_request('actions/rebuild', j: { image: image }) { |j| j[:root_password] }
end

#request_consoleObject



72
73
74
# File 'lib/hcloud/server.rb', line 72

def request_console
  prepare_request('actions/request_console', method: :post) { |j| [j[:wss_url], j[:password]] }
end

#reset_passwordObject



27
28
29
# File 'lib/hcloud/server.rb', line 27

def reset_password
  prepare_request('actions/reset_password', method: :post) { |j| j[:root_password] }
end