Class: Morpheus::ServersInterface
- Inherits:
-
APIClient
- Object
- APIClient
- Morpheus::ServersInterface
- Defined in:
- lib/morpheus/api/servers_interface.rb
Instance Method Summary collapse
- #assign_account(serverId, payload = {}) ⇒ Object
- #create(options) ⇒ Object
- #destroy(id, params = {}) ⇒ Object
- #get(options = nil) ⇒ Object
-
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ ServersInterface
constructor
A new instance of ServersInterface.
- #install_agent(serverId, payload = {}) ⇒ Object
- #list(options = {}) ⇒ Object
- #reinitialize(serverId, payload = {}) ⇒ Object
- #reprovision(serverId, payload = {}) ⇒ Object
- #resize(id, payload) ⇒ Object
- #service_plans(params) ⇒ Object
- #start(serverId, payload = {}) ⇒ Object
- #stop(serverId, payload = {}) ⇒ Object
- #upgrade(serverId, payload = {}) ⇒ Object
- #volumes(id) ⇒ Object
- #workflow(id, task_set_id, payload) ⇒ Object
Constructor Details
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ ServersInterface
Returns a new instance of ServersInterface.
4 5 6 7 8 9 |
# File 'lib/morpheus/api/servers_interface.rb', line 4 def initialize(access_token, refresh_token,expires_at = nil, base_url=nil) @access_token = access_token @refresh_token = refresh_token @base_url = base_url @expires_at = expires_at end |
Instance Method Details
#assign_account(serverId, payload = {}) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/morpheus/api/servers_interface.rb', line 79 def assign_account(serverId,payload = {}) url = "#{@base_url}/api/servers/#{serverId}/assign-account" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#create(options) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/morpheus/api/servers_interface.rb', line 29 def create() url = "#{@base_url}/api/servers" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = opts = {method: :post, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#destroy(id, params = {}) ⇒ Object
93 94 95 96 97 98 |
# File 'lib/morpheus/api/servers_interface.rb', line 93 def destroy(id, params={}) url = "#{@base_url}/api/servers/#{id}" headers = { :params => params,:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :delete, url: url, headers: headers} execute(opts) end |
#get(options = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/morpheus/api/servers_interface.rb', line 11 def get(=nil) url = "#{@base_url}/api/servers" headers = { params: {}, authorization: "Bearer #{@access_token}" } if .is_a?(Hash) headers[:params].merge!() elsif .is_a?(Numeric) url = "#{@base_url}/api/servers/#{}" elsif .is_a?(String) headers[:params]['name'] = end opts = {method: :get, url: url, headers: headers} execute(opts) end |
#install_agent(serverId, payload = {}) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/morpheus/api/servers_interface.rb', line 51 def install_agent(serverId,payload = {}) url = "#{@base_url}/api/servers/#{serverId}/install-agent" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#list(options = {}) ⇒ Object
25 26 27 |
# File 'lib/morpheus/api/servers_interface.rb', line 25 def list(={}) get() end |
#reinitialize(serverId, payload = {}) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/morpheus/api/servers_interface.rb', line 72 def reinitialize(serverId,payload = {}) url = "#{@base_url}/api/servers/#{serverId}/reinitialize" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#reprovision(serverId, payload = {}) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/morpheus/api/servers_interface.rb', line 65 def reprovision(serverId,payload = {}) url = "#{@base_url}/api/servers/#{serverId}/reprovision" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#resize(id, payload) ⇒ Object
114 115 116 117 118 119 |
# File 'lib/morpheus/api/servers_interface.rb', line 114 def resize(id,payload) url = "#{@base_url}/api/servers/#{id}/resize" headers = { :params => {},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#service_plans(params) ⇒ Object
100 101 102 103 104 105 |
# File 'lib/morpheus/api/servers_interface.rb', line 100 def service_plans(params) url = "#{@base_url}/api/servers/service-plans" headers = { params: params, authorization: "Bearer #{@access_token}" } opts = {method: :get, url: url, headers: headers} execute(opts) end |
#start(serverId, payload = {}) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/morpheus/api/servers_interface.rb', line 44 def start(serverId,payload = {}) url = "#{@base_url}/api/servers/#{serverId}/start" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#stop(serverId, payload = {}) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/morpheus/api/servers_interface.rb', line 37 def stop(serverId,payload = {}) url = "#{@base_url}/api/servers/#{serverId}/stop" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#upgrade(serverId, payload = {}) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/morpheus/api/servers_interface.rb', line 58 def upgrade(serverId,payload = {}) url = "#{@base_url}/api/servers/#{serverId}/upgrade" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#volumes(id) ⇒ Object
107 108 109 110 111 112 |
# File 'lib/morpheus/api/servers_interface.rb', line 107 def volumes(id) url = "#{@base_url}/api/servers/#{id}/volumes" headers = { :params => {},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :get, url: url, headers: headers} execute(opts) end |
#workflow(id, task_set_id, payload) ⇒ Object
86 87 88 89 90 91 |
# File 'lib/morpheus/api/servers_interface.rb', line 86 def workflow(id,task_set_id,payload) url = "#{@base_url}/api/servers/#{id}/workflow" headers = { :params => {:taskSetId => task_set_id},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers, payload: payload.to_json} execute(opts) end |