Class: Morpheus::CustomInstanceTypesInterface

Inherits:
APIClient
  • Object
show all
Defined in:
lib/morpheus/api/custom_instance_types.rb,
lib/morpheus/api/custom_instance_types_interface.rb

Instance Method Summary collapse

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, #security_groups, #servers, #task_sets, #tasks, #users, #virtual_images, #whoami

Constructor Details

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

Returns a new instance of CustomInstanceTypesInterface.



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

#create(options) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/morpheus/api/custom_instance_types.rb', line 29

def create(options)
  url = "#{@base_url}/api/custom-instance-types"
  headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  payload = options
  response = Morpheus::RestClient.execute(method: :post, url: url,
                          timeout: 10, headers: headers, payload: payload.to_json, verify_ssl:false)
  JSON.parse(response.to_s)
end

#create_upgrade(instance_type_id, options) ⇒ Object



106
107
108
109
110
111
112
113
# File 'lib/morpheus/api/custom_instance_types_interface.rb', line 106

def create_upgrade(instance_type_id, options)
  url = "#{@base_url}/api/custom-instance-types/#{instance_type_id}/upgrades"
  headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json'}
  payload = options
  response = Morpheus::RestClient.execute(method: :post, url: url,
                          timeout: 10, headers: headers, payload: payload.to_json, verify_ssl:false)
  JSON.parse(response.to_s)
end

#create_version(instance_type_id, options) ⇒ Object



79
80
81
82
83
84
85
86
# File 'lib/morpheus/api/custom_instance_types_interface.rb', line 79

def create_version(instance_type_id, options)
  url = "#{@base_url}/api/custom-instance-types/#{instance_type_id}/versions"
  headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json'}
  payload = options
  response = Morpheus::RestClient.execute(method: :post, url: url,
                          timeout: 10, headers: headers, payload: payload.to_json, verify_ssl:false)
  JSON.parse(response.to_s)
end

#destroy(id) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/morpheus/api/custom_instance_types.rb', line 47

def destroy(id)
  url = "#{@base_url}/api/custom-instance-types/#{id}"
  headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  response = Morpheus::RestClient.execute(method: :delete, url: url,
                          timeout: 10, headers: headers, verify_ssl:false)
  JSON.parse(response.to_s)
end

#destroy_upgrade(instance_type_id, id) ⇒ Object



124
125
126
127
128
129
130
131
# File 'lib/morpheus/api/custom_instance_types_interface.rb', line 124

def destroy_upgrade(instance_type_id, id)
  url = "#{@base_url}/api/custom-instance-types/#{instance_type_id}/upgrades/#{id}"
  headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json'}
  payload = options
  response = Morpheus::RestClient.execute(method: :delete, url: url,
                          timeout: 10, headers: headers, verify_ssl:false)
  JSON.parse(response.to_s)
end

#destroy_version(instance_type_id, id) ⇒ Object



97
98
99
100
101
102
103
104
# File 'lib/morpheus/api/custom_instance_types_interface.rb', line 97

def destroy_version(instance_type_id, id)
  url = "#{@base_url}/api/custom-instance-types/#{instance_type_id}/versions/#{id}"
  headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json'}
  payload = options
  response = Morpheus::RestClient.execute(method: :delete, url: url,
                          timeout: 10, headers: headers, verify_ssl:false)
  JSON.parse(response.to_s)
end

#get(id) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/morpheus/api/custom_instance_types.rb', line 12

def get(id)
  url = "#{@base_url}/api/custom-instance-types"
  headers = { params: {}, authorization: "Bearer #{@access_token}" }
  response = Morpheus::RestClient.execute(method: :get, url: url,
                          timeout: 10, headers: headers, verify_ssl:false)
  JSON.parse(response.to_s)
end

#list(options = {}) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/morpheus/api/custom_instance_types.rb', line 20

def list(options={})
  url = "#{@base_url}/api/custom-instance-types"
  headers = { params: {}, authorization: "Bearer #{@access_token}" }
  headers[:params].merge!(options)
  response = Morpheus::RestClient.execute(method: :get, url: url,
                          timeout: 10, headers: headers, verify_ssl:false)
  JSON.parse(response.to_s)
end

#update(id, options) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/morpheus/api/custom_instance_types.rb', line 38

def update(id, options)
  url = "#{@base_url}/api/custom-instance-types/#{id}"
  headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  payload = options
  response = Morpheus::RestClient.execute(method: :put, url: url,
                          timeout: 10, headers: headers, payload: payload.to_json, verify_ssl:false)
  JSON.parse(response.to_s)
end

#update_logo(id, logo_file) ⇒ Object

NOT json, multipart file upload



60
61
62
63
64
65
66
67
68
69
# File 'lib/morpheus/api/custom_instance_types_interface.rb', line 60

def (id, logo_file)
  url = "#{@base_url}/api/custom-instance-types/#{id}/updateLogo"
  headers = { :params => {}, :authorization => "Bearer #{@access_token}"}
  payload = {}
  payload[:logo] = logo_file
  payload[:multipart] = true
  response = Morpheus::RestClient.execute(method: :post, url: url,
                          timeout: 10, headers: headers, payload: payload, verify_ssl:false)
  JSON.parse(response.to_s)
end

#update_upgrade(instance_type_id, id, options) ⇒ Object



115
116
117
118
119
120
121
122
# File 'lib/morpheus/api/custom_instance_types_interface.rb', line 115

def update_upgrade(instance_type_id, id, options)
  url = "#{@base_url}/api/custom-instance-types/#{instance_type_id}/upgrades/#{id}"
  headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json'}
  payload = options
  response = Morpheus::RestClient.execute(method: :put, url: url,
                          timeout: 10, headers: headers, payload: payload.to_json, verify_ssl:false)
  JSON.parse(response.to_s)
end

#update_version(instance_type_id, id, options) ⇒ Object



88
89
90
91
92
93
94
95
# File 'lib/morpheus/api/custom_instance_types_interface.rb', line 88

def update_version(instance_type_id, id, options)
  url = "#{@base_url}/api/custom-instance-types/#{instance_type_id}/versions/#{id}"
  headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json'}
  payload = options
  response = Morpheus::RestClient.execute(method: :put, url: url,
                          timeout: 10, headers: headers, payload: payload.to_json, verify_ssl:false)
  JSON.parse(response.to_s)
end