Class: Morpheus::AppsInterface
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
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.
-
#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
-
#security_groups(id) ⇒ Object
-
#update(app_id, options) ⇒ Object
Methods inherited from APIClient
#accounts, #app_templates, #apps, #clouds, #custom_instance_types, #dashboard, #deploy, #deployments, #groups, #instance_types, #instances, #key_pairs, #license, #load_balancers, #logs, #options, #provision_types, #roles, #security_group_rules, #servers, #task_sets, #tasks, #users, #virtual_images, #whoami
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
#add_instance(app_id, options) ⇒ Object
49
50
51
52
53
54
55
56
57
|
# File 'lib/morpheus/api/apps_interface.rb', line 49
def add_instance(app_id, options)
url = "#{@base_url}/api/apps/#{app_id}/add-instance"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
payload = options
response = Morpheus::RestClient.execute(method: :post, url: url,
timeout: 30, headers: , payload: payload.to_json)
JSON.parse(response.to_s)
end
|
#apply_security_groups(id, options) ⇒ Object
127
128
129
130
131
132
133
134
|
# File 'lib/morpheus/api/apps_interface.rb', line 127
def apply_security_groups(id, options)
url = "#{@base_url}/api/apps/#{id}/security-groups"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
payload = options
response = Morpheus::RestClient.execute(method: :post, url: url,
timeout: 30, headers: , payload: payload.to_json)
JSON.parse(response.to_s)
end
|
#create(options) ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'lib/morpheus/api/apps_interface.rb', line 29
def create(options)
url = "#{@base_url}/api/apps"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
payload = options
response = Morpheus::RestClient.execute(method: :post, url: url,
timeout: 30, headers: , payload: payload.to_json)
JSON.parse(response.to_s)
end
|
#destroy(id) ⇒ Object
69
70
71
72
73
74
75
|
# File 'lib/morpheus/api/apps_interface.rb', line 69
def destroy(id)
url = "#{@base_url}/api/apps/#{id}"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
response = Morpheus::RestClient.execute(method: :delete, url: url,
timeout: 30, headers: )
JSON.parse(response.to_s)
end
|
#firewall_disable(id) ⇒ Object
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
def start(id)
url = "#{@base_url}/api/apps/#{id}/start"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
response = Morpheus::RestClient.execute(method: :put, url: url,
timeout: 30, headers: )
JSON.parse(response.to_s)
end
def restart(id)
url = "#{@base_url}/api/apps/#{id}/restart"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
response = Morpheus::RestClient.execute(method: :put, url: url,
timeout: 30, headers: )
JSON.parse(response.to_s)
end
103
104
105
106
107
108
109
|
# File 'lib/morpheus/api/apps_interface.rb', line 103
def firewall_disable(id)
url = "#{@base_url}/api/apps/#{id}/security-groups/disable"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
response = Morpheus::RestClient.execute(method: :put, url: url,
timeout: 30, headers: )
JSON.parse(response.to_s)
end
|
#firewall_enable(id) ⇒ Object
111
112
113
114
115
116
117
|
# File 'lib/morpheus/api/apps_interface.rb', line 111
def firewall_enable(id)
url = "#{@base_url}/api/apps/#{id}/security-groups/enable"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
response = Morpheus::RestClient.execute(method: :put, url: url,
timeout: 30, 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(options=nil)
url = "#{@base_url}/api/apps"
= { params: {}, authorization: "Bearer #{@access_token}" }
if options.is_a?(Hash)
[:params].merge!(options)
elsif options.is_a?(Numeric)
url = "#{@base_url}/api/apps/#{options}"
elsif options.is_a?(String)
[:params]['name'] = options
end
response = Morpheus::RestClient.execute(method: :get, url: url,
timeout: 30, headers: )
JSON.parse(response.to_s)
end
|
#remove_instance(app_id, options) ⇒ Object
59
60
61
62
63
64
65
66
67
|
# File 'lib/morpheus/api/apps_interface.rb', line 59
def remove_instance(app_id, options)
url = "#{@base_url}/api/apps/#{app_id}/remove-instance"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
payload = options
response = Morpheus::RestClient.execute(method: :post, url: url,
timeout: 30, headers: , payload: payload.to_json)
JSON.parse(response.to_s)
end
|
#security_groups(id) ⇒ Object
119
120
121
122
123
124
125
|
# File 'lib/morpheus/api/apps_interface.rb', line 119
def security_groups(id)
url = "#{@base_url}/api/apps/#{id}/security-groups"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
response = Morpheus::RestClient.execute(method: :get, url: url,
timeout: 30, headers: )
JSON.parse(response.to_s)
end
|
#update(app_id, options) ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/morpheus/api/apps_interface.rb', line 39
def update(app_id, options)
url = "#{@base_url}/api/apps/#{app_id}"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
payload = options
response = Morpheus::RestClient.execute(method: :put, url: url,
timeout: 30, headers: , payload: payload.to_json)
JSON.parse(response.to_s)
end
|