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, options) ⇒ Object
- #cloud_types ⇒ Object
- #create(options) ⇒ Object
- #destroy(id, params = {}) ⇒ Object
- #firewall_disable(id) ⇒ Object
- #firewall_enable(id) ⇒ Object
- #get(options = 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, options) ⇒ 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, options) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/morpheus/api/clouds_interface.rb', line 77 def apply_security_groups(id, ) url = "#{@base_url}/api/zones/#{id}/security-groups" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = opts = {method: :post, url: url, timeout: 30, headers: headers, payload: payload.to_json} execute(opts) end |
#cloud_types ⇒ Object
11 12 13 14 15 16 |
# File 'lib/morpheus/api/clouds_interface.rb', line 11 def cloud_types() url = "#{@base_url}/api/zone-types" headers = { params: {}, authorization: "Bearer #{@access_token}" } opts = {method: :get, url: url, timeout: 30, headers: headers} execute(opts) end |
#create(options) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/morpheus/api/clouds_interface.rb', line 33 def create() url = "#{@base_url}/api/zones" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = opts = {method: :post, url: url, timeout: 30, headers: headers, payload: payload.to_json} execute(opts) end |
#destroy(id, params = {}) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/morpheus/api/clouds_interface.rb', line 49 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, timeout: 30, headers: headers} execute(opts) end |
#firewall_disable(id) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/morpheus/api/clouds_interface.rb', line 56 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, timeout: 30, headers: headers} execute(opts) end |
#firewall_enable(id) ⇒ Object
63 64 65 66 67 68 |
# File 'lib/morpheus/api/clouds_interface.rb', line 63 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, timeout: 30, headers: headers} execute(opts) end |
#get(options = 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(=nil) url = "#{@base_url}/api/zones" headers = { params: {}, authorization: "Bearer #{@access_token}" } if .is_a?(Hash) headers[:params].merge!() elsif .is_a?(Numeric) url = "#{@base_url}/api/zones/#{options}" elsif .is_a?(String) headers[:params]['name'] = end opts = {method: :get, url: url, timeout: 30, headers: headers} execute(opts) end |
#security_groups(id) ⇒ Object
70 71 72 73 74 75 |
# File 'lib/morpheus/api/clouds_interface.rb', line 70 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, timeout: 30, headers: headers} execute(opts) end |
#update(id, options) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/morpheus/api/clouds_interface.rb', line 41 def update(id, ) url = "#{@base_url}/api/zones/#{id}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = opts = {method: :put, url: url, headers: headers, payload: payload.to_json} execute(opts) end |