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, params = {}) ⇒ 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
- #validate(options) ⇒ Object
- #validate_instance(options) ⇒ Object
Constructor Details
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ AppsInterface
Returns a new instance of 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
60 61 62 63 64 65 66 |
# File 'lib/morpheus/api/apps_interface.rb', line 60 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
126 127 128 129 130 131 132 |
# File 'lib/morpheus/api/apps_interface.rb', line 126 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
44 45 46 47 48 49 50 |
# File 'lib/morpheus/api/apps_interface.rb', line 44 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, params = {}) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/morpheus/api/apps_interface.rb', line 76 def destroy(id, params={}) url = "#{@base_url}/api/apps/#{id}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } headers[:params] = params opts = {method: :delete, url: url, headers: headers} execute(opts) end |
#firewall_disable(id) ⇒ Object
105 106 107 108 109 110 |
# File 'lib/morpheus/api/apps_interface.rb', line 105 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
112 113 114 115 116 117 |
# File 'lib/morpheus/api/apps_interface.rb', line 112 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
68 69 70 71 72 73 74 |
# File 'lib/morpheus/api/apps_interface.rb', line 68 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
98 99 100 101 102 103 |
# File 'lib/morpheus/api/apps_interface.rb', line 98 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
119 120 121 122 123 124 |
# File 'lib/morpheus/api/apps_interface.rb', line 119 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
91 92 93 94 95 96 |
# File 'lib/morpheus/api/apps_interface.rb', line 91 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
84 85 86 87 88 89 |
# File 'lib/morpheus/api/apps_interface.rb', line 84 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
52 53 54 55 56 57 58 |
# File 'lib/morpheus/api/apps_interface.rb', line 52 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 |
#validate(options) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/morpheus/api/apps_interface.rb', line 26 def validate() # url = "#{@base_url}/api/apps/validate-instance" url = "#{@base_url}/api/apps/validate" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = opts = {method: :post, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#validate_instance(options) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/morpheus/api/apps_interface.rb', line 35 def validate_instance() # url = "#{@base_url}/api/apps/validate-instance" url = "#{@base_url}/api/apps/validate-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 |