Class: Hcloud::ServerResource
- Inherits:
-
AbstractResource
- Object
- AbstractResource
- Hcloud::ServerResource
- Defined in:
- lib/hcloud/server_resource.rb
Instance Attribute Summary
Attributes inherited from AbstractResource
Instance Method Summary collapse
- #[](arg) ⇒ Object
- #create(name:, server_type:, image:, datacenter: nil, location: nil, start_after_create: nil, ssh_keys: [], public_net: nil, firewalls: nil, networks: [], placement_group: nil, user_data: nil, volumes: nil, automount: nil, labels: {}) ⇒ Object
Methods inherited from AbstractResource
#all, bind_to, #each, filter_attributes, #find, #find_by, #initialize, #limit, #order, #page, #pagination, #per_page, resource, resource_class, resource_path, resource_url, #run, #where
Constructor Details
This class inherits a constructor from Hcloud::AbstractResource
Instance Method Details
#[](arg) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/hcloud/server_resource.rb', line 36 def [](arg) case arg when Integer then find_by(id: arg) when String then find_by(name: arg) end end |
#create(name:, server_type:, image:, datacenter: nil, location: nil, start_after_create: nil, ssh_keys: [], public_net: nil, firewalls: nil, networks: [], placement_group: nil, user_data: nil, volumes: nil, automount: nil, labels: {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/hcloud/server_resource.rb', line 9 def create(name:, server_type:, image:, datacenter: nil, location: nil, start_after_create: nil, ssh_keys: [], public_net: nil, firewalls: nil, networks: [], placement_group: nil, user_data: nil, volumes: nil, automount: nil, labels: {}) prepare_request('servers', j: COLLECT_ARGS.call(__method__, binding), expected_code: 201) do |response| [ Action.new(client, response.parsed_json[:action]), Server.new(client, response.parsed_json[:server]), response.parsed_json[:root_password], response.parsed_json[:next_actions].to_a.map do |action| Action.new(client, action) end ] end end |