Class: Morpheus::CloudsInterface
- Inherits:
-
APIClient
- Object
- APIClient
- Morpheus::CloudsInterface
- Defined in:
- lib/morpheus/api/clouds_interface.rb
Instance Method Summary collapse
- #apply_security_groups(id, payload) ⇒ Object
- #base_path ⇒ Object
- #cloud_type(params) ⇒ Object
- #cloud_types(params = {}) ⇒ Object
- #create(payload) ⇒ Object
- #create_affinity_group(id, payload) ⇒ Object
- #destroy(id, params = {}) ⇒ Object
- #destroy_affinity_group(id, affinity_group_id, params = {}) ⇒ Object
- #firewall_disable(id) ⇒ Object
- #firewall_enable(id) ⇒ Object
- #get(id, params = {}) ⇒ Object
- #get_affinity_group(id, affinity_group_id, params = {}) ⇒ Object
- #list(params = {}) ⇒ Object
- #list_affinity_groups(id, params = {}) ⇒ Object
- #refresh(id, params = {}, payload = {}) ⇒ Object
- #security_groups(id) ⇒ Object
- #sync(id, params = {}, payload = {}) ⇒ Object
- #update(id, payload) ⇒ Object
- #update_affinity_group(id, affinity_group_id, payload) ⇒ Object
-
#update_logo(id, logo_file, dark_logo_file = nil) ⇒ Object
NOT json, multipart file upload.
- #update_wiki(id, payload) ⇒ Object
- #wiki(id, params) ⇒ Object
Instance Method Details
#apply_security_groups(id, payload) ⇒ Object
102 103 104 105 106 107 |
# File 'lib/morpheus/api/clouds_interface.rb', line 102 def apply_security_groups(id, payload) url = "#{@base_url}/api/zones/#{id}/security-groups" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :post, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#base_path ⇒ Object
5 6 7 |
# File 'lib/morpheus/api/clouds_interface.rb', line 5 def base_path "/api/zones" end |
#cloud_type(params) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/morpheus/api/clouds_interface.rb', line 16 def cloud_type(params) url = "#{@base_url}/api/zone-types" headers = { params: {}, authorization: "Bearer #{@access_token}" } if params.is_a?(Hash) headers[:params].merge!(params) elsif params.is_a?(Numeric) url = "#{@base_url}/api/zone-types/#{params}" elsif params.is_a?(String) headers[:params]['name'] = params end opts = {method: :get, url: url, headers: headers} execute(opts) end |
#cloud_types(params = {}) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/morpheus/api/clouds_interface.rb', line 9 def cloud_types(params={}) url = "#{@base_url}/api/zone-types" headers = { params: params, authorization: "Bearer #{@access_token}" } opts = {method: :get, url: url, headers: headers} execute(opts) end |
#create(payload) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/morpheus/api/clouds_interface.rb', line 46 def create(payload) url = "#{@base_url}/api/zones" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :post, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#create_affinity_group(id, payload) ⇒ Object
157 158 159 160 161 |
# File 'lib/morpheus/api/clouds_interface.rb', line 157 def create_affinity_group(id, payload) url = "#{base_path}/#{id}/affinity-groups" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } execute(method: :post, url: url, headers: headers, payload: payload.to_json) end |
#destroy(id, params = {}) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/morpheus/api/clouds_interface.rb', line 60 def destroy(id, params={}) url = "#{@base_url}/api/zones/#{id}" headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :delete, url: url, headers: headers} execute(opts) end |
#destroy_affinity_group(id, affinity_group_id, params = {}) ⇒ Object
169 170 171 172 173 |
# File 'lib/morpheus/api/clouds_interface.rb', line 169 def destroy_affinity_group(id, affinity_group_id, params={}) url = "#{base_path}/#{id}/affinity-groups/#{affinity_group_id}" headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } execute(method: :delete, url: url, headers: headers) end |
#firewall_disable(id) ⇒ Object
81 82 83 84 85 86 |
# File 'lib/morpheus/api/clouds_interface.rb', line 81 def firewall_disable(id) url = "#{@base_url}/api/zones/#{id}/security-groups/disable" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers} execute(opts) end |
#firewall_enable(id) ⇒ Object
88 89 90 91 92 93 |
# File 'lib/morpheus/api/clouds_interface.rb', line 88 def firewall_enable(id) url = "#{@base_url}/api/zones/#{id}/security-groups/enable" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers} execute(opts) end |
#get(id, params = {}) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/morpheus/api/clouds_interface.rb', line 31 def get(id, params={}) validate_id!(id) url = "#{@base_url}/api/zones/#{id}" headers = { params: params, authorization: "Bearer #{@access_token}" } opts = {method: :get, url: url, headers: headers} execute(opts) end |
#get_affinity_group(id, affinity_group_id, params = {}) ⇒ Object
151 152 153 154 155 |
# File 'lib/morpheus/api/clouds_interface.rb', line 151 def get_affinity_group(id, affinity_group_id, params={}) url = "#{base_path}/#{id}/affinity-groups/#{affinity_group_id}" headers = { params: params, authorization: "Bearer #{@access_token}" } execute(method: :get, url: url, headers: headers) end |
#list(params = {}) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/morpheus/api/clouds_interface.rb', line 39 def list(params={}) url = "#{@base_url}/api/zones" headers = { params: params, authorization: "Bearer #{@access_token}" } opts = {method: :get, url: url, headers: headers} execute(opts) end |
#list_affinity_groups(id, params = {}) ⇒ Object
145 146 147 148 149 |
# File 'lib/morpheus/api/clouds_interface.rb', line 145 def list_affinity_groups(id, params={}) url = "#{base_path}/#{id}/affinity-groups" headers = { params: params, authorization: "Bearer #{@access_token}" } execute(method: :get, url: url, headers: headers) end |
#refresh(id, params = {}, payload = {}) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/morpheus/api/clouds_interface.rb', line 67 def refresh(id, params={}, payload={}) url = "#{@base_url}/api/zones/#{id}/refresh" headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :post, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#security_groups(id) ⇒ Object
95 96 97 98 99 100 |
# File 'lib/morpheus/api/clouds_interface.rb', line 95 def security_groups(id) url = "#{@base_url}/api/zones/#{id}/security-groups" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :get, url: url, headers: headers} execute(opts) end |
#sync(id, params = {}, payload = {}) ⇒ Object
74 75 76 77 78 79 |
# File 'lib/morpheus/api/clouds_interface.rb', line 74 def sync(id, params={}, payload={}) url = "#{@base_url}/api/zones/#{id}/sync" headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :post, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#update(id, payload) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/morpheus/api/clouds_interface.rb', line 53 def update(id, payload) url = "#{@base_url}/api/zones/#{id}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#update_affinity_group(id, affinity_group_id, payload) ⇒ Object
163 164 165 166 167 |
# File 'lib/morpheus/api/clouds_interface.rb', line 163 def update_affinity_group(id, affinity_group_id, payload) url = "#{base_path}/#{id}/affinity-groups/#{affinity_group_id}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } execute(method: :put, url: url, headers: headers, payload: payload.to_json) end |
#update_logo(id, logo_file, dark_logo_file = nil) ⇒ Object
NOT json, multipart file upload
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/morpheus/api/clouds_interface.rb', line 124 def update_logo(id, logo_file, dark_logo_file=nil) url = "#{@base_url}/api/zones/#{id}/update-logo" headers = { :params => {}, :authorization => "Bearer #{@access_token}"} payload = {} # payload["zone"] = {} if logo_file # payload["zone"]["logo"] = logo_file payload["logo"] = logo_file end if dark_logo_file # payload["instanceType"]["darkLogo"] = dark_logo_file payload["darkLogo"] = dark_logo_file end if logo_file.is_a?(File) || dark_logo_file.is_a?(File) payload[:multipart] = true else headers['Content-Type'] = 'application/x-www-form-urlencoded' end execute(method: :post, url: url, headers: headers, payload: payload) end |
#update_wiki(id, payload) ⇒ Object
116 117 118 119 120 121 |
# File 'lib/morpheus/api/clouds_interface.rb', line 116 def update_wiki(id, payload) url = "#{@base_url}/api/zones/#{id}/wiki" headers = {authorization: "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#wiki(id, params) ⇒ Object
109 110 111 112 113 114 |
# File 'lib/morpheus/api/clouds_interface.rb', line 109 def wiki(id, params) url = "#{@base_url}/api/zones/#{id}/wiki" headers = { params: params, authorization: "Bearer #{@access_token}" } opts = {method: :get, url: url, headers: headers} execute(opts) end |