Class: Purest::PhysicalArray
- Inherits:
-
Rest
- Object
- CustomExceptions
- Rest
- Purest::PhysicalArray
- Defined in:
- lib/purest/physical_array.rb
Constant Summary collapse
- GET_PARAMS =
[:action, :banner, :connection_key, :controllers, :historical, :idle_timeout, :ntpserver, :phonehome, :proxy, :relayhost, :scsi_timeout, :senderdomain, :space, :syslogserver, :throttle]
Instance Method Summary collapse
-
#create(options = nil) ⇒ Object
Create a connection between two arrays.
-
#delete(options = nil) ⇒ Object
Disconnect one array from another.
-
#get(options = nil) ⇒ Object
Get a list of hosts, GET.
-
#update(options = nil) ⇒ Object
Update attributes on an array, PUT.
Methods inherited from Rest
access_method?, #authenticated?, #concat_url, #initialize, #logout, method_missing, #use_named_parameter
Constructor Details
This class inherits a constructor from Purest::Rest
Instance Method Details
#create(options = nil) ⇒ Object
Create a connection between two arrays
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/purest/physical_array.rb', line 41 def create( = nil) = raw_resp = @conn.post do |req| req.url "/api/#{Purest.configuration.api_version}/array/connection" req.body = .to_json end JSON.parse(raw_resp.body, :symbolize_names => true) end |
#delete(options = nil) ⇒ Object
Disconnect one array from another
94 95 96 97 98 99 100 |
# File 'lib/purest/physical_array.rb', line 94 def delete( = nil) = raw_resp = @conn.delete do |req| req.url "/api/#{Purest.configuration.api_version}/array/connection/#{@options[:connected_array]}" end end |
#get(options = nil) ⇒ Object
Get a list of hosts, GET
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/purest/physical_array.rb', line 13 def get( = nil) = create_session unless authenticated? raw_resp = @conn.get do |req| url = ["/api/#{Purest.configuration.api_version}/array"] # Map /connection, /console_lock, /phonehome, /remoteassist # depending on what was passed in [:connection, :console_lock, :phonehome, :remoteassist].each do |path| url.map!{|u| u + "/#{path.to_s}"} if !.nil? && [path] end # Generate array, consisting of url parts, to be built # by concat_url method below GET_PARAMS.each do |param| url += self.send(:"use_#{param}",) end # Build url from array of parts, send request req.url concat_url url end JSON.parse(raw_resp.body, :symbolize_names => true) end |
#update(options = nil) ⇒ Object
Update attributes on an array, PUT
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/purest/physical_array.rb', line 54 def update( = nil) = raw_resp = @conn.put do |req| url = ["/api/#{Purest.configuration.api_version}/array"] if !.nil? && [:connected_array] url.map!{|u| u + "/connection/#{@options[:connected_array]}"} end # Small conditional to ease remote assistance connecting/disconnecting if !.nil? && [:remote_assist] url.map!{|u| u + "/remoteassist"} [:action] = .delete(:remote_assist) end # Small loop to ease console locking and home phoning [:console_lock, :phonehome].each do |path| if !.nil? && [path] url.map!{|u| u + "/#{path.to_s}"} [:enabled] = .delete(path) end end # Keeping things consistent [:name] = .delete(:new_name) if [:new_name] # Don't send this as part of the JSON body if it's present # in the options hash, as it's not a valid param .delete(:connected_array) req.body = .to_json req.url concat_url url end JSON.parse(raw_resp.body, :symbolize_names => true) end |