Class: XClarityClient::DiscoverRequestManagement

Inherits:
Services::XClarityService show all
Defined in:
lib/xclarity_client/services/discover_request_management.rb

Instance Method Summary collapse

Methods inherited from Services::XClarityService

#fetch_all, #get_headers_with_opts, #get_object, #get_object_with_id, #get_object_with_opts, #initialize

Methods included from Services::ResponseBuilderMixin

#build_response_with_resource_list

Methods included from Services::ListNameInterpreterMixin

#add_listname_on_body

Constructor Details

This class inherits a constructor from XClarityClient::Services::XClarityService

Instance Method Details

#discover_manageable_devices(ip_addresses) ⇒ Object



7
8
9
10
11
# File 'lib/xclarity_client/services/discover_request_management.rb', line 7

def discover_manageable_devices(ip_addresses)
  post_req = JSON.generate([ipAddresses: ip_addresses])
  response = @connection.do_post(managed_resource::BASE_URI, post_req)
  response
end

#monitor_discover_request(job_id) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/xclarity_client/services/discover_request_management.rb', line 13

def monitor_discover_request(job_id)
  response = @connection.do_get(managed_resource::BASE_URI + "/jobs/" + job_id)
  return [] unless response.success?

  body = JSON.parse(response.body)

  body = {managed_resource::LIST_NAME => body} if body.is_a? Array
  body = {managed_resource::LIST_NAME => [body]} unless body.has_key? managed_resource::LIST_NAME
  body[managed_resource::LIST_NAME].map do |resource_params|
    managed_resource.new resource_params
  end
end