Class: Morpheus::InstancesInterface
- Inherits:
-
APIClient
- Object
- APIClient
- Morpheus::InstancesInterface
- Defined in:
- lib/morpheus/api/instances_interface.rb
Instance Method Summary collapse
- #apply_security_groups(id, options) ⇒ Object
- #backup(id, server = true) ⇒ Object
- #backups(id, params) ⇒ Object
- #clone(id, options) ⇒ Object
- #create(options) ⇒ Object
- #create_env(id, options) ⇒ Object
- #del_env(id, name) ⇒ Object
- #destroy(id, params = {}) ⇒ Object
- #eject(id, server = true) ⇒ Object
- #firewall_disable(id) ⇒ Object
- #firewall_enable(id) ⇒ Object
- #get(options = nil) ⇒ Object
- #get_envs(id, options = nil) ⇒ Object
- #import_snapshot(id, params = {}) ⇒ Object
-
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ InstancesInterface
constructor
A new instance of InstancesInterface.
- #resize(id, payload) ⇒ Object
- #restart(id, server = true) ⇒ Object
- #security_groups(id) ⇒ Object
- #service_plans(params) ⇒ Object
- #start(id, server = true) ⇒ Object
- #stop(id, server = true) ⇒ Object
- #suspend(id, server = true) ⇒ Object
- #update(id, options) ⇒ Object
- #volumes(id) ⇒ Object
- #workflow(id, task_set_id, payload) ⇒ Object
Constructor Details
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ InstancesInterface
4 5 6 7 8 9 |
# File 'lib/morpheus/api/instances_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
#apply_security_groups(id, options) ⇒ Object
170 171 172 173 174 175 176 |
# File 'lib/morpheus/api/instances_interface.rb', line 170 def apply_security_groups(id, ) url = "#{@base_url}/api/instances/#{id}/security-groups" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = opts = {method: :post, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#backup(id, server = true) ⇒ Object
127 128 129 130 131 132 |
# File 'lib/morpheus/api/instances_interface.rb', line 127 def backup(id,server=true) url = "#{@base_url}/api/instances/#{id}/backup" headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers} execute(opts) end |
#backups(id, params) ⇒ Object
134 135 136 137 138 139 |
# File 'lib/morpheus/api/instances_interface.rb', line 134 def backups(id, params) url = "#{@base_url}/api/instances/#{id}/backups" headers = { params: params, authorization: "Bearer #{@access_token}" } opts = {method: :get, url: url, headers: headers} execute(opts) end |
#clone(id, options) ⇒ Object
141 142 143 144 145 146 147 |
# File 'lib/morpheus/api/instances_interface.rb', line 141 def clone(id, ) url = "#{@base_url}/api/instances/#{id}/clone" headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = opts = {method: :put, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#create(options) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/morpheus/api/instances_interface.rb', line 48 def create() url = "#{@base_url}/api/instances" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = opts = {method: :post, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#create_env(id, options) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/morpheus/api/instances_interface.rb', line 33 def create_env(id, ) url = "#{@base_url}/api/instances/#{id}/envs" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = opts = {method: :post, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#del_env(id, name) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/morpheus/api/instances_interface.rb', line 41 def del_env(id, name) url = "#{@base_url}/api/instances/#{id}/envs/#{name}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :delete, url: url, headers: headers} execute(opts) end |
#destroy(id, params = {}) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/morpheus/api/instances_interface.rb', line 64 def destroy(id, params = {}) url = "#{@base_url}/api/instances/#{id}" headers = {:params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :delete, url: url, headers: headers} execute(opts) end |
#eject(id, server = true) ⇒ Object
99 100 101 102 103 104 |
# File 'lib/morpheus/api/instances_interface.rb', line 99 def eject(id,server=true) url = "#{@base_url}/api/instances/#{id}/eject" headers = { :params => {:server => server},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers} execute(opts) end |
#firewall_disable(id) ⇒ Object
149 150 151 152 153 154 |
# File 'lib/morpheus/api/instances_interface.rb', line 149 def firewall_disable(id) url = "#{@base_url}/api/instances/#{id}/security-groups/disable" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers} execute(opts) end |
#firewall_enable(id) ⇒ Object
156 157 158 159 160 161 |
# File 'lib/morpheus/api/instances_interface.rb', line 156 def firewall_enable(id) url = "#{@base_url}/api/instances/#{id}/security-groups/enable" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers} execute(opts) end |
#get(options = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/morpheus/api/instances_interface.rb', line 11 def get(=nil) url = "#{@base_url}/api/instances" headers = { params: {}, authorization: "Bearer #{@access_token}" } if .is_a?(Hash) headers[:params].merge!() elsif .is_a?(Numeric) url = "#{@base_url}/api/instances/#{}" elsif .is_a?(String) headers[:params]['name'] = end opts = {method: :get, url: url, headers: headers} execute(opts) end |
#get_envs(id, options = nil) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/morpheus/api/instances_interface.rb', line 26 def get_envs(id, =nil) url = "#{@base_url}/api/instances/#{id}/envs" headers = { params: {}, authorization: "Bearer #{@access_token}" } opts = {method: :get, url: url, headers: headers} execute(opts) end |
#import_snapshot(id, params = {}) ⇒ Object
177 178 179 180 181 182 |
# File 'lib/morpheus/api/instances_interface.rb', line 177 def import_snapshot(id, params={}) url = "#{@base_url}/api/instances/#{id}/import-snapshot" headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers} execute(opts) end |
#resize(id, payload) ⇒ Object
113 114 115 116 117 118 |
# File 'lib/morpheus/api/instances_interface.rb', line 113 def resize(id,payload) url = "#{@base_url}/api/instances/#{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 |
#restart(id, server = true) ⇒ Object
85 86 87 88 89 90 |
# File 'lib/morpheus/api/instances_interface.rb', line 85 def restart(id,server=true) url = "#{@base_url}/api/instances/#{id}/restart" headers = { :params => {:server => server},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers} execute(opts) end |
#security_groups(id) ⇒ Object
163 164 165 166 167 168 |
# File 'lib/morpheus/api/instances_interface.rb', line 163 def security_groups(id) url = "#{@base_url}/api/instances/#{id}/security-groups" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :get, url: url, headers: headers} execute(opts) end |
#service_plans(params) ⇒ Object
184 185 186 187 188 189 |
# File 'lib/morpheus/api/instances_interface.rb', line 184 def service_plans(params) url = "#{@base_url}/api/instances/service-plans" headers = { params: params, authorization: "Bearer #{@access_token}" } opts = {method: :get, url: url, headers: headers} execute(opts) end |
#start(id, server = true) ⇒ Object
78 79 80 81 82 83 |
# File 'lib/morpheus/api/instances_interface.rb', line 78 def start(id,server=true) url = "#{@base_url}/api/instances/#{id}/start" headers = { :params => {:server => server}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers} execute(opts) end |
#stop(id, server = true) ⇒ Object
71 72 73 74 75 76 |
# File 'lib/morpheus/api/instances_interface.rb', line 71 def stop(id,server=true) url = "#{@base_url}/api/instances/#{id}/stop" headers = { :params => {:server => server}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers} execute(opts) end |
#suspend(id, server = true) ⇒ Object
92 93 94 95 96 97 |
# File 'lib/morpheus/api/instances_interface.rb', line 92 def suspend(id,server=true) url = "#{@base_url}/api/instances/#{id}/suspend" headers = { :params => {:server => server},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers} execute(opts) end |
#update(id, options) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/morpheus/api/instances_interface.rb', line 56 def update(id, ) url = "#{@base_url}/api/instances/#{id}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = opts = {method: :put, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#volumes(id) ⇒ Object
106 107 108 109 110 111 |
# File 'lib/morpheus/api/instances_interface.rb', line 106 def volumes(id) url = "#{@base_url}/api/instances/#{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
120 121 122 123 124 125 |
# File 'lib/morpheus/api/instances_interface.rb', line 120 def workflow(id,task_set_id,payload) url = "#{@base_url}/api/instances/#{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 |