Class: Morpheus::SecurityGroupsInterface
- Inherits:
-
APIClient
- Object
- APIClient
- Morpheus::SecurityGroupsInterface
- Defined in:
- lib/morpheus/api/security_groups_interface.rb
Instance Method Summary collapse
- #create(options) ⇒ Object
- #delete(id) ⇒ Object
- #get(options) ⇒ Object
-
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ SecurityGroupsInterface
constructor
A new instance of SecurityGroupsInterface.
- #list(options = nil) ⇒ Object
- #update(id) ⇒ Object
Constructor Details
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ SecurityGroupsInterface
Returns a new instance of SecurityGroupsInterface.
5 6 7 8 9 10 |
# File 'lib/morpheus/api/security_groups_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
#create(options) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/morpheus/api/security_groups_interface.rb', line 34 def create() url = "#{@base_url}/api/security-groups" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = response = Morpheus::RestClient.execute(method: :post, url: url, timeout: 30, headers: headers, verify_ssl: false, payload: payload.to_json) JSON.parse(response.to_s) end |
#delete(id) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/morpheus/api/security_groups_interface.rb', line 52 def delete(id) url = "#{@base_url}/api/security-groups/#{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 |
#get(options) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/morpheus/api/security_groups_interface.rb', line 23 def get() url = "#{@base_url}/api/security-groups/#{options[:id]}" headers = { params: {}, authorization: "Bearer #{@access_token}" } if .is_a?(Hash) headers[:params].merge!() end response = Morpheus::RestClient.execute(method: :get, url: url, timeout: 30, headers: headers, verify_ssl: false) JSON.parse(response.to_s) end |
#list(options = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/morpheus/api/security_groups_interface.rb', line 12 def list(=nil) url = "#{@base_url}/api/security-groups" headers = { params: {}, authorization: "Bearer #{@access_token}" } if .is_a?(Hash) headers[:params].merge!() end response = Morpheus::RestClient.execute(method: :get, url: url, timeout: 30, headers: headers, verify_ssl: false) JSON.parse(response.to_s) end |
#update(id) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/morpheus/api/security_groups_interface.rb', line 44 def update(id) url = "#{@base_url}/api/security-groups/#{id}" 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 |