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) ⇒ 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
Constructor Details
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ CloudsInterface
Returns a new instance of CloudsInterface.
5 6 7 8 9 10 |
# File 'lib/morpheus/api/clouds_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
#apply_security_groups(id, options) ⇒ Object
81 82 83 84 85 86 87 88 |
# File 'lib/morpheus/api/clouds_interface.rb', line 81 def apply_security_groups(id, ) url = "#{@base_url}/api/zones/#{id}/security-groups" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = response = Morpheus::RestClient.execute(method: :post, url: url, timeout: 30, headers: headers, payload: payload.to_json,verify_ssl: false) JSON.parse(response.to_s) end |
#cloud_types ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/morpheus/api/clouds_interface.rb', line 12 def cloud_types() url = "#{@base_url}/api/zone-types" headers = { 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 |
#create(options) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/morpheus/api/clouds_interface.rb', line 39 def create() url = "#{@base_url}/api/zones" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = {zone: } response = Morpheus::RestClient.execute(method: :post, url: url, timeout: 30, headers: headers, payload: payload.to_json,verify_ssl: false) JSON.parse(response.to_s) end |
#destroy(id) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/morpheus/api/clouds_interface.rb', line 49 def destroy(id) url = "#{@base_url}/api/zones/#{id}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } response = Morpheus::RestClient.execute(method: :delete, url: url, timeout: 30, headers: headers,verify_ssl: false) JSON.parse(response.to_s) end |
#firewall_disable(id) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/morpheus/api/clouds_interface.rb', line 57 def firewall_disable(id) url = "#{@base_url}/api/zones/#{id}/security-groups/disable" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } response = Morpheus::RestClient.execute(method: :put, url: url, timeout: 30, headers: headers,verify_ssl: false) JSON.parse(response.to_s) end |
#firewall_enable(id) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/morpheus/api/clouds_interface.rb', line 65 def firewall_enable(id) url = "#{@base_url}/api/zones/#{id}/security-groups/enable" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } response = Morpheus::RestClient.execute(method: :put, url: url, timeout: 30, headers: headers,verify_ssl: false) JSON.parse(response.to_s) end |
#get(options = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/morpheus/api/clouds_interface.rb', line 22 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/#{}" elsif .is_a?(String) headers[:params]['name'] = end response = Morpheus::RestClient.execute(method: :get, url: url, timeout: 30, headers: headers,verify_ssl: false) JSON.parse(response.to_s) end |
#security_groups(id) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/morpheus/api/clouds_interface.rb', line 73 def security_groups(id) url = "#{@base_url}/api/zones/#{id}/security-groups" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } response = Morpheus::RestClient.execute(method: :get, url: url, timeout: 30, headers: headers,verify_ssl: false) JSON.parse(response.to_s) end |