Class: Morpheus::AppsInterface
- Inherits:
-
APIClient
- Object
- APIClient
- Morpheus::AppsInterface
- Defined in:
- lib/morpheus/api/apps_interface.rb
Instance Method Summary collapse
- #add_instance(app_id, options) ⇒ Object
- #apply_security_groups(id, options) ⇒ Object
- #create(options) ⇒ Object
- #destroy(id) ⇒ Object
- #firewall_disable(id) ⇒ Object
- #firewall_enable(id) ⇒ Object
- #get(options = nil) ⇒ Object
-
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ AppsInterface
constructor
A new instance of AppsInterface.
- #remove_instance(app_id, options) ⇒ Object
- #restart(id) ⇒ Object
- #security_groups(id) ⇒ Object
- #start(id) ⇒ Object
- #stop(id) ⇒ Object
- #update(app_id, options) ⇒ Object
Constructor Details
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ AppsInterface
4 5 6 7 8 9 |
# File 'lib/morpheus/api/apps_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
#add_instance(app_id, options) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/morpheus/api/apps_interface.rb', line 42 def add_instance(app_id, ) url = "#{@base_url}/api/apps/#{app_id}/add-instance" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = opts = {method: :post, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#apply_security_groups(id, options) ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/morpheus/api/apps_interface.rb', line 107 def apply_security_groups(id, ) url = "#{@base_url}/api/apps/#{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 |
#create(options) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/morpheus/api/apps_interface.rb', line 26 def create() url = "#{@base_url}/api/apps" 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) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/morpheus/api/apps_interface.rb', line 58 def destroy(id) url = "#{@base_url}/api/apps/#{id}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :delete, url: url, headers: headers} execute(opts) end |
#firewall_disable(id) ⇒ Object
86 87 88 89 90 91 |
# File 'lib/morpheus/api/apps_interface.rb', line 86 def firewall_disable(id) url = "#{@base_url}/api/apps/#{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
93 94 95 96 97 98 |
# File 'lib/morpheus/api/apps_interface.rb', line 93 def firewall_enable(id) url = "#{@base_url}/api/apps/#{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
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/morpheus/api/apps_interface.rb', line 12 def get(=nil) url = "#{@base_url}/api/apps" headers = { params: {}, authorization: "Bearer #{@access_token}" } if .is_a?(Hash) headers[:params].merge!() elsif .is_a?(Numeric) url = "#{@base_url}/api/apps/#{}" elsif .is_a?(String) headers[:params]['name'] = end opts = {method: :get, url: url, headers: headers} execute(opts) end |
#remove_instance(app_id, options) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/morpheus/api/apps_interface.rb', line 50 def remove_instance(app_id, ) url = "#{@base_url}/api/apps/#{app_id}/remove-instance" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = opts = {method: :post, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#restart(id) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/morpheus/api/apps_interface.rb', line 79 def restart(id) url = "#{@base_url}/api/apps/#{id}/restart" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers} execute(opts) end |
#security_groups(id) ⇒ Object
100 101 102 103 104 105 |
# File 'lib/morpheus/api/apps_interface.rb', line 100 def security_groups(id) url = "#{@base_url}/api/apps/#{id}/security-groups" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :get, url: url, headers: headers} execute(opts) end |
#start(id) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/morpheus/api/apps_interface.rb', line 72 def start(id) url = "#{@base_url}/api/apps/#{id}/start" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers} execute(opts) end |
#stop(id) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/morpheus/api/apps_interface.rb', line 65 def stop(id) url = "#{@base_url}/api/apps/#{id}/stop" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers} execute(opts) end |
#update(app_id, options) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/morpheus/api/apps_interface.rb', line 34 def update(app_id, ) url = "#{@base_url}/api/apps/#{app_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 |