/// <summary>
 /// Asynchronously updates a saved search.
 /// </summary>
 /// <param name="name">
 /// Name of the saved search to be updated.
 /// </param>
 /// <param name="attributes">
 /// New attributes for the saved search to be updated.
 /// </param>
 /// <param name="dispatchArgs">
 /// New dispatch arguments for the saved search to be updated.
 /// </param>
 /// <param name="templateArgs">
 /// New template arguments for the saved search to be updated.
 /// </param>
 /// <returns>
 /// An object representing the saved search that was updated.
 /// </returns>
 /// <remarks>
 /// This method uses the <a href="http://goo.gl/aV9eiZ">POST 
 /// saved/searches/{name}</a> endpoint to update the saved search
 /// identified by <see cref="name"/>.
 /// </remarks>
 public async Task<SavedSearch> UpdateSavedSearchAsync(string name, SavedSearchAttributes attributes = null, 
     SavedSearchDispatchArgs dispatchArgs = null, SavedSearchTemplateArgs templateArgs = null)
 {
     var resource = new SavedSearch(this.Context, this.Namespace, name);
     await resource.UpdateAsync(attributes, dispatchArgs, templateArgs);
     return resource;
 }
 /// <summary>
 /// Asynchronously dispatches a <see cref="SavedSearch"/> just like the
 /// scheduler would.
 /// </summary>
 /// <param name="name">
 /// The name of the <see cref="SavedSearch"/> to dispatch.
 /// </param>
 /// <param name="dispatchArgs">
 /// A set of arguments to the dispatcher.
 /// </param>
 /// <param name="templateArgs">
 /// A set of template arguments to the <see cref="SavedSearch"/>.
 /// </param>
 /// <returns>
 /// The search <see cref="Job"/> that was dispatched.
 /// </returns>
 /// <remarks>
 /// This method uses the <a href="http://goo.gl/AfzBJO">POST 
 /// saved/searches/{name}/dispatch</a> endpoint to dispatch the <see 
 /// cref="SavedSearch"/> identified by <see cref="name"/>.
 /// </remarks>
 public async Task<Job> DispatchSavedSearchAsync(string name, SavedSearchDispatchArgs dispatchArgs = null,
     SavedSearchTemplateArgs templateArgs = null)
 {
     var savedSearch = new SavedSearch(this.Context, this.Namespace, name);
     var job = await savedSearch.DispatchAsync(dispatchArgs, templateArgs);
     return job;
 }
 public Task<bool> UpdateAsync(string search = null, SavedSearchAttributes attributes = null, 
     SavedSearchDispatchArgs dispatchArgs = null, SavedSearchTemplateArgs templateArgs = null)
 {
     Contract.Requires<ArgumentException>(!(search == null && attributes == null && dispatchArgs == null && templateArgs == null));
     return default(Task<bool>);
 }
Example #4
0
 public abstract Task<Job> DispatchSavedSearchAsync(string name, SavedSearchDispatchArgs dispatchArgs = null, SavedSearchTemplateArgs templateArgs = null);
Example #5
0
        public void SavedSearchDispatch()
        {
            Service service = this.Connect();

            SavedSearchCollection savedSearches = service.GetSavedSearches();

            // Ensure test starts in a known good state
            if (savedSearches.ContainsKey("sdk-test1"))
            {
                savedSearches.Remove("sdk-test1");
            }

            Assert.IsFalse(savedSearches.ContainsKey("sdk-test1"), this.assertRoot + "#67");

            // Create a saved search
            Job         job;
            string      search      = "search index=sdk-tests * earliest=-1m";
            SavedSearch savedSearch = savedSearches.Create("sdk-test1", search);

            // Dispatch the saved search and wait for results.
            job = savedSearch.Dispatch();
            this.Wait(job);
            job.Results().Close();
            job.Cancel();

            // Dispatch with some additional search options
            job = savedSearch.Dispatch(new Args("dispatch.buckets", 100));
            this.Wait(job);
            job.Timeline().Close();
            job.Cancel();

            // Dispatch with some additional search options
            job = savedSearch.Dispatch(new Args("dispatch.earliest_time", "aaaa"));
            this.Wait(job);
            job.Timeline().Close();
            job.Cancel();

            var savedSearchDispatchArgs = new SavedSearchDispatchArgs();

            savedSearchDispatchArgs.ActionEmailAuthPassword           = "******";
            savedSearchDispatchArgs.ActionEmailAuthUsername           = "******";
            savedSearchDispatchArgs.ActionEmailBcc                    = "*****@*****.**";
            savedSearchDispatchArgs.ActionEmailCc                     = "*****@*****.**";
            savedSearchDispatchArgs.ActionEmailCommand                = "$name1$";
            savedSearchDispatchArgs.ActionEmailFormat                 = "text";
            savedSearchDispatchArgs.ActionEmailFrom                   = "*****@*****.**";
            savedSearchDispatchArgs.ActionEmailHostname               = "dummy1.host.com";
            savedSearchDispatchArgs.ActionEmailInline                 = true;
            savedSearchDispatchArgs.ActionEmailMailServer             = "splunk.com";
            savedSearchDispatchArgs.ActionEmailMaxResults             = 101;
            savedSearchDispatchArgs.ActionEmailMaxTime                = "10s";
            savedSearchDispatchArgs.ActionEmailPdfView                = "dummy";
            savedSearchDispatchArgs.ActionEmailReportPaperOrientation = "landscape";
            savedSearchDispatchArgs.ActionEmailReportPaperSize        = "letter";
            savedSearchDispatchArgs.ActionEmailReportServerEnabled    = false;
            savedSearchDispatchArgs.ActionEmailReportServerUrl        = "splunk.com";
            savedSearchDispatchArgs.ActionEmailSendPdf                = false;
            savedSearchDispatchArgs.ActionEmailSendResults            = false;
            savedSearchDispatchArgs.ActionEmailSubject                = "sdk-subject";
            savedSearchDispatchArgs.ActionEmailTo                     = "*****@*****.**";
            savedSearchDispatchArgs.ActionEmailTrackAlert             = false;
            savedSearchDispatchArgs.ActionEmailTtl                    = "61";
            savedSearchDispatchArgs.ActionEmailUseSsl                 = false;
            savedSearchDispatchArgs.ActionEmailUseTls                 = false;
            savedSearchDispatchArgs.ActionEmailWidthSortColumns       = false;
            savedSearchDispatchArgs.ActionPopulateLookupCommand       = "$name2$";
            savedSearchDispatchArgs.ActionPopulateLookupDest          = "dummypath";
            savedSearchDispatchArgs.ActionPopulateLookupHostname      = "dummy2.host.com";
            savedSearchDispatchArgs.ActionPopulateLookupMaxResults    = 102;
            savedSearchDispatchArgs.ActionPopulateLookupMaxTime       = "20s";
            savedSearchDispatchArgs.ActionPopulateLookupTrackAlert    = false;
            savedSearchDispatchArgs.ActionPopulateLookupTtl           = "62";
            savedSearchDispatchArgs.ActionRssCommand                  = "$name3$";
            savedSearchDispatchArgs.ActionRssHostname                 = "dummy3.host.com";
            savedSearchDispatchArgs.ActionRssMaxResults               = 103;
            savedSearchDispatchArgs.ActionRssMaxTime                  = "30s";
            savedSearchDispatchArgs.ActionRssTrackAlert               = false;
            savedSearchDispatchArgs.ActionRssTtl                 = "63";
            savedSearchDispatchArgs.ActionScriptCommand          = "$name4$";
            savedSearchDispatchArgs.ActionScriptFilename         = "action_script_filename";
            savedSearchDispatchArgs.ActionScriptHostname         = "dummy4.host.com";
            savedSearchDispatchArgs.ActionScriptMaxResults       = 104;
            savedSearchDispatchArgs.ActionScriptMaxTime          = "40s";
            savedSearchDispatchArgs.ActionScriptTrackAlert       = false;
            savedSearchDispatchArgs.ActionScriptTtl              = "64";
            savedSearchDispatchArgs.ActionSummaryIndexCommand    = "$name5$";
            savedSearchDispatchArgs.ActionSummaryIndexHostname   = "dummy5.host.com";
            savedSearchDispatchArgs.ActionSummaryIndexInline     = false;
            savedSearchDispatchArgs.ActionSummaryIndexMaxResults = 105;
            savedSearchDispatchArgs.ActionSummaryIndexMaxTime    = "50s";
            savedSearchDispatchArgs.ActionSummaryIndexTrackAlert = false;
            savedSearchDispatchArgs.ActionSummaryIndexTtl        = "65";
            savedSearchDispatchArgs.Actions = "rss,email,populate_lookup,script,summary_index";

            // Same as the previous dispatch except using custom arg
            job = savedSearch.Dispatch(savedSearchDispatchArgs);
            this.Wait(job);
            job.Timeline().Close();
            job.Cancel();

            // Delete the saved search
            savedSearches.Remove("sdk-test1");
            Assert.IsFalse(savedSearches.ContainsKey("sdk-test1"), this.assertRoot + "#68");
        }