@@ -4,7 +4,7 @@ import * as vscode from 'vscode';
4
4
import { SplunkMessage } from './utils/messages' ;
5
5
import { getModuleStatements } from './utils/parsing' ;
6
6
7
- export function getClient ( ) {
7
+ export function getClient ( ) : any {
8
8
const config = vscode . workspace . getConfiguration ( ) ;
9
9
const restUrl = config . get < string > ( 'splunk.commands.splunkRestUrl' ) ;
10
10
const token = config . get < string > ( 'splunk.commands.token' ) ;
@@ -26,12 +26,12 @@ export function getClient() {
26
26
return service ;
27
27
}
28
28
29
- export function splunkLogin ( service ) {
29
+ export function splunkLogin ( service ) : Promise < any > {
30
30
let request = service . login ( ) ;
31
31
return request ;
32
32
}
33
33
34
- export function createSearchJob ( jobs , query , options ) {
34
+ export function createSearchJob ( jobs , query , options ) : Promise < any > {
35
35
let request = jobs . create ( query , options ) ;
36
36
return request ;
37
37
}
@@ -57,7 +57,7 @@ function makeHeaders(service: any): object {
57
57
*
58
58
* @returns Promise<void>
59
59
*/
60
- export function getSearchHeadClusterMemberClient ( service : any ) {
60
+ export function getSearchHeadClusterMemberClient ( service : any ) : Promise < any > {
61
61
const shcUrl = `${ service . prefix } /services/shcluster/member/members?output_mode=json` ;
62
62
console . log ( `Attempting to determine SHC info if present using ${ shcUrl } ` ) ;
63
63
return needle (
@@ -111,7 +111,7 @@ export function getSearchHeadClusterMemberClient(service: any) {
111
111
* @param module Full contents of the module to update with
112
112
* @returns Promise<void> (or throw Error containing data.messages[])
113
113
*/
114
- export function updateSpl2Module ( service : any , moduleName : string , namespace : string , module : string ) {
114
+ export function updateSpl2Module ( service : any , moduleName : string , namespace : string , module : string ) : Promise < void > {
115
115
// The Splunk SDK for Javascript doesn't currently support the spl2/modules endpoints
116
116
// nor does it support sending requests in JSON format (only receiving responses), so
117
117
// for now use the underlying needle library that the SDK uses for requests/responses
@@ -165,9 +165,9 @@ export function updateSpl2Module(service: any, moduleName: string, namespace: st
165
165
* @param namespace Namespace _within_ the apps.<app> to run, this will be used directly in the body of the request
166
166
* @param earliest Earliest time to be included in the body of the request
167
167
* @param latest Latest time to be included in the body of the request
168
- * @returns A Promise containing the job id created (or throw an Error containing data.messages[])
168
+ * @returns A Promise containing the job information including sid created (or throw an Error containing data.messages[])
169
169
*/
170
- export function dispatchSpl2Module ( service : any , spl2Module : string , app : string , namespace : string , earliest : string , latest : string ) {
170
+ export function dispatchSpl2Module ( service : any , spl2Module : string , app : string , namespace : string , earliest : string , latest : string ) : Promise < any > {
171
171
// For now we're using /services/<app> which doesn't respect relative namespaces,
172
172
// so for now hardcode this to '' but if/when /servicesNS/<app>
173
173
namespace = '' ;
@@ -237,10 +237,6 @@ export function dispatchSpl2Module(service: any, spl2Module: string, app: string
237
237
// This is in the expected successful response format
238
238
const sid = data [ 0 ] [ 'sid' ] ;
239
239
return getSearchJobBySid ( service , sid ) ;
240
- } )
241
- . then ( ( info ) => {
242
- console . log ( `Retrieved job info: ${ JSON . stringify ( info ) } ` ) ;
243
- return info ;
244
240
} ) ;
245
241
}
246
242
@@ -306,33 +302,33 @@ function handleErrorPayloads(data: any, statusCode: number) {
306
302
} ) ;
307
303
}
308
304
309
- export function getSearchJobBySid ( service , sid ) {
305
+ export function getSearchJobBySid ( service , sid ) : Promise < any > {
310
306
let request = service . getJob ( sid ) ;
311
307
return request ;
312
308
}
313
309
314
310
315
- export function getSearchJob ( job ) {
311
+ export function getSearchJob ( job ) : Promise < any > {
316
312
let request = job . fetch ( ) ;
317
313
return request ;
318
314
}
319
315
320
- export function getJobSearchLog ( job ) {
316
+ export function getJobSearchLog ( job ) : Promise < any > {
321
317
let request = job . searchlog ( ) ;
322
318
return request ;
323
319
}
324
320
325
- export function getSearchJobResults ( job ) {
321
+ export function getSearchJobResults ( job ) : Promise < any > {
326
322
let request = job . get ( "results" , { "output_mode" : "json_cols" } ) ;
327
323
return request ;
328
324
}
329
325
330
- export function cancelSearchJob ( job ) {
326
+ export function cancelSearchJob ( job ) : Promise < any > {
331
327
let request = job . cancel ( ) ;
332
328
return request ;
333
329
}
334
330
335
- export function wait ( ms = 1000 ) {
331
+ export function wait ( ms = 1000 ) : Promise < void > {
336
332
return new Promise ( resolve => {
337
333
setTimeout ( resolve , ms ) ;
338
334
} ) ;
0 commit comments