Class: Morpheus::AppsInterface
- Inherits:
-
APIClient
- Object
- APIClient
- Morpheus::AppsInterface
- Defined in:
- lib/morpheus/api/apps_interface.rb
Instance Method Summary collapse
- #apply_security_groups(id, options) ⇒ Object
- #create(options) ⇒ Object
- #create_env(id, options) ⇒ Object
- #del_env(id, name) ⇒ Object
- #destroy(id) ⇒ Object
- #firewall_disable(id) ⇒ Object
- #firewall_enable(id) ⇒ Object
- #get(options = nil) ⇒ Object
- #get_envs(id, options = nil) ⇒ Object
-
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ AppsInterface
constructor
A new instance of AppsInterface.
- #restart(id) ⇒ Object
- #security_groups(id) ⇒ Object
- #start(id) ⇒ Object
- #stop(id) ⇒ Object
Constructor Details
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ AppsInterface
Returns a new instance of AppsInterface.
5 6 7 8 9 10 |
# File 'lib/morpheus/api/apps_interface.rb', line 5 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
123 124 125 126 127 128 129 130 |
# File 'lib/morpheus/api/apps_interface.rb', line 123 def apply_security_groups(id, ) url = "#{@base_url}/api/apps/#{id}/security-groups" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = response = Morpheus::RestClient.execute(method: :post, url: url, timeout: 30, headers: headers, payload: payload.to_json) JSON.parse(response.to_s) end |
#create(options) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/morpheus/api/apps_interface.rb', line 57 def create() url = "#{@base_url}/api/apps" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = response = Morpheus::RestClient.execute(method: :post, url: url, timeout: 30, headers: headers, payload: payload.to_json) JSON.parse(response.to_s) end |
#create_env(id, options) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/morpheus/api/apps_interface.rb', line 37 def create_env(id, ) url = "#{@base_url}/api/apps/#{id}/envs" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = {envs: } response = Morpheus::RestClient.execute(method: :post, url: url, timeout: 30, headers: headers, payload: payload.to_json) JSON.parse(response.to_s) end |
#del_env(id, name) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/morpheus/api/apps_interface.rb', line 47 def del_env(id, name) url = "#{@base_url}/api/apps/#{id}/envs/#{name}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } response = Morpheus::RestClient.execute(method: :delete, url: url, timeout: 30, headers: headers) JSON.parse(response.to_s) end |
#destroy(id) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/morpheus/api/apps_interface.rb', line 67 def destroy(id) url = "#{@base_url}/api/apps/#{id}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } response = Morpheus::RestClient.execute(method: :delete, url: url, timeout: 30, headers: headers) JSON.parse(response.to_s) end |
#firewall_disable(id) ⇒ Object
99 100 101 102 103 104 105 |
# 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' } response = Morpheus::RestClient.execute(method: :put, url: url, timeout: 30, headers: headers) JSON.parse(response.to_s) end |
#firewall_enable(id) ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/morpheus/api/apps_interface.rb', line 107 def firewall_enable(id) url = "#{@base_url}/api/apps/#{id}/security-groups/enable" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } response = Morpheus::RestClient.execute(method: :put, url: url, timeout: 30, headers: headers) JSON.parse(response.to_s) end |
#get(options = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/morpheus/api/apps_interface.rb', line 13 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 response = Morpheus::RestClient.execute(method: :get, url: url, timeout: 30, headers: headers) JSON.parse(response.to_s) end |
#get_envs(id, options = nil) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/morpheus/api/apps_interface.rb', line 29 def get_envs(id, =nil) url = "#{@base_url}/api/apps/#{id}/envs" headers = { params: {}, authorization: "Bearer #{@access_token}" } response = Morpheus::RestClient.execute(method: :get, url: url, timeout: 30, headers: headers) JSON.parse(response.to_s) end |
#restart(id) ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/morpheus/api/apps_interface.rb', line 91 def restart(id) url = "#{@base_url}/api/apps/#{id}/restart" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } response = Morpheus::RestClient.execute(method: :put, url: url, timeout: 30, headers: headers) JSON.parse(response.to_s) end |
#security_groups(id) ⇒ Object
115 116 117 118 119 120 121 |
# File 'lib/morpheus/api/apps_interface.rb', line 115 def security_groups(id) url = "#{@base_url}/api/apps/#{id}/security-groups" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } response = Morpheus::RestClient.execute(method: :get, url: url, timeout: 30, headers: headers) JSON.parse(response.to_s) end |
#start(id) ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/morpheus/api/apps_interface.rb', line 83 def start(id) url = "#{@base_url}/api/apps/#{id}/start" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } response = Morpheus::RestClient.execute(method: :put, url: url, timeout: 30, headers: headers) JSON.parse(response.to_s) end |
#stop(id) ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/morpheus/api/apps_interface.rb', line 75 def stop(id) url = "#{@base_url}/api/apps/#{id}/stop" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } response = Morpheus::RestClient.execute(method: :put, url: url, timeout: 30, headers: headers) JSON.parse(response.to_s) end |