<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Set default app in ruby api? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Set-default-app-in-ruby-api/m-p/25953#M4249</link>
    <description>&lt;P&gt;The below code snippet will only work if my saved search is saved in the default "search" app.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;query = "My Saved Query"
saved_search = splunkService.saved_searches.fetch("#{query}")
search_job = saved_search.dispatch()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I modify this so this it will get the query from the "mycustom_app" app? I've experimented with various ideas but nothing seems to work. &lt;/P&gt;</description>
    <pubDate>Tue, 06 Aug 2013 08:41:32 GMT</pubDate>
    <dc:creator>st0kes</dc:creator>
    <dc:date>2013-08-06T08:41:32Z</dc:date>
    <item>
      <title>Set default app in ruby api?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Set-default-app-in-ruby-api/m-p/25953#M4249</link>
      <description>&lt;P&gt;The below code snippet will only work if my saved search is saved in the default "search" app.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;query = "My Saved Query"
saved_search = splunkService.saved_searches.fetch("#{query}")
search_job = saved_search.dispatch()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I modify this so this it will get the query from the "mycustom_app" app? I've experimented with various ideas but nothing seems to work. &lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2013 08:41:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Set-default-app-in-ruby-api/m-p/25953#M4249</guid>
      <dc:creator>st0kes</dc:creator>
      <dc:date>2013-08-06T08:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: Set default app in ruby api?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Set-default-app-in-ruby-api/m-p/25954#M4250</link>
      <description>&lt;P&gt;Hi - This trick is to set the namespace in order to pull back the saved search that you want.  Also - there is a "bug" in our docs for pulling back metadata of a saved search.  NOTE: in the example below I am not using a : to pull back the description of the saved search.  We are working to get that corrected ASAP.  &lt;/P&gt;

&lt;P&gt;Here is the snippet to create a namespace object and then to connect to splunk in that namespace.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ns = Splunk::namespace(:sharing =&amp;gt; "app", :app =&amp;gt; "testrubySS")
svc = Splunk::connect(:username =&amp;gt; 'admin', :password =&amp;gt; 'changed', :namespace =&amp;gt; ns)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is my full example that you can use to test out and see if your namespace has been limited.  For example, when you list saved searches prior to applying the namespace you will see everything that is system.  &lt;/P&gt;

&lt;P&gt;After applying namespace you will just see the saved searches in that app.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require 'splunk-sdk-ruby'

class MyTest

  def initialize()

end

def run

ns = Splunk::namespace(:sharing =&amp;gt; "app", :app =&amp;gt; "testrubySS")

svc = Splunk::connect(:username =&amp;gt; 'admin', :password =&amp;gt; 'changed', :namespace =&amp;gt; ns)

svc.apps.each do |a|

  puts "App name is: #{a.name}"

end

svc.saved_searches.each do |saved_search|

  puts "Saved search is: #{saved_search.name}" 

end

ruby_ss = svc.saved_searches.fetch("my_ruby_search")

if ruby_ss.nil?
  puts "COULDN'T GET THE SAVED SEARCH"
else
 puts "Description for #{ruby_ss.fetch('description')}"

 testJob = ruby_ss.dispatch()

end

end

end

test = MyTest.new()
test.run
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Aug 2013 21:46:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Set-default-app-in-ruby-api/m-p/25954#M4250</guid>
      <dc:creator>psanford_splunk</dc:creator>
      <dc:date>2013-08-06T21:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: Set default app in ruby api?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Set-default-app-in-ruby-api/m-p/25955#M4251</link>
      <description>&lt;P&gt;Brilliant answer, thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2013 07:27:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Set-default-app-in-ruby-api/m-p/25955#M4251</guid>
      <dc:creator>st0kes</dc:creator>
      <dc:date>2013-08-07T07:27:27Z</dc:date>
    </item>
  </channel>
</rss>

