Sha256: af55e44f94d5a9cb254b6e7e2e6d000f0f7c97622532c313d0768df60421c4ec

Contents?: true

Size: 948 Bytes

Versions: 7

Compression:

Stored size: 948 Bytes

Contents

# Author::        Christopher Brito (cbrito@gmail.com)
# Original Repo:: https://github.com/cbrito/splunk-client

require File.expand_path File.join(File.dirname(__FILE__), 'splunk_results')


class SplunkJob
  attr_reader :jobId

  def initialize(jobId, clientPointer)
    @jobId  = jobId
    @client = clientPointer #SplunkClient object pointer
  end

  def wait
    wait_for_results
  end

  def wait_for_results
    # Wait for the Splunk search to complete
    sleep 1 until complete?
  end

  def complete?
    # Return status of job
    @client.get_search_status(@jobId).to_i == 1
  end

  def results(maxResults=0, mode=nil)
    # Return search results
    @client.get_search_results(@jobId, maxResults, mode)
  end

  def cancel
    @client.control_job(@jobId, 'cancel')
  end
  
  def parsedResults
    # Return a SplunkResults object with methods for the result fields
    SplunkResults.new(results).results
  end
  
end #class SplunkJob

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
splunk-client-0.10.0 lib/splunk_client/splunk_job.rb
splunk-client-0.9.0 lib/splunk_client/splunk_job.rb
splunk-client-0.8.1 lib/splunk_client/splunk_job.rb
splunk-client-0.8.0 lib/splunk_client/splunk_job.rb
splunk-client-0.7.0 lib/splunk_client/splunk_job.rb
splunk-client-0.6.1 lib/splunk_client/splunk_job.rb
splunk-client-0.6 lib/splunk_client/splunk_job.rb