Method: F5::Icontrol::RAPI#load

Defined in:
lib/f5/icontrol/rapi.rb

#load(resource = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/f5/icontrol/rapi.rb', line 14

def load(resource = nil)
  tail = resource.nil? ? '' : "/#{resource}"
  response = RestClient::Request.execute(method: :get,
                                         url: "#{url}#{tail}",
                                         user: @args[:username],
                                         password: @args[:password],
                                         verify_ssl: OpenSSL::SSL::VERIFY_NONE
                                     )
  object = JSON.parse response.body

  if object.has_key? 'items'
    object['items'].map { |r| Resource.new r, @args }
  else
    Resource.new object, @args
  end
end