Class: Purest::PhysicalArray

Inherits:
APIMethods show all
Defined in:
lib/purest/physical_array.rb

Constant Summary collapse

GET_PARAMS =
%i[action banner connection_key controllers historical
idle_timeout ntpserver phonehome proxy relayhost scsi_timeout
senderdomain space syslogserver throttle].freeze

Instance Method Summary collapse

Methods inherited from APIMethods

#append_path

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



17
18
19
# File 'lib/purest/physical_array.rb', line 17

def create(options = nil)
  super(options, 'array/connection')
end

#delete(options = nil) ⇒ Object

Disconnect one array from another

Parameters:

  • options (Hash) (defaults to: nil)

    options to pass in



63
64
65
66
67
68
69
# File 'lib/purest/physical_array.rb', line 63

def delete(options = nil)
  @options = options

  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

Parameters:

  • options (Hash) (defaults to: nil)

    options to pass



13
14
15
# File 'lib/purest/physical_array.rb', line 13

def get(options = nil)
  super(options, 'array', GET_PARAMS, %i[show_connection show_console_lock show_phonehome show_remoteassist])
end

#update(options = nil) ⇒ Object

Update attributes on an array, PUT

Parameters:

  • options (Hash) (defaults to: nil)

    options to pass in



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/purest/physical_array.rb', line 23

def update(options = nil)
  @options = options

  raw_resp = @conn.put do |req|
    url = ["/api/#{Purest.configuration.api_version}/array"]

    if !@options.nil? && @options[:connected_array]
      url.map! { |u| u + "/connection/#{@options[:connected_array]}" }
    end

    # Small conditional to ease remote assistance connecting/disconnecting
    if !@options.nil? && @options[:remote_assist]
      url.map! { |u| u + '/remoteassist' }
      @options[:action] = @options.delete(:remote_assist)
    end

    # Small loop to ease console locking and home phoning
    %i[console_lock phonehome].each do |path|
      if !@options.nil? && @options[path]
        url.map! { |u| u + "/#{path}" }
        @options[:enabled] = @options.delete(path)
      end
    end

    # Keeping things consistent
    @options[:name] = @options.delete(:new_name) if @options[: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
    @options.delete(:connected_array)
    req.body = @options.to_json

    req.url concat_url url
  end

  JSON.parse(raw_resp.body, symbolize_names: true)
end