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
- #cloud_types(params = {}) ⇒ Object
- #create(payload) ⇒ Object
- #destroy(id, params = {}) ⇒ Object
- #firewall_disable(id) ⇒ Object
- #firewall_enable(id) ⇒ Object
- #get(params = nil) ⇒ Object
-
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ CloudsInterface
constructor
A new instance of CloudsInterface.
- #security_groups(id) ⇒ Object
- #update(id, payload) ⇒ Object
Constructor Details
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ CloudsInterface
Returns a new instance of CloudsInterface.
4 5 6 7 8 9 |
# File 'lib/morpheus/api/clouds_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
#apply_security_groups(id, payload) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/morpheus/api/clouds_interface.rb', line 75 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 |
#cloud_types(params = {}) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/morpheus/api/clouds_interface.rb', line 11 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
33 34 35 36 37 38 |
# File 'lib/morpheus/api/clouds_interface.rb', line 33 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 |
#destroy(id, params = {}) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/morpheus/api/clouds_interface.rb', line 47 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 |
#firewall_disable(id) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/morpheus/api/clouds_interface.rb', line 54 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
61 62 63 64 65 66 |
# File 'lib/morpheus/api/clouds_interface.rb', line 61 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(params = nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/morpheus/api/clouds_interface.rb', line 18 def get(params=nil) url = "#{@base_url}/api/zones" headers = { params: {}, authorization: "Bearer #{@access_token}" } if params.is_a?(Hash) headers[:params].merge!(params) elsif params.is_a?(Numeric) url = "#{@base_url}/api/zones/#{params}" elsif params.is_a?(String) headers[:params]['name'] = params end opts = {method: :get, url: url, headers: headers} execute(opts) end |
#security_groups(id) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/morpheus/api/clouds_interface.rb', line 68 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 |
#update(id, payload) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/morpheus/api/clouds_interface.rb', line 40 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 |