def wait_for(task_uri)
      raise ArgumentError, 'Must specify a task_uri!' if task_uri.nil? || task_uri.empty?
      loop do
        task_uri.gsub!(%r{https:(.*)\/rest}, '/rest')
        task = rest_get(task_uri)
        body = JSON.parse(task.body)
        case body['taskState'].downcase
        when 'completed'
          return body
        when 'warning'
          @logger.warn "Task ended with warning status. Details: #{JSON.pretty_generate(body['taskErrors']) rescue body}"
          return body
        when 'error', 'killed', 'terminated'
          msg = "Task ended with bad state: '#{body['taskState']}'.\nResponse: "
          msg += body['taskErrors'] ? JSON.pretty_generate(body['taskErrors']) : JSON.pretty_generate(body)
          raise TaskError, msg
        else
          print '.' if @print_wait_dots
          sleep 10
        end
      end
    end
def wait_for(task_uri)
      raise ArgumentError, 'Must specify a task_uri!' if task_uri.nil? || task_uri.empty?
      loop do
        task_uri.gsub!(%r{https:(.*)\/rest}, '/rest')
        task = rest_get(task_uri)
        body = JSON.parse(task.body)
        case body['taskState'].downcase
        when 'completed'
          return body
        when 'warning'
          @logger.warn "Task ended with warning status. Details: #{JSON.pretty_generate(body['taskErrors']) rescue body}"
          return body
        when 'error', 'killed', 'terminated'
          msg = "Task ended with bad state: '#{body['taskState']}'.\nResponse: "
          msg += body['taskErrors'] ? JSON.pretty_generate(body['taskErrors']) : JSON.pretty_generate(body)
          raise TaskError, msg
        else
          print '.' if @print_wait_dots
          sleep 10
        end
      end
    end
Wait for a task to complete
 @param [String] task_uri
 @raise [OneviewSDK::TaskError] if the task resulted in an error or early termination.
 @return [Hash] if the task completed successfully, return the task details