Class: Morpheus::ServersInterface
Instance Method Summary
collapse
-
#assign_account(serverId, payload = {}) ⇒ Object
-
#create(options) ⇒ Object
-
#destroy(id, params = {}) ⇒ Object
-
#get(options = nil) ⇒ Object
-
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ ServersInterface
constructor
A new instance of ServersInterface.
-
#install_agent(serverId, payload = {}) ⇒ Object
-
#list(options = {}) ⇒ Object
-
#reinitialize(serverId, payload = {}) ⇒ Object
-
#reprovision(serverId, payload = {}) ⇒ Object
-
#resize(id, payload) ⇒ Object
-
#service_plan(options) ⇒ Object
-
#service_plans(params) ⇒ Object
-
#start(serverId, payload = {}, params = {}) ⇒ Object
-
#stop(serverId, payload = {}, params = {}) ⇒ Object
-
#update(serverId, options) ⇒ Object
-
#update_wiki(id, payload) ⇒ Object
-
#upgrade(serverId, payload = {}) ⇒ Object
-
#volumes(id) ⇒ Object
-
#wiki(id, params) ⇒ Object
-
#workflow(id, task_set_id, payload) ⇒ Object
Methods inherited from APIClient
#account_groups, #accounts, #apps, #archive_buckets, #archive_files, #auth, #blueprints, #cloud_datastores, #cloud_folders, #cloud_policies, #cloud_resource_pools, #clouds, #clusters, #containers, #custom_instance_types, #cypher, #dashboard, #default_content_type, #deploy, #deployments, #dry, #dry_run, #environments, #execute, #execute_schedules, #execution_request, #file_copy_request, #group_policies, #groups, #image_builder, #inspect, #instance_types, #instances, #key_pairs, #library_compute_type_layouts, #library_container_scripts, #library_container_templates, #library_container_types, #library_container_upgrades, #library_instance_types, #library_layouts, #license, #load_balancers, #logged_in?, #login, #logout, #logs, #monitoring, #network_domain_records, #network_domains, #network_groups, #network_pool_ips, #network_pool_servers, #network_pools, #network_proxies, #network_services, #network_subnet_types, #network_subnets, #network_types, #networks, #old_cypher, #option_type_lists, #option_types, #options, #packages, #policies, #power_schedules, #processes, #provision_types, #refresh_token, #reports, #roles, #security_group_rules, #security_groups, #server_types, #servers, #set_ssl_verification_enabled, #setopts, #setup, #ssl_verification_enabled?, #storage_providers, #task_sets, #tasks, #to_s, #url, #user_groups, #user_settings, #user_sources, #users, #virtual_images, #whoami, #withopts
Constructor Details
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ ServersInterface
Returns a new instance of ServersInterface.
4
5
6
7
8
9
|
# File 'lib/morpheus/api/servers_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
#assign_account(serverId, payload = {}) ⇒ Object
97
98
99
100
101
102
|
# File 'lib/morpheus/api/servers_interface.rb', line 97
def assign_account(serverId,payload = {})
url = "#{@base_url}/api/servers/#{serverId}/assign-account"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#create(options) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/morpheus/api/servers_interface.rb', line 29
def create(options)
url = "#{@base_url}/api/servers"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
payload = options
opts = {method: :post, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#destroy(id, params = {}) ⇒ Object
111
112
113
114
115
116
|
# File 'lib/morpheus/api/servers_interface.rb', line 111
def destroy(id, params={})
url = "#{@base_url}/api/servers/#{id}"
= { :params => params,:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :delete, url: url, headers: }
execute(opts)
end
|
#get(options = nil) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/morpheus/api/servers_interface.rb', line 11
def get(options=nil)
url = "#{@base_url}/api/servers"
= { params: {}, authorization: "Bearer #{@access_token}" }
if options.is_a?(Hash)
[:params].merge!(options)
elsif options.is_a?(Numeric)
url = "#{@base_url}/api/servers/#{options}"
elsif options.is_a?(String)
[:params]['name'] = options
end
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#install_agent(serverId, payload = {}) ⇒ Object
69
70
71
72
73
74
|
# File 'lib/morpheus/api/servers_interface.rb', line 69
def install_agent(serverId,payload = {})
url = "#{@base_url}/api/servers/#{serverId}/install-agent"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#list(options = {}) ⇒ Object
25
26
27
|
# File 'lib/morpheus/api/servers_interface.rb', line 25
def list(options={})
get(options)
end
|
#reinitialize(serverId, payload = {}) ⇒ Object
90
91
92
93
94
95
|
# File 'lib/morpheus/api/servers_interface.rb', line 90
def reinitialize(serverId,payload = {})
url = "#{@base_url}/api/servers/#{serverId}/reinitialize"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#reprovision(serverId, payload = {}) ⇒ Object
83
84
85
86
87
88
|
# File 'lib/morpheus/api/servers_interface.rb', line 83
def reprovision(serverId,payload = {})
url = "#{@base_url}/api/servers/#{serverId}/reprovision"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#resize(id, payload) ⇒ Object
147
148
149
150
151
152
|
# File 'lib/morpheus/api/servers_interface.rb', line 147
def resize(id,payload)
url = "#{@base_url}/api/servers/#{id}/resize"
= { :params => {},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#service_plan(options) ⇒ Object
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
# File 'lib/morpheus/api/servers_interface.rb', line 125
def service_plan(options)
url = "#{@base_url}/api/service-plans"
= { params: {}, authorization: "Bearer #{@access_token}" }
if options.is_a?(Hash)
[:params].merge!(options)
elsif options.is_a?(Numeric)
url = "#{url}/#{options}"
elsif options.is_a?(String)
[:params]['name'] = options
end
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#service_plans(params) ⇒ Object
118
119
120
121
122
123
|
# File 'lib/morpheus/api/servers_interface.rb', line 118
def service_plans(params)
url = "#{@base_url}/api/servers/service-plans"
= { params: params, authorization: "Bearer #{@access_token}" }
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#start(serverId, payload = {}, params = {}) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/morpheus/api/servers_interface.rb', line 57
def start(serverId,payload = {}, params = {})
url = "#{@base_url}/api/servers/start"
if serverId.is_a?(Array)
params['ids'] = serverId
else
url = "#{@base_url}/api/servers/#{serverId}/start"
end
= { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#stop(serverId, payload = {}, params = {}) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/morpheus/api/servers_interface.rb', line 45
def stop(serverId,payload = {}, params={})
url = "#{@base_url}/api/servers/stop"
if serverId.is_a?(Array)
params['ids'] = serverId
else
url = "#{@base_url}/api/servers/#{serverId}/stop"
end
= { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#update(serverId, options) ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/morpheus/api/servers_interface.rb', line 37
def update(serverId, options)
url = "#{@base_url}/api/servers/#{serverId}"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
payload = options
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#update_wiki(id, payload) ⇒ Object
161
162
163
164
165
166
|
# File 'lib/morpheus/api/servers_interface.rb', line 161
def update_wiki(id, payload)
url = "#{@base_url}/api/servers/#{id}/wiki"
= {authorization: "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#upgrade(serverId, payload = {}) ⇒ Object
76
77
78
79
80
81
|
# File 'lib/morpheus/api/servers_interface.rb', line 76
def upgrade(serverId,payload = {})
url = "#{@base_url}/api/servers/#{serverId}/upgrade"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|
#volumes(id) ⇒ Object
140
141
142
143
144
145
|
# File 'lib/morpheus/api/servers_interface.rb', line 140
def volumes(id)
url = "#{@base_url}/api/servers/#{id}/volumes"
= { :params => {},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#wiki(id, params) ⇒ Object
154
155
156
157
158
159
|
# File 'lib/morpheus/api/servers_interface.rb', line 154
def wiki(id, params)
url = "#{@base_url}/api/servers/#{id}/wiki"
= { params: params, authorization: "Bearer #{@access_token}" }
opts = {method: :get, url: url, headers: }
execute(opts)
end
|
#workflow(id, task_set_id, payload) ⇒ Object
104
105
106
107
108
109
|
# File 'lib/morpheus/api/servers_interface.rb', line 104
def workflow(id,task_set_id,payload)
url = "#{@base_url}/api/servers/#{id}/workflow"
= { :params => {:taskSetId => task_set_id},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: , payload: payload.to_json}
execute(opts)
end
|