Class: Morpheus::InstanceTypesInterface

Inherits:
APIClient
  • Object
show all
Defined in:
lib/morpheus/api/instance_types_interface.rb

Instance Method Summary collapse

Methods inherited from APIClient

#accounts, #app_templates, #apps, #clouds, #deploy, #deployments, #groups, #instance_types, #instances, #key_pairs, #license, #load_balancers, #logs, #options, #provision_types, #roles, #security_group_rules, #security_groups, #servers, #task_sets, #tasks, #users, #virtual_images

Constructor Details

#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ InstanceTypesInterface

Returns a new instance of InstanceTypesInterface.



5
6
7
8
9
10
# File 'lib/morpheus/api/instance_types_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

#get(options = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/morpheus/api/instance_types_interface.rb', line 13

def get(options=nil)
	url = "#{@base_url}/api/instance-types"
	headers = { params: {}, authorization: "Bearer #{@access_token}" }

	if options.is_a?(Hash)
		headers[:params].merge!(options)
	elsif options.is_a?(Numeric)
		url = "#{@base_url}/api/instance-types/#{options}"
	elsif options.is_a?(String)
		headers[:params]['name'] = options
	end
	response = Morpheus::RestClient.execute(method: :get, url: url,
                           timeout: 30, headers: headers, verify_ssl:false)
	JSON.parse(response.to_s)
end

#service_plan_options(service_plan_id, params) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/morpheus/api/instance_types_interface.rb', line 41

def service_plan_options(service_plan_id, params)
	url = "#{@base_url}/api/instance-types/service-plans/#{service_plan_id}/options"
	headers = { params: params, authorization: "Bearer #{@access_token}" }

	response = Morpheus::RestClient.execute(method: :get, url: url,
                           timeout: 30, headers: headers, verify_ssl: false)
	JSON.parse(response.to_s)
end

#service_plans(layout_id, name = nil) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/morpheus/api/instance_types_interface.rb', line 29

def service_plans(layout_id, name=nil)
	url = "#{@base_url}/api/instance-types/service-plans/#{layout_id}"
	headers = { params: {}, authorization: "Bearer #{@access_token}" }

	if !name.nil?
		headers[:params][:name] = name
	end
	response = Morpheus::RestClient.execute(method: :get, url: url,
                           timeout: 30, headers: headers, verify_ssl: false)
	JSON.parse(response.to_s)
end