Class: Morpheus::GroupsInterface
- Inherits:
-
APIClient
- Object
- APIClient
- Morpheus::GroupsInterface
- Defined in:
- lib/morpheus/api/groups_interface.rb
Instance Method Summary collapse
- #create(options) ⇒ Object
- #destroy(id) ⇒ Object
- #get(options = nil) ⇒ Object
-
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ GroupsInterface
constructor
A new instance of GroupsInterface.
- #update(id, options) ⇒ Object
- #update_zones(id, options) ⇒ Object
Constructor Details
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ GroupsInterface
4 5 6 7 8 9 |
# File 'lib/morpheus/api/groups_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
#create(options) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/morpheus/api/groups_interface.rb', line 27 def create() url = "#{@base_url}/api/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 |
#destroy(id) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/morpheus/api/groups_interface.rb', line 43 def destroy(id) url = "#{@base_url}/api/groups/#{id}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :delete, url: url, timeout: 30, headers: headers} execute(opts) end |
#get(options = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/morpheus/api/groups_interface.rb', line 12 def get(=nil) url = "#{@base_url}/api/groups" headers = { params: {}, authorization: "Bearer #{@access_token}" } if .is_a?(Hash) headers[:params].merge!() elsif .is_a?(Numeric) url = "#{@base_url}/api/groups/#{}" elsif .is_a?(String) headers[:params]['name'] = end opts = {method: :get, url: url, timeout: 30, headers: headers} execute(opts) end |
#update(id, options) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/morpheus/api/groups_interface.rb', line 35 def update(id, ) url = "#{@base_url}/api/groups/#{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 |
#update_zones(id, options) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/morpheus/api/groups_interface.rb', line 50 def update_zones(id, ) url = "#{@base_url}/api/groups/#{id}/update-zones" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = opts = {method: :put, url: url, timeout: 30, headers: headers, payload: payload.to_json} execute(opts) end |