Class: XClarityClient::UnmanageRequestManagement

Inherits:
Services::XClarityService show all
Defined in:
lib/xclarity_client/services/unmanage_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

#fetch_unmanage_request(job_id) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/xclarity_client/services/unmanage_request_management.rb', line 21

def fetch_unmanage_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

#unmanage_discovered_devices(endpoints, force) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/xclarity_client/services/unmanage_request_management.rb', line 7

def unmanage_discovered_devices(endpoints, force)
  deploy_hash = {}
  deploy_hash.merge!({:endpoints => endpoints})
  if force.downcase.eql? "true"
    deploy_hash.merge!({:forceUnmanage => true})
  else
     deploy_hash.merge!({:forceUnmanage => false})
    end
    response = @connection.do_post(managed_resource::BASE_URI, JSON.generate(deploy_hash))
  if response.status == 200 or response.status == 201
    puts response.headers[:location].split("/")[-1]
  end
end