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, payload) ⇒ Object
- #apply_security_groups(id, payload) ⇒ Object
- #create(payload) ⇒ Object
- #destroy(id, params = {}) ⇒ Object
- #firewall_disable(id) ⇒ Object
- #firewall_enable(id) ⇒ Object
- #get(params = {}) ⇒ Object
-
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ AppsInterface
constructor
A new instance of AppsInterface.
- #remove_instance(app_id, payload) ⇒ Object
- #restart(id) ⇒ Object
- #security_groups(id) ⇒ Object
- #start(id) ⇒ Object
- #stop(id) ⇒ Object
- #update(app_id, payload) ⇒ Object
- #validate(payload) ⇒ Object
- #validate_instance(payload) ⇒ 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, payload) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/morpheus/api/apps_interface.rb', line 56 def add_instance(app_id, payload) url = "#{@base_url}/api/apps/#{app_id}/add-instance" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :post, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#apply_security_groups(id, payload) ⇒ Object
120 121 122 123 124 125 |
# File 'lib/morpheus/api/apps_interface.rb', line 120 def apply_security_groups(id, payload) url = "#{@base_url}/api/apps/#{id}/security-groups" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :post, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#create(payload) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/morpheus/api/apps_interface.rb', line 42 def create(payload) url = "#{@base_url}/api/apps" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :post, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#destroy(id, params = {}) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/morpheus/api/apps_interface.rb', line 70 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
99 100 101 102 103 104 |
# File 'lib/morpheus/api/apps_interface.rb', line 99 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
106 107 108 109 110 111 |
# File 'lib/morpheus/api/apps_interface.rb', line 106 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(params = {}) ⇒ 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(params={}) url = "#{@base_url}/api/apps" headers = { params: {}, authorization: "Bearer #{@access_token}" } if params.is_a?(Hash) headers[:params].merge!(params) elsif params.is_a?(Numeric) url = "#{@base_url}/api/apps/#{params}" elsif params.is_a?(String) headers[:params]['name'] = params end opts = {method: :get, url: url, headers: headers} execute(opts) end |
#remove_instance(app_id, payload) ⇒ Object
63 64 65 66 67 68 |
# File 'lib/morpheus/api/apps_interface.rb', line 63 def remove_instance(app_id, payload) url = "#{@base_url}/api/apps/#{app_id}/remove-instance" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :post, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#restart(id) ⇒ Object
92 93 94 95 96 97 |
# File 'lib/morpheus/api/apps_interface.rb', line 92 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
113 114 115 116 117 118 |
# File 'lib/morpheus/api/apps_interface.rb', line 113 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
85 86 87 88 89 90 |
# File 'lib/morpheus/api/apps_interface.rb', line 85 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
78 79 80 81 82 83 |
# File 'lib/morpheus/api/apps_interface.rb', line 78 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, payload) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/morpheus/api/apps_interface.rb', line 49 def update(app_id, payload) url = "#{@base_url}/api/apps/#{app_id}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#validate(payload) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/morpheus/api/apps_interface.rb', line 26 def validate(payload) # url = "#{@base_url}/api/apps/validate-instance" url = "#{@base_url}/api/apps/validate" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :post, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#validate_instance(payload) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/morpheus/api/apps_interface.rb', line 34 def validate_instance(payload) # url = "#{@base_url}/api/apps/validate-instance" url = "#{@base_url}/api/apps/validate-instance" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :post, url: url, headers: headers, payload: payload.to_json} execute(opts) end |