def response_handler(response)
      case response.code.to_i
      when RESPONSE_CODE_OK # Synchronous read/query
        begin
          return JSON.parse(response.body)
        rescue JSON::ParserError => e
          @logger.warn "Failed to parse JSON response. #{e}"
          return response.body
        end
      when RESPONSE_CODE_CREATED # Synchronous add
        return JSON.parse(response.body)
      when RESPONSE_CODE_ACCEPTED # Asynchronous add, update or delete
        return JSON.parse(response.body) # TODO: Remove when tested
        # TODO: Make this actually wait for the task
        # @logger.debug "Waiting for task: #{response.header['location']}"
        # task = wait_for(response.header['location'])
        # return true unless task['associatedResource'] && task['associatedResource']['resourceUri']
        # resource_data = rest_get(task['associatedResource']['resourceUri'])
        # return JSON.parse(resource_data.body)
      when RESPONSE_CODE_NO_CONTENT # Synchronous delete
        return {}
      when RESPONSE_CODE_BAD_REQUEST
        raise BadRequest, "400 BAD REQUEST #{response.body}"
      when RESPONSE_CODE_UNAUTHORIZED
        raise Unauthorized, "401 UNAUTHORIZED #{response.body}"
      when RESPONSE_CODE_NOT_FOUND
        raise NotFound, "404 NOT FOUND #{response.body}"
      else
        raise RequestError, "#{response.code} #{response.body}"
      end
    end
def response_handler(response)
      case response.code.to_i
      when RESPONSE_CODE_OK # Synchronous read/query
        begin
          return JSON.parse(response.body)
        rescue JSON::ParserError => e
          @logger.warn "Failed to parse JSON response. #{e}"
          return response.body
        end
      when RESPONSE_CODE_CREATED # Synchronous add
        return JSON.parse(response.body)
      when RESPONSE_CODE_ACCEPTED # Asynchronous add, update or delete
        return JSON.parse(response.body) # TODO: Remove when tested
        # TODO: Make this actually wait for the task
        # @logger.debug "Waiting for task: #{response.header['location']}"
        # task = wait_for(response.header['location'])
        # return true unless task['associatedResource'] && task['associatedResource']['resourceUri']
        # resource_data = rest_get(task['associatedResource']['resourceUri'])
        # return JSON.parse(resource_data.body)
      when RESPONSE_CODE_NO_CONTENT # Synchronous delete
        return {}
      when RESPONSE_CODE_BAD_REQUEST
        raise BadRequest, "400 BAD REQUEST #{response.body}"
      when RESPONSE_CODE_UNAUTHORIZED
        raise Unauthorized, "401 UNAUTHORIZED #{response.body}"
      when RESPONSE_CODE_NOT_FOUND
        raise NotFound, "404 NOT FOUND #{response.body}"
      else
        raise RequestError, "#{response.code} #{response.body}"
      end
    end
Handle the response for rest call.
   If an asynchronous task was started, this waits for it to complete.
 @param [HTTPResponse] HTTP response
 @raise [ILO_SDK::BadRequest] if the request failed with a 400 status
 @raise [ILO_SDK::Unauthorized] if the request failed with a 401 status
 @raise [ILO_SDK::NotFound] if the request failed with a 404 status
 @raise [ILO_SDK::RequestError] if the request failed with any other status
 @return [Hash] The parsed JSON body