Class: Splunk::SavedSearch
- Inherits:
-
Entity
- Object
- ReadOnlyEntity
- Entity
- Splunk::SavedSearch
- Defined in:
- lib/splunk-sdk-ruby/entity/saved_search.rb
Overview
Class representing saved searches.
Instance Attribute Summary
Attributes inherited from ReadOnlyEntity
#name, #namespace, #resource, #service
Instance Method Summary collapse
- #dispatch(args = {}) ⇒ Object
-
#history ⇒ Object
Returns a list of the jobs dispatched from this saved search.
-
#update(args) ⇒ Object
Updates the state of this saved search.
Methods inherited from Entity
#[]=, #delete, #disable, #enable
Methods inherited from ReadOnlyEntity
#[], #fetch, #initialize, #links, #read, #readmeta, #refresh
Constructor Details
This class inherits a constructor from Splunk::ReadOnlyEntity
Instance Method Details
#dispatch(args = {}) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/splunk-sdk-ruby/entity/saved_search.rb', line 27 def dispatch(args={}) response = @service.request(:method => :POST, :namespace => @namespace, :resource => @resource + [name, "dispatch"], :body => args) sid = Splunk::text_at_xpath("//response/sid", response.body) return Job.new(@service, sid) end |
#history ⇒ Object
Returns a list of the jobs dispatched from this saved search.
Returns: an Array of Job objects.
41 42 43 44 45 46 47 48 |
# File 'lib/splunk-sdk-ruby/entity/saved_search.rb', line 41 def history() response = @service.request(:namespace => @namespace, :resource => @resource + [@name, "history"]) feed = AtomFeed.new(response.body) return feed.entries.map do |entry| Job.new(@service, entry["title"], entry) end end |
#update(args) ⇒ Object
Updates the state of this saved search.
See the method on Entity for documentation.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/splunk-sdk-ruby/entity/saved_search.rb', line 55 def update(args) # :nodoc: # In versions before Splunk 5.0, updating a saved search requires passing # a +search+ argument, or it will return an error or set the search to # empty. This is fixed in 5.0, but while the 4.x series is supported, we # set the search field on args if it's not already set. This, of course, # has a race condition if someone else has set the search since the last # time the entity was refreshed. # # You might want to check if "search" is in the +requiredFields+ list # on the entity, but that isn't always returned. if !args.has_key?(:search) && !args.has_key?("search") args[:search] = fetch("search") end super(args) end |