Class: RubyApiPackCloudways::Api::CwServer

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_api_pack_cloudways/api/cw_server.rb

Constant Summary collapse

ENDPOINTS =

Server endpoints

{
  list: '/server',
  attach_block_storage: '/server/attach_block_storage',
  clone: '/server/clone',
  create: '/server/create',
  delete: '/server/delete',
  details: '/server/details',
  disk_usage: '/server/disk_usage',
  restart: '/server/restart',
  scale_block_storage: '/server/scale_block_storage',
  scale_volume_size: '/server/scale_volume_size',
  start: '/server/start',
  stop: '/server/stop',
  update_label: '/server/update_label',
  upgrade: '/server/upgrade'
}.freeze

Class Method Summary collapse

Class Method Details

.attach_block_storage(server_id, params) ⇒ Object

Attach block storage to a server



30
31
32
# File 'lib/ruby_api_pack_cloudways/api/cw_server.rb', line 30

def self.attach_block_storage(server_id, params)
  post_with_id(ENDPOINTS[:attach_block_storage], server_id, params)
end

.clone_server(server_id, params) ⇒ Object

Clone a server



35
36
37
# File 'lib/ruby_api_pack_cloudways/api/cw_server.rb', line 35

def self.clone_server(server_id, params)
  post_with_id(ENDPOINTS[:clone], server_id, params)
end

.create_server(params) ⇒ Object

Create a new server



40
41
42
# File 'lib/ruby_api_pack_cloudways/api/cw_server.rb', line 40

def self.create_server(params)
  post_without_id(ENDPOINTS[:create], params)
end

.delete_server(server_id) ⇒ Object

Delete a server



45
46
47
# File 'lib/ruby_api_pack_cloudways/api/cw_server.rb', line 45

def self.delete_server(server_id)
  fetch_with_id(ENDPOINTS[:delete], server_id)
end

.disk_usage(server_id) ⇒ Object

Get disk usage information



50
51
52
# File 'lib/ruby_api_pack_cloudways/api/cw_server.rb', line 50

def self.disk_usage(server_id)
  fetch_with_id(ENDPOINTS[:disk_usage], server_id)
end

.restart_server(server_id) ⇒ Object

Restart a server



55
56
57
# File 'lib/ruby_api_pack_cloudways/api/cw_server.rb', line 55

def self.restart_server(server_id)
  fetch_with_id(ENDPOINTS[:restart], server_id)
end

.scale_block_storage(server_id, params) ⇒ Object

Scale block storage of a server



65
66
67
# File 'lib/ruby_api_pack_cloudways/api/cw_server.rb', line 65

def self.scale_block_storage(server_id, params)
  post_with_id(ENDPOINTS[:scale_block_storage], server_id, params)
end

.scale_volume_size(server_id, params) ⇒ Object

Scale volume size of a server



70
71
72
# File 'lib/ruby_api_pack_cloudways/api/cw_server.rb', line 70

def self.scale_volume_size(server_id, params)
  post_with_id(ENDPOINTS[:scale_volume_size], server_id, params)
end

.server_details(server_id) ⇒ Object

Get server details



60
61
62
# File 'lib/ruby_api_pack_cloudways/api/cw_server.rb', line 60

def self.server_details(server_id)
  fetch_with_id(ENDPOINTS[:details], server_id)
end

.server_listObject

List all servers



25
26
27
# File 'lib/ruby_api_pack_cloudways/api/cw_server.rb', line 25

def self.server_list
  fetch_list(ENDPOINTS[:list])['servers']
end

.start_server(server_id) ⇒ Object

Start a server



75
76
77
# File 'lib/ruby_api_pack_cloudways/api/cw_server.rb', line 75

def self.start_server(server_id)
  fetch_with_id(ENDPOINTS[:start], server_id)
end

.stop_server(server_id) ⇒ Object

Stop a server



80
81
82
# File 'lib/ruby_api_pack_cloudways/api/cw_server.rb', line 80

def self.stop_server(server_id)
  fetch_with_id(ENDPOINTS[:stop], server_id)
end

.update_server_label(server_id, params) ⇒ Object

Update server label



85
86
87
# File 'lib/ruby_api_pack_cloudways/api/cw_server.rb', line 85

def self.update_server_label(server_id, params)
  post_with_id(ENDPOINTS[:update_label], server_id, params)
end

.upgrade_server(server_id, params) ⇒ Object

Upgrade a server



90
91
92
# File 'lib/ruby_api_pack_cloudways/api/cw_server.rb', line 90

def self.upgrade_server(server_id, params)
  post_with_id(ENDPOINTS[:upgrade], server_id, params)
end