Skip to content

Commit 4bda67d

Browse files
committed
Clean up function signatures
1 parent 6612d53 commit 4bda67d

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

out/notebooks/splunk.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as vscode from 'vscode';
44
import { SplunkMessage } from './utils/messages';
55
import { getModuleStatements } from './utils/parsing';
66

7-
export function getClient() {
7+
export function getClient(): any {
88
const config = vscode.workspace.getConfiguration();
99
const restUrl = config.get<string>('splunk.commands.splunkRestUrl');
1010
const token = config.get<string>('splunk.commands.token');
@@ -26,12 +26,12 @@ export function getClient() {
2626
return service;
2727
}
2828

29-
export function splunkLogin(service) {
29+
export function splunkLogin(service): Promise<any> {
3030
let request = service.login();
3131
return request;
3232
}
3333

34-
export function createSearchJob(jobs, query, options) {
34+
export function createSearchJob(jobs, query, options): Promise<any> {
3535
let request = jobs.create(query, options);
3636
return request;
3737
}
@@ -57,7 +57,7 @@ function makeHeaders(service: any): object {
5757
*
5858
* @returns Promise<void>
5959
*/
60-
export function getSearchHeadClusterMemberClient(service: any) {
60+
export function getSearchHeadClusterMemberClient(service: any): Promise<any> {
6161
const shcUrl = `${service.prefix}/services/shcluster/member/members?output_mode=json`;
6262
console.log(`Attempting to determine SHC info if present using ${shcUrl}`);
6363
return needle(
@@ -111,7 +111,7 @@ export function getSearchHeadClusterMemberClient(service: any) {
111111
* @param module Full contents of the module to update with
112112
* @returns Promise<void> (or throw Error containing data.messages[])
113113
*/
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> {
115115
// The Splunk SDK for Javascript doesn't currently support the spl2/modules endpoints
116116
// nor does it support sending requests in JSON format (only receiving responses), so
117117
// 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
165165
* @param namespace Namespace _within_ the apps.<app> to run, this will be used directly in the body of the request
166166
* @param earliest Earliest time to be included in the body of the request
167167
* @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[])
169169
*/
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> {
171171
// For now we're using /services/<app> which doesn't respect relative namespaces,
172172
// so for now hardcode this to '' but if/when /servicesNS/<app>
173173
namespace = '';
@@ -237,10 +237,6 @@ export function dispatchSpl2Module(service: any, spl2Module: string, app: string
237237
// This is in the expected successful response format
238238
const sid = data[0]['sid'];
239239
return getSearchJobBySid(service, sid);
240-
})
241-
.then((info) => {
242-
console.log(`Retrieved job info: ${JSON.stringify(info)}`);
243-
return info;
244240
});
245241
}
246242

@@ -306,33 +302,33 @@ function handleErrorPayloads(data: any, statusCode: number) {
306302
});
307303
}
308304

309-
export function getSearchJobBySid(service, sid) {
305+
export function getSearchJobBySid(service, sid): Promise<any> {
310306
let request = service.getJob(sid);
311307
return request;
312308
}
313309

314310

315-
export function getSearchJob(job) {
311+
export function getSearchJob(job): Promise<any> {
316312
let request = job.fetch();
317313
return request;
318314
}
319315

320-
export function getJobSearchLog(job) {
316+
export function getJobSearchLog(job): Promise<any> {
321317
let request = job.searchlog();
322318
return request;
323319
}
324320

325-
export function getSearchJobResults(job) {
321+
export function getSearchJobResults(job): Promise<any> {
326322
let request = job.get("results", {"output_mode": "json_cols"});
327323
return request;
328324
}
329325

330-
export function cancelSearchJob(job) {
326+
export function cancelSearchJob(job): Promise<any> {
331327
let request = job.cancel();
332328
return request;
333329
}
334330

335-
export function wait(ms = 1000) {
331+
export function wait(ms = 1000): Promise<void> {
336332
return new Promise(resolve => {
337333
setTimeout(resolve, ms);
338334
});

0 commit comments

Comments
 (0)